41 res.Form(
"CutG_%d",cnt++);
42 }
while (gROOT->GetListOfSpecials()->FindObject(res));
97 Int_t n =
fxCut->GetN();
98 auto xarr =
fxCut->GetX();
99 fxCut->SetBit(kMustCleanup,0);
100 Int_t nxmin = TMath::LocMin(n,xarr);
106 if(!
fxCut)
return 0.;
107 Int_t n=
fxCut->GetN();
108 auto xarr=
fxCut->GetX();
109 Int_t nxmax=TMath::LocMax(n,xarr);
116 Int_t n=
fxCut->GetN();
117 auto yarr=
fxCut->GetY();
118 Int_t nymin=TMath::LocMin(n,yarr);
124 if(!
fxCut)
return 0.;
125 Int_t n =
fxCut->GetN();
126 auto yarr =
fxCut->GetY();
127 Int_t nymax = TMath::LocMax(n,yarr);
139 TCutG *tempcut =
fxCut;
151 TCutG *tempcut = source->
GetCut(
false);
154 TCutG *ret= (TCutG *)tempcut->Clone(GetName());
165#ifdef POLYCOND_UPDATE_WITHCLONE
169 fxCut = (TCutG*) newcut->Clone(GetName());
170 fxCut->SetBit(kCanDelete,kFALSE);
173 Int_t pn = newcut->GetN();
175 fxCut =
new TCutG(GetName(),pn);
176 fxCut->SetBit(kMustCleanup);
183 Double_t xp = 0, yp = 0;
184 for (Int_t i = 0; i < pn; ++i) {
185 newcut->GetPoint(i, xp, yp);
186 fxCut->SetPoint(i, xp, yp);
192 SetLineColor(newcut->GetLineColor());
193 SetLineWidth(newcut->GetLineWidth());
194 SetLineStyle(newcut->GetLineStyle());
195 SetFillColor(newcut->GetFillColor());
196 SetFillStyle(newcut->GetFillStyle());
208 fxCut->SetName(GetName());
211 SetLineColor(newcut->GetLineColor());
212 SetLineWidth(newcut->GetLineWidth());
213 SetLineStyle(newcut->GetLineStyle());
214 SetFillColor(newcut->GetFillColor());
215 SetFillStyle(newcut->GetFillStyle());
226 fxCut =
new TCutG(GetName(), len, x, y);
227 fxCut->SetBit(kMustCleanup);
242 Bool_t outside = (
fxCut->IsInside(x,y) == 0);
254 std::cout <<
"No polygon specified!" << std::endl;
256 fxCut->Print(
nullptr);
271 if(cond->InheritsFrom(TGo4PolyCond::Class())) {
273#ifdef POLYCOND_UPDATE_WITHCLONE
291 TCutG * srccut = source->
GetCut(
false);
293 if(!srccut)
return kFALSE;
295 Int_t pn = srccut->GetN();
297 Double_t xp = 0, yp = 0;
298 for (Int_t i = 0; i < pn; ++i) {
299 srccut->GetPoint(i, xp, yp);
300 fxCut->SetPoint(i, xp, yp);
312 std::cout <<
"Cannot update " << GetName() <<
" from " << cond->ClassName() << std::endl;
323 message.Form(
"TGo4PolyCond::UpdateFromUrl - condition %s: with url:%s", GetName(), rest_url_opt);
331 TString xname, yname;
332 std::vector<Double_t> X(npoints), Y(npoints);
333 for (Int_t i = 0; i < npoints; ++i) {
338 message.Append(TString::Format(
" X[%i]=%f, Y[%i]=%f\n", i, X[i], i, Y[i]));
342 message.Append(
" - setting Polygon condition to new values!");
350 return fxCut ?
fxCut->IntegralHist(
dynamic_cast<TH2 *
>(histo),opt) : 0.;
389 Int_t maxbin =
fxCutHis->GetMaximumBin();
390 Int_t xmaxbin = maxbin % (
fxCutHis->GetNbinsX() + 2);
391 return xax->GetBinCenter(xmaxbin);
400 Int_t maxbin =
fxCutHis->GetMaximumBin();
401 Int_t maxybin = maxbin / (
fxCutHis->GetNbinsX() + 2);
402 return yax->GetBinCenter(maxybin);
420 if (painter->InheritsFrom(TGo4PolyCondPainter::Class())) {
426 TGo4Log::Warn(
"Could not set painter of class %s for TGo4PolyCond %s", painter->ClassName(), GetName());
444 TH2 *his =
dynamic_cast<TH2 *
>(source);
451 TAxis *xaxis =
fxCutHis->GetXaxis();
452 TAxis *yaxis =
fxCutHis->GetYaxis();
453 xaxis->SetRange(0, 0);
454 yaxis->SetRange(0, 0);
456 for (Int_t i = 0; i < nx; ++i) {
457 Double_t x = xaxis->GetBinCenter(i);
458 for (Int_t j = 0; j < ny; ++j) {
459 Double_t y = yaxis->GetBinCenter(j);
478 TSeqCollection *specials = gROOT->GetListOfSpecials();
479 TIter iter(specials);
480 while(
auto ob = iter()) {
481 if(ob->InheritsFrom(TCutG::Class()))
482 specials->Remove(ob);
488 Int_t size =
sizeof(*this);
489 if (GetName()) size += strlen(GetName());
490 if (GetTitle()) size += strlen(GetTitle());
492 size +=
sizeof(*fxCut);
493 size +=
fxCut->GetMaxSize()*2*
sizeof(Double_t);
501 TString line, varname =
MakeScript(out, TString::Format(
"polycond%d", cnt++).Data(), opt);
504 line.Form(
" %s->SetValues(0, 0, 0);", varname.Data());
506 TString xname = varname;
507 xname.ReplaceAll(
"->At(",
"_sub");
508 xname.ReplaceAll(
")",
"");
509 TString yname = xname +
"_y";
510 xname = xname +
"_x";
511 line.Form(
" Double_t %s[%d], %s[%d];", xname.Data(),
fxCut->GetN(), yname.Data(),
fxCut->GetN());
512 out << line << std::endl;
513 for (Int_t n = 0; n <
fxCut->GetN(); n++) {
515 fxCut->GetPoint(n, x, y);
516 line.Form(
" %s[%d] = %f; %s[%d] = %f;", xname.Data(), n, x, yname.Data(), n, y);
517 out << line << std::endl;
519 line.Form(
" %s->SetValues(%s, %s, %d);", varname.Data(), xname.Data(), yname.Data(),
fxCut->GetN());
522 out << line << std::endl;
virtual void SetCondition(TGo4Condition *con)
Not inline, because we overwrite this for polygon condition.
virtual Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
Copy values from cond to this.
Double_t GetUrlOptionAsDouble(const char *key, Double_t def_value)
Scan list of url options for key.
virtual Bool_t UpdateFromUrl(const char *rest_url_opt)
Method used by HTTP server to update some fields, specified in URL syntax.
Int_t GetUrlOptionAsInt(const char *key, Int_t def_value)
Scan list of url options for key.
void IncCounts()
Increment the test counter.
TGo4ConditionPainter * fxPainter
Painter instance to display the condition in root pad.
Bool_t FixedResult() const
Returns the value set by Disable(value).
void SetDimension(Int_t d)
void IncTrueCounts()
Increment the "test was true" counter.
Bool_t IsTrue() const
Use this as return, if test was true.
Bool_t UrlOptionHasKey(const char *key)
returns true if key is present in list of url options.
virtual void PrintCondition(Bool_t full=kTRUE)
Prints counters and boolean members.
Bool_t IsFalse() const
Use this as return, if test was false.
const char * MakeScript(std::ostream &out, const char *varname, Option_t *opt="", const char *arrextraargs=nullptr)
virtual void SetWorkHistogram(TH1 *histo)
Set reference to work histogram for statistics functions.
Bool_t IsEnabled() const
Returns true if condition is enabled.
static void Warn(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 2.
static const char * Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS
Display a message.
TCutG * fxCut
Cut pointer.
Double_t GetCMax(TH1 *histo) override
Calculate value for histogram inside condition limits.
TGo4ConditionPainter * CreatePainter() override
Factory method to generate the subclass implementation for painter.
Double_t GetRMS(TH1 *histo, Int_t axis=1) override
Calculate value for histogram inside condition limits.
Bool_t IsCutHis(TH1 *source)
Returns true if fxCutHis can be used, create if possible.
void PrintCondition(Bool_t points=kTRUE) override
Printout values.
Double_t GetSkewness(TH1 *histo, Int_t axis=1) override
Calculate value for histogram inside condition limits.
Double_t GetCurtosis(TH1 *histo, Int_t axis=1) override
Calculate value for histogram inside condition limits.
Double_t GetXUp() const override
maximum extension of polygon in x axis
static TString fgxURL_YPRE
web condition editor keyword used in UpdateFromUrl.
void SetPainter(TGo4ConditionPainter *painter) override
Replace default painter of this condition by external one.
void ClearCutHis()
Set new cut histogram.
Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts) override
Copy values from cond to this.
Bool_t UpdateFromUrl(const char *rest_url_opt) override
Method used by HTTP server to update some fields, specified in URL syntax.
TH2 * fxCutHis
temporary histogram used to calculate statistics on polygon cuts.
virtual void SetValues()
Set values needed, i.e.
Double_t GetYUp() const override
maximum extension of polygon in y axis
void SavePrimitive(std::ostream &fs, Option_t *opt="") override
Standard way to store parameter in form of macro.
Double_t GetYLow() const override
minimum extension of polygon in y axis
static TString fgxURL_XPRE
web condition editor keyword used in UpdateFromUrl.
virtual Bool_t Test()
Test if condition is true.
static TString NextAvailableName()
Double_t GetMean(TH1 *histo, Int_t axis=1) override
Calculate value for histogram inside condition limits.
void SetValuesDirect(TCutG *newcut)
Delete old cut and get ownership over newcut.
Double_t GetXMax(TH1 *histo) override
Calculate value for histogram inside condition limits.
Double_t GetIntegral(TH1 *histo, Option_t *opt="") override
Calculate value for histogram inside condition limits.
static void CleanupSpecials()
Remove all references to any TCutGs from ROOT list of specials.
static TString fgxURL_NPOINTS
web condition editor keyword used in UpdateFromUrl.
Int_t GetMemorySize() const override
void SetWorkHistogram(TH1 *histo) override
Set reference to work histogram for statistics functions.
Bool_t IsPolygonType() const override
Double_t GetYMax(TH1 *histo) override
Calculate value for histogram inside condition limits.
TCutG * GetCut(Bool_t changeowner) override
Used to return the cut pointer of a TGo4PolyCond.
Double_t GetXLow() const override
minimum extension of polygon in x axis
TCutG * CloneCut(TGo4PolyCond *source)
Returns pointer to a cloned cut from source.