75 Bool_t RooPlot::_addDirStatus = kTRUE ;
77 Bool_t RooPlot::addDirectoryStatus() {
return _addDirStatus ; }
78 Bool_t RooPlot::setAddDirectoryStatus(Bool_t flag) { Bool_t ret = flag ; _addDirStatus = flag ;
return ret ; }
85 RooPlot::RooPlot() : _hist(0), _plotVarClone(0), _plotVarSet(0), _normVars(0), _normObj(0), _dir(0)
87 _iterator= _items.MakeIterator() ;
89 if (gDirectory && addDirectoryStatus()) {
91 gDirectory->Append(
this) ;
99 RooPlot::RooPlot(Double_t xmin, Double_t xmax) :
100 _hist(0), _items(), _plotVarClone(0), _plotVarSet(0), _normObj(0),
101 _defYmin(1e-5), _defYmax(1), _dir(0)
103 Bool_t histAddDirStatus = TH1::AddDirectoryStatus();
104 TH1::AddDirectory(kFALSE) ;
106 _hist =
new TH1D(histName(),
"A RooPlot",100,xmin,xmax) ;
107 _hist->Sumw2(kFALSE) ;
108 _hist->GetSumw2()->Set(0) ;
111 TH1::AddDirectory(histAddDirStatus) ;
124 RooPlot::RooPlot(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax) :
125 _hist(0), _items(), _plotVarClone(0),
126 _plotVarSet(0), _normObj(0), _defYmin(1e-5), _defYmax(0), _dir(0)
128 Bool_t histAddDirStatus = TH1::AddDirectoryStatus();
129 TH1::AddDirectory(kFALSE) ;
131 _hist =
new TH1D(histName(),
"A RooPlot",100,xmin,xmax) ;
132 _hist->Sumw2(kFALSE) ;
133 _hist->GetSumw2()->Set(0) ;
135 TH1::AddDirectory(histAddDirStatus) ;
147 RooPlot::RooPlot(
const RooAbsRealLValue &var1,
const RooAbsRealLValue &var2) :
149 _plotVarClone(0), _plotVarSet(0), _normObj(0), _defYmin(1e-5), _defYmax(0), _dir(0)
151 Bool_t histAddDirStatus = TH1::AddDirectoryStatus();
152 TH1::AddDirectory(kFALSE) ;
154 _hist =
new TH1D(histName(),
"A RooPlot",100,var1.getMin(),var1.getMax()) ;
155 _hist->Sumw2(kFALSE) ;
156 _hist->GetSumw2()->Set(0) ;
158 TH1::AddDirectory(histAddDirStatus) ;
160 if(!var1.hasMin() || !var1.hasMax()) {
161 coutE(InputArguments) <<
"RooPlot::RooPlot: cannot create plot for variable without finite limits: "
162 << var1.GetName() << endl;
165 if(!var2.hasMin() || !var2.hasMax()) {
166 coutE(InputArguments) <<
"RooPlot::RooPlot: cannot create plot for variable without finite limits: "
167 << var1.GetName() << endl;
170 SetMinimum(var2.getMin());
171 SetMaximum(var2.getMax());
172 SetXTitle(var1.getTitle(kTRUE));
173 SetYTitle(var2.getTitle(kTRUE));
183 RooPlot::RooPlot(
const RooAbsRealLValue &var1,
const RooAbsRealLValue &var2,
184 Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax) :
185 _hist(0), _items(), _plotVarClone(0),
186 _plotVarSet(0), _normObj(0), _defYmin(1e-5), _defYmax(0), _dir(0)
188 Bool_t histAddDirStatus = TH1::AddDirectoryStatus();
189 TH1::AddDirectory(kFALSE) ;
191 _hist =
new TH1D(histName(),
"A RooPlot",100,xmin,xmax) ;
192 _hist->Sumw2(kFALSE) ;
193 _hist->GetSumw2()->Set(0) ;
195 TH1::AddDirectory(histAddDirStatus) ;
199 SetXTitle(var1.getTitle(kTRUE));
200 SetYTitle(var2.getTitle(kTRUE));
209 RooPlot::RooPlot(
const char* name,
const char* title,
const RooAbsRealLValue &var, Double_t xmin, Double_t xmax, Int_t nbins) :
211 _plotVarClone(0), _plotVarSet(0), _normObj(0), _defYmin(1e-5), _defYmax(1), _dir(0)
213 Bool_t histAddDirStatus = TH1::AddDirectoryStatus();
214 TH1::AddDirectory(kFALSE) ;
216 _hist =
new TH1D(name,title,nbins,xmin,xmax) ;
217 _hist->Sumw2(kFALSE) ;
218 _hist->GetSumw2()->Set(0) ;
220 TH1::AddDirectory(histAddDirStatus) ;
223 _plotVarSet = (RooArgSet*) RooArgSet(var).snapshot() ;
224 _plotVarClone= (RooAbsRealLValue*)_plotVarSet->find(var.GetName()) ;
226 TString xtitle= var.getTitle(kTRUE);
227 SetXTitle(xtitle.Data());
231 _normBinWidth = (xmax-xmin)/nbins ;
239 RooPlot::RooPlot(
const RooAbsRealLValue &var, Double_t xmin, Double_t xmax, Int_t nbins) :
241 _plotVarClone(0), _plotVarSet(0), _normObj(0), _defYmin(1e-5), _defYmax(1), _dir(0)
243 Bool_t histAddDirStatus = TH1::AddDirectoryStatus();
244 TH1::AddDirectory(kFALSE) ;
246 _hist =
new TH1D(histName(),
"RooPlot",nbins,xmin,xmax) ;
247 _hist->Sumw2(kFALSE) ;
248 _hist->GetSumw2()->Set(0) ;
250 TH1::AddDirectory(histAddDirStatus) ;
253 _plotVarSet = (RooArgSet*) RooArgSet(var).snapshot() ;
254 _plotVarClone= (RooAbsRealLValue*)_plotVarSet->find(var.GetName()) ;
256 TString xtitle= var.getTitle(kTRUE);
257 SetXTitle(xtitle.Data());
259 TString title(
"A RooPlot of \"");
260 title.Append(var.getTitle());
262 SetTitle(title.Data());
265 _normBinWidth = (xmax-xmin)/nbins ;
277 RooPlot* RooPlot::frame(
const RooAbsRealLValue &var, Double_t xmin, Double_t xmax, Int_t nBins){
278 return new RooPlot(var,xmin,xmax,nBins);
289 RooPlot* RooPlot::frameWithLabels(
const RooAbsRealLValue &var){
290 RooPlot* pl =
new RooPlot();
291 int nbins = var.getBinning().numBins();
293 Bool_t histAddDirStatus = TH1::AddDirectoryStatus();
294 TH1::AddDirectory(kFALSE) ;
295 pl->_hist =
new TH1D(pl->histName(),
"RooPlot",nbins,var.getMin(),var.getMax()) ;
296 pl->_hist->Sumw2(kFALSE) ;
297 pl->_hist->GetSumw2()->Set(0) ;
298 TH1::AddDirectory(histAddDirStatus) ;
300 pl->_hist->SetNdivisions(-nbins);
301 for(
int i=0; i<nbins; ++i){
302 TString s = TString::Format(
"%g-%g",var.getBinning().binLow(i),var.getBinning().binHigh(i));
303 pl->_hist->GetXaxis()->SetBinLabel(i+1,s);
307 pl->_plotVarSet = (RooArgSet*) RooArgSet(var).snapshot() ;
308 pl->_plotVarClone= (RooAbsRealLValue*)pl->_plotVarSet->find(var.GetName()) ;
310 TString xtitle= var.getTitle(kTRUE);
311 pl->SetXTitle(xtitle.Data());
313 TString title(
"A RooPlot of \"");
314 title.Append(var.getTitle());
316 pl->SetTitle(title.Data());
319 pl->_normBinWidth = 1.;
326 RooPlot* RooPlot::emptyClone(
const char* name)
328 RooPlot* clone =
new RooPlot(*_plotVarClone,_hist->GetXaxis()->GetXmin(),_hist->GetXaxis()->GetXmax(),_hist->GetNbinsX()) ;
329 clone->SetName(name) ;
337 void RooPlot::initialize()
339 SetName(histName()) ;
341 if (gDirectory && addDirectoryStatus()) {
343 gDirectory->Append(
this) ;
347 _hist->SetStats(kFALSE);
355 _iterator= _items.MakeIterator();
356 assert(0 != _iterator);
363 TString RooPlot::histName()
const
366 return TString(Form(
"frame_%s_%lx",_plotVarClone->GetName(),(ULong_t)
this)) ;
368 return TString(Form(
"frame_%lx",(ULong_t)
this)) ;
380 if (!_dir->TestBit(TDirectoryFile::kCloseDirectory)) {
381 _dir->GetList()->RecursiveRemove(
this) ;
387 if(_plotVarSet)
delete _plotVarSet;
388 if(_normVars)
delete _normVars;
401 void RooPlot::updateNormVars(
const RooArgSet &vars)
403 if(0 == _normVars) _normVars= (RooArgSet*) vars.snapshot(kTRUE);
411 Stat_t RooPlot::GetBinContent(Int_t )
const {
420 Stat_t RooPlot::GetBinContent(Int_t, Int_t)
const
430 Stat_t RooPlot::GetBinContent(Int_t, Int_t, Int_t)
const
443 void RooPlot::addObject(TObject *obj, Option_t *drawOptions, Bool_t invisible)
446 coutE(InputArguments) << fName <<
"::addObject: called with a null pointer" << endl;
449 DrawOpt opt(drawOptions) ;
450 opt.invisible = invisible ;
451 _items.Add(obj,opt.rawOpt());
462 void RooPlot::addTH1(TH1 *hist, Option_t *drawOptions, Bool_t invisible)
465 coutE(InputArguments) << fName <<
"::addTH1: called with a null pointer" << endl;
469 if(1 != hist->GetDimension()) {
470 coutE(InputArguments) << fName <<
"::addTH1: cannot plot histogram with "
471 << hist->GetDimension() <<
" dimensions" << endl;
476 TString options(drawOptions);
478 if(!options.Contains(
"SAME")) options.Append(
"SAME");
481 updateYAxis(hist->GetMinimum(),hist->GetMaximum(),hist->GetYaxis()->GetTitle());
484 updateFitRangeNorm(hist);
487 addObject(hist,options.Data(),invisible);
494 void translateGraph(TH1* hist, RooAbsRealLValue* xvar, TGraph* graph){
496 if(graph->GetXaxis()->IsAlphanumeric())
return;
497 double xmin = hist->GetXaxis()->GetXmin();
498 double xmax = hist->GetXaxis()->GetXmax();
499 if(graph->TestBit(TGraph::kIsSortedX)){
502 std::vector<double> x;
503 std::vector<double> y;
505 y.push_back(graph->Eval(xvar->getBinning().binLow(0)));
506 for(
int i=0; i<hist->GetNbinsX(); ++i){
507 x.push_back(hist->GetXaxis()->GetBinUpEdge(i+1));
508 y.push_back(graph->Eval(xvar->getBinning().binHigh(i)));
509 x.push_back(hist->GetXaxis()->GetBinCenter(i+1));
510 y.push_back(graph->Eval(xvar->getBinning().binCenter(i)));
514 for(
int i=0; i<n; ++i){
515 graph->SetPoint(i,x[i],y[i]);
520 std::map<int,double> minValues;
521 std::map<int,double> maxValues;
522 int n = graph->GetN();
525 for(
int i=0; i<n; ++i){
526 graph->GetPoint(i,x,y);
527 int bin = xvar->getBinning().binNumber(x)+1;
528 if(maxValues.find(bin)!=maxValues.end()){
529 maxValues[bin] = std::max(maxValues[bin],y);
533 if(minValues.find(bin)!=minValues.end()){
534 minValues[bin] = std::min(minValues[bin],y);
539 double xminY = graph->Eval(xmin);
540 double xmaxY = graph->Eval(xmax);
541 graph->Set(hist->GetNbinsX()+2);
543 graph->SetPoint(np,xmin,xminY);
545 for(
auto it = maxValues.begin(); it != maxValues.end(); ++it){
546 graph->SetPoint(++np,hist->GetXaxis()->GetBinCenter(it->first),it->second);
548 graph->SetPoint(++np,xmax,xmaxY);
549 for(
auto it = minValues.rbegin(); it != minValues.rend(); ++it){
550 graph->SetPoint(++np,hist->GetXaxis()->GetBinCenter(it->first),it->second);
552 graph->SetPoint(++np,xmin,xminY);
555 graph->GetXaxis()->Set(hist->GetNbinsX(),xmin,xmax);
556 for(
int i=0; i<hist->GetNbinsX(); ++i){
557 graph->GetXaxis()->SetBinLabel(i+1,hist->GetXaxis()->GetBinLabel(i+1));
561 void translateGraph(TH1* hist, RooAbsRealLValue* xvar, TGraphAsymmErrors* graph){
563 if(graph->GetXaxis()->IsAlphanumeric())
return;
564 int n = graph->GetN();
565 double xmin = hist->GetXaxis()->GetXmin();
566 double xmax = hist->GetXaxis()->GetXmax();
570 for(
int i=0; i<n; ++i){
571 if(graph->GetPoint(i,x,y)!=i)
break;
572 int bin = xvar->getBinning().binNumber(x);
573 graph->SetPoint(i,hist->GetXaxis()->GetBinCenter(bin+1),y);
574 graph->SetPointEXhigh(i,0.5*hist->GetXaxis()->GetBinWidth(bin+1));
575 graph->SetPointEXlow(i,0.5*hist->GetXaxis()->GetBinWidth(bin+1));
577 graph->GetXaxis()->Set(hist->GetNbinsX(),xmin,xmax);
579 for(
int i=0; i<hist->GetNbinsX(); ++i){
580 graph->GetXaxis()->SetBinLabel(i+1,hist->GetXaxis()->GetBinLabel(i+1));
591 void RooPlot::addPlotable(RooPlotable *plotable, Option_t *drawOptions, Bool_t invisible, Bool_t refreshNorm)
594 updateYAxis(plotable->getYAxisMin(),plotable->getYAxisMax(),plotable->getYAxisLabel());
597 updateFitRangeNorm(plotable,refreshNorm) ;
600 TObject *obj= plotable->crossCast();
602 coutE(InputArguments) << fName <<
"::add: cross-cast to TObject failed (nothing added)" << endl;
606 if(this->_hist->GetXaxis()->IsAlphanumeric()){
607 if(obj->InheritsFrom(RooCurve::Class())){
608 ::translateGraph(this->_hist,_plotVarClone,static_cast<RooCurve*>(obj));
609 }
else if(obj->InheritsFrom(RooHist::Class())){
610 ::translateGraph(this->_hist,_plotVarClone,static_cast<RooHist*>(obj));
614 DrawOpt opt(drawOptions) ;
615 opt.invisible = invisible ;
616 _items.Add(obj,opt.rawOpt());
625 void RooPlot::updateFitRangeNorm(
const TH1* hist)
627 const TAxis* xa = ((TH1*)hist)->GetXaxis() ;
628 _normBinWidth = (xa->GetXmax()-xa->GetXmin())/hist->GetNbinsX() ;
629 _normNumEvts = hist->GetEntries()/_normBinWidth ;
637 void RooPlot::updateFitRangeNorm(
const RooPlotable* rp, Bool_t refreshNorm)
639 if (_normNumEvts != 0) {
642 if (!refreshNorm) return ;
644 Double_t corFac(1.0) ;
645 if (dynamic_cast<const RooHist*>(rp)) corFac = _normBinWidth/rp->getFitRangeBinW() ;
648 if (fabs(rp->getFitRangeNEvt()/corFac-_normNumEvts)>1e-6) {
649 coutI(Plotting) <<
"RooPlot::updateFitRangeNorm: New event count of " << rp->getFitRangeNEvt()/corFac
650 <<
" will supercede previous event count of " << _normNumEvts <<
" for normalization of PDF projections" << endl ;
655 _normNumEvts = rp->getFitRangeNEvt()/corFac ;
663 _normNumEvts = rp->getFitRangeNEvt() ;
664 if (rp->getFitRangeBinW()) {
665 _normBinWidth = rp->getFitRangeBinW() ;
680 void RooPlot::updateYAxis(Double_t ymin, Double_t ymax,
const char *label)
683 if(GetMinimum() == 0 && ymin > 0) ymin= 0;
686 Double_t ypad= getPadFactor()*(ymax-ymin);
688 if(ymin < 0) ymin-= ypad;
691 if(GetMaximum() < ymax) {
695 _hist->SetBinContent(1,ymax) ;
697 if(GetMinimum() > ymin) {
703 if(0 == strlen(_hist->GetYaxis()->GetTitle())) _hist->SetYTitle(label);
712 void RooPlot::Draw(Option_t *option)
714 TString optArg = option ;
719 if (optArg.Contains(
"same")) {
720 _hist->Draw(
"FUNCSAME");
727 while((obj= _iterator->Next())) {
728 DrawOpt opt(_iterator->GetOption()) ;
729 if (!opt.invisible) {
732 if (!strlen(opt.drawOptions) && obj->IsA()->InheritsFrom(TGraph::Class()) ) strlcpy(opt.drawOptions,
"LP",3);
733 obj->Draw(opt.drawOptions);
737 _hist->Draw(
"AXISSAME");
745 void RooPlot::printName(ostream& os)
const
754 void RooPlot::printTitle(ostream& os)
const
763 void RooPlot::printClassName(ostream& os)
const
765 os << IsA()->GetName() ;
772 void RooPlot::printArgs(ostream& os)
const
776 _plotVarClone->printStream(os,kName,kInline) ;
786 void RooPlot::printValue(ostream& os)
const
791 Bool_t first(kTRUE) ;
792 while((obj= _iterator->Next())) {
798 if(obj->IsA()->InheritsFrom(RooPrintable::Class())) {
799 RooPrintable* po =
dynamic_cast<RooPrintable*
>(obj) ;
801 po->printStream(os,kClassName|kName,kInline) ;
805 os << obj->ClassName() <<
"::" << obj->GetName() ;
815 void RooPlot::printMultiline(ostream& os, Int_t , Bool_t verbose, TString indent)
const
817 TString deeper(indent);
819 if(0 != _plotVarClone) {
820 os << indent <<
"RooPlot " << GetName() <<
" (" << GetTitle() <<
") plots variable ";
821 _plotVarClone->printStream(os,kName|kTitle,kSingleLine,
"");
824 os << indent <<
"RooPlot " << GetName() <<
" (" << GetTitle() <<
") has no associated plot variable" << endl ;
826 os << indent <<
" Plot frame contains " << _items.GetSize() <<
" object(s):" << endl;
832 while((obj= _iterator->Next())) {
833 os << deeper <<
"[" << i++ <<
"] (Options=\"" << _iterator->GetOption() <<
"\") ";
835 if(obj->IsA()->InheritsFrom(RooPrintable::Class())) {
836 RooPrintable* po =
dynamic_cast<RooPrintable*
>(obj) ;
838 po->printStream(os,kName|kClassName|kArgs|kExtras,kSingleLine) ;
843 os << obj->ClassName() <<
"::" << obj->GetName() << endl;
855 const char* RooPlot::nameOf(Int_t idx)
const
857 TObject* obj = _items.At(idx) ;
859 coutE(InputArguments) <<
"RooPlot::nameOf(" << GetName() <<
") index " << idx <<
" out of range" << endl ;
862 return obj->GetName() ;
871 TObject* RooPlot::getObject(Int_t idx)
const
873 TObject* obj = _items.At(idx) ;
875 coutE(InputArguments) <<
"RooPlot::getObject(" << GetName() <<
") index " << idx <<
" out of range" << endl ;
887 TAttLine *RooPlot::getAttLine(
const char *name)
const
889 return dynamic_cast<TAttLine*
>(findObject(name));
897 TAttFill *RooPlot::getAttFill(
const char *name)
const
899 return dynamic_cast<TAttFill*
>(findObject(name));
907 TAttMarker *RooPlot::getAttMarker(
const char *name)
const
909 return dynamic_cast<TAttMarker*
>(findObject(name));
917 TAttText *RooPlot::getAttText(
const char *name)
const
919 return dynamic_cast<TAttText*
>(findObject(name));
928 RooCurve* RooPlot::getCurve(
const char* name)
const
930 return dynamic_cast<RooCurve*
>(findObject(name)) ;
938 RooHist* RooPlot::getHist(
const char* name)
const
940 return dynamic_cast<RooHist*
>(findObject(name)) ;
950 void RooPlot::remove(
const char* name, Bool_t deleteToo)
952 TObject* obj = findObject(name) ;
955 coutE(InputArguments) <<
"RooPlot::remove(" << GetName() <<
") ERROR: no object found with name " << name << endl ;
957 coutE(InputArguments) <<
"RooPlot::remove(" << GetName() <<
") ERROR: plot frame is empty, cannot remove last object" << endl ;
975 Bool_t RooPlot::drawBefore(
const char *before,
const char *target)
977 return _items.moveBefore(before, target, caller(
"drawBefore"));
986 Bool_t RooPlot::drawAfter(
const char *after,
const char *target)
988 return _items.moveAfter(after, target, caller(
"drawAfter"));
1003 TObject *RooPlot::findObject(
const char *name,
const TClass* clas)
const
1008 TIterator* iter = _items.MakeIterator() ;
1009 while((obj=iter->Next())) {
1010 if ((!name || !TString(name).CompareTo(obj->GetName())) &&
1011 (!clas || (obj->IsA()==clas))) {
1018 coutE(InputArguments) <<
"RooPlot::findObject(" << GetName() <<
") cannot find object " << (name?name:
"<last>") << endl ;
1028 TString RooPlot::getDrawOptions(
const char *name)
const
1030 TObjOptLink *link= _items.findLink(name,caller(
"getDrawOptions"));
1031 DrawOpt opt(0 == link ?
"" : link->GetOption()) ;
1032 return TString(opt.drawOptions) ;
1040 Bool_t RooPlot::setDrawOptions(
const char *name, TString options)
1042 TObjOptLink *link= _items.findLink(name,caller(
"setDrawOptions"));
1043 if(0 == link)
return kFALSE;
1045 DrawOpt opt(link->GetOption()) ;
1046 strlcpy(opt.drawOptions,options,128) ;
1047 link->SetOption(opt.rawOpt());
1055 Bool_t RooPlot::getInvisible(
const char* name)
const
1057 TObjOptLink *link= _items.findLink(name,caller(
"getInvisible"));
1058 if(0 == link)
return kFALSE;
1060 return DrawOpt(link->GetOption()).invisible ;
1068 void RooPlot::setInvisible(
const char* name, Bool_t flag)
1070 TObjOptLink *link= _items.findLink(name,caller(
"getInvisible"));
1075 opt.initialize(link->GetOption()) ;
1076 opt.invisible = flag ;
1077 link->SetOption(opt.rawOpt()) ;
1087 TString RooPlot::caller(
const char *method)
const
1089 TString name(fName);
1090 if(strlen(method)) {
1092 name.Append(method);
1102 void RooPlot::SetMaximum(Double_t maximum)
1104 _hist->SetMaximum(maximum==-1111?_defYmax:maximum) ;
1112 void RooPlot::SetMinimum(Double_t minimum)
1114 _hist->SetMinimum(minimum==-1111?_defYmin:minimum) ;
1131 Double_t RooPlot::chiSquare(
const char* curvename,
const char* histname,
int nFitParam)
const
1135 RooCurve* curve = (RooCurve*) findObject(curvename,RooCurve::Class()) ;
1137 coutE(InputArguments) <<
"RooPlot::chiSquare(" << GetName() <<
") cannot find curve" << endl ;
1142 RooHist* hist = (RooHist*) findObject(histname,RooHist::Class()) ;
1144 coutE(InputArguments) <<
"RooPlot::chiSquare(" << GetName() <<
") cannot find histogram" << endl ;
1148 return curve->chiSquare(*hist,nFitParam) ;
1157 RooHist* RooPlot::residHist(
const char* histname,
const char* curvename,
bool normalize,
bool useAverage)
const
1160 RooCurve* curve = (RooCurve*) findObject(curvename,RooCurve::Class()) ;
1162 coutE(InputArguments) <<
"RooPlot::residHist(" << GetName() <<
") cannot find curve" << endl ;
1167 RooHist* hist = (RooHist*) findObject(histname,RooHist::Class()) ;
1169 coutE(InputArguments) <<
"RooPlot::residHist(" << GetName() <<
") cannot find histogram" << endl ;
1173 return hist->makeResidHist(*curve,normalize,useAverage) ;
1181 void RooPlot::DrawOpt::initialize(
const char* inRawOpt)
1184 drawOptions[0] = 0 ;
1188 strlcpy(drawOptions,inRawOpt,128) ;
1189 strtok(drawOptions,
":") ;
1190 const char* extraOpt = strtok(0,
":") ;
1192 invisible = (extraOpt[0]==
'I') ;
1200 const char* RooPlot::DrawOpt::rawOpt()
const
1202 static char buf[128] ;
1203 strlcpy(buf,drawOptions,128) ;
1205 strlcat(buf,
":I",128) ;
1220 Double_t RooPlot::getFitRangeNEvt(Double_t xlo, Double_t xhi)
const
1222 Double_t scaleFactor = 1.0 ;
1224 scaleFactor = _normObj->getFitRangeNEvt(xlo,xhi)/_normObj->getFitRangeNEvt() ;
1226 coutW(Plotting) <<
"RooPlot::getFitRangeNEvt(" << GetName() <<
") WARNING: Unable to obtain event count in range "
1227 << xlo <<
" to " << xhi <<
", substituting full event count" << endl ;
1229 return getFitRangeNEvt()*scaleFactor ;
1236 void RooPlot::SetName(
const char *name)
1238 if (_dir) _dir->GetList()->Remove(
this);
1239 TNamed::SetName(name) ;
1240 if (_dir) _dir->GetList()->Add(
this);
1247 void RooPlot::SetNameTitle(
const char *name,
const char* title)
1249 if (_dir) _dir->GetList()->Remove(
this);
1250 TNamed::SetNameTitle(name,title) ;
1251 if (_dir) _dir->GetList()->Add(
this);
1258 void RooPlot::SetTitle(
const char* title)
1260 TNamed::SetTitle(title) ;
1261 _hist->SetTitle(title) ;
1269 Int_t RooPlot::defaultPrintContents(Option_t* )
const
1271 return kName|kArgs|kValue ;
1276 TAxis* RooPlot::GetXaxis()
const {
return _hist->GetXaxis() ; }
1277 TAxis* RooPlot::GetYaxis()
const {
return _hist->GetYaxis() ; }
1278 Int_t RooPlot::GetNbinsX()
const {
return _hist->GetNbinsX() ; }
1279 Int_t RooPlot::GetNdivisions(Option_t* axis)
const {
return _hist->GetNdivisions(axis) ; }
1280 Double_t RooPlot::GetMinimum(Double_t minval)
const {
return _hist->GetMinimum(minval) ; }
1281 Double_t RooPlot::GetMaximum(Double_t maxval)
const {
return _hist->GetMaximum(maxval) ; }
1284 void RooPlot::SetAxisColor(Color_t color, Option_t* axis) { _hist->SetAxisColor(color,axis) ; }
1285 void RooPlot::SetAxisRange(Double_t xmin, Double_t xmax, Option_t* axis) { _hist->SetAxisRange(xmin,xmax,axis) ; }
1286 void RooPlot::SetBarOffset(Float_t offset) { _hist->SetBarOffset(offset) ; }
1287 void RooPlot::SetBarWidth(Float_t width) { _hist->SetBarWidth(width) ; }
1288 void RooPlot::SetContour(Int_t nlevels,
const Double_t* levels) { _hist->SetContour(nlevels,levels) ; }
1289 void RooPlot::SetContourLevel(Int_t level, Double_t value) { _hist->SetContourLevel(level,value) ; }
1290 void RooPlot::SetDrawOption(Option_t* option) { _hist->SetDrawOption(option) ; }
1291 void RooPlot::SetFillAttributes() { _hist->SetFillAttributes() ; }
1292 void RooPlot::SetFillColor(Color_t fcolor) { _hist->SetFillColor(fcolor) ; }
1293 void RooPlot::SetFillStyle(Style_t fstyle) { _hist->SetFillStyle(fstyle) ; }
1294 void RooPlot::SetLabelColor(Color_t color, Option_t* axis) { _hist->SetLabelColor(color,axis) ; }
1295 void RooPlot::SetLabelFont(Style_t font, Option_t* axis) { _hist->SetLabelFont(font,axis) ; }
1296 void RooPlot::SetLabelOffset(Float_t offset, Option_t* axis) { _hist->SetLabelOffset(offset,axis) ; }
1297 void RooPlot::SetLabelSize(Float_t size, Option_t* axis) { _hist->SetLabelSize(size,axis) ; }
1298 void RooPlot::SetLineAttributes() { _hist->SetLineAttributes() ; }
1299 void RooPlot::SetLineColor(Color_t lcolor) { _hist->SetLineColor(lcolor) ; }
1300 void RooPlot::SetLineStyle(Style_t lstyle) { _hist->SetLineStyle(lstyle) ; }
1301 void RooPlot::SetLineWidth(Width_t lwidth) { _hist->SetLineWidth(lwidth) ; }
1302 void RooPlot::SetMarkerAttributes() { _hist->SetMarkerAttributes() ; }
1303 void RooPlot::SetMarkerColor(Color_t tcolor) { _hist->SetMarkerColor(tcolor) ; }
1304 void RooPlot::SetMarkerSize(Size_t msize) { _hist->SetMarkerSize(msize) ; }
1305 void RooPlot::SetMarkerStyle(Style_t mstyle) { _hist->SetMarkerStyle(mstyle) ; }
1306 void RooPlot::SetNdivisions(Int_t n, Option_t* axis) { _hist->SetNdivisions(n,axis) ; }
1307 void RooPlot::SetOption(Option_t* option) { _hist->SetOption(option) ; }
1308 void RooPlot::SetStats(Bool_t stats) { _hist->SetStats(stats) ; }
1309 void RooPlot::SetTickLength(Float_t length, Option_t* axis) { _hist->SetTickLength(length,axis) ; }
1310 void RooPlot::SetTitleFont(Style_t font, Option_t* axis) { _hist->SetTitleFont(font,axis) ; }
1311 void RooPlot::SetTitleOffset(Float_t offset, Option_t* axis) { _hist->SetTitleOffset(offset,axis) ; }
1312 void RooPlot::SetTitleSize(Float_t size, Option_t* axis) { _hist->SetTitleSize(size,axis) ; }
1313 void RooPlot::SetXTitle(
const char *title) { _hist->SetXTitle(title) ; }
1314 void RooPlot::SetYTitle(
const char *title) { _hist->SetYTitle(title) ; }
1315 void RooPlot::SetZTitle(
const char *title) { _hist->SetZTitle(title) ; }
1323 void RooPlot::Browse(TBrowser * )
1334 void RooPlot::Streamer(TBuffer &R__b)
1338 if (R__b.IsReading()) {
1340 TH1::AddDirectory(kFALSE) ;
1349 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1351 R__b.ReadClassBuffer(RooPlot::Class(),
this,R__v,R__s,R__c);
1357 _hist->TH1::Streamer(R__b);
1358 SetName(_hist->GetName());
1359 SetTitle(_hist->GetTitle());
1360 RooPrintable::Streamer(R__b);
1361 _items.Streamer(R__b);
1363 R__b >> _plotVarClone;
1364 R__b >> _plotVarSet;
1366 R__b >> _normNumEvts;
1367 R__b >> _normBinWidth;
1370 R__b.CheckByteCount(R__s, R__c, RooPlot::IsA());
1373 TH1::AddDirectory(kTRUE) ;
1378 R__b.WriteClassBuffer(RooPlot::Class(),
this);
1384 std::unique_ptr<TLegend> RooPlot::BuildLegend()
const {
1385 std::unique_ptr<TLegend> leg(
new TLegend(0.5, 0.7, 0.9, 0.9));
1386 leg->SetBorderSize(0);
1387 leg->SetFillStyle(0);
1388 for (
int i=0; i < _items.GetSize(); ++i) {
1389 leg->AddEntry(getObject(i));