1#ifndef GAMR_TOOLKIT_GATE_HH
2#define GAMR_TOOLKIT_GATE_HH
32 class Gate :
public TNamed,
public TAttLine,
public TAttFill {
44 Gate(
const char *name);
45 Gate(
const char *name,
const char *title);
46 Gate(
const char *name, TVirtualPad *canvas, Option_t *opt=
"");
47 Gate(
const char *name,
const char *title, TVirtualPad *canvas, Option_t *opt=
"");
48 Gate(TVirtualPad *canvas, Option_t *opt=
"");
58 int SetGate(TVirtualPad *canvas, Option_t *opt=
"");
66 void SetLow(std::string l) { std::stringstream(l) >> Low;
Valid();};
68 void SetHigh(std::string h) { std::stringstream(h) >> High;
Valid();};
69 void SetScale(
double s) {
double cent = (Low + High)/2.;
double width =
GetWidth(); Low = cent - s*width/2.; High = cent + s*width/2.; }
70 double GetLow()
const {
return Low; };
72 double GetWidth()
const {
return High - Low; };
73 int GetBinLow(TH1 *hist)
const {
return hist->FindBin(Low); }
74 int GetBinHigh(TH1 *hist)
const {
return hist->FindBin(High); }
75 int GetBinWidth(TH1 *hist)
const {
return hist->FindBin(High) - hist->FindBin(Low) + 1; };
81 double GetIntegral(TH1 *hist, std::vector<Gate> background)
const;
87 double GetCounts(TH1 *hist, std::vector<Gate> background)
const;
90 double GetCountsError(TH1 *hist, std::vector<Gate> background)
const;
94 return ((x >= Low) && (x <= High));
96 Bool_t
Pass(
double x)
const
98 return ((x >= Low) && (x <= High));
100 template <
size_t Meas,
class TDetector>
101 Bool_t
PassDetector(TDetector det, Bool_t calibrated = kTRUE, Int_t
id = -1);
102 TH1D *
ApplyX(TH2 *hist)
const;
103 TH1D *
ApplyX(TH2 *hist,
const char *name)
const;
104 TH1D *
ApplyY(TH2 *hist)
const;
105 TH1D *
ApplyY(TH2 *hist,
const char *name)
const;
106 void Norm(TH1 *hist, TH1 *ref);
108 void Paint(Option_t *option =
"same");
112 void ls(Option_t *option =
"")
const;
115 if (this->Low > this->High) {
116 std::cout <<
"Warning! Gate low edge is higher than high edge" << std::endl;
127 std::ostream &
operator<<(std::ostream &
os, Gate
const &g);
137 std::map<std::string, Gate > fMap;
141 GateMap(
const char *name) : TNamed(name, name){};
142 GateMap(
const char *name,
const char *title) : TNamed(name, title){};
146 void ls(Option_t *option =
"")
const;
149 return std::any_of(fMap.cbegin(), fMap.cend(),
150 [&x](
const std::pair<std::string, Gate> &g) { return g.second.Pass(x); });
void os(std::vector< int > indexes, TCanvas *canvas, Option_t *option)
void py(TVirtualPad *canvas)
void px(TVirtualPad *canvas)
double GetCountsError(TH1 *hist) const
void Paint(Option_t *option="same")
Bool_t PassAny(double x) const
int GetBinWidth(TH1 *hist) const
TH1D * ApplyY(TH2 *hist) const
void SetGate(double l, double h)
double GetCounts(TH1 *hist) const
int GetBinLow(TH1 *hist) const
TH1D * ApplyX(TH2 *hist) const
Bool_t Pass(double x) const
void SetLow(std::string l)
double GetTrueWidth(TH1 *hist) const
Gate & operator[](std::string key)
void NormBackSub(TH1 *hist, TH1 *ref, Gate background)
void SetHigh(std::string h)
double GetIntegralError(TH1 *hist) const
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
double GetIntegral(TH1 *hist) const
void Norm(TH1 *hist, TH1 *ref)
int GetBinHigh(TH1 *hist) const
Int_t DistancetoPrimitive(Int_t px, Int_t py)
GateMap(const char *name, const char *title)
Bool_t PassDetector(TDetector det, Bool_t calibrated=kTRUE, Int_t id=-1)
GateMap(const char *name)
std::ostream & operator<<(std::ostream &os, Gate const &g)