39 res.Form(
"CutG_%d",cnt++);
40 }
while (gROOT->GetListOfSpecials()->FindObject(res));
95 Int_t n =
fxCut->GetN();
96 auto xarr =
fxCut->GetX();
97 fxCut->SetBit(kMustCleanup,0);
98 Int_t nxmin = TMath::LocMin(n,xarr);
104 if(!
fxCut)
return 0.;
105 Int_t n=
fxCut->GetN();
106 auto xarr=
fxCut->GetX();
107 Int_t nxmax=TMath::LocMax(n,xarr);
114 Int_t n=
fxCut->GetN();
115 auto yarr=
fxCut->GetY();
116 Int_t nymin=TMath::LocMin(n,yarr);
122 if(!
fxCut)
return 0.;
123 Int_t n =
fxCut->GetN();
124 auto yarr =
fxCut->GetY();
125 Int_t nymax = TMath::LocMax(n,yarr);
137 TCutG *tempcut =
fxCut;
149 TCutG *tempcut = source->
GetCut(
false);
152 TCutG *ret= (TCutG *)tempcut->Clone(GetName());
163 #ifdef POLYCOND_UPDATE_WITHCLONE 167 fxCut = (TCutG*) newcut->Clone(GetName());
168 fxCut->SetBit(kCanDelete,kFALSE);
171 Int_t pn = newcut->GetN();
173 fxCut =
new TCutG(GetName(),pn);
174 fxCut->SetBit(kMustCleanup);
181 Double_t xp = 0, yp = 0;
182 for (Int_t i = 0; i < pn; ++i) {
183 newcut->GetPoint(i, xp, yp);
184 fxCut->SetPoint(i, xp, yp);
190 SetLineColor(newcut->GetLineColor());
191 SetLineWidth(newcut->GetLineWidth());
192 SetLineStyle(newcut->GetLineStyle());
193 SetFillColor(newcut->GetFillColor());
194 SetFillStyle(newcut->GetFillStyle());
206 fxCut->SetName(GetName());
209 SetLineColor(newcut->GetLineColor());
210 SetLineWidth(newcut->GetLineWidth());
211 SetLineStyle(newcut->GetLineStyle());
212 SetFillColor(newcut->GetFillColor());
213 SetFillStyle(newcut->GetFillStyle());
224 fxCut =
new TCutG(GetName(), len, x, y);
225 fxCut->SetBit(kMustCleanup);
240 Bool_t outside = (
fxCut->IsInside(x,y) == 0);
252 std::cout <<
"No polygon specified!" << std::endl;
254 fxCut->Print(
nullptr);
269 if(cond->InheritsFrom(TGo4PolyCond::Class())) {
271 #ifdef POLYCOND_UPDATE_WITHCLONE 289 TCutG * srccut = source->
GetCut(
false);
291 if(!srccut)
return kFALSE;
293 Int_t pn = srccut->GetN();
295 Double_t xp = 0, yp = 0;
296 for (Int_t i = 0; i < pn; ++i) {
297 srccut->GetPoint(i, xp, yp);
298 fxCut->SetPoint(i, xp, yp);
310 std::cout <<
"Cannot update " << GetName() <<
" from " << cond->ClassName() << std::endl;
321 message.Form(
"TGo4PolyCond::UpdateFromUrl - condition %s: with url:%s", GetName(), rest_url_opt);
329 TString xname, yname;
330 Double_t *X =
new Double_t[npoints];
331 Double_t *Y =
new Double_t[npoints];
332 for (Int_t i = 0; i < npoints; ++i) {
337 message.Append(TString::Format(
" X[%i]=%f, Y[%i]=%f\n", i, X[i], i, Y[i]));
343 message.Append(
" - setting Polygon condition to new values!");
351 return fxCut ?
fxCut->IntegralHist(dynamic_cast<TH2 *>(histo),opt) : 0.;
390 Int_t maxbin =
fxCutHis->GetMaximumBin();
391 Int_t xmaxbin = maxbin % (
fxCutHis->GetNbinsX() + 2);
392 return xax->GetBinCenter(xmaxbin);
401 Int_t maxbin =
fxCutHis->GetMaximumBin();
402 Int_t maxybin = maxbin / (
fxCutHis->GetNbinsX() + 2);
403 return yax->GetBinCenter(maxybin);
421 if (painter->InheritsFrom(TGo4PolyCondPainter::Class())) {
427 TGo4Log::Warn(
"Could not set painter of class %s for TGo4PolyCond %s", painter->ClassName(), GetName());
445 TH2 *his =
dynamic_cast<TH2 *
>(source);
452 TAxis *xaxis =
fxCutHis->GetXaxis();
453 TAxis *yaxis =
fxCutHis->GetYaxis();
454 xaxis->SetRange(0, 0);
455 yaxis->SetRange(0, 0);
457 for (Int_t i = 0; i < nx; ++i) {
458 Double_t x = xaxis->GetBinCenter(i);
459 for (Int_t j = 0; j < ny; ++j) {
460 Double_t y = yaxis->GetBinCenter(j);
479 TSeqCollection *specials = gROOT->GetListOfSpecials();
480 TIter iter(specials);
481 while(
auto ob = iter()) {
482 if(ob->InheritsFrom(TCutG::Class()))
483 specials->Remove(ob);
489 Int_t size =
sizeof(*this);
490 if (GetName()) size += strlen(GetName());
491 if (GetTitle()) size += strlen(GetTitle());
493 size +=
sizeof(*fxCut);
494 size +=
fxCut->GetMaxSize()*2*
sizeof(Double_t);
502 TString line, varname =
MakeScript(out, TString::Format(
"polycond%d", cnt++).Data(), opt);
505 line.Form(
" %s->SetValues(0, 0, 0);", varname.Data());
507 TString xname = varname;
508 xname.ReplaceAll(
"->At(",
"_sub");
509 xname.ReplaceAll(
")",
"");
510 TString yname = xname +
"_y";
511 xname = xname +
"_x";
512 line.Form(
" Double_t %s[%d], %s[%d];", xname.Data(),
fxCut->GetN(), yname.Data(),
fxCut->GetN());
513 out << line << std::endl;
514 for (Int_t n = 0; n <
fxCut->GetN(); n++) {
516 fxCut->GetPoint(n, x, y);
517 line.Form(
" %s[%d] = %f; %s[%d] = %f;", xname.Data(), n, x, yname.Data(), n, y);
518 out << line << std::endl;
520 line.Form(
" %s->SetValues(%s, %s, %d);", varname.Data(), xname.Data(), yname.Data(),
fxCut->GetN());
523 out << line << std::endl;
void SetPainter(TGo4ConditionPainter *painter) override
Bool_t UrlOptionHasKey(const char *key)
Double_t GetIntegral(TH1 *histo, Option_t *opt="") override
static TString fgxURL_XPRE
Double_t GetMean(TH1 *histo, Int_t axis=1) override
TCutG * GetCut(Bool_t changeowner) override
virtual Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
static TString NextAvailableName()
Double_t GetYLow() const override
virtual void PrintCondition(Bool_t full=kTRUE)
TCutG * CloneCut(TGo4PolyCond *source)
void SetValuesDirect(TCutG *newcut)
Bool_t IsCutHis(TH1 *source)
static void CleanupSpecials()
const char * MakeScript(std::ostream &out, const char *varname, Option_t *opt="", const char *arrextraargs=nullptr)
Double_t GetXLow() const override
Bool_t IsPolygonType() const override
static TString fgxURL_YPRE
static const char * Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS
Double_t GetXUp() const override
Double_t GetYUp() const override
virtual Bool_t UpdateFromUrl(const char *rest_url_opt)
virtual void SetWorkHistogram(TH1 *histo)
Int_t GetMemorySize() const override
Double_t GetCurtosis(TH1 *histo, Int_t axis=1) override
virtual void SetCondition(TGo4Condition *con)
Double_t GetRMS(TH1 *histo, Int_t axis=1) override
Double_t GetYMax(TH1 *histo) override
Double_t GetSkewness(TH1 *histo, Int_t axis=1) override
TGo4ConditionPainter * fxPainter
TGo4ConditionPainter * CreatePainter() override
void SavePrimitive(std::ostream &fs, Option_t *opt="") override
void SetWorkHistogram(TH1 *histo) override
Double_t GetCMax(TH1 *histo) override
Bool_t FixedResult() const
Int_t GetUrlOptionAsInt(const char *key, Int_t def_value)
Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts) override
Double_t GetXMax(TH1 *histo) override
static TString fgxURL_NPOINTS
static void Warn(const char *text,...) GO4_PRINTF_ARGS
Bool_t UpdateFromUrl(const char *rest_url_opt) override
Double_t GetUrlOptionAsDouble(const char *key, Double_t def_value)
void SetDimension(Int_t d)
void PrintCondition(Bool_t points=kTRUE) override