22 SubCut::SubCut(Int_t size) : TObject(), fMin(nullptr), fMax(nullptr), fValue(nullptr), fUnitName(nullptr) {
25 fMin =
new Double_t[fSize];
26 fMax =
new Double_t[fSize];
27 fValue =
new Double_t[fSize];
28 fUnitName =
new TString[fSize];
31 fMin =
new Double_t[1];
32 fMax =
new Double_t[1];
33 fValue =
new Double_t[1];
34 fUnitName =
new TString[1];
36 for (
int i = 0; i < fSize; i++) {
40 fUnitName[i] =
"unknown [XU]";
45 this->fSize = other.fSize;
46 this->fMin =
new Double_t[fSize];
47 this->fMax =
new Double_t[fSize];
48 this->fValue =
new Double_t[fSize];
49 this->fUnitName =
new TString[fSize];
50 for (
int i = 0; i < fSize; i++) {
51 this->fMin[i] = other.fMin[i];
52 this->fMax[i] = other.fMax[i];
53 this->fValue[i] = other.fValue[i];
54 this->fUnitName[i] = other.fUnitName[i];
69 this->fSize = other.fSize;
70 this->fMin =
new Double_t[fSize];
71 this->fMax =
new Double_t[fSize];
72 this->fValue =
new Double_t[fSize];
73 this->fUnitName =
new TString[fSize];
74 for (
int i = 0; i < fSize; i++) {
75 this->fMin[i] = other.fMin[i];
76 this->fMax[i] = other.fMax[i];
77 this->fValue[i] = other.fValue[i];
78 this->fUnitName[i] = other.fUnitName[i];
90 report->
AddObject(fAcceptanceHistogram->Clone());
93 for (Int_t i = 0; i < fSize; i++) {
94 if (fValue[i] > fMax[i] || fValue[i] < fMin[i]) {
return kFALSE; }
100 for (Int_t i = 0; i < fSize; i++) {
101 Double_t val = TMath::Abs(fValue[i]);
102 if (val > fMax[i] || val < fMin[i]) {
return kFALSE; }
112 TObject(other), fSize(other.fSize), fParX(other.fParX), fParY(other.fParY), fParZ(other.fParZ) {
113 if (other.fAcceptanceHistogram != NULL) {
114 this->fAcceptanceHistogram = (TH1*) other.fAcceptanceHistogram->Clone();
115 fAcceptanceHistogram->SetDirectory(0);
119 SubCutHisto::~SubCutHisto() {
120 if (fAcceptanceHistogram)
delete fAcceptanceHistogram;
126 case 1: prob = fAcceptanceHistogram->GetBinContent(fAcceptanceHistogram->FindBin(x));
break;
127 case 2: prob = fAcceptanceHistogram->GetBinContent(fAcceptanceHistogram->FindFixBin(x, y));
break;
128 case 3: prob = fAcceptanceHistogram->GetBinContent(fAcceptanceHistogram->FindFixBin(x, y, z));
break;
131 if (prob == 0)
return kFALSE;
132 if (prob == 1)
return kTRUE;
133 Double_t randval = gRandom->Rndm();
134 if (randval <= prob) {
142 return Validate(TMath::Abs(x), TMath::Abs(y), TMath::Abs(z));
146 if (fAcceptanceHistogram ==
nullptr)
return kFALSE;
147 fAcceptanceHistogram->GetXaxis()->SetTitle(thisCut.
GetUnit(par1));
148 if (par2 != -1) fAcceptanceHistogram->GetYaxis()->SetTitle(thisCut.
GetUnit(par2));
149 if (par3 != -1) fAcceptanceHistogram->GetZaxis()->SetTitle(thisCut.
GetUnit(par3));
154 if (h.InheritsFrom(
"TH3")) {
155 if (fSize != 3)
return kFALSE;
156 for (
int i = 0; i <= h.GetNbinsX() + 1; i++) {
157 for (
int j = 0; j <= h.GetNbinsY() + 1; j++) {
158 for (
int k = 0; k <= h.GetNbinsZ() + 1; k++) {
159 Double_t cont = h.GetBinContent(i, j, k);
160 if (cont < 0 || cont > 1)
return kFALSE;
164 }
else if (h.InheritsFrom(
"TH2")) {
165 if (fSize != 2)
return kFALSE;
166 for (
int i = 0; i <= h.GetNbinsX() + 1; i++) {
167 for (
int j = 0; j <= h.GetNbinsY() + 1; j++) {
168 Double_t cont = h.GetBinContent(i, j);
169 if (cont < 0 || cont > 1)
return kFALSE;
173 if (fSize != 1)
return kFALSE;
174 for (
int i = 0; i <= h.GetNbinsX() + 1; i++) {
175 Double_t cont = h.GetBinContent(i);
176 if (cont < 0 || cont > 1)
return kFALSE;
179 fAcceptanceHistogram = (TH1*) h.Clone();
180 fAcceptanceHistogram->SetDirectory(0);
185 if (
this == &other) {
188 this->fSize = other.fSize;
189 if (other.fAcceptanceHistogram !=
nullptr) {
190 this->fAcceptanceHistogram = (TH1*) other.fAcceptanceHistogram->Clone();
191 fAcceptanceHistogram->SetDirectory(0);
198 SubCutRectangle::SubCutRectangle() : fParX(0), fParY(0) {}
200 void SubCutRectangle::AddSquare(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax) {
202 fMinX.push_back(xmax);
203 fMaxX.push_back(xmin);
205 fMinX.push_back(xmin);
206 fMaxX.push_back(xmax);
209 fMinY.push_back(ymax);
210 fMaxY.push_back(ymin);
212 fMinY.push_back(ymin);
213 fMaxY.push_back(ymax);
219 for (
unsigned int i = 0; i < fMinX.size(); i++) {
220 if (x >= fMinX[i] && x <= fMaxX[i] && y >= fMinY[i] && y <= fMaxY[i]) res++;
231 for (
unsigned int i = 0; i < fMinX.size(); i++) {
242 fNameX = thisCut.
GetUnit(fParX);
243 fNameY = thisCut.
GetUnit(fParY);
244 if (fMinX.size() > 0)
return kTRUE;
248 SubCutRectangle::~SubCutRectangle() {}
TString GetUnit(Int_t i) const
void AddObject(TObject *object)
Bool_t ValidateAbs(Double_t x, Double_t y=0, Double_t z=0)
Bool_t SetAcceptanceHistogram(const TH1 &h)
SubCutHisto(Int_t size=3)
void AddToReport(Package *report) const
SubCutHisto & operator=(const SubCutHisto &other)
Bool_t Init(const Cut &thisCut, Int_t par1, Int_t par2=-1, Int_t par3=-1)
Bool_t Validate(Double_t x, Double_t y=0, Double_t z=0)
Int_t Validate(Double_t x, Double_t y)
Bool_t Init(const Cut &thisCut, Int_t par1, Int_t par2=1)
void AddToReport(Package *report) const
void SetMax(Double_t val, Int_t i=0)
void SetMin(Double_t val, Int_t i=0)
SubCut & operator=(const SubCut &other)