65 GCanvas* C_projections =
nullptr;
66 GCanvas* C_gammagamma =
nullptr;
67 if(gROOT->GetListOfCanvases()->FindObject(
"C_projections")) {
68 C_projections =
static_cast<GCanvas*
>(gROOT->GetListOfCanvases()->FindObject(
"C_projections"));
70 C_projections =
new GCanvas(
"C_projections",
"Projection Canvas", 0, 0, 1450, 600);
71 C_projections->Divide(2, 1);
74 if(gROOT->GetListOfCanvases()->FindObject(
"C_gammagamma")) {
75 C_gammagamma =
static_cast<GCanvas*
>(gROOT->GetListOfCanvases()->FindObject(
"C_gammagamma"));
77 C_gammagamma =
new GCanvas(
"C_gammagamma",
"Gamma-Gamma Canvas", 1700, 0, 650, 650);
84 GH1D* Proj_x =
hist->ProjectionX(
"Gamma_Gamma_xProjection");
86 GH1D* Proj_x_Clone =
static_cast<GH1D*
>(Proj_x->Clone());
87 GH1D* Proj_gated =
nullptr;
89 if(bg_high > 0 && bg_low > 0) {
91 Form(
"Projection with Gate From [%.01f,%.01f] and Background [%.01f,%.01f]", low, high, bg_low, bg_high));
93 Proj_x->SetTitle(Form(
"Projection with Gate From [%.01f,%.01f] NO background", low, high));
95 Proj_x->GetXaxis()->SetTitle(
"Energy [keV]");
96 Proj_x->GetYaxis()->SetTitle(
"Counts ");
99 double ZoomHigh = high + Grace;
100 double ZoomLow = low - Grace;
101 if(bg_high > 0 && bg_high > high) {
102 ZoomHigh = bg_high + Grace;
104 if(bg_low > 0 && bg_low < low) {
105 ZoomLow = bg_low - Grace;
108 Proj_x->GetXaxis()->SetRangeUser(ZoomLow, ZoomHigh);
110 double Projx_Max = Proj_x->GetMaximum();
111 double Projx_Min = Proj_x->GetMinimum();
113 auto* CutLow =
new TLine(low, Projx_Min, low, Projx_Max);
114 auto* CutHigh =
new TLine(high, Projx_Min, high, Projx_Max);
115 auto* BGLow =
new TLine(bg_low, Projx_Min, bg_low, Projx_Max);
116 auto* BGHigh =
new TLine(bg_high, Projx_Min, bg_high, Projx_Max);
117 CutLow->SetLineColor(kRed);
118 CutHigh->SetLineColor(kRed);
119 CutLow->SetLineWidth(2);
120 CutHigh->SetLineWidth(2);
121 BGLow->SetLineColor(kBlue);
122 BGHigh->SetLineColor(kBlue);
123 BGLow->SetLineWidth(2);
124 BGHigh->SetLineWidth(2);
125 BGLow->SetLineStyle(kDashed);
126 BGHigh->SetLineStyle(kDashed);
127 CutLow->Draw(
"same");
128 CutHigh->Draw(
"same");
129 if(bg_low > 0 && bg_high > 0) {
130 BGHigh->Draw(
"same");
134 Proj_gated = Proj_x_Clone->
Project(low, high);
137 if(bg_high > 0 && bg_low > 0) {
138 Proj_gated->SetTitle(Form(
"Gate From [%.01f,%.01f] with Background [%.01f,%.01f]", low, high, bg_low, bg_high));
140 Proj_gated->SetTitle(Form(
"Gate From [%.01f,%.01f] NO Background", low, high));
142 Proj_gated->GetXaxis()->SetTitle(
"Energy [keV]");
143 Proj_gated->GetYaxis()->SetTitle(
"Counts");
145 C_projections->cd(2);
152 TSpectrum::StaticSearch(
hist, sigma,
"Qnodraw", thresh);
153 auto* polyMarker =
static_cast<TPolyMarker*
>(
hist->GetListOfFunctions()->FindObject(
"TPolyMarker"));
154 if(polyMarker ==
nullptr) {
158 auto* array =
static_cast<TObjArray*
>(
hist->GetListOfFunctions()->FindObject(
"PeakLabels"));
159 if(array !=
nullptr) {
160 hist->GetListOfFunctions()->Remove(
static_cast<TObject*
>(array));
163 array =
new TObjArray();
164 array->SetName(
"PeakLabels");
165 int n = polyMarker->GetN();
169 double* markerX = polyMarker->GetX();
170 for(
int i = 0; i < n; i++) {
172 for(
double i_x = markerX[i] - 3; i_x < markerX[i] + 3; i_x++) {
173 if((
hist->GetBinContent(
hist->GetXaxis()->FindBin(i_x))) > y) {
174 y =
hist->GetBinContent(
hist->GetXaxis()->FindBin(i_x));
178 auto* text =
new TText(markerX[i], y, Form(
"%.1f", markerX[i]));
179 text->SetTextSize(0.025);
180 text->SetTextAngle(90);
181 text->SetTextAlign(12);
182 text->SetTextFont(42);
183 text->SetTextColor(
hist->GetLineColor());
186 hist->GetListOfFunctions()->Remove(polyMarker);
187 polyMarker->Delete();
188 hist->GetListOfFunctions()->Add(array);
238 std::vector<TH1*> hists;
239 if(histogram !=
nullptr) {
240 hists.push_back(histogram);
249 int first = hists.at(0)->GetXaxis()->GetFirst();
250 int last = hists.at(0)->GetXaxis()->GetLast();
254 int min = std::min(first, 0);
255 int max = std::max(last, hists.at(0)->GetXaxis()->GetNbins() + 1);
257 int xdiff = last - first;
258 int mdiff = max - min - 2;
261 GH1D* gHist =
dynamic_cast<GH1D*
>(hists.at(0));
264 double yMin = hists.at(0)->GetMinimum();
265 double yMax = hists.at(0)->GetMaximum();
271 if(first == (min + 1)) {
273 }
else if((first - (xdiff / 2)) < min) {
275 last = min + (xdiff) + 1;
277 first = first - (xdiff / 2);
278 last = last - (xdiff / 2);
281 for(
auto*
hist : hists) {
282 hist->GetXaxis()->SetRange(first, last);
289 if(last == (max - 1)) {
291 }
else if((last + (xdiff / 2)) > max) {
292 first = max - 1 - (xdiff);
295 last = last + (xdiff / 2);
296 first = first + (xdiff / 2);
299 for(
auto*
hist : hists) {
300 hist->GetXaxis()->SetRange(first, last);
306 if(gHist !=
nullptr) {
308 if(next !=
nullptr) {
309 next->GetXaxis()->SetRange(first, last);
314 for(
auto*
hist : hists) {
315 hist->GetYaxis()->SetRangeUser(yMin, yMin + (yMax - yMin) / 2.);
321 if(gHist !=
nullptr) {
323 if(prev !=
nullptr) {
324 prev->GetXaxis()->SetRange(first, last);
329 for(
auto*
hist : hists) {
330 hist->GetYaxis()->SetRangeUser(yMin, yMin + (yMax - yMin) * 2.);
335 std::cout <<
"Move1DHistogram: unknown key = " << key <<
hex(key) << std::endl;
346 std::vector<TH1*> hists;
347 if(histogram !=
nullptr) {
348 hists.push_back(histogram);
353 int firstX = hists.at(0)->GetXaxis()->GetFirst();
354 int lastX = hists.at(0)->GetXaxis()->GetLast();
355 int firstY = hists.at(0)->GetYaxis()->GetFirst();
356 int lastY = hists.at(0)->GetYaxis()->GetLast();
358 int minX = std::min(firstX, 0);
359 int maxX = std::max(lastX, hists.at(0)->GetXaxis()->GetNbins() + 1);
360 int minY = std::min(firstY, 0);
361 int maxY = std::max(lastY, hists.at(0)->GetYaxis()->GetNbins() + 1);
363 int xdiff = lastX - firstX;
364 int mxdiff = maxX - minX - 2;
365 int ydiff = lastY - firstY;
366 int mydiff = maxY - minY - 2;
371 if(firstX == (minX + 1)) {
372 }
else if((firstX - (xdiff / 2)) < minX) {
374 lastX = minX + (xdiff) + 1;
376 firstX = firstX - (xdiff / 2);
377 lastX = lastX - (xdiff / 2);
380 for(
auto*
hist : hists) {
381 hist->GetXaxis()->SetRange(firstX, lastX);
388 if(lastX == (maxX - 1)) {
389 }
else if((lastX + (xdiff / 2)) > maxX) {
390 firstX = maxX - 1 - (xdiff);
393 lastX = lastX + (xdiff / 2);
394 firstX = firstX + (xdiff / 2);
397 for(
auto*
hist : hists) {
398 hist->GetXaxis()->SetRange(firstX, lastX);
405 if(lastY == (maxY - 1)) {
406 }
else if((lastY + (ydiff / 2)) > maxY) {
407 firstY = maxY - 1 - ydiff;
410 firstY = firstY + (ydiff / 2);
411 lastY = lastY + (ydiff / 2);
414 for(
auto*
hist : hists) {
415 hist->GetYaxis()->SetRange(firstY, lastY);
422 if(firstY == (minY + 1)) {
424 }
else if((firstY - (ydiff / 2)) < minY) {
426 lastY = minY + (ydiff) + 1;
428 firstY = firstY - (ydiff / 2);
429 lastY = lastY - (ydiff / 2);
432 for(
auto*
hist : hists) {
433 hist->GetYaxis()->SetRange(firstY, lastY);
439 std::cout <<
"Move2DHistogram: unknown key = " << key <<
hex(key) << std::endl;
611 std::string script_filename = Form(
"%s/pygui/grut-view.py", getenv(
"GRSISYS"));
612 std::ifstream script(script_filename);
613 std::string script_text((std::istreambuf_iterator<char>(script)), std::istreambuf_iterator<char>());
614 TPython::Exec(script_text.c_str());
616 auto* gui_timer =
new TTimer(R
"lit(TPython::Exec("update()");)lit", 10, true);
620 for(
int i = 0; i < gROOT->GetListOfFiles()->GetSize(); i++) {
621 TPython::Bind(
static_cast<TFile*
>(gROOT->GetListOfFiles()->At(i)),
"tdir");
622 gROOT->ProcessLine(R
"lit(TPython::Exec("window.AddDirectory(tdir)");)lit");