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