5 #include <TPaveStats.h>
23 file0_ =
new TFile( file0 );
24 if( file0_->IsZombie() )
exit(1);
25 dir0_ = file0_->GetDirectory( dir0 );
28 file1_ =
new TFile( file1 );
29 if( file1_->IsZombie() )
exit(1);
30 dir1_ = file1_->GetDirectory( dir1 );
43 legend_.AddEntry( s0_, leg0,
"mlf");
44 legend_.AddEntry( s1_, leg1,
"mlf");
48 int binxmin,
int binxmax,
59 string name0 = out0.str();
60 string name1 = out1.str();
63 TH1* h0 = Histo( key, 0);
64 TH1* h1 = Histo( key, 1);
66 TH2* h0_2d =
dynamic_cast< TH2*
>(h0);
67 TH2* h1_2d =
dynamic_cast< TH2*
>(h1);
69 if(h0_2d->GetNbinsY() == 1 ||
70 h1_2d->GetNbinsY() == 1 ) {
71 cerr<<key<<
" is not 2D"<<endl;
75 TH1::AddDirectory(
false );
77 TH1D* h0_slice = h0_2d->ProjectionY(name0.c_str(),
78 binxmin, binxmax,
"");
79 TH1D* h1_slice = h1_2d->ProjectionY(name1.c_str(),
80 binxmin, binxmax,
"");
81 TH1::AddDirectory(
true );
82 Draw( h0_slice, h1_slice, mode);
87 TDirectory*
dir = dir1_;
89 TH2D *h2 = (TH2D*) dir->Get(key);
95 TH2D *h2b = (TH2D*) dir->Get(key);
104 TDirectory*
dir = dir1_;
106 TH2D *h2 = (TH2D*) dir->Get(key);
108 TH1D* ha=TH2Ana.
RMS();
112 TH2D *h2b = (TH2D*) dir->Get(key);
114 TH1D* hb=TH2Anab.
RMS();
121 TDirectory*
dir = dir1_;
123 TH2D *h2 = (TH2D*) dir->Get(key);
129 TH2D *h2b = (TH2D*) dir->Get(key);
138 const Double_t
value=
sqrt(par[0]*par[0]+par[1]*par[1]*(x[0]-par[3])+par[2]*par[2]*(x[0]-par[3])*(x[0]-par[3]))/x[0];
143 const int binxmax,
const bool cst_binning,
Mode mode)
145 TDirectory*
dir = dir1_;
147 TH2D *h2 = (TH2D*) dir->Get(key);
148 TH2Analyzer TH2Ana(h2, binxmin, binxmax, rebinFactor, cst_binning);
149 TH1D* hrms=TH2Ana.
RMS();
150 TF1 *fitfcndgssrms3 =
new TF1(
"fitfcndgssrms3",
fitFunction_f,hrms->GetXaxis()->GetBinLowEdge(1),hrms->GetXaxis()->GetBinUpEdge(hrms->GetNbinsX()),4);
151 fitfcndgssrms3->SetNpx(500);
152 fitfcndgssrms3->SetLineWidth(3);
153 fitfcndgssrms3->SetLineStyle(2);
154 fitfcndgssrms3->SetLineColor(4);
155 hrms->Fit(
"fitfcndgssrms3",
"0R");
158 TF1 *fitfcndgsse3 =
new TF1(
"fitfcndgsse3",
fitFunction_f,hrms->GetXaxis()->GetBinLowEdge(1),hrms->GetXaxis()->GetBinUpEdge(hrms->GetNbinsX()),4);
159 fitfcndgsse3->SetNpx(500);
160 fitfcndgsse3->SetLineWidth(3);
161 fitfcndgsse3->SetLineStyle(1);
162 fitfcndgsse3->SetLineColor(4);
163 ha->Fit(
"fitfcndgsse3",
"0R");
167 TH2D *h2b = (TH2D*) dir->Get(key);
168 TH2Analyzer TH2Anab(h2b, binxmin, binxmax, rebinFactor, cst_binning);
169 TH1D* hrmsb=TH2Anab.
RMS();
170 TF1 *fitfcndgssrmsb3 =
new TF1(
"fitfcndgssrmsb3",
fitFunction_f,hrms->GetXaxis()->GetBinLowEdge(1),hrms->GetXaxis()->GetBinUpEdge(hrms->GetNbinsX()),4);
171 fitfcndgssrmsb3->SetNpx(500);
172 fitfcndgssrmsb3->SetLineWidth(3);
173 fitfcndgssrmsb3->SetLineStyle(2);
174 fitfcndgssrmsb3->SetLineColor(2);
175 hrmsb->Fit(
"fitfcndgssrmsb3",
"0R");
178 TF1 *fitfcndgsseb3 =
new TF1(
"fitfcndgsseb3",
fitFunction_f,hrms->GetXaxis()->GetBinLowEdge(1),hrms->GetXaxis()->GetBinUpEdge(hrms->GetNbinsX()),4);
179 fitfcndgsseb3->SetNpx(500);
180 fitfcndgsseb3->SetLineWidth(3);
181 fitfcndgsseb3->SetLineStyle(1);
182 fitfcndgsseb3->SetLineColor(2);
183 hb->Fit(
"fitfcndgsseb3",
"0R");
188 fitfcndgssrms3->Draw(
"same");
189 fitfcndgsse3->Draw(
"same");
190 fitfcndgssrmsb3->Draw(
"same");
191 fitfcndgsseb3->Draw(
"same");
195 const int binxmax,
const bool cst_binning,
Mode mode)
198 TDirectory*
dir = dir1_;
200 TH2D *h2 = (TH2D*) dir->Get(key);
201 TH2Analyzer TH2Ana(h2, binxmin, binxmax, rebinFactor, cst_binning);
202 TH1D* hrms=TH2Ana.
RMS();
204 TH1D* meanXslice = TH2Ana.
MeanX();
212 hrms->Divide(meanXslice);
214 TF1 *fitXfcndgssrms3 =
new TF1(
"fitXfcndgssrms3",
fitFunction_f,hrms->GetXaxis()->GetBinLowEdge(1),hrms->GetXaxis()->GetBinUpEdge(hrms->GetNbinsX()),4);
215 fitXfcndgssrms3->SetNpx(500);
216 fitXfcndgssrms3->SetLineWidth(3);
217 fitXfcndgssrms3->SetLineStyle(2);
218 fitXfcndgssrms3->SetLineColor(4);
219 hrms->Fit(
"fitXfcndgssrms3",
"0R");
222 ha->Divide(meanXslice);
223 TF1 *fitXfcndgsse3 =
new TF1(
"fitXfcndgsse3",
fitFunction_f,ha->GetXaxis()->GetBinLowEdge(1),ha->GetXaxis()->GetBinUpEdge(ha->GetNbinsX()),4);
224 fitXfcndgsse3->SetNpx(500);
225 fitXfcndgsse3->SetLineWidth(3);
226 fitXfcndgsse3->SetLineStyle(1);
227 fitXfcndgsse3->SetLineColor(4);
228 ha->Fit(
"fitXfcndgsse3",
"0R");
232 TH2D *h2b = (TH2D*) dir->Get(key);
233 TH2Analyzer TH2Anab(h2b, binxmin, binxmax, rebinFactor, cst_binning);
234 TH1D* hrmsb=TH2Anab.
RMS();
235 hrmsb->Divide(meanXslice);
236 TF1 *fitXfcndgssrmsb3 =
new TF1(
"fitXfcndgssrmsb3",
fitFunction_f,hrmsb->GetXaxis()->GetBinLowEdge(1),hrmsb->GetXaxis()->GetBinUpEdge(hrmsb->GetNbinsX()),4);
237 fitXfcndgssrmsb3->SetNpx(500);
238 fitXfcndgssrmsb3->SetLineWidth(3);
239 fitXfcndgssrmsb3->SetLineStyle(2);
240 fitXfcndgssrmsb3->SetLineColor(2);
241 hrmsb->Fit(
"fitXfcndgssrmsb3",
"0R");
244 hb->Divide(meanXslice);
245 TF1 *fitXfcndgsseb3 =
new TF1(
"fitXfcndgsseb3",
fitFunction_f,hb->GetXaxis()->GetBinLowEdge(1),hb->GetXaxis()->GetBinUpEdge(hb->GetNbinsX()),4);
246 fitXfcndgsseb3->SetNpx(500);
247 fitXfcndgsseb3->SetLineWidth(3);
248 fitXfcndgsseb3->SetLineStyle(1);
249 fitXfcndgsseb3->SetLineColor(2);
250 hb->Fit(
"fitXfcndgsseb3",
"0R");
255 fitXfcndgssrms3->Draw(
"same");
256 fitXfcndgsse3->Draw(
"same");
257 fitXfcndgssrmsb3->Draw(
"same");
258 fitXfcndgsseb3->Draw(
"same");
264 TDirectory*
dir = dir1_;
267 TH2D *h2_b = (TH2D*) dir->Get(key2);
269 TH1D* meanslice=TH2Ana_b.
Average();
271 TH2D *h2 = (TH2D*) dir->Get(key);
275 ha->Divide(meanslice);
279 TH2D *h2b = (TH2D*) dir->Get(key);
282 TH2D *h2b_b = (TH2D*) dir->Get(key2);
284 TH1D* meansliceb=TH2Anab_b.
Average();
287 hb->Divide(meansliceb);
295 TH1::AddDirectory(
false );
296 TH1* h0 = Histo( key, 0);
297 TH1* h1 = (TH1*) Histo( key, 1)->Clone(
"h1");
299 TH1::AddDirectory(
true );
309 h0 = Histo( key0, 0);
310 h1 = Histo( key1, 1);
314 h0 = Histo( key0, 0);
315 TH1 * h0b = Histo( key1, 0);
316 h1 = Histo( key0, 1);
317 TH1 * h1b = Histo( key1, 1);
325 h0->GetXaxis()->SetRangeUser( xMin_, xMax_);
326 h1->GetXaxis()->SetRangeUser( xMin_, xMax_);
327 h0b->GetXaxis()->SetRangeUser( xMin_, xMax_);
328 h1b->GetXaxis()->SetRangeUser( xMin_, xMax_);
333 h0->Divide(h0,h0b,1.,1.,
"B");
336 h1->Divide(h1,h1b,1.,1.,
"B");
343 cerr<<
"bad dir index: "<<dirIndex<<endl;
347 if(dirIndex == 0) dir = dir0_;
348 if(dirIndex == 1) dir = dir1_;
353 TH1*
h = (TH1*) dir->Get(key);
355 cerr<<
"no key "<<key<<
" in directory "<<dir->GetName()<<endl;
362 cerr<<
"invalid histo"<<endl;
366 TH1::AddDirectory(
false );
367 h0_ = (TH1*) h0->Clone(
"h0_");
368 h1_ = (TH1*) h1->Clone(
"h1_");
369 TH1::AddDirectory(
true );
387 h0_->GetXaxis()->SetRangeUser( xMin_, xMax_);
388 h1_->GetXaxis()->SetRangeUser( xMin_, xMax_);
395 TPaveStats *ptstats =
new TPaveStats(0.7385057,0.720339,
396 0.9396552,0.8792373,
"brNDC");
397 ptstats->SetName(
"stats");
398 ptstats->SetBorderSize(1);
399 ptstats->SetLineColor(2);
400 ptstats->SetFillColor(10);
401 ptstats->SetTextAlign(12);
402 ptstats->SetTextColor(2);
403 ptstats->SetOptStat(1111);
404 ptstats->SetOptFit(0);
406 h0_->GetListOfFunctions()->Add(ptstats);
407 ptstats->SetParent(h0_->GetListOfFunctions());
414 TPaveStats *ptstats2 =
new TPaveStats(0.7399425,0.529661,
415 0.941092,0.6885593,
"brNDC");
416 ptstats2->SetName(
"stats");
417 ptstats2->SetBorderSize(1);
418 ptstats2->SetLineColor(4);
419 ptstats2->SetFillColor(10);
420 ptstats2->SetTextAlign(12);
421 ptstats2->SetTextColor(4);
422 TText *
text = ptstats2->AddText(
"h1_");
423 text->SetTextSize(0.03654661);
425 std::ostringstream oss3;
426 oss3 << h1_->GetEntries();
427 const std::string txt_entries=
"Entries = "+oss3.str();
428 text = ptstats2->AddText(txt_entries.c_str());
429 std::ostringstream oss;
430 oss << h1_->GetMean();
432 text = ptstats2->AddText(txt_mean.c_str());
433 std::ostringstream oss2;
434 oss2 << h1_->GetRMS();
436 text = ptstats2->AddText(txt_rms.c_str());
437 ptstats2->SetOptStat(1111);
438 ptstats2->SetOptFit(0);
440 h1_->GetListOfFunctions()->Add(ptstats2);
441 ptstats2->SetParent(h1_->GetListOfFunctions());
445 TPaveStats *ptstats =
new TPaveStats(0.0,0.0,
448 h0_->GetListOfFunctions()->Add(ptstats);
449 ptstats->SetParent(h0_->GetListOfFunctions());
456 h1_->Scale( h0_->GetEntries()/h1_->GetEntries() );
463 if( h1_->GetMaximum()>h0_->GetMaximum()) {
464 h0_->SetMaximum( h1_->GetMaximum()*1.15 );
478 max= h0_->GetMaximum();
479 if ( h1_->GetMaximum() >
max )
480 max = h1_->GetMaximum();
481 if(max > 0.8) max = 1;
485 min= h0_->GetMinimum();
486 if ( h1_->GetMinimum() <
min )
487 min = h1_->GetMinimum();
488 if(min > 0.2) min = 0.;
491 h0_->SetMaximum( max );
492 h0_->SetMinimum( min );
503 if( h1_->GetMaximum()>h0_->GetMaximum()) {
504 h0_->SetMaximum( h1_->GetMaximum()*1.15 );
506 if( h1_->GetMinimum()<h0_->GetMinimum()) {
507 h0_->SetMinimum( h1_->GetMinimum()*1.15 );
509 h0_->SetMarkerStyle(21);
510 h0_->SetMarkerColor(2);
511 h1_->SetMarkerStyle(21);
512 h1_->SetMarkerColor(4);
void SetStyles(Style *s0, Style *s1, const char *leg0, const char *leg1)
static void FormatHisto(TH1 *h, const Style *s)
void DrawSigmaSlice(const char *key, const int rebinFactor, Mode mode)
void Draw(const char *key, Mode mode)
void DrawGaussSigmaOverMeanXSlice(const char *key, const int rebinFactor, const int binxmin, const int binxmax, const bool cst_binning, Mode mode)
void DrawMeanSlice(const char *key, const int rebinFactor, Mode mode)
void SetDirs(const char *file0, const char *dir0, const char *file1, const char *dir1)
set the 2 files, and the directory within each file, in which the histograms will be compared ...
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
TH1 * Histo(const char *key, unsigned dirIndex)
Double_t fitFunction_f(Double_t *x, Double_t *par)
void DrawSlice(const char *key, int binxmin, int binxmax, Mode mode)
void DrawGaussSigmaOverMeanSlice(const char *key, const char *key2, const int rebinFactor, Mode mode)
void DrawGaussSigmaSlice(const char *key, const int rebinFactor, Mode mode)