GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
GCanvas.cxx
Go to the documentation of this file.
1#include "Globals.h"
2#include "GCanvas.h"
3
4#include "TClass.h"
5#include "TPaveStats.h"
6#include "TList.h"
7#include "TText.h"
8#include "TLatex.h"
9#include "TH1.h"
10#include "TH2.h"
11#include "TGraphErrors.h"
12#include "Buttons.h"
13#include "KeySymbols.h"
14#include "TVirtualX.h"
15#include "TROOT.h"
16#include "TFrame.h"
17#include "TF1.h"
18#include "TGraph.h"
19#include "TPolyMarker.h"
20#include "TSpectrum.h"
21//#include "TPython.h"
22#include "TCutG.h"
23#include "TGInputDialog.h"
24
25#include "TApplication.h"
26#include "TContextMenu.h"
27#include "TGButton.h"
28
29#include "GPopup.h"
30
31#include "GRootCommands.h"
32#include "GH2I.h"
33#include "GH2D.h"
34#include "GH1D.h"
35
36#include <iostream>
37#include <fstream>
38#include <string>
39#include <cstring>
40
41#include "TMath.h"
42
43#include "TGRSIint.h"
44#include "TLevelScheme.h"
45
46#ifndef kArrowKeyPress
47// NOLINTBEGIN(cppcoreguidelines-macro-usage)
48#define kArrowKeyPress 25
49#define kArrowKeyRelease 26
50// NOLINTEND(cppcoreguidelines-macro-usage)
51#endif
52
53GMarker::GMarker(int x, int y, TH1* hist)
54 : fHist(hist)
55{
56 if(fHist->GetDimension() == 1) {
57 double localX = gPad->AbsPixeltoX(x);
58
59 fLineX = new TLine(localX, gPad->GetUymin(), localX, gPad->GetUymax());
60 fLineY = nullptr;
61 SetColor(kRed);
62 Draw();
63 } else if(fHist->GetDimension() == 2) {
64 double localX = gPad->AbsPixeltoX(x);
65 double localY = gPad->AbsPixeltoY(y);
66
67 fLineX = new TLine(localX, gPad->GetUymin(), localX, gPad->GetUymax());
68 fLineY = new TLine(gPad->GetUxmin(), localY, gPad->GetUxmax(), localY);
69
70 SetColor(kRed);
71 Draw();
72 }
73}
74
75void GMarker::Copy(TObject& object) const
76{
77 TObject::Copy(object);
78 (static_cast<GMarker&>(object)).fLineX = nullptr;
79 (static_cast<GMarker&>(object)).fLineY = nullptr;
80 (static_cast<GMarker&>(object)).fHist = fHist;
81}
82
83double GCanvas::fLastX = 0;
84double GCanvas::fLastY = 0;
85
86GCanvas::GCanvas(Bool_t build) : TCanvas(build)
87{
89}
90
91GCanvas::GCanvas(const char* name, const char* title, Int_t form) : TCanvas(name, title, form)
92{
94}
95
96GCanvas::GCanvas(const char* name, const char* title, Int_t winw, Int_t winh) : TCanvas(name, title, winw, winh)
97{
99}
100
101GCanvas::GCanvas(const char* name, Int_t winw, Int_t winh, Int_t winid) : TCanvas(name, winw, winh, winid)
102{
103 // this constructor is used to create an embedded canvas
104 // I see no reason for us to support this here. pcb.
105 GCanvasInit();
106 fGuiEnabled = true; // NOLINT(cppcoreguidelines-prefer-member-initializer)
107}
108
109GCanvas::GCanvas(const char* name, const char* title, Int_t wtopx, Int_t wtopy, Int_t winw, Int_t winh, bool gui)
110 : TCanvas(name, title, wtopx, wtopy, winw, winh)
111{
112 GCanvasInit();
113 fGuiEnabled = gui; // NOLINT(cppcoreguidelines-prefer-member-initializer)
114}
115
117{
118 // TCanvas::~TCanvas();
119 delete[] fCutName;
120}
121
123{
124 // ok, to interact with the default TGWindow
125 // stuff from the root gui we need our own GRootCanvas.
126 // We make this using GROOTGuiFactory, which replaces the
127 // TRootGuiFactory used in the creation of some of the
128 // default gui's (canvas,browser,etc).
129 // fStatsDisplayed = true;
130 fMarkerMode = true;
131 fGuiEnabled = false;
133 fCutName = new char[256];
134 SetBit(kNotDeleted, false); // root voodoo.
135}
136
137void GCanvas::AddMarker(int x, int y, TH1* hist)
138{
139 auto* mark = new GMarker(x, y, hist);
140 unsigned int max_number_of_markers = (hist->GetDimension() == 1) ? 4 : 2;
141
142 fMarkers.push_back(mark);
143
144 if(fMarkers.size() > max_number_of_markers) {
145 delete fMarkers.at(0);
146 fMarkers.erase(fMarkers.begin());
147 }
148}
149
150void GCanvas::RemoveMarker(Option_t* opt)
151{
152 TString options(opt);
153
154 if(options.Contains("all")) {
155 for(auto* marker : fMarkers) {
156 delete marker;
157 }
158 for(auto* marker : fBackgroundMarkers) {
159 delete marker;
160 }
161 fMarkers.clear();
162 fBackgroundMarkers.clear();
163 } else {
164 if(fMarkers.empty()) {
165 return;
166 }
167 delete fMarkers.back();
168 fMarkers.pop_back();
169 }
170}
171
173{
174 std::sort(fMarkers.begin(), fMarkers.end());
175}
176
178{
179 gPad->Update();
180 for(auto* marker : fMarkers) {
181 marker->Update(GetUxmin(), GetUxmax(), GetUymin(), GetUymax());
182 marker->Draw();
183 }
184
185 for(auto* marker : fBackgroundMarkers) {
186 marker->Update(GetUxmin(), GetUxmax(), GetUymin(), GetUymax());
187 marker->Draw();
188 }
189}
190
192{
193 if(GetNMarkers() < 2) {
194 return false;
195 }
196
197 // Delete previous background, if any.
198 for(auto* marker : fBackgroundMarkers) {
199 delete marker;
200 }
201 fBackgroundMarkers.clear();
202
203 // Push last two markers into the background.
204 fBackgroundMarkers.push_back(fMarkers.back());
205 fMarkers.pop_back();
206 fBackgroundMarkers.push_back(fMarkers.back());
207 fMarkers.pop_back();
208
209 // Change background marker color.
210 for(auto* marker : fBackgroundMarkers) {
211 marker->SetColor(kBlue);
212 }
213
215
216 return true;
217}
218
220{
221 if(fBackgroundMarkers.size() < 2) {
222 return false;
223 }
224
225 Color_t color = 0;
226
227 switch(fBackgroundMode) {
230 Prompt();
231 color = kBlue;
232 break;
235 color = kGreen;
236 break;
239 color = kOrange;
240 break;
243 color = kMagenta;
244 break;
247 color = 0;
248 break;
249 };
250
251 for(auto* marker : fBackgroundMarkers) {
252 marker->SetColor(color);
253 }
254
255 return true;
256}
257
259{
260 // Static function to build a default canvas.
261
262 const char* defcanvas = gROOT->GetDefCanvasName();
263 char* cdef = nullptr;
264 auto* lc = static_cast<TList*>(gROOT->GetListOfCanvases());
265 if(lc->FindObject(defcanvas) != nullptr) {
266 Int_t n = lc->GetSize() + 1;
267 cdef = new char[strlen(defcanvas) + 15];
268 do {
269 strlcpy(cdef, Form("%s_n%d", defcanvas, n++), strlen(defcanvas) + 15);
270 } while(lc->FindObject(cdef) != nullptr);
271 } else {
272 cdef = StrDup(Form("%s", defcanvas));
273 }
274 auto* c = new GCanvas(cdef, cdef, 1);
275 delete[] cdef;
276 return c;
277}
278
279void GCanvas::HandleInput(int event, Int_t x, Int_t y)
280{
281 // If the below switch breaks. You need to upgrade your version of ROOT
282 // Version 5.34.24 works. //older version should work now too pcb (8/2015)
283 bool used = false;
284 switch(event) {
285 case kButton1Down: // single click
286 used = StorePosition(event, x, y);
287 if(used) { break; }
288 // next comment prevents warning about falling through for gcc, with c++17 we can also use "[[fallthrough]];"
289 // fall through
290 case kButton1Double: // double click
291 used = HandleMousePress(event, x, y);
292 break;
293 case kButton1Shift: // shift-click
294 used = HandleMouseShiftPress(event, x, y);
295 break;
296 case 9: // control-click
297 used = HandleMouseControlPress(event, x, y);
298 break;
299 case kButton1Up: // button released
300 used = Zoom(event, x, y);
301 break;
302 case kWheelUp:
303 case kWheelDown:
304 used = HandleWheel(event, x, y);
305 break;
306 };
307 if(!used) {
308 TCanvas::HandleInput(static_cast<EEventType>(event), x, y);
309 }
310}
311
312void GCanvas::Draw(Option_t* opt)
313{
314 std::cout << "GCanvas Draw was called." << std::endl;
315 TCanvas::Draw(opt);
316 if(FindObject("TFrame") != nullptr) {
317 FindObject("TFrame")->SetBit(TBox::kCannotMove);
318 }
319}
320
321std::vector<TH1*> GCanvas::FindHists(int dim)
322{
323 std::vector<TH1*> tempvec;
324 TIter iter(gPad->GetListOfPrimitives());
325 while(TObject* obj = iter.Next()) {
326 if(obj->InheritsFrom(TH1::Class())) {
327 TH1* hist = static_cast<TH1*>(obj);
328 if(hist->GetDimension() == dim) {
329 tempvec.push_back(hist);
330 }
331 }
332 }
333 return tempvec;
334}
335
336std::vector<TH1*> GCanvas::FindAllHists()
337{
338 std::vector<TH1*> tempvec;
339 TIter iter(gPad->GetListOfPrimitives());
340 while(TObject* obj = iter.Next()) {
341 if(obj->InheritsFrom("TH1")) {
342 tempvec.push_back(static_cast<TH1*>(obj));
343 }
344 }
345 return tempvec;
346}
347
348bool GCanvas::HandleArrowKeyPress(Event_t* event, const UInt_t* keysym)
349{
350 bool edited = Process1DArrowKeyPress(event, keysym);
351 if(!edited) {
352 edited = Process2DArrowKeyPress(event, keysym);
353 }
354
355 if(edited) {
356 gPad->Modified();
357 gPad->Update();
358 }
359 return true;
360}
361
362bool GCanvas::HandleKeyboardPress(Event_t* event, const UInt_t* keysym)
363{
364 bool edited = false;
365
366 edited = ProcessNonHistKeyboardPress(event, keysym);
367
368 if(!edited) {
369 edited = Process1DKeyboardPress(event, keysym);
370 }
371 if(!edited) {
372 edited = Process2DKeyboardPress(event, keysym);
373 }
374
375 if(edited) {
376 gPad->Modified();
377 gPad->Update();
378 }
379 return true;
380}
381
382bool GCanvas::HandleMousePress(Int_t event, Int_t x, Int_t y)
383{
384 if(GetSelected() == nullptr) {
385 return false;
386 }
387
388 TH1* hist = nullptr;
389 if(GetSelected()->InheritsFrom(TH1::Class())) {
390 hist = static_cast<TH1*>(GetSelected());
391 } else if(GetSelected()->IsA() == TFrame::Class()) {
392 std::vector<TH1*> hists = FindAllHists();
393 if(!hists.empty()) {
394 hist = hists.front();
395
396 // Let everybody know that the histogram is selected
397 SetSelected(hist);
398 SetClickSelected(hist);
399 Selected(GetSelectedPad(), hist, event);
400 }
401 }
402
403 if((hist == nullptr) || hist->GetDimension() > 2) {
404 return false;
405 }
406
407 bool used = false;
408
409 if(fMarkerMode) {
410 AddMarker(x, y, hist);
411 used = true;
412 }
413
414 if(used) {
415 gPad->Modified();
416 gPad->Update();
417 }
418
419 return used;
420}
421
422bool GCanvas::HandleMouseShiftPress(Int_t, Int_t, Int_t)
423{
424 TH1* hist = nullptr;
425 TIter iter(gPad->GetListOfPrimitives());
426 while(TObject* obj = iter.Next()) {
427 if(obj->InheritsFrom(TH1::Class())) {
428 hist = static_cast<TH1*>(obj);
429 }
430 }
431 if(hist == nullptr) {
432 return false;
433 }
434
435 TString options;
436 switch(hist->GetDimension()) {
437 case 1: {
438 if(hist->InheritsFrom(GH1D::Class())) {
439 new GCanvas();
440 (static_cast<GH1D*>(hist))->GetParent()->Draw("colz");
441 return true;
442 }
443 std::vector<TH1*> hists = FindHists(1);
444 new GCanvas();
445 // options.Append("HIST");
446 hists.at(0)->DrawCopy(options.Data());
447 for(unsigned int j = 1; j < hists.size(); j++) {
448 hists.at(j)->DrawCopy("same");
449 }
450 }
451 return true;
452 case 2:
453 options.Append("colz");
454 auto* ghist = new GH2D(*(static_cast<TH2*>(hist)));
455 new GCanvas();
456 ghist->Draw();
457 return true;
458 };
459 return false;
460}
461
462bool GCanvas::HandleMouseControlPress(Int_t, Int_t, Int_t)
463{
464 if(GetSelected() == nullptr) {
465 return false;
466 }
467 if(GetSelected()->InheritsFrom(TCutG::Class())) {
468 // TODO: Bring this back, once we have brought over more from GRUTinizer
469 // if(TRuntimeObjects::Get())
470 // TRuntimeObjects::Get()->GetGates().Add(GetSelected());
471 }
472 return true;
473}
474
475bool GCanvas::StorePosition(Int_t, Int_t px, Int_t py)
476{
477 /// Store the position the mouse button was pressed at.
478 if(std::strcmp(GetName(), "LevelScheme") != 0) { return false; }
479
480 fLastX = PixeltoX(px);
481 fLastY = PixeltoY(py - GetWh()); // see https:://root.cern.ch/root/htmldoc/guides/users-guide/Graphics.html 11.3.3 "Converting between Coordinate Systems"
482
483 return true;
484}
485
486bool GCanvas::Zoom(Int_t, Int_t px, Int_t py)
487{
488 /// Mouse button was released at this point, set the new range.
489
490 if(std::strcmp(GetName(), "LevelScheme") != 0) { return false; }
491
492 double x = PixeltoX(px);
493 double y = PixeltoY(py - GetWh()); // see https:://root.cern.ch/root/htmldoc/guides/users-guide/Graphics.html 11.3.3 "Converting between Coordinate Systems"
494 // ensure x,y is the second point of the range
495 if(fLastX > x) { std::swap(fLastX, x); }
496 if(fLastY > y) { std::swap(fLastY, y); }
497 Range(fLastX, fLastY, x, y);
498 Modified();
499 Update();
500
501 return true;
502}
503
504bool GCanvas::HandleWheel(Int_t event, Int_t px, Int_t py)
505{
506 /// Zoom in (wheel up) and out (wheel down) of level scheme, focused around x, y.
507 /// Does nothing if the canvas doesn't have the name "LevelScheme".
508
509 if(std::strcmp(GetName(), "LevelScheme") != 0) { return false; }
510
511 // convert from pixel coordinates to user coordinates
512 double x = PixeltoX(px);
513 double y = PixeltoY(py - GetWh()); // see https:://root.cern.ch/root/htmldoc/guides/users-guide/Graphics.html 11.3.3 "Converting between Coordinate Systems"
514
515 // get the current range
516 double x1 = 0.;
517 double y1 = 0.;
518 double x2 = 0.;
519 double y2 = 0.;
520 GetRange(x1, y1, x2, y2);
521
522 // calculate the new range
523 double width = (x2 - x1);
524 double height = (y2 - y1);
525
526 if(event == kWheelUp) {
527 width /= 1.1;
528 height /= 1.1;
529 } else if(event == kWheelDown) {
530 width *= 1.1;
531 height *= 1.1;
532 } else {
533 std::cout << "Don't know what to do, got event " << event << " which isn't kWheelUp (" << kWheelUp << ") or kWheelDown (" << kWheelDown << ")" << std::endl;
534 return false;
535 }
536
537 x1 = x - width / 2.;
538 y1 = y - height / 2.;
539 x2 = x + width / 2.;
540 y2 = y + height / 2.;
541
542 Range(x1, y1, x2, y2);
543 Modified();
544 Update();
545
546 return true;
547}
548
550{
551 TH1* hist = nullptr;
552 TIter iter(gPad->GetListOfPrimitives());
553 while(TObject* obj = iter.Next()) {
554 if(obj->InheritsFrom("TH1") && !obj->InheritsFrom("TH2") && !obj->InheritsFrom("TH3")) {
555 hist = static_cast<TH1*>(obj);
556 }
557 }
558 if(hist == nullptr) {
559 return nullptr;
560 }
561 if(hist->GetListOfFunctions()->GetSize() > 0) {
562 TF1* tmpfit = static_cast<TF1*>(hist->GetListOfFunctions()->Last());
563 return tmpfit;
564 }
565 return nullptr;
566}
567
568bool GCanvas::Process1DArrowKeyPress(Event_t*, const UInt_t* keysym)
569{
570 /// Moves displayed 1D histograms by 50% of the visible range left, right, or selects the next (up) or previous (down) GH1D histogram.
571 bool edited = Move1DHistogram(*keysym);
572 if(edited) { RedrawMarkers(); }
573 return edited;
574}
575
576bool GCanvas::ProcessNonHistKeyboardPress(Event_t*, const UInt_t* keysym)
577{
578 bool edited = false;
579
580 switch(*keysym) {
581 case kKey_F2:
582 GetCanvasImp()->ShowEditor(!GetCanvasImp()->HasEditor());
583 edited = true;
584 break;
585 case kKey_F9:
586 SetCrosshair(static_cast<Int_t>(!HasCrosshair()));
587 edited = true;
588 break;
589#if __cplusplus >= 201703L
590 case kKey_u:
591 if(GetListOfPrimitives()->FindObject("TLevelScheme") != nullptr) {
592 static_cast<TLevelScheme*>(GetListOfPrimitives()->FindObject("TLevelScheme"))->UnZoom();
593 edited = true;
594 }
595 break;
596#endif
597 }
598
599 return edited;
600}
601
602bool GCanvas::Process1DKeyboardPress(Event_t*, const UInt_t* keysym)
603{
604 bool edited = false;
605 std::vector<TH1*> hists = FindHists(1);
606 if(hists.empty()) {
607 return edited;
608 }
609
610 switch(*keysym) {
611 case kKey_b: edited = SetBackgroundMarkers(); break;
612
613 case kKey_B: edited = CycleBackgroundSubtraction(); break;
614
615 case kKey_d: {
616 new GPopup(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), 500, 200);
617 } break;
618
619 case kKey_e:
620 if(GetNMarkers() < 2) {
621 break;
622 }
623 {
624 if(fMarkers.at(fMarkers.size() - 1)->GetLocalX() < fMarkers.at(fMarkers.size() - 2)->GetLocalX()) {
625 for(auto* hist : hists) {
626 hist->GetXaxis()->SetRangeUser(fMarkers.at(fMarkers.size() - 1)->GetLocalX(),
627 fMarkers.at(fMarkers.size() - 2)->GetLocalX());
628 }
629 } else {
630 for(auto* hist : hists) {
631 hist->GetXaxis()->SetRangeUser(fMarkers.at(fMarkers.size() - 2)->GetLocalX(),
632 fMarkers.at(fMarkers.size() - 1)->GetLocalX());
633 }
634 }
635 }
636 edited = true;
637 RemoveMarker("all");
638 break;
639 case kKey_E:
640 // GetListOfPrimitives()->Print();
641 GetContextMenu()->Action(hists.back()->GetXaxis(),
642 TAxis::Class()->GetMethodAny("SetRangeUser"));
643 {
644 double x1 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetXaxis()->GetFirst());
645 double x2 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetXaxis()->GetLast());
646 TIter iter(GetListOfPrimitives());
647 while(TObject* obj = iter.Next()) {
648 if(obj->InheritsFrom(TPad::Class())) {
649 TPad* pad = static_cast<TPad*>(obj);
650 TIter iter2(pad->GetListOfPrimitives());
651 while(TObject* obj2 = iter2.Next()) {
652 if(obj2->InheritsFrom(TH1::Class())) {
653 TH1* hist = static_cast<TH1*>(obj2);
654 hist->GetXaxis()->SetRangeUser(x1, x2);
655 pad->Modified();
656 pad->Update();
657 }
658 }
659 }
660 }
661
662 // for(int i=0;i<hists.size()-1;i++) // this doesn't work, set range needs values not bins. pcb.
663 // hists.at(i)->GetXaxis()->SetRangeUser(hists.back()->GetXaxis()->GetFirst(),hists.back()->GetXaxis()->GetLast());
664 }
665 edited = true;
666 break;
667 case kKey_f:
668 if(!hists.empty() && GetNMarkers() > 1) {
669 std::cout << "x low = " << fMarkers.at(fMarkers.size() - 2)->GetLocalX() << "\t\txhigh = " << fMarkers.back()->GetLocalX() << std::endl;
670 if(PhotoPeakFit(hists.back(), fMarkers.at(fMarkers.size() - 2)->GetLocalX(), fMarkers.back()->GetLocalX()) != nullptr) {
671 edited = true;
672 }
673 }
674 break;
675
676 case kKey_F:
677 if(!hists.empty() && GetNMarkers() > 1) {
678 std::cout << "x low = " << fMarkers.at(fMarkers.size() - 2)->GetLocalX() << "\t\txhigh = " << fMarkers.back()->GetLocalX() << std::endl;
679 if(AltPhotoPeakFit(hists.back(), fMarkers.at(fMarkers.size() - 2)->GetLocalX(), fMarkers.back()->GetLocalX(), "+") !=
680 nullptr) {
681 edited = true;
682 }
683 }
684 break;
685
686 case kKey_g:
687 if(!hists.empty() && GetNMarkers() > 1 && GausFit(hists.back(), fMarkers.at(fMarkers.size() - 2)->GetLocalX(), fMarkers.back()->GetLocalX()) != nullptr) {
688 edited = true;
689 }
690 break;
691
692 case kKey_i:
693 if(!hists.empty() && GetNMarkers() > 1) {
694 int binlow = fMarkers.at(fMarkers.size() - 1)->GetBinX();
695 int binhigh = fMarkers.at(fMarkers.size() - 2)->GetBinX();
696 if(binlow > binhigh) {
697 std::swap(binlow, binhigh);
698 }
699 double xlow = hists.back()->GetXaxis()->GetBinLowEdge(binlow);
700 double xhigh = hists.back()->GetXaxis()->GetBinLowEdge(binhigh);
701
702 {
703 double epsilon = 16 * (std::nextafter(xlow, INFINITY) - xlow);
704 xlow += epsilon;
705 }
706
707 {
708 double epsilon = 16 * (xhigh - std::nextafter(xhigh, -INFINITY));
709 xhigh -= epsilon;
710 }
711
712 double sum =
713 hists.back()->Integral(hists.back()->GetXaxis()->FindBin(xlow), hists.back()->GetXaxis()->FindBin(xhigh));
714 std::cout << BLUE << std::endl
715 << "\tSum [" << xlow << " : " << xhigh << "] = " << sum << RESET_COLOR << std::endl;
716 }
717 break;
718 case kKey_I:
719 if(!hists.empty()) {
720 }
721 break;
722 case kKey_l:
723 case kKey_y:
724 if(GetLogy() != 0) {
725 // Show full y range, not restricted to positive values.
726 for(auto* hist : hists) {
727 hist->GetYaxis()->UnZoom();
728 }
729 SetLogy(0);
730 } else {
731 // Only show plot from 0 up when in log scale.
732 for(auto* hist : hists) {
733 if(hist->GetYaxis()->GetXmin() < 0) {
734 hist->GetYaxis()->SetRangeUser(0, hist->GetYaxis()->GetXmax());
735 }
736 }
737 SetLogy(1);
738 }
739 // TODO: Make this work, instead of disappearing the markers in log mode.
740 // RedrawMarkers();
741 edited = true;
742 break;
743
744 case kKey_m: SetMarkerMode(true); break;
745 case kKey_M:
746 SetMarkerMode(false);
747 [[fallthrough]];
748 case kKey_n:
749 RemoveMarker("all");
750 for(auto* hist : hists) {
751 hist->GetListOfFunctions()->Clear();
752 }
753 for(auto* hist : hists) {
754 hist->Sumw2(false);
755 }
756 RemovePeaks(hists.data(), hists.size());
757 edited = true;
758 break;
759 case kKey_N:
760 RemoveMarker("all");
761 for(auto* hist : hists) {
762 hist->GetListOfFunctions()->Clear();
763 }
764 RemovePeaks(hists.data(), hists.size());
765 Clear();
766 hists.at(0)->Draw("hist");
767 for(unsigned int i = 1; i < hists.size(); i++) {
768 hists.at(i)->Draw("histsame");
769 }
770 edited = true;
771 break;
772 case kKey_o:
773 case kKey_u:
774 for(auto* hist : hists) {
775 hist->GetXaxis()->UnZoom();
776 hist->GetYaxis()->UnZoom();
777 }
778 RemoveMarker("all");
779 edited = true;
780 break;
781
782 case kKey_p: {
783 if(GetNMarkers() < 2) {
784 break;
785 }
786 GH1D* ghist = nullptr;
787 for(auto* hist : hists) {
788 if(hist->InheritsFrom(GH1D::Class())) {
789 ghist = static_cast<GH1D*>(hist);
790 break;
791 }
792 }
793 // ok, i found a bug. if someone tries to gate on a histogram
794 // that is already zoomed, bad things will happen; namely the bins
795 // in the zoomed histogram will not map correctly to the parent. To get
796 // around this we need the bin value, not the bin! pcb.
797 //
798 if(ghist != nullptr) {
799 GH1D* proj = nullptr;
800 int binlow = fMarkers.at(fMarkers.size() - 1)->GetBinX();
801 int binhigh = fMarkers.at(fMarkers.size() - 2)->GetBinX();
802 if(binlow > binhigh) {
803 std::swap(binlow, binhigh);
804 }
805 double value_low = ghist->GetXaxis()->GetBinLowEdge(binlow);
806 double value_high = ghist->GetXaxis()->GetBinLowEdge(binhigh);
807
808 {
809 double epsilon = 16 * (std::nextafter(value_low, INFINITY) - value_low);
810 value_low += epsilon;
811 }
812
813 {
814 double epsilon = 16 * (value_high - std::nextafter(value_high, -INFINITY));
815 value_high -= epsilon;
816 }
817
819 int bg_binlow = fBackgroundMarkers.at(0)->GetBinX();
820 int bg_binhigh = fBackgroundMarkers.at(1)->GetBinX();
821 if(bg_binlow > bg_binhigh) {
822 std::swap(bg_binlow, bg_binhigh);
823 }
824 double bg_value_low = ghist->GetXaxis()->GetBinCenter(bg_binlow);
825 double bg_value_high = ghist->GetXaxis()->GetBinCenter(bg_binhigh);
826 // Using binhigh-1 instead of binhigh,
827 // because the ProjectionX/Y functions from ROOT use inclusive bin numbers,
828 // rather than exclusive.
829 //
830 proj = ghist->Project_Background(value_low, value_high, bg_value_low, bg_value_high, fBackgroundMode);
831 } else {
832 proj = ghist->Project(value_low, value_high);
833 }
834 if(proj != nullptr) {
835 proj->Draw("");
836 edited = true;
837 }
838 }
839 } break;
840
841 case kKey_P: {
842 GH1D* ghist = nullptr;
843 for(auto* hist : hists) {
844 if(hist->InheritsFrom(GH1D::Class())) {
845 ghist = static_cast<GH1D*>(hist);
846 break;
847 }
848 }
849
850 if(ghist != nullptr) {
851 ghist->GetParent()->Draw();
852 edited = true;
853 }
854 } break;
855 case kKey_q: {
856 TH1* ghist = hists.at(0);
857 if(GetNMarkers() > 1) {
858 edited = (PhotoPeakFit(ghist, fMarkers.at(fMarkers.size() - 2)->GetLocalX(), fMarkers.back()->GetLocalX()) != nullptr);
859 }
860 if(edited) {
861 ghist->Draw("hist");
862
863 TIter iter(ghist->GetListOfFunctions());
864 while(TObject* o = iter.Next()) {
865 if(o->InheritsFrom(TF1::Class())) {
866 (static_cast<TF1*>(o))->Draw("same");
867 }
868 }
869 }
870 }
871
872 break;
873
874 case kKey_r:
875 if(GetNMarkers() < 2) {
876 break;
877 }
878 {
879 if(fMarkers.at(fMarkers.size() - 1)->GetLocalY() < fMarkers.at(fMarkers.size() - 2)->GetLocalY()) {
880 for(auto* hist : hists) {
881 hist->GetYaxis()->SetRangeUser(fMarkers.at(fMarkers.size() - 1)->GetLocalY(),
882 fMarkers.at(fMarkers.size() - 2)->GetLocalY());
883 }
884 } else {
885 for(auto* hist : hists) {
886 hist->GetYaxis()->SetRangeUser(fMarkers.at(fMarkers.size() - 2)->GetLocalY(),
887 fMarkers.at(fMarkers.size() - 1)->GetLocalY());
888 }
889 }
890 }
891 edited = true;
892 RemoveMarker("all");
893 break;
894 case kKey_R:
895 // GetListOfPrimitives()->Print();
896 GetContextMenu()->Action(hists.back()->GetYaxis(),
897 TAxis::Class()->GetMethodAny("SetRangeUser"));
898 {
899 double y1 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetYaxis()->GetFirst());
900 double y2 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetYaxis()->GetLast());
901 TIter iter(GetListOfPrimitives());
902 while(TObject* obj = iter.Next()) {
903 if(obj->InheritsFrom(TPad::Class())) {
904 TPad* pad = static_cast<TPad*>(obj);
905 TIter iter2(pad->GetListOfPrimitives());
906 while(TObject* obj2 = iter2.Next()) {
907 if(obj2->InheritsFrom(TH1::Class())) {
908 TH1* hist = static_cast<TH1*>(obj2);
909 hist->GetYaxis()->SetRangeUser(y1, y2);
910 pad->Modified();
911 pad->Update();
912 }
913 }
914 }
915 }
916
917 // for(int i=0;i<hists.size()-1;i++) // this doesn't work, set range needs values not bins. pcb.
918 // hists.at(i)->GetXaxis()->SetRangeUser(hists.back()->GetXaxis()->GetFirst(),hists.back()->GetXaxis()->GetLast());
919 }
920 edited = true;
921 break;
922
923 case kKey_s:
924
925 if(GetNMarkers() < 2) {
926 edited = ShowPeaks(hists.data(), hists.size());
927 RemoveMarker("all");
928 } else {
929 double x1 = fMarkers.at(fMarkers.size() - 1)->GetLocalX();
930 double x2 = fMarkers.at(fMarkers.size() - 2)->GetLocalX();
931 if(x1 > x2) {
932 std::swap(x1, x2);
933 }
934 double y1 = fMarkers.at(fMarkers.size() - 1)->GetLocalY();
935 double y2 = fMarkers.at(fMarkers.size() - 2)->GetLocalY();
936 if(y1 > y2) {
937 std::swap(y1, y2);
938 }
939
940 double ymax = hists.at(0)->GetMaximum();
941 double thresh = y1 / ymax;
942 double sigma = x2 - x1;
943 if(sigma > 10.0) {
944 sigma = 10.0;
945 }
946 edited = ShowPeaks(hists.data(), hists.size(), sigma, thresh);
947 RemoveMarker("all");
948 }
949 break;
950 case kKey_S:
951
952 if(GetNMarkers() < 2) {
953 edited = ShowPeaks(hists.data(), hists.size());
954 RemoveMarker("all");
955 } else {
956 double x1 = fMarkers.at(fMarkers.size() - 1)->GetLocalX();
957 double x2 = fMarkers.at(fMarkers.size() - 2)->GetLocalX();
958 if(x1 > x2) {
959 std::swap(x1, x2);
960 }
961 double y1 = fMarkers.at(fMarkers.size() - 1)->GetLocalY();
962 double y2 = fMarkers.at(fMarkers.size() - 2)->GetLocalY();
963 if(y1 > y2) {
964 std::swap(y1, y2);
965 }
966
967 double ymax = hists.at(0)->GetMaximum();
968 double thresh = y1 / ymax;
969 double sigma = 1.0;
970 if(sigma > 10.0) {
971 sigma = 10.0;
972 }
973 edited = ShowPeaks(hists.data(), hists.size(), sigma, thresh);
974 RemoveMarker("all");
975 }
976 break;
977 case kKey_F9: {
978 int color = hists.at(0)->GetLineColor() + 1;
979 if(color > 9) {
980 color = 1;
981 }
982 hists.at(0)->SetLineColor(static_cast<Color_t>(color));
983 edited = true;
984 } break;
985
986 case kKey_F10: {
987 } break;
988 };
989 return edited;
990}
991
992bool GCanvas::Process1DMousePress(Int_t, Int_t, Int_t)
993{
994 bool edited = false;
995 return edited;
996}
997
998bool GCanvas::Process2DArrowKeyPress(Event_t*, const UInt_t* keysym)
999{
1000 /// Moves displayed 2D histograms by 50% of the visible range left, right, up, or down
1001 return Move2DHistogram(*keysym);
1002}
1003
1004bool GCanvas::Process2DKeyboardPress(Event_t*, const UInt_t* keysym)
1005{
1006 bool edited = false;
1007 std::vector<TH1*> hists = FindHists(2);
1008 if(hists.empty()) {
1009 return edited;
1010 }
1011 switch(*keysym) {
1012 case kKey_c: {
1013 TString defaultName = "cut";
1014 if(gROOT->FindObject("CUTG") == nullptr) {
1015 std::cout << "Something went wrong, can't find 'CUTG', did you initialize the cut beforehand? Or maybe you already pressed c?" << std::endl
1016 << "Current list of cuts is ";
1017 if(fCuts.empty()) { std::cout << "empty"; }
1018 for(auto* cut : fCuts) {
1019 std::cout << cut->GetName() << " ";
1020 }
1021 std::cout << std::endl;
1022 break;
1023 }
1024 fCuts.push_back(static_cast<TCutG*>(gROOT->FindObject("CUTG")));
1025 fCuts.back()->SetName(fCutName);
1026 std::cout << "Added cut to list of cuts: ";
1027 for(auto* cut : fCuts) {
1028 std::cout << cut->GetName() << " ";
1029 }
1030 std::cout << std::endl;
1031 } break;
1032
1033 case kKey_e:
1034 if(GetNMarkers() < 2) {
1035 break;
1036 }
1037 {
1038 double x1 = fMarkers.at(fMarkers.size() - 1)->GetLocalX();
1039 double y1 = fMarkers.at(fMarkers.size() - 1)->GetLocalY();
1040 double x2 = fMarkers.at(fMarkers.size() - 2)->GetLocalX();
1041 double y2 = fMarkers.at(fMarkers.size() - 2)->GetLocalY();
1042 if(x1 > x2) {
1043 std::swap(x1, x2);
1044 }
1045 if(y1 > y2) {
1046 std::swap(y1, y2);
1047 }
1048 for(auto* hist : hists) {
1049 hist->GetXaxis()->SetRangeUser(x1, x2);
1050 hist->GetYaxis()->SetRangeUser(y1, y2);
1051 }
1052 }
1053 edited = true;
1054 RemoveMarker("all");
1055 break;
1056
1057 case kKey_E:
1058 // GetListOfPrimitives()->Print();
1059 GetContextMenu()->Action(hists.back()->GetXaxis(),
1060 TAxis::Class()->GetMethodAny("SetRangeUser"));
1061 {
1062 double x1 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetXaxis()->GetFirst());
1063 double x2 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetXaxis()->GetLast());
1064 TIter iter(GetListOfPrimitives());
1065 while(TObject* obj = iter.Next()) {
1066 if(obj->InheritsFrom(TPad::Class())) {
1067 TPad* pad = static_cast<TPad*>(obj);
1068 TIter iter2(pad->GetListOfPrimitives());
1069 while(TObject* obj2 = iter2.Next()) {
1070 if(obj2->InheritsFrom(TH1::Class())) {
1071 TH1* hist = static_cast<TH1*>(obj2);
1072 hist->GetXaxis()->SetRangeUser(x1, x2);
1073 pad->Modified();
1074 pad->Update();
1075 }
1076 }
1077 }
1078 }
1079
1080 // for(int i=0;i<hists.size()-1;i++) // this doesn't work, set range needs values not bins. pcb.
1081 // hists.at(i)->GetXaxis()->SetRangeUser(hists.back()->GetXaxis()->GetFirst(),hists.back()->GetXaxis()->GetLast());
1082 }
1083 edited = true;
1084 break;
1085
1086 case kKey_g:
1087 if(GetNMarkers() < 2) {
1088 break;
1089 }
1090 {
1091 static int cutcounter = 0;
1092 auto* cut = new TCutG(Form("_cut%i", cutcounter++), 9);
1093 // cut->SetVarX("");
1094 // cut->SetVarY("");
1095 //
1096 double x1 = fMarkers.at(fMarkers.size() - 1)->GetLocalX();
1097 double y1 = fMarkers.at(fMarkers.size() - 1)->GetLocalY();
1098 double x2 = fMarkers.at(fMarkers.size() - 2)->GetLocalX();
1099 double y2 = fMarkers.at(fMarkers.size() - 2)->GetLocalY();
1100 if(x1 > x2) {
1101 std::swap(x1, x2);
1102 }
1103 if(y1 > y2) {
1104 std::swap(y1, y2);
1105 }
1106 double xdist = (x2 - x1) / 2.0;
1107 double ydist = (y2 - y1) / 2.0;
1108 //
1109 //
1110 cut->SetPoint(0, x1, y1);
1111 cut->SetPoint(1, x1, y1 + ydist);
1112 cut->SetPoint(2, x1, y2);
1113 cut->SetPoint(3, x1 + xdist, y2);
1114 cut->SetPoint(4, x2, y2);
1115 cut->SetPoint(5, x2, y2 - ydist);
1116 cut->SetPoint(6, x2, y1);
1117 cut->SetPoint(7, x2 - xdist, y1);
1118 cut->SetPoint(8, x1, y1);
1119 cut->SetLineColor(kBlack);
1120 hists.at(0)->GetListOfFunctions()->Add(cut);
1121
1122 // TODO: Bring this back once we have pulled in parts of TGRUTint
1123 // TGRSIint::instance()->LoadTCutG(cut);
1124 }
1125 edited = true;
1126 RemoveMarker("all");
1127 break;
1128
1129 case kKey_i: {
1130 TString defaultName = "cut";
1131 new TGInputDialog(nullptr, static_cast<TRootCanvas*>(GetCanvasImp()), "Enter name of cut", defaultName, fCutName);
1132 if(strlen(fCutName) == 0) {
1133 break;
1134 }
1135 gROOT->SetEditorMode("CutG");
1136 } break;
1137
1138 case kKey_n:
1139 RemoveMarker("all");
1140 // for(unsigned int i=0;i<hists.size();i++)
1141 // hists.at(i)->GetListOfFunctions()->Delete();
1142 RemovePeaks(hists.data(), hists.size());
1143 for(auto* hist : hists) {
1144 hist->Sumw2(false);
1145 }
1146 edited = true;
1147 break;
1148 case kKey_o:
1149 case kKey_u:
1150 for(auto* hist : hists) {
1151 TH2* h = static_cast<TH2*>(hist);
1152 h->GetXaxis()->UnZoom();
1153 h->GetYaxis()->UnZoom();
1154 }
1155 RemoveMarker("all");
1156 edited = true;
1157 break;
1158 case kKey_P: {
1159 GH2D* ghist = nullptr;
1160 for(auto* hist : hists) {
1161 if(hist->InheritsFrom(GH2Base::Class())) {
1162 ghist = static_cast<GH2D*>(hist);
1163 break;
1164 }
1165 }
1166
1167 if((ghist != nullptr) && (ghist->GetProjections()->GetSize() != 0)) {
1168 ghist->GetProjections()->At(0)->Draw("");
1169 edited = true;
1170 }
1171 } break;
1172 case kKey_r:
1173 if(GetNMarkers() < 2) {
1174 break;
1175 }
1176 {
1177 if(fMarkers.at(fMarkers.size() - 1)->GetLocalY() < fMarkers.at(fMarkers.size() - 2)->GetLocalY()) {
1178 for(auto* hist : hists) {
1179 hist->GetYaxis()->SetRangeUser(fMarkers.at(fMarkers.size() - 1)->GetLocalY(),
1180 fMarkers.at(fMarkers.size() - 2)->GetLocalY());
1181 }
1182 } else {
1183 for(auto* hist : hists) {
1184 hist->GetYaxis()->SetRangeUser(fMarkers.at(fMarkers.size() - 2)->GetLocalY(),
1185 fMarkers.at(fMarkers.size() - 1)->GetLocalY());
1186 }
1187 }
1188 }
1189 edited = true;
1190 RemoveMarker("all");
1191 break;
1192 case kKey_R:
1193 // GetListOfPrimitives()->Print();
1194 GetContextMenu()->Action(hists.back()->GetYaxis(),
1195 TAxis::Class()->GetMethodAny("SetRangeUser"));
1196 {
1197 double y1 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetYaxis()->GetFirst());
1198 double y2 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetYaxis()->GetLast());
1199 TIter iter(GetListOfPrimitives());
1200 while(TObject* obj = iter.Next()) {
1201 if(obj->InheritsFrom(TPad::Class())) {
1202 TPad* pad = static_cast<TPad*>(obj);
1203 TIter iter2(pad->GetListOfPrimitives());
1204 while(TObject* obj2 = iter2.Next()) {
1205 if(obj2->InheritsFrom(TH1::Class())) {
1206 TH1* hist = static_cast<TH1*>(obj2);
1207 hist->GetYaxis()->SetRangeUser(y1, y2);
1208 pad->Modified();
1209 pad->Update();
1210 }
1211 }
1212 }
1213 }
1214
1215 // for(int i=0;i<hists.size()-1;i++) // this doesn't work, set range needs values not bins. pcb.
1216 // hists.at(i)->GetXaxis()->SetRangeUser(hists.back()->GetXaxis()->GetFirst(),hists.back()->GetXaxis()->GetLast());
1217 }
1218 edited = true;
1219 break;
1220
1221 case kKey_s: {
1222 TDirectory* oldDir = gDirectory;
1223 TString defaultName = "CutFile.cuts";
1224 char* fileName = new char[256];
1225 new TGInputDialog(nullptr, static_cast<TRootCanvas*>(GetCanvasImp()), "Enter file name to save cuts to", defaultName, fileName);
1226 if(strlen(fileName) == 0) {
1227 break;
1228 }
1229 TFile f(fileName, "update");
1230 if(!f.IsOpen()) {
1231 std::cout << RESET_COLOR << "Failed to open file '" << fileName << "', not saving cuts!" << std::endl;
1232 break;
1233 }
1234 std::cout << RESET_COLOR << "Writing the following cuts to '" << fileName << "':" << std::endl;
1235 for(auto* cut : fCuts) {
1236 std::cout << cut->GetName() << std::endl;
1237 cut->Write();
1238 }
1239 f.Close();
1240 delete[] fileName;
1241 oldDir->cd();
1242 } break;
1243
1244 case kKey_x: {
1245 GH2D* ghist = nullptr;
1246 for(auto* hist : hists) {
1247 if(hist->InheritsFrom(GH2Base::Class())) {
1248 ghist = static_cast<GH2D*>(hist);
1249 break;
1250 }
1251 }
1252
1253 if(ghist != nullptr) {
1254 ghist->SetSummary(false);
1255 TH1* phist = ghist->ProjectionX(); //->Draw();
1256 if(phist != nullptr) {
1257 new GCanvas();
1258 phist->Draw("");
1259 }
1260 edited = true;
1261 }
1262 } break;
1263
1264 case kKey_X: {
1265 GH2D* ghist = nullptr;
1266 for(auto* hist : hists) {
1267 if(hist->InheritsFrom(GH2Base::Class())) {
1268 ghist = static_cast<GH2D*>(hist);
1269 break;
1270 }
1271 }
1272
1273 if(ghist != nullptr) {
1274 ghist->SetSummary(true);
1276 TH1* phist = ghist->GetNextSummary(nullptr, false);
1277 if(phist != nullptr) {
1278 new GCanvas();
1279 phist->Draw("");
1280 }
1281 edited = true;
1282 }
1283 } break;
1284
1285 case kKey_y: {
1286 GH2D* ghist = nullptr;
1287 for(auto* hist : hists) {
1288 if(hist->InheritsFrom(GH2Base::Class())) {
1289 ghist = static_cast<GH2D*>(hist);
1290 break;
1291 }
1292 }
1293
1294 if(ghist != nullptr) {
1295 ghist->SetSummary(false);
1296 TH1* phist = ghist->ProjectionY(); //->Draw();
1297 if(phist != nullptr) {
1298 new GCanvas();
1299 phist->Draw("");
1300 }
1301 edited = true;
1302 }
1303 } break;
1304
1305 case kKey_Y: {
1306 GH2D* ghist = nullptr;
1307 for(auto* hist : hists) {
1308 if(hist->InheritsFrom(GH2Base::Class())) {
1309 ghist = static_cast<GH2D*>(hist);
1310 break;
1311 }
1312 }
1313
1314 if(ghist != nullptr) {
1315 ghist->SetSummary(true);
1317 // TH1* phist = ghist->SummaryProject(1);
1318 TH1* phist = ghist->GetNextSummary(nullptr, false);
1319 if(phist != nullptr) {
1320 new GCanvas();
1321 phist->Draw("");
1322 }
1323 edited = true;
1324 }
1325 } break;
1326
1327 case kKey_l:
1328 case kKey_z:
1329 if(GetLogz() != 0) {
1330 // Show full z range, not restricted to positive values.
1331 for(auto* hist : hists) {
1332 hist->GetZaxis()->UnZoom();
1333 }
1334 TVirtualPad* cpad = gPad;
1335 cd();
1336 gPad->SetLogz(0);
1337 cpad->cd();
1338 } else {
1339 // Only show plot from 0 up when in log scale.
1340 for(auto* hist : hists) {
1341 if(hist->GetZaxis()->GetXmin() < 0) {
1342 hist->GetZaxis()->SetRangeUser(0, hist->GetYaxis()->GetXmax());
1343 }
1344 }
1345 TVirtualPad* cpad = gPad;
1346 cd();
1347 gPad->SetLogz(1);
1348 cpad->cd();
1349 }
1350 edited = true;
1351 break;
1352 };
1353 return edited;
1354}
1355
1356bool GCanvas::Process2DMousePress(Int_t, Int_t, Int_t)
1357{
1358 bool edited = false;
1359 return edited;
1360}
bool Move2DHistogram(const Int_t &key, TH2 *histogram=nullptr)
bool ShowPeaks(TH1 **, unsigned int, double sigma=2.0, double thresh=0.02)
bool Move1DHistogram(const Int_t &key, TH1 *histogram=nullptr)
GGaus * GausFit(TH1 *, double, double, Option_t *opt="")
void Prompt()
GPeak * PhotoPeakFit(TH1 *, double, double, Option_t *opt="")
TPeak * AltPhotoPeakFit(TH1 *, double, double, Option_t *opt="")
bool RemovePeaks(TH1 **, unsigned int)
#define BLUE
Definition Globals.h:6
#define RESET_COLOR
Definition Globals.h:5
TH1D * hist
Definition UserFillObj.h:3
static GCanvas * MakeDefCanvas()
Definition GCanvas.cxx:258
GCanvas(Bool_t build=kTRUE)
Definition GCanvas.cxx:86
EBackgroundSubtraction fBackgroundMode
Definition GCanvas.h:277
bool Process2DMousePress(Int_t event, Int_t x, Int_t y)
Definition GCanvas.cxx:1356
bool HandleMouseControlPress(Int_t event, Int_t x, Int_t y)
Definition GCanvas.cxx:462
bool HandleArrowKeyPress(Event_t *event, const UInt_t *keysym)
Definition GCanvas.cxx:348
void GCanvasInit()
Definition GCanvas.cxx:122
bool HandleMousePress(Int_t event, Int_t x, Int_t y)
Definition GCanvas.cxx:382
void RedrawMarkers()
Definition GCanvas.cxx:177
std::vector< TCutG * > fCuts
Definition GCanvas.h:278
bool StorePosition(Int_t event, Int_t x, Int_t y)
Definition GCanvas.cxx:475
bool fGuiEnabled
Definition GCanvas.h:272
bool fMarkerMode
Definition GCanvas.h:274
static double fLastY
Definition GCanvas.h:270
void SetMarkerMode(bool flag=true)
Definition GCanvas.h:260
bool SetBackgroundMarkers()
Definition GCanvas.cxx:191
char * fCutName
Definition GCanvas.h:279
static TF1 * GetLastFit()
Definition GCanvas.cxx:549
bool Process1DKeyboardPress(Event_t *event, const UInt_t *keysym)
Definition GCanvas.cxx:602
bool CycleBackgroundSubtraction()
Definition GCanvas.cxx:219
bool Process1DArrowKeyPress(Event_t *event, const UInt_t *keysym)
Definition GCanvas.cxx:568
bool Process2DKeyboardPress(Event_t *event, const UInt_t *keysym)
Definition GCanvas.cxx:1004
void OrderMarkers()
Definition GCanvas.cxx:172
bool Process2DArrowKeyPress(Event_t *event, const UInt_t *keysym)
Definition GCanvas.cxx:998
bool Zoom(Int_t event, Int_t x, Int_t y)
Definition GCanvas.cxx:486
static std::vector< TH1 * > FindAllHists()
Definition GCanvas.cxx:336
void HandleInput(int event, Int_t x, Int_t y)
Definition GCanvas.cxx:279
std::vector< GMarker * > fBackgroundMarkers
Definition GCanvas.h:276
void Draw(Option_t *opt="") override
Definition GCanvas.cxx:312
bool HandleKeyboardPress(Event_t *event, const UInt_t *keysym)
Definition GCanvas.cxx:362
bool HandleWheel(Int_t event, Int_t x, Int_t y)
Definition GCanvas.cxx:504
void AddMarker(int, int, TH1 *hist)
Definition GCanvas.cxx:137
static double fLastX
Definition GCanvas.h:269
bool HandleMouseShiftPress(Int_t event, Int_t x, Int_t y)
Definition GCanvas.cxx:422
std::vector< GMarker * > fMarkers
Definition GCanvas.h:275
void RemoveMarker(Option_t *opt="")
Definition GCanvas.cxx:150
Int_t GetNMarkers()
Definition GCanvas.h:259
bool ProcessNonHistKeyboardPress(Event_t *event, const UInt_t *keysym)
Definition GCanvas.cxx:576
bool Process1DMousePress(Int_t event, Int_t x, Int_t y)
Definition GCanvas.cxx:992
static std::vector< TH1 * > FindHists(int dim=1)
Definition GCanvas.cxx:321
Definition GH1D.h:17
GH1D * Project_Background(double value_low, double value_high, double bg_value_low, double bg_value_high, EBackgroundSubtraction mode=EBackgroundSubtraction::kRegionBackground) const
Definition GH1D.cxx:190
GH1D * Project(int bins=-1)
Definition GH1D.cxx:220
void Draw(Option_t *opt="") override
Definition GH1D.cxx:108
TObject * GetParent() const
Definition GH1D.h:40
GH1D * GetNextSummary(const GH1D *curr, bool DrawEmpty=false)
Definition GH2Base.cxx:244
TList * GetProjections()
Definition GH2Base.h:60
void SetSummary(bool is_summary=true)
Definition GH2Base.h:63
void SetSummaryDirection(EDirection dir)
Definition GH2Base.h:66
Definition GH2D.h:18
GH1D * ProjectionX(const char *name="_px", int firstbin=0, int lastbin=-1, Option_t *option="")
Definition GH2D.cxx:114
GH1D * ProjectionY(const char *name="_py", int firstbin=0, int lastbin=-1, Option_t *option="")
Definition GH2D.cxx:119
TLine * fLineX
Definition GCanvas.h:155
TLine * fLineY
Definition GCanvas.h:156
void Copy(TObject &object) const override
Definition GCanvas.cxx:75
const TH1 * fHist
Definition GCanvas.h:154
GMarker()=default
Definition GPopup.h:6