GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
GH1D.cxx
Go to the documentation of this file.
1#include "GH1D.h"
2
3#include <iostream>
4#include <fstream>
5#include <cstring>
6
7#include "TVirtualPad.h"
8#include "TString.h"
9#include "TF1.h"
10#include "TFrame.h"
11//#include "TROOT.h"
12//#include "TSystem.h"
13#include "KeySymbols.h"
14#include "TVirtualX.h"
15
16#include "Globals.h"
17#include "GRootCommands.h"
18#include "GCanvas.h"
19#include "GH2I.h"
20#include "GH2D.h"
21
23
24GH1D::GH1D(const TH1& source) : fParent(nullptr), fProjectionAxis(-1)
25{
26 source.Copy(*this);
27}
28
29GH1D::GH1D(const TH1* source) : fParent(nullptr), fProjectionAxis(-1)
30{
31 source->Copy(*this);
32}
33
34GH1D::GH1D(const TF1& function, Int_t nbinsx, Double_t xlow, Double_t xup)
35 : TH1D(Form("%s_hist", function.GetName()), Form("%s_hist", function.GetName()), nbinsx, xlow, xup), fParent(nullptr),
36 fProjectionAxis(-1)
37{
38 for(int i = 0; i < nbinsx; i++) {
39 Fill(GetBinCenter(i), function.Eval(i));
40 }
41}
42
43bool GH1D::WriteDatFile(const char* outFile)
44{
45 if(strlen(outFile) < 1) {
46 return false;
47 }
48
49 std::ofstream out;
50 out.open(outFile);
51
52 if(!(out.is_open())) {
53 return false;
54 }
55
56 for(int i = 0; i < GetNbinsX(); i++) {
57 out << GetXaxis()->GetBinCenter(i) << "\t" << GetBinContent(i) << std::endl;
58 }
59 out << std::endl;
60 out.close();
61
62 return true;
63}
64
65/*
66GH1D::GH1D(const TH1 *source)
67 : fParent(nullptr), fProjectionAxis(-1) {
68 if(source->GetDiminsion()>1) {
69 return;
70 }
71
72 // Can copy from any 1-d TH1, not just a TH1D
73 source->Copy(*this);
74
75 // Force a refresh of any parameters stored in the option string.
76 SetOption(GetOption());
77}
78
79void GH1D::SetOption(Option_t* opt) {
80 fOption = opt;
81
82 TString sopt = opt;
83 if(sopt.Index("axis:")) {
84 fProjectionAxis = 0;// TODO
85 }
86}
87*/
88
89void GH1D::Clear(Option_t* opt)
90{
91 TH1D::Clear(opt);
92 fParent = nullptr;
93}
94
95void GH1D::Print(Option_t* opt) const
96{
97 TH1D::Print(opt);
98 std::cout << "\tParent: " << fParent.GetObject() << std::endl;
99}
100
101void GH1D::Copy(TObject& obj) const
102{
103 TH1D::Copy(obj);
104
105 static_cast<GH1D&>(obj).fParent = fParent;
106}
107
108void GH1D::Draw(Option_t* opt)
109{
110 TString option(opt);
111 if(option.Contains("new", TString::kIgnoreCase)) {
112 option.ReplaceAll("new", "");
113 new GCanvas;
114 }
115 TH1D::Draw(option.Data());
116 DrawRegions(opt);
117 if(gPad != nullptr) {
118 gPad->Update();
119 gPad->GetFrame()->SetBit(TBox::kCannotMove);
120 SetPad(gPad);
121 }
122}
123
124TH1* GH1D::DrawCopy(Option_t* opt, const char* name_postfix) const
125{
126 TH1* hist = TH1D::DrawCopy(opt, name_postfix);
127 if(gPad != nullptr) {
128 gPad->Update();
129 gPad->GetFrame()->SetBit(TBox::kCannotMove);
130 }
131 return hist;
132}
133
134TH1* GH1D::DrawNormalized(Option_t* opt, Double_t norm) const
135{
136 TH1* hist = TH1D::DrawNormalized(opt, norm);
137 if(gPad != nullptr) {
138 gPad->Update();
139 gPad->GetFrame()->SetBit(TBox::kCannotMove);
140 }
141 return hist;
142}
143
144GH1D* GH1D::GetPrevious(bool DrawEmpty) const
145{
146 if((fParent.GetObject() != nullptr) && fParent.GetObject()->InheritsFrom(GH2Base::Class())) {
147 GH2D* gpar = static_cast<GH2D*>(fParent.GetObject());
148 int first = GetXaxis()->GetFirst();
149 int last = GetXaxis()->GetLast();
150 GH1D* prev = gpar->GetPrevious(this, DrawEmpty);
151 prev->GetXaxis()->SetRange(first, last);
152 return prev; // gpar->GetPrevious(this,DrawEmpty);
153 }
154 return nullptr;
155}
156
157GH1D* GH1D::GetNext(bool DrawEmpty) const
158{
159 if((fParent.GetObject() != nullptr) && fParent.GetObject()->InheritsFrom(GH2Base::Class())) {
160 GH2D* gpar = static_cast<GH2D*>(fParent.GetObject());
161 int first = GetXaxis()->GetFirst();
162 int last = GetXaxis()->GetLast();
163 GH1D* next = gpar->GetNext(this, DrawEmpty);
164 next->GetXaxis()->SetRange(first, last);
165 return next; // gpar->GetNext(this,DrawEmpty);
166 }
167 return nullptr;
168}
169
170GH1D* GH1D::Project(double value_low, double value_high) const
171{
172
173 if((fParent.GetObject() != nullptr) && fParent.GetObject()->InheritsFrom(GH2Base::Class()) && fProjectionAxis != -1) {
174 if(value_low > value_high) {
175 std::swap(value_low, value_high);
176 }
177 GH2D* gpar = static_cast<GH2D*>(fParent.GetObject());
178 if(fProjectionAxis == 0) {
179 int bin_low = gpar->GetXaxis()->FindBin(value_low);
180 int bin_high = gpar->GetXaxis()->FindBin(value_high);
181 return gpar->ProjectionY("_py", bin_low, bin_high);
182 }
183 int bin_low = gpar->GetYaxis()->FindBin(value_low);
184 int bin_high = gpar->GetYaxis()->FindBin(value_high);
185 return gpar->ProjectionX("_px", bin_low, bin_high);
186 }
187 return nullptr;
188}
189
190GH1D* GH1D::Project_Background(double value_low, double value_high, double bg_value_low, double bg_value_high,
191 EBackgroundSubtraction mode) const
192{
193 if((fParent.GetObject() != nullptr) && fParent.GetObject()->InheritsFrom(GH2Base::Class()) && fProjectionAxis != -1) {
194 if(value_low > value_high) {
195 std::swap(value_low, value_high);
196 }
197 if(bg_value_low > bg_value_high) {
198 std::swap(bg_value_low, bg_value_high);
199 }
200
201 GH2D* gpar = static_cast<GH2D*>(fParent.GetObject());
202 if(fProjectionAxis == 0) {
203 int bin_low = gpar->GetXaxis()->FindBin(value_low);
204 int bin_high = gpar->GetXaxis()->FindBin(value_high);
205 int bg_bin_low = gpar->GetXaxis()->FindBin(bg_value_low);
206 int bg_bin_high = gpar->GetXaxis()->FindBin(bg_value_high);
207
208 return gpar->ProjectionY_Background(bin_low, bin_high, bg_bin_low, bg_bin_high, mode);
209 }
210 int bin_low = gpar->GetYaxis()->FindBin(value_low);
211 int bin_high = gpar->GetYaxis()->FindBin(value_high);
212 int bg_bin_low = gpar->GetYaxis()->FindBin(bg_value_low);
213 int bg_bin_high = gpar->GetYaxis()->FindBin(bg_value_high);
214
215 return gpar->ProjectionX_Background(bin_low, bin_high, bg_bin_low, bg_bin_high, mode);
216 }
217 return nullptr;
218}
219
221{
222 GH1D* proj = nullptr;
223 double ymax = GetMinimum();
224 double ymin = GetMaximum();
225 if(bins == -1) {
226 bins = static_cast<int>(std::abs(ymax - ymin));
227 if(bins < 1) {
228 bins = 100;
229 }
230 }
231 proj = new GH1D(Form("%s_y_axis_projection", GetName()), Form("%s_y_axis_projection", GetName()), bins, ymin, ymax);
232 for(int i = 0; i < GetNbinsX(); i++) {
233 if(GetBinContent(i) != 0) {
234 proj->Fill(GetBinContent(i));
235 }
236 }
237
238 return proj;
239}
240
241void GH1D::SetPad(TVirtualPad* pad)
242{
243 fPad = pad;
244 fPad->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "GH1D", this, "HandleMovement(Int_t,Int_t,Int_t, TObject*)");
245 gClient->Connect("ProcessedEvent(Event_t*, Window_t)", "GH1D", this, "HandleEvent(Event_t*, Window_t)");
246}
247
248void GH1D::HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject* selected)
249{
250 double currentX = fPad->PixeltoX(eventX);
251 double currentY = fPad->PixeltoY(eventY - fPad->GetWh());
252
253 if(selected != nullptr && selected->InheritsFrom(TRegion::Class())) {
254 auto* region = static_cast<TRegion*>(selected);
255 if(eventType == kKeyPress && eventX == kKey_d) {
256 RemoveRegion(region);
257 } else if(eventType == kButton1Down) {
258 fStartX = currentX;
259 fStartY = currentY;
261 std::cout << "button 1 down at " << currentX << ", " << currentY << std::endl;
262 }
263 } else if(eventType == kButton1Motion) {
265 std::cout << "button 1 motion at " << currentX << ", " << currentY << std::endl;
266 }
267 } else if(eventType == kButton1Up) {
268 region->Update(fStartX, currentX);
270 std::cout << "button 1 up at " << currentX << ", " << currentY << std::endl;
271 }
272 }
273 } else if(VerboseLevel() > EVerbosity::kLoops) {
274 std::cout << "nullptr selected at " << currentX << ", " << currentY << std::endl;
275 }
276}
277
278void GH1D::HandleEvent(Event_t* event, Window_t window)
279{
280 //auto* tgWindow = gClient->GetWindowById(window);
281
282 if(gPad != fPad && VerboseLevel() < EVerbosity::kAll) {
283 return;
284 }
285
286 UInt_t keySymbol = 0;
287 std::array<char, 2> str;
288 gVirtualX->LookupString(event, str.data(), str.size(), keySymbol);
289
290 if((VerboseLevel() > EVerbosity::kBasicFlow && event->fType != kMotionNotify && event->fType != kLeaveNotify) ||
291 (VerboseLevel() > EVerbosity::kSubroutines && event->fState != 0) ||
293 std::cout << __PRETTY_FUNCTION__ << ", event " << event << ", window " << window << ", type " << event->fType << ", code " << event->fCode << ", state " << event->fState << ", x " << event->fX << ", root-x " << event->fXRoot << ", y " << event->fY << ", root-y " << event->fYRoot << ", x/y coordinates: x " << fPad->PixeltoX(event->fX) << ", y " << fPad->PixeltoY(event->fY - fPad->GetWh()) << ", root-x " << fPad->PixeltoX(event->fXRoot) << ", root-y " << fPad->PixeltoY(event->fYRoot - fPad->GetWh()) << ", key symbol " << keySymbol << " = " << hex(keySymbol) << "; fPad " << fPad << " = \"" << fPad->GetName() << "\", gPad " << gPad << " = \"" << gPad->GetName() << "\"" << std::endl; // NOLINT(cppcoreguidelines-pro-type-const-cast, cppcoreguidelines-pro-bounds-array-to-pointer-decay)
294 }
295
296 switch(event->fType) {
297 case kGKeyPress: // if a key is held, this one gets repeated
298 if(str[0] == kESC) { // ESC sets the escape flag
299 gROOT->SetEscape();
300 gPad->Modified();
301 }
302 if(str[0] == 3) { // ctrl-c sets the interrupt flag
303 gROOT->SetInterrupt();
304 }
305
306 switch(keySymbol) {
307 case kKey_b:
308 fBackground = true;
309 break;
310 case kKey_g:
311 fGate = true;
312 break;
313 case kKey_r:
314 fRegion = true;
315 break;
316 case kKey_l:
317 // toggle logscale for y
318 if(fPad->GetLogy() == 0) {
319 fPad->SetLogy(1);
320 } else {
321 fPad->SetLogy(0);
322 }
323 // we need to update the pad to get the new frame the histogram is draw in, then update it again after the regions have been re-drawn ...
324 UpdatePad();
325 DrawRegions();
326 UpdatePad();
327 break;
328 case kKey_p:
329 //f2DPlayer->Project();
330 break;
331 case kKey_u:
332 GetXaxis()->UnZoom();
333 GetYaxis()->UnZoom();
334 // we need to update the pad to get the new frame the histogram is draw in, then update it again after the regions have been re-drawn ...
335 UpdatePad();
336 DrawRegions();
337 UpdatePad();
339 PrintRegions();
340 }
341 break;
342 case kKey_U:
343 GetYaxis()->UnZoom();
344 // we need to update the pad to get the new frame the histogram is draw in, then update it again after the regions have been updated ...
345 UpdatePad();
346 DrawRegions();
347 UpdatePad();
349 PrintRegions();
350 }
351 break;
352 case kKey_Escape:
353 if(fGate || fBackground || fRegion) {
355 }
357 std::cout << "Escape!" << std::endl;
358 }
359 break;
360 case kKey_Left:
361 case kKey_Up:
362 case kKey_Right:
363 case kKey_Down:
364 // handle arrow keys
366 std::cout << "Moving histogram" << std::endl;
367 }
368 Move1DHistogram(keySymbol, this);
369 // we need to update the pad to get the new frame the histogram is draw in, then update it again after the regions have been updated ...
370 UpdatePad();
371 DrawRegions();
372 UpdatePad();
374 PrintRegions();
375 }
376 break;
377 }
378 break;
379 case kKeyRelease:
380 break;
381 case kButtonPress:
382 switch(event->fCode) {
383 case 1:
384 if(event->fState == 0 && (fGate || fBackground || fRegion)) {
385 fStartX = fPad->PixeltoX(event->fX);
386 fStartY = fPad->PixeltoY(event->fY - fPad->GetWh());
388 if(fGate) {
389 fCurrentRegion->SetFillColorAlpha(kRed, 0.2);
390 } else if(fBackground) {
391 fCurrentRegion->SetFillColorAlpha(kBlue, 0.2);
392 } else if(fRegion) {
393 fCurrentRegion->SetFillColorAlpha(fRegionColor[fNofRegions % fRegionColor.size()], 0.2);
394 }
395 fCurrentRegion->Draw();
397 PrintRegions();
398 }
399 }
400 break;
401 case 4:
402 case 5:
403 // code 4 & 5 are wheel down & up, respectively
404 // state 0 - no key, 1 - shift, 4 - control, 8 - option, 16 - command
405 if(event->fState == 0) {
406 // we want to increase/reduce our range by 10% w/o changing the minimum
407 // for wheel down/up, respectively
408 double factor = 0.90;
409 if(event->fCode == 4) {
410 factor = 1.10;
411 }
413 std::cout << "factor " << factor << ": maximum " << GetMinimum() + (GetMaximum() - GetMinimum()) * factor << ", old range " << (GetMaximum() - GetMinimum()) << " = " << GetMaximum() << " - " << GetMinimum() << std::endl;
414 }
415 SetMaximum(GetMinimum() + (GetMaximum() - GetMinimum()) * factor);
417 std::cout << "new range: " << (GetMaximum() - GetMinimum()) << " = " << GetMaximum() << " - " << GetMinimum() << std::endl;
418 }
419 } else if(event->fState == 1) {
420 if(event->fCode == 4) {
421 Move1DHistogram(kKey_Left, this);
422 } else {
423 Move1DHistogram(kKey_Right, this);
424 }
425 }
426 // we need to update the pad to get the new frame the histogram is draw in, then update it again after the regions have been updated ...
427 UpdatePad();
428 DrawRegions();
429 UpdatePad();
431 PrintRegions();
432 }
433 break;
434 default:
435 break;
436 }
437 break;
438 case kMotionNotify:
439 if(event->fState == 256 && (fGate || fBackground || fRegion)) {
440 double currentX = fPad->PixeltoX(event->fX);
441 double currentY = fPad->PixeltoY(event->fY - fPad->GetWh());
443 std::cout << "current box: " << fStartX << " - " << fStartY << ", " << currentX << " - " << currentY << ", canvas: " << fPad->PixeltoX(fPad->GetCanvas()->GetEventX()) << " - " << fPad->PixeltoY(fPad->GetCanvas()->GetEventY()) << std::endl;
444 }
445 fCurrentRegion->SetX2(currentX);
446 fCurrentRegion->SetY2(currentY);
447 fCurrentRegion->Draw();
448 UpdatePad();
450 PrintRegions();
451 }
452 }
453 break;
454 case kButtonRelease:
455 if(event->fCode == 1) {
456 if(event->fState == 0) {
457 if(!fGate && !fBackground && !fRegion) {
458 // check whether we are in the frame or not
459 double currentX = fPad->PixeltoX(event->fX);
460 double currentY = fPad->PixeltoY(event->fY - fPad->GetWh());
461 if(VerboseLevel() > EVerbosity::kBasicFlow) { std::cout << "current x " << currentX << ", current y " << currentY << std::endl; }
462 if(Pad()->GetFrame()->GetX1() < currentX && currentX < Pad()->GetFrame()->GetX2() &&
463 Pad()->GetFrame()->GetY1() < currentY && currentY < Pad()->GetFrame()->GetY2()) {
465 std::cout << "inside frame" << std::endl;
466 }
467 } else {
468 // not a new gate, background, or region, and we're outside the frame => we just zoomed in on the x-axis
469 GetYaxis()->UnZoom();
471 std::cout << "outside frame" << std::endl;
472 }
473 }
474 // we need to update the pad to get the new frame the histogram is draw in, then update it again after the regions have been updated ...
475 UpdatePad();
476 DrawRegions();
477 UpdatePad();
479 PrintRegions();
480 }
481 } else {
482 double stopX = fPad->PixeltoX(event->fX);
483 double stopY = fPad->PixeltoY(event->fY - fPad->GetWh());
484 fCurrentRegion->SetX2(stopX);
485 fCurrentRegion->SetY2(stopY);
486 if(fGate) {
488 std::cout << "new gate: " << fStartX << " - " << stopX << std::endl;
489 }
491 fGate = false;
492 } else if(fBackground) {
494 std::cout << "new background: " << fStartX << " - " << stopX << std::endl;
495 }
497 fBackground = false;
498 } else if(fRegion) {
500 std::cout << "new region: " << fStartX << " - " << stopX << std::endl;
501 }
503 fRegion = false;
504 ++fNofRegions;
505 }
507 static_cast<TRegion*>(fRegions.Last())->Draw();
509 PrintRegions();
510 }
511 }
512 }
513 }
514 break;
515 default:
516 break;
517 }
518}
519
521{
522 for(auto* obj : fRegions) {
523 static_cast<TRegion*>(obj)->Update();
524 }
525}
526
527void GH1D::DrawRegions(Option_t* opt)
528{
529 for(auto* obj : fRegions) {
530 static_cast<TRegion*>(obj)->Draw(opt);
531 }
532}
533
535{
536 std::cout << GetName() << "/" << GetTitle() << " - Regions:" << std::endl;
537 int index = 0;
538 for(auto* obj : *(Pad()->GetListOfPrimitives())) {
539 if(obj->InheritsFrom(TRegion::Class())) {
540 std::cout << index << ": " << obj << " ";
541 obj->Print();
542 ++index;
543 }
544 }
545}
546
548{
549 fGate = false;
550 fBackground = false;
551 fRegion = false;
552 fPad->GetListOfPrimitives()->Remove(fCurrentRegion);
553 delete fCurrentRegion;
554 fCurrentRegion = nullptr;
555}
556
558{
559 fPad->GetListOfPrimitives()->Remove(region);
560 fRegions.Remove(region);
561}
562
563TRegion::TRegion(TBox* box, ERegionType type, GH1D* parent)
564 : TBox(*box), fParent(parent), fType(type), fLowX(box->GetX1()), fHighX(box->GetX2())
565{
566 // make sure that x1 is smaller than x2
567 if(GetX1() > GetX2()) {
568 double tmpX = GetX1();
569 SetX1(GetX2());
570 SetX2(tmpX);
571 std::swap(fLowX, fHighX);
572 }
573 // align the edges of the region with the bins of the histogram
574 auto* axis = parent->GetXaxis();
575 fLowX = axis->GetBinLowEdge(axis->FindBin(fLowX));
576 fHighX = axis->GetBinUpEdge(axis->FindBin(fHighX));
577}
578
580{
581 /// Updates y-range of this region to match the current y-range of the frame the parent is drawn in.
582 /// Also checks the x-range and adjust it to only cover the displayed range if necessary.
583 /// Returns whether the region should be drawn or not.
584 /// Does not update the pad itself!
585
586 bool result = true;
587
588 auto* frame = fParent->Pad()->GetFrame();
590 std::cout << "Frame: " << frame->GetX1() << " - " << frame->GetX2() << ", " << frame->GetY1() << " - " << frame->GetY2() << " -> updating y-range from " << GetY1() << " - " << GetY2();
591 }
592 if(fParent->Pad()->GetLogy() == 0) {
593 // linear scale: set y-range directly from frame
594 SetY1(frame->GetY1());
595 SetY2(frame->GetY2());
596 } else {
597 // logarithmic scale: frame reports the exponent as y1 and y2
598 SetY1(TMath::Power(10., frame->GetY1()));
599 SetY2(TMath::Power(10., frame->GetY2()));
600 }
602 std::cout << " to " << GetY1() << " - " << GetY2() << std::endl;
603 }
604
606 std::cout << "Updating x-range from " << GetX1() << " - " << GetX2() << " (" << fLowX << " - " << fHighX << ")";
607 }
608 if(frame->GetX1() < fLowX && fHighX < frame->GetX2()) {
609 // whole region is visible -> use original range
611 std::cout << " (whole region)";
612 }
613 SetX1(fLowX);
614 SetX2(fHighX);
615 } else if(frame->GetX2() < fLowX || fHighX < frame->GetX1()) {
616 // region is out of frame, do nothing? What if the region is just out of the frame but in the canvas?
617 // Using GetUxmin() and GetUxmax() to set range to values outside the pad range and not just the frame range does not work.
618 // So we simply hide this region whenever it is outside the frame.
619 // This also means we have to actively draw it whenever it is (partly) in frame (in case it was hidden before).
621 std::cout << " (out of " << frame->GetX1() << " - " << frame->GetX2() << ")";
622 }
623 result = false;
624 } else if(fHighX < frame->GetX2()) {
625 // low part of region is out of frame -> adjust low x
627 std::cout << " (high part)";
628 }
629 SetX1(frame->GetX1());
630 SetX2(fHighX);
631 } else if(frame->GetX1() < fLowX) {
632 // high part of region is out of frame -> adjust high x
634 std::cout << " (low part)";
635 }
636 SetX1(fLowX);
637 SetX2(frame->GetX2());
638 } else {
639 // region is larger than visible range on both side -> adjust both
641 std::cout << " (region too big)";
642 }
643 SetX1(frame->GetX1());
644 SetX2(frame->GetX2());
645 }
647 std::cout << " to " << GetX1() << " - " << GetX2() << std::endl;
648 }
649
650 return result;
651}
652
653void TRegion::Draw(Option_t* opt)
654{
655 /// Draw this region. Calls Update() first to update ranges and to check if we actuall want to draw this range.
656 /// If Update() returns false this function will actually hide this region!
657 /// Updates the pad at the end.
658 if(fParent == nullptr) {
659 throw std::runtime_error("Can't draw region without parent histogram!");
660 }
661
662 if(Update()) {
663 if(fParent->Pad()->GetListOfPrimitives()->FindObject(this) == nullptr) {
664 TBox::Draw(opt);
666 std::cout << this << " region " << fLowX << " - " << fHighX << " already has been drawn" << std::endl;
667 }
668 } else {
669 Hide();
670 }
672}
673
675{
676 /// Hide this region. Removes region from list of primitives. Does not update the pad.
677 if(fParent == nullptr) {
678 throw std::runtime_error("Can't draw region without parent histogram!");
679 }
680
681 fParent->Pad()->GetListOfPrimitives()->Remove(this);
683 std::cout << "hid region " << fLowX << " - " << fHighX << std::endl;
685 }
686}
687
688void TRegion::Update(double startX, double stopX)
689{
690 /// Depending on the starting position this function updates the left or right edge of the region to the stopping position.
692 std::cout << "region " << fLowX << " - " << fHighX << ", start x " << startX << ", stop x " << stopX;
693 }
694 if(std::abs(startX - fLowX) < std::abs(startX - fHighX)) {
695 fLowX = stopX;
696 } else {
697 fHighX = stopX;
698 }
700 std::cout << " => " << fLowX << " - " << fHighX << std::endl;
701 }
702 Update();
703}
ERegionType
Definition GH1D.h:111
EBackgroundSubtraction
Definition GH2Base.h:14
bool Move1DHistogram(const Int_t &key, TH1 *histogram=nullptr)
EVerbosity
Definition Globals.h:143
@ kQuiet
Definition Globals.h:144
@ kSubroutines
Definition Globals.h:146
@ kLoops
Definition Globals.h:147
@ kAll
Definition Globals.h:148
@ kBasicFlow
Definition Globals.h:145
std::string hex(T val, int width=-1)
Definition Globals.h:129
TH1D * hist
Definition UserFillObj.h:3
Definition GH1D.h:17
double fStartX
! initial x-position of new region
Definition GH1D.h:94
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
TVirtualPad * Pad() const
Definition GH1D.h:67
void SetPad(TVirtualPad *pad)
Definition GH1D.cxx:241
void DrawRegions(Option_t *opt="")
Definition GH1D.cxx:527
std::array< int, 3 > fRegionColor
Definition GH1D.h:100
TH1 * DrawNormalized(Option_t *opt="", Double_t norm=1) const override
Definition GH1D.cxx:134
void UpdatePad()
Definition GH1D.h:75
void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject *selected)
Definition GH1D.cxx:248
void PrintRegions()
Definition GH1D.cxx:534
void RemoveCurrentRegion()
Definition GH1D.cxx:547
bool fGate
Definition GH1D.h:96
double fStartY
! initial y-position of new region
Definition GH1D.h:95
GH1D * GetNext(bool DrawEmpty=false) const
Definition GH1D.cxx:157
TRef fParent
Definition GH1D.h:90
static EVerbosity fVerboseLevel
! level of verbosity
Definition GH1D.h:104
void Copy(TObject &obj) const override
Definition GH1D.cxx:101
size_t fNofRegions
! counts number of regions in this histogram, only used to set the color of the region
Definition GH1D.h:101
void Print(Option_t *opt="") const override
Definition GH1D.cxx:95
bool WriteDatFile(const char *outFile)
Definition GH1D.cxx:43
void Clear(Option_t *opt="") override
Definition GH1D.cxx:89
TBox * fCurrentRegion
! box for the current region
Definition GH1D.h:99
GH1D * GetPrevious(bool DrawEmpty=false) const
Definition GH1D.cxx:144
static EVerbosity VerboseLevel()
Definition GH1D.h:85
void HandleEvent(Event_t *event, Window_t window)
Definition GH1D.cxx:278
void UpdateRegions()
Definition GH1D.cxx:520
GH1D * Project(int bins=-1)
Definition GH1D.cxx:220
int fProjectionAxis
Definition GH1D.h:91
bool fRegion
Definition GH1D.h:98
TH1 * DrawCopy(Option_t *opt="", const char *name_postfix="copy") const override
Definition GH1D.cxx:124
TList fRegions
Definition GH1D.h:102
TVirtualPad * fPad
!
Definition GH1D.h:92
GH1D()
Definition GH1D.h:19
void RemoveRegion(TRegion *region)
Definition GH1D.cxx:557
bool fBackground
Definition GH1D.h:97
void Draw(Option_t *opt="") override
Definition GH1D.cxx:108
GH1D * GetPrevious(const GH1D *curr, bool DrawEmpty=true)
Definition GH2Base.cxx:198
GH1D * ProjectionY_Background(int firstbin=0, int lastbin=-1, int first_bg_bin=0, int last_bg_bin=-1, EBackgroundSubtraction mode=EBackgroundSubtraction::kRegionBackground)
Definition GH2Base.cxx:192
GH1D * GetNext(const GH1D *curr, bool DrawEmpty=true)
Definition GH2Base.cxx:221
GH1D * ProjectionX_Background(int firstbin=0, int lastbin=-1, int first_bg_bin=0, int last_bg_bin=-1, EBackgroundSubtraction mode=EBackgroundSubtraction::kRegionBackground)
Definition GH2Base.cxx:138
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
void Draw(Option_t *opt="") override
Definition GH1D.cxx:653
void Hide()
Definition GH1D.cxx:674
TRegion()=default
GH1D * fParent
Definition GH1D.h:133
double fHighX
Definition GH1D.h:136
bool Update()
Definition GH1D.cxx:579
double fLowX
Definition GH1D.h:135