16 #include "Riostream.h"
44 res.Form(
"CutG_%d",cnt++);
45 }
while (gROOT->GetListOfSpecials()->FindObject(res)!=0);
82 if(
fxCut==0)
return 0;
83 Int_t n=
fxCut->GetN();
84 Double_t* xarr=
fxCut->GetX();
85 fxCut->SetBit(kMustCleanup,0);
86 Int_t nxmin=TMath::LocMin(n,xarr);
91 if(
fxCut==0)
return 0;
92 Int_t n=
fxCut->GetN();
93 Double_t* xarr=
fxCut->GetX();
94 Int_t nxmax=TMath::LocMax(n,xarr);
99 if(
fxCut==0)
return 0;
100 Int_t n=
fxCut->GetN();
101 Double_t* yarr=
fxCut->GetY();
102 Int_t nymin=TMath::LocMin(n,yarr);
103 return (yarr[nymin]);
107 if(
fxCut==0)
return 0;
108 Int_t n=
fxCut->GetN();
109 Double_t* yarr=
fxCut->GetY();
110 Int_t nymax=TMath::LocMax(n,yarr);
111 return (yarr[nymax]);
123 TCutG* tempcut =
fxCut;
139 TCutG * tempcut = source->
GetCut(
false);
144 TCutG* ret= (TCutG *)tempcut->Clone(GetName());
153 if(newcut==0)
return;
154 #ifdef POLYCOND_UPDATE_WITHCLONE
158 fxCut = (TCutG*) newcut->Clone(GetName());
159 fxCut->SetBit(kCanDelete,kFALSE);
162 Int_t pn = newcut->GetN();
165 fxCut =
new TCutG(GetName(),pn);
166 fxCut->SetBit(kMustCleanup);
175 for(Int_t i=0; i<pn; ++i) {
176 newcut->GetPoint(i,xp,yp);
177 fxCut->SetPoint(i,xp,yp);
183 SetLineColor(newcut->GetLineColor());
184 SetLineWidth(newcut->GetLineWidth());
185 SetLineStyle(newcut->GetLineStyle());
186 SetFillColor(newcut->GetFillColor());
187 SetFillStyle(newcut->GetFillStyle());
196 if(newcut==0)
return;
201 fxCut->SetName(GetName());
204 SetLineColor(newcut->GetLineColor());
205 SetLineWidth(newcut->GetLineWidth());
206 SetLineStyle(newcut->GetLineStyle());
207 SetFillColor(newcut->GetFillColor());
208 SetFillStyle(newcut->GetFillStyle());
222 fxCut =
new TCutG(GetName(), len, x, y);
223 fxCut->SetBit(kMustCleanup);
239 Bool_t outside = (
fxCut->IsInside(x,y) == 0);
250 std::cout <<
"No polygon specified!" << std::endl;
267 if(cond->InheritsFrom(TGo4PolyCond::Class()))
270 #ifdef POLYCOND_UPDATE_WITHCLONE
279 if(old != 0)
delete old;
292 TCutG * srccut = source->
GetCut(
false);
295 if(srccut==0)
return kFALSE;
297 Int_t pn = srccut->GetN();
301 for(Int_t i=0; i<pn; ++i) {
302 srccut->GetPoint(i,xp,yp);
303 fxCut->SetPoint(i,xp,yp);
316 std::cout <<
"Cannot update " << GetName() <<
" from " << cond->ClassName() << std::endl;
325 message.Form(
"TGo4PolyCond::UpdateFromUrl - condition %s: with url:%s", GetName(), rest_url_opt);
335 Double_t* X =
new Double_t[npoints];
336 Double_t* Y =
new Double_t[npoints];
337 for(Int_t i=0; i<npoints;++i) {
342 message.Form(
" i:%d, X=%f, Y=%f\n",i,X[i],Y[i]);
345 delete[] X;
delete[] Y;
347 message.Form(
" - setting Polygon condition to new values!");
359 #if ROOT_VERSION_CODE >= ROOT_VERSION(4,0,8)
361 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,25,1)
362 return (
fxCut->IntegralHist(dynamic_cast<TH2*>(histo),opt));
364 return (
fxCut->Integral(dynamic_cast<TH2*>(histo),opt));
397 return (
fxCutHis->GetSkewness(axis));
405 return (
fxCutHis->GetKurtosis(axis));
416 Int_t maxbin=
fxCutHis->GetMaximumBin();
417 Int_t xmaxbin=maxbin%(
fxCutHis->GetNbinsX()+2);
418 result=xax->GetBinCenter(xmaxbin);
433 Int_t maxbin=
fxCutHis->GetMaximumBin();
434 Int_t maxybin=maxbin/(
fxCutHis->GetNbinsX()+2);
435 result=yax->GetBinCenter(maxybin);
454 if(painter==0)
return;
455 if(painter->InheritsFrom(TGo4PolyCondPainter::Class()))
463 TGo4Log::Warn(
"Could not set painter of class %s for TGo4PolyCond %s",
464 painter->ClassName(),GetName());
481 TH2* his=
dynamic_cast<TH2*
>(source);
483 TH2* work= (TH2*) his->Clone();
485 Int_t nx=work->GetNbinsX();
486 Int_t ny=work->GetNbinsY();
487 TAxis* xaxis = work->GetXaxis();
488 TAxis* yaxis = work->GetYaxis();
489 xaxis->SetRange(0,0);
490 yaxis->SetRange(0,0);
492 for(Int_t i=0; i<nx;++i)
494 Double_t x = xaxis->GetBinCenter(i);
495 for(Int_t j=0; j<ny;++j)
497 Double_t y = yaxis->GetBinCenter(j);
499 work->SetBinContent(i,j,0);
507 work->SetDirectory(0);
515 TSeqCollection* specials=gROOT->GetListOfSpecials();
516 TIter iter(specials);
518 while((ob = iter())!=0) {
519 if(ob->InheritsFrom(TCutG::Class())) {
520 specials->Remove(ob);
528 Int_t size =
sizeof(*this);
529 if (GetName()!=0) size+=strlen(GetName());
530 if (GetTitle()!=0) size+=strlen(GetTitle());
532 size +=
sizeof(*fxCut);
533 #if ROOT_VERSION_CODE > ROOT_VERSION(4,0,8)
534 size +=
fxCut->GetMaxSize()*2*
sizeof(Double_t);
536 size +=
fxCut->GetN()*2*
sizeof(Double_t);
545 TString line, varname =
MakeScript(out, Form(
"polycond%d", cnt++), opt);
548 line.Form(
" %s->SetValues(0, 0, 0);", varname.Data());
550 TString xname = varname;
551 xname.ReplaceAll(
"->At(",
"_sub");
552 xname.ReplaceAll(
")",
"");
553 TString yname = xname +
"_y";
554 xname = xname +
"_x";
555 line.Form(
" Double_t %s[%d], %s[%d];", xname.Data(),
fxCut->GetN(), yname.Data(),
fxCut->GetN());
556 out << line << std::endl;
557 for (Int_t n=0;n<
fxCut->GetN();n++) {
559 fxCut->GetPoint(n, x, y);
560 line.Form(
" %s[%d] = %f; %s[%d] = %f;", xname.Data(), n, x, yname.Data(), n, y);
561 out << line << std::endl;
563 line.Form(
" %s->SetValues(%s, %s, %d);", varname.Data(), xname.Data(), yname.Data(),
fxCut->GetN());
566 out << line << std::endl;
virtual void PrintCondition(Bool_t points=kTRUE)
Bool_t UrlOptionHasKey(const char *key)
static TString fgxURL_XPRE
virtual Double_t GetXUp()
virtual Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
virtual Double_t GetIntegral(TH1 *histo, Option_t *opt="")
virtual Int_t GetMemorySize()
static TString NextAvailableName()
virtual Bool_t IsPolygonType()
virtual void PrintCondition(Bool_t full=kTRUE)
static void Warn(const char *text,...)
TCutG * CloneCut(TGo4PolyCond *source)
void SetValuesDirect(TCutG *newcut)
TH2 * CreateCutHistogram(TH1 *source)
virtual Double_t GetYMax(TH1 *histo)
static void CleanupSpecials()
virtual Double_t GetXMax(TH1 *histo)
Bool_t FixedResult() const
virtual Double_t GetRMS(TH1 *histo, Int_t axis=1)
TCutG * GetCut(Bool_t changeowner)
static TString fgxURL_YPRE
virtual Double_t GetYUp()
virtual Double_t GetSkewness(TH1 *histo, Int_t axis=1)
virtual Bool_t UpdateFromUrl(const char *rest_url_opt)
virtual Bool_t UpdateFromUrl(const char *rest_url_opt)
virtual void SetPainter(TGo4ConditionPainter *painter)
virtual Double_t GetCurtosis(TH1 *histo, Int_t axis=1)
static const char * Message(Int_t prio, const char *text,...)
virtual void SetCondition(TGo4Condition *con)
const char * MakeScript(std::ostream &out, const char *varname, Option_t *opt="", const char *arrextraargs=0)
virtual void SavePrimitive(std::ostream &fs, Option_t *="")
Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
TGo4ConditionPainter * fxPainter
virtual TGo4ConditionPainter * CreatePainter()
Int_t GetUrlOptionAsInt(const char *key, Int_t def_value)
virtual Double_t GetCMax(TH1 *histo)
static TString fgxURL_NPOINTS
virtual Double_t GetXLow()
Double_t GetUrlOptionAsDouble(const char *key, Double_t def_value)
void SetDimension(Int_t d)
virtual Double_t GetYLow()
virtual Double_t GetMean(TH1 *histo, Int_t axis=1)