ATLAS Offline Software
Loading...
Searching...
No Matches
Resplot.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
21
22
23#ifndef RESPLOT_RESPLOT_H
24#define RESPLOT_RESPLOT_H
25
26#include <stdlib.h>
27
28#include <iostream>
29#include <string>
30#include <vector>
31
32#include "TROOT.h"
33#include "TH1D.h"
34#include "TH2D.h"
35#include "TF1.h"
36#include "TFile.h"
37#include "TString.h"
38
39
40#include "StatVal.h"
41
42
43// Just because we inherit from a
44// TH2D, but I bet it *still* won't work because I use the
45// lovely "vector" class from the stl.
46#include "TObject.h"
47
48
49
50class Resplot : public TObject {
51
52private:
53
54 class ResException {
55 public:
56 ResException(const std::string& s) { std::cerr<<s<<std::endl; }
57 };
58
60
61public:
62
63 // NB, the destructor MUST NOT delete all the histograms, since root will
64 // when closing the file, and it will crash if we let the destructor
65 // try to clean up properly afterwards - LIKE WE SHOULD BE ABLE TO!
66 // NB: NB!! Actually, now we explicitly *remove* them from root managerment
67 // so we can do *proper* garbage collection, not like the
68 // alleged garbage collection in root
69
71 m_Set(false), m_Nentries(NULL),
72 m_mean(NULL), m_sigma(NULL), m_chi2(NULL),
73 m_h2d(NULL), m_h1d(NULL),
74 m_dir(NULL),
75 m_n_primary(0),
77 m_a_secondary(0.0),
78 m_b_secondary(0.0),
79 m_xaxis(""), m_yaxis(""), m_fitname(""), m_finalised(false),
80 m_uniform(true)
81 { }
82
83
84 Resplot(const std::string& name,
85 int n1, double a1, double b1,
86 int n2, double a2, double b2, const std::string& xaxis="") :
87 // TH2D( "2d", "2d", n1, a1, b1, n2, a2, b2),
88 m_Set(false), m_name(name),
89 m_Nentries(NULL),
90 m_mean(NULL), m_sigma(NULL), m_chi2(NULL),
91 m_h2d(NULL), m_h1d(NULL),
92 m_dir(NULL),
93 m_xaxis(xaxis), m_yaxis(""), m_fitname(""), m_finalised(false),
94 m_uniform(true)
95 { Initialise(name, n1, a1, b1, n2, a2, b2); }
96
97
98 Resplot(const std::string& name,
99 int n1, const double* a1,
100 int n2, double a2, double b2, const std::string& xaxis="") :
101 // TH2D( "2d", "2d", n1, a1, n2, a2, b2),
102 m_Set(false), m_name(name),
103 m_Nentries(NULL),
104 m_mean(NULL), m_sigma(NULL), m_chi2(NULL),
105 m_h2d(NULL), m_h1d(NULL),
106 m_dir(NULL),
107 m_xaxis(xaxis), m_yaxis(""), m_fitname(""), m_finalised(false),
108 m_uniform(true)
109 { Initialise(name, n1, a1, n2, a2, b2); }
110
111 Resplot(const std::string& name,
112 const std::vector<double>& a,
113 int n2, double a2, double b2, const std::string& xaxis="") :
114 m_Set(false), m_name(name),
115 m_Nentries(NULL),
116 m_mean(NULL), m_sigma(NULL), m_chi2(NULL),
117 m_h2d(NULL), m_h1d(NULL),
118 m_dir(NULL),
119 m_xaxis(xaxis), m_yaxis(""), m_slices(), m_fitname(""), m_finalised(false),
120 m_uniform(true)
121 { Initialise(name, a, n2, a2, b2); }
122
123
124 Resplot(const std::string& name,
125 const std::vector<double>& a,
126 const std::vector<double>& b,
127 const std::string& xaxis="") :
128 m_Set(false), m_name(name),
129 m_Nentries(NULL),
130 m_mean(NULL), m_sigma(NULL), m_chi2(NULL),
131 m_h2d(NULL), m_h1d(NULL),
132 m_dir(NULL),
133 m_xaxis(xaxis), m_yaxis(""), m_slices(), m_fitname(""), m_finalised(false),
134 m_uniform(false)
135 { Initialise(name, a, b); }
136
137
138
139 Resplot(const Resplot& r, const std::string& tag="") :
140 // TH2D( (TH2D)r ),
141 TObject(r),
142 m_Set(r.m_Set), m_name(r.m_name+tag),
143 m_Nentries(new TH1D(*r.m_Nentries)),
144 m_mean(new TH1D(*r.m_mean)), m_sigma(new TH1D(*r.m_sigma)), m_chi2(new TH1D(*r.m_chi2)),
145 m_h2d(new TH2D(*r.m_h2d)), m_h1d(new TH1D(*r.m_h1d)),
146 m_dir(NULL),
147 m_n_primary(r.m_n_primary), // a_primary(r.a_primary), b_primary(r.b_primary),
150 m_uniform(true)
151 {
152 // TH2D::SetDirectory(0);
153 skip(m_h2d);
154 skip(m_h1d);
155 skip(m_mean);
156 skip(m_sigma);
157 skip(m_chi2);
159 }
160
161 Resplot(const std::string& name, TH2* hin, const bool flip=false) :
162 m_Set(false), m_name(name),
163 m_Nentries(NULL),
164 m_mean(NULL), m_sigma(NULL), m_chi2(NULL),
165 m_h2d(NULL), m_h1d(NULL),
166 m_dir(NULL),
167 m_xaxis(""), m_yaxis(""), m_fitname(""), m_finalised(false),
168 m_uniform(true)
169 {
170
171 TH2D* h = 0;
172
173 if ( flip ) h = rotate( hin );
174 else h = static_cast<TH2D*>(hin);
175
176 // get the major bin edges
177 std::vector<double> a1;
178
179 TAxis* axe = h->GetXaxis();
180
181 for ( int i=1 ; i<=axe->GetNbins()+1 ; i++ ) a1.push_back(axe->GetBinLowEdge(i));
182
183 // get the y bin limits
184 TH1D* s = h->ProjectionY("_duff", 1, 1, "e");
185
186 int n2 = s->GetNbinsX();
187 double a2 = s->GetBinLowEdge(1);
188 double b2 = s->GetBinLowEdge(s->GetNbinsX()+1);
189
190 delete s;
191
192 Initialise(name, a1, n2, a2, b2 );
193
194 // replace default histograms
195 delete m_h2d;
196 m_h2d = (TH2D*)h->Clone("2d");
197 skip(m_h2d);
198
199 delete m_h1d;
200 m_h1d = h->ProjectionY("1d", 1, h->GetNbinsX(), "e");
201 m_h1d->SetTitle("1d");
202 skip(m_h1d);
203 }
204
205
206 // hmmmm, this constructor doesn't work for some
207 // reason. Can't work out why, must be due to root directory
208 // object ownership, I shouldn't wonder
209 Resplot(const std::string& name) :
210 m_Set(false),
211 m_name(name),
212 m_dir(NULL),
213 m_n_secondary(0),
214 m_a_secondary(0.0),
215 m_b_secondary(0.0),
216 m_xaxis(""), m_yaxis(""), m_fitname(""), m_finalised(true),
217 m_uniform(true)
218 // m_Nentries ( new TH1D(*(TH1D*)gDirectory->Get((name+"/fractional uncertainty").c_str())) ),
219 // m_mean ( new TH1D(*(TH1D*)gDirectory->Get((name+"/1d").c_str())) ),
220 // m_sigma ( new TH1D(*(TH1D*)gDirectory->Get((name+"/sigma").c_str())) ),
221 // m_chi2 ( new TH1D(*(TH1D*)gDirectory->Get((name+"/chi2").c_str())) ),
222 // m_h2d ( new TH2D(*(TH2D*)gDirectory->Get((name+"/2d").c_str())) ),
223 // m_h1d ( new TH1D(*(TH1D*)gDirectory->Get((name+"/1d").c_str())) )
224 {
225
226 m_Nentries = new TH1D(*(TH1D*)gDirectory->Get((name+"/fractional uncertainty").c_str()));
227 m_mean = new TH1D(*(TH1D*)gDirectory->Get((name+"/mean").c_str()));
228 m_sigma = new TH1D(*(TH1D*)gDirectory->Get((name+"/sigma").c_str()));
229 m_chi2 = new TH1D(*(TH1D*)gDirectory->Get((name+"/chi2").c_str()));
230 m_h2d = new TH2D(*(TH2D*)gDirectory->Get((name+"/2d").c_str()));
231 m_h1d = new TH1D(*(TH1D*)gDirectory->Get((name+"/1d").c_str()));
232
233 skip(m_h2d);
234 skip(m_h1d);
235 skip(m_mean);
236 skip(m_sigma);
237 skip(m_chi2);
239
240 m_n_primary = m_h2d->GetNbinsX();
241
242 // std::cout << "Resplot(std::string)" << name << "\t m_n_primary " << m_n_primary << std::endl;
243
244 // deep copy
245 for ( int i=1 ; i<=m_h2d->GetNbinsX() ; i++ ) {
246 char slicename[512];
247 sprintf(slicename, "/slices/slice[%03d]", i);
248 // std::cout << i << " " << (name+slicename) << std::endl;
249 m_slices.push_back((TH1D*)gDirectory->Get((name+slicename).c_str()));
250 skip(m_slices.back()); //->SetDirectory(0);
251 }
252
253 }
254
255
256 virtual ~Resplot();
257
258
259 void Initialise(const std::string& name,
260 int n1, double a1, double b1,
261 int n2, double a2, double b2);
262
263 void Initialise(const std::string& name,
264 int n1, const double* a1,
265 int n2, double a2, double b2);
266
267 void Initialise(const std::string& name,
268 int n1, const double* a1,
269 int n2, const double* a2);
270
271 void Initialise(const std::string& name,
272 const std::vector<double>& a,
273 int n2, double a2, double b2);
274
275 void Initialise(const std::string& name,
276 const std::vector<double>& a,
277 const std::vector<double>& b );
278
279
280 // Fill the helper histograms
281 int Fill(double x, double y, double w=1) {
282 // m_h2d->Fill(x, y, w);
283 // TH2D::Fill(x, y, w);
284 m_h2d->Fill(x, y, w);
285 m_h1d->Fill(y, w);
286 return 0;
287 }
288
289
290 // Get the efficiency for a single slice of the major ordinate
291 StatVal GetEfficiency(TH1D* h, double lower, double upper);
292
293
294 // Get the global efficiency
295 StatVal GetGlobalEfficiency(double lower, double upper) {
296 return GetEfficiency(m_h1d, lower, upper);
297 }
298
299
300 // Get all efficiencies for all the major bins
301 // within the range lower .. upper
302 TH1D* GetEfficiencies(const std::string& hname, double lower, double upper);
303
304 // Get all efficiencies for all the major bins
305 // within the range += Nsigma*sigma about the fitted
306 // mean, where the mean and sigma are taken from the fit,
307 // either gaussian of cauchy
308 TH1D* GetEfficiencies(const std::string& hname, double Nsigma);
309
310 // set the name of the x axis variable
311 void SetXAxis(const std::string& xaxis) {
312 m_xaxis = xaxis;
313 m_mean->SetXTitle(m_xaxis.c_str());
314 m_sigma->SetXTitle(m_xaxis.c_str());
315 m_chi2->SetXTitle(m_xaxis.c_str());
316 m_Nentries->SetXTitle(m_xaxis.c_str());
317 m_h2d->SetXTitle(m_xaxis.c_str());
318 m_h1d->SetXTitle(m_xaxis.c_str());
319 }
320
321 // and the y axis variable
322 void SetYAxis(const std::string& yaxis) {
323 m_yaxis = yaxis;
324 m_h2d->SetXTitle(m_yaxis.c_str());
325 m_h1d->SetXTitle(m_yaxis.c_str());
326 }
327
328 // get the limits of the slices in the x coordinate
329 std::vector<double> GetPrimaryLimits() const {
330 std::vector<double> d;
331 for ( int i=1 ; i<=m_mean->GetNbinsX()+1 ; i++ ) d.push_back(m_mean->GetBinLowEdge(i));
332 return d;
333 }
334
335 // get the central values for each slice in the x coordinate
336 std::vector<double> GetPrimaryCentres() const {
337 std::vector<double> d;
338 for ( int i=1 ; i<=m_mean->GetNbinsX() ; i++ ) d.push_back(m_mean->GetBinCenter(i));
339 return d;
340 }
341
342 const std::string& Name() const { return m_name; }
343
344 const std::string& Name(const std::string& s) { return m_name=s; }
345
346 // get the histogram of the mean of the distributions
347 TH1D* Mean() { return m_mean; }
348 const TH1D* Mean() const { return m_mean; }
349
350 // and the "width"
351 TH1D* Sigma() { return m_sigma; }
352
353 // and the chi2
354 TH1D* Chi2() { return m_chi2; }
355 const TH1D* Chi2() const { return m_chi2; }
356
357 // and the overall projection in y
358 TH1D* H1D() { return m_h1d; }
359 const TH1D* H1D() const { return m_h1d; }
360
361 // and the overall 2D histo
362 TH2D* H2D() { return m_h2d; }
363 const TH2D* H2D() const { return m_h2d; }
364
365 // return 1/sqrt(Nentries) approximate stat precision
366 TH1D* Uncertainty() { return m_Nentries; }
367 const TH1D* Uncertainty() const { return m_Nentries; }
368
369 bool finalised() const { return m_finalised; }
370
371 // and the fitted slices
372 const std::vector<TH1D*>& Slices() const { return m_slices; }
373
374 // and the name of the fitted function
375 // NB. this is useful for setting plot paramaters
376 // of the fit for plotting, such as the line colour etc
377 const std::string& FitName() const { return m_fitname; }
378
379 // Static fit functions!!!!
380 // NB. *Any* fit function can be used to fit the distributions
381 // as long as it has this form of method, it does not need
382 // to be a member of the class Resplot, but using static
383 // member functions here, gaurantees there are a few simple
384 // examples that will be safely encapsulated inside the
385 // class so there will be no interference with other functions
386
387 // fit Generic to histogram
388 static TF1* FitInternal(TH1D* s, double a=-999, double b=-999, TF1* f1=0);
389
390 // fit Gaussian to histogram
391 static TF1* FitGaussian(TH1D* s, double a=-999, double b=-999);
392
393 // fit Gaussian with radial dependence to histogram
394 static TF1* FitRGaussian(TH1D* s, double a=-999, double b=-999);
395
396 // or fit a Breit Wigner
397 static TF1* FitBreit(TH1D* s, double a=-999, double b=-999);
398
399 // or fit a Breit Wigner with radial dependence
400 static TF1* FitRBreit(TH1D* s, double a=-999, double b=-999);
401
402 // or fit an inverse tan turn on curve
403 static TF1* FitATan(TH1D* s, double a=-999, double b=-999);
404
405 // use histo mean and rms
406 static TF1* FitNull(TH1D* s, double a=-999, double b=-999);
407
408 // fit a poisson distribution
409 static TF1* FitPoisson(TH1D* s, double a=-999, double b=-999);
410
411 // fit a ax^b exp(c*x)+d distribution
412 static TF1* FitXExp(TH1D* s, double a=-999, double b=-999);
413
414 static TF1* FitLandauGauss(TH1D* s, double a=-999, double b=-999);
415
416 // fit Central Gaussian to histogram
417 static TF1* FitCentralGaussian(TH1D* s, double a=-999, double b=-999);
418
419 // fit histo mean and rms only to central 95% of histogram
420 static TF1* FitNull95(TH1D* s, double a=0, double b=0);
421 // static TF1* FitNull95(TH1D* s, double frac=0.95, bool useroot=false);
422 static TF1* FitNull95New(TH1D* s, double frac=0.95, bool useroot=false);
423 static TF1* FitNull95Obsolete(TH1D* s, double frac=0.95, bool useroot=false);
424
425 static TF1* FitNull95Central(TH1D* s);
426
427
428
429 // Get the offsets and resolutions overall and for each slice
430 // int Finalise(double a=-999, double b=-999, TF1* (*func)(TH1D* s, double a, double b)=Resplot::FitGaussian);
431 int Finalise(double a=-999, double b=-999, TF1* (*func)(TH1D* s, double a, double b)=Resplot::FitGaussian);
432
433 int Finalise(TF1* (*func)(TH1D* s, double a, double b), double a=-999, double b=-999 ) {
434 return Finalise( a, b, func);
435 }
436
437 int Fit(TF1* (*func)(TH1D* s, double a, double b) ) {
438 if ( m_finalised ) return -1;
439 return Finalise( func );
440 }
441
442 int Refit(TF1* (*func)(TH1D* s, double a, double b) ) {
443 clear();
444 return Finalise( func );
445 }
446
447
448 TDirectory* Dir() { return m_dir; }
449
454 Int_t Write(const char* =0, Int_t =0, Int_t =0) const { return DWrite(); }
455 Int_t Write(const char* =0, Int_t =0, Int_t =0) { return DWrite(); }
456 Int_t DWrite(TDirectory* g=0) const;
457
459 static void AddDirectory(bool t=false) { s_mAddDirectoryStatus=t; }
460
461 void SetDirectory(TDirectory* =0) { }
462
463 static void setInterpolateFlag(bool b) { s_interpolate_flag = b; }
464
465
467
469
470 clear();
471
472 // std::cout << "Resplot::operator+= " << Name() << std::endl;
473
474 if ( r.H1D()->GetNbinsX()!=H1D()->GetNbinsX()) throw ResException("histogram limits do not match");
475 if ( r.H2D()->GetNbinsX()!=H2D()->GetNbinsX()) throw ResException("histogram limits do not match");
476 if ( r.H2D()->GetNbinsY()!=H2D()->GetNbinsY()) throw ResException("histogram limits do not match");
477
478 for ( int i=0 ; i<=r.H2D()->GetNbinsX()+1 ; i++ ) {
479 for ( int j=0 ; j<=r.H2D()->GetNbinsY()+1 ; j++ ) {
480 H2D()->SetBinContent( i, j, H2D()->GetBinContent(i,j) + r.H2D()->GetBinContent(i,j) );
481 H2D()->SetBinError( i, j, std::sqrt(H2D()->GetBinError(i,j)*H2D()->GetBinError(i,j) + r.H2D()->GetBinError(i,j)*r.H2D()->GetBinError(i,j) ) );
482 }
483 }
484
485 for ( int i=0 ; i<=r.H1D()->GetNbinsX()+1 ; i++ ) {
486 H1D()->SetBinContent( i, H1D()->GetBinContent(i) + r.H1D()->GetBinContent(i) );
487 H1D()->SetBinError( i, std::sqrt(H1D()->GetBinError(i)*H1D()->GetBinError(i) + r.H1D()->GetBinError(i)*r.H1D()->GetBinError(i) ) );
488 }
489
490 m_finalised = false;
491
492 // std::cout << "Resplot::operator+= done" << std::endl;
493
494 return *this;
495 }
496
497
498
499 Resplot& operator*=(double d) {
500
501 std::cout << "Resplot::operator*= " << Name() << " " << m_finalised << " " << m_slices.size() << std::endl;
502
503 clear();
504
505 std::cout << "Resplot::operator*= " << Name() << " " << m_finalised << " " << m_slices.size() << std::endl;
506 std::cout << "Resplot::operator*= " << Name() << "\tH2D " << H2D() << std::endl;
507
508 H2D()->DrawCopy();
509
510 std::cout << "Resplot::operator*= " << Name() << "\tDraw " << std::endl;
511
512 for ( int i=0 ; i<=H2D()->GetNbinsX()+1 ; i++ ) {
513 for ( int j=0 ; j<=H2D()->GetNbinsY()+1 ; j++ ) {
514 H2D()->SetBinContent( i, j, H2D()->GetBinContent(i,j)*d);
515 H2D()->SetBinError( i, j, H2D()->GetBinError(i,j)*d);
516 }
517 }
518
519
520 std::cout << "Resplot::operator*= " << Name() << "\tH1D " << H1D() << std::endl;
521
522 for ( int i=0 ; i<=H1D()->GetNbinsX()+1 ; i++ ) {
523 H1D()->SetBinContent( i, H1D()->GetBinContent(i)*d );
524 H1D()->SetBinError( i, H1D()->GetBinError(i)*d );
525 }
526
527 m_finalised = false;
528
529 std::cout << "Resplot::operator*= done" << std::endl;
530
531 return *this;
532 }
533
534 Resplot operator*(double d) const {
535 Resplot r(*this);
536 return (r*=d);
537 }
538
539 Resplot operator+(const Resplot& r) const {
540 Resplot r0(*this);
541 return (r0+=r);
542 }
543
544
545 void Integrate() {
546 if ( !m_finalised ) return;
547
550 }
551
552 void setUniform(bool t=false) { m_uniform=t; }
553
554 static const std::string& version() { return s_rversion; }
555 static bool setoldrms95(bool b) { return s_oldrms95=b; }
556 static bool setscalerms95(bool b) { return s_scalerms95=b; }
557 static bool setnofit(bool b) { return s_nofit=b; }
558
560 static TH2D* rotate(const TH2* h);
561
564 static TH2D* combine(const TH2* h, double x, int N);
566 static TH1D* combine(const TH1* h, double x, int N);
567
570 static TH2D* combine(const TH2* h, double epsilon);
571 static TH1D* combine(const TH1* h, double epsilon);
572
573 static std::vector<double> findbins(const TH1* h, double epsilon);
574 static TH1D* rebin(const TH1* h, const std::vector<double>& bins);
575
576 static std::vector<double> getbins(const TH1* h);
577
578private:
579
580 void MakeSlices() { }
581
582private:
583
584 // stop the root default histogram ownership nonsense
585 void skip(TH1D* t) { if ( t ) t->SetDirectory(0); }
586 void delskip(TH1D* t) { if ( t ) { t->SetDirectory(0); delete t; } }
587 void deletehist(TH1D* t) { if ( t ) delete t; }
588
589 void skip(TH2D* t) { if ( t ) t->SetDirectory(0); }
590 void delskip(TH2D* t) { if ( t ) { t->SetDirectory(0); delete t; } }
591 void deletehist(TH2D* t) { if ( t ) delete t; }
592
593
594 void SetPrimary(int n, const double* ) { m_n_primary=n; }
595 void SetPrimary(int n, double , double ) { m_n_primary=n; } // a_primary=a; b_primary=b; }
596 void SetSecondary(int n, double a, double b) { m_n_secondary=n; m_a_secondary=a; m_b_secondary=b; }
597
598
599 // stuff for calculating efficiencies
600
603
604
605 void AddEfficiency(TH1D* h, int i, double lower, double upper) {
606 StatVal v = GetGlobalEfficiency( lower, upper);
607 h->SetBinContent(i, v.value);
608 h->SetBinError(i, v.error);
609 }
610
611 void AddResolution(TH1D* h, int i) {
612 StatVal v = get_sigma();
613 h->SetBinContent(i, v.value);
614 h->SetBinError(i, v.error);
615 }
616
617 void AddMean(TH1D* h, int i) {
618 StatVal v = get_mean();
619 h->SetBinContent(i, v.value);
620 h->SetBinError(i, v.error);
621 }
622
623private:
624
625 void clear() {
626 // std::cout << "clear " << m_slices.size() << std::endl;
627 m_finalised = false;
628 for ( int i=m_slices.size() ; i-- ; ) if ( m_slices[i] ) delete m_slices[i];
629 m_slices.clear();
630 // std::cout << "cleared" << std::endl;
631 }
632
633private:
634
637
638 static const std::string s_rversion;
639
640 bool m_Set;
641
642 std::string m_name;
643
644 TH1D* m_Nentries = 0;
645 TH1D* m_mean = 0;
646 TH1D* m_sigma = 0;
647 TH1D* m_chi2 = 0;
648
649 TH2D* m_h2d = 0;
650 TH1D* m_h1d = 0;
651
654
655 TDirectory* m_dir = 0;
656
658
661
662 std::string m_xaxis;
663 std::string m_yaxis;
664
665 std::vector<TH1D*> m_slices;
666 std::string m_fitname;
667
669 TDirectory* m_slicedir = 0;
670
672
675 static bool s_oldrms95;
676 static bool s_scalerms95;
677
678 static bool s_nofit;
679
680
682
683 ClassDef(Resplot, 1)
684
685};
686
687
688inline Resplot operator*(double d, Resplot r) { return (r*=d); }
689
690
691#endif /* RESPLOT_RESPLOT_H */
692
int upper(int c)
static Double_t a
static const std::vector< std::string > bins
Resplot operator*(double d, Resplot r)
Definition Resplot.h:688
#define y
#define x
Header file for AthHistogramAlgorithm.
ResException(const std::string &s)
Definition Resplot.h:56
static bool s_nofit
Definition Resplot.h:678
static TH2D * rotate(const TH2 *h)
flip the x and y axes
Definition Resplot.cxx:563
TH1D * H1D()
Definition Resplot.h:358
TH2D * m_h2d
Definition Resplot.h:649
std::vector< double > GetPrimaryLimits() const
Definition Resplot.h:329
const TH2D * H2D() const
Definition Resplot.h:363
static TF1 * FitRGaussian(TH1D *s, double a=-999, double b=-999)
Definition Resplot.cxx:1030
static std::vector< double > getbins(const TH1 *h)
Definition Resplot.cxx:920
std::string m_yaxis
Definition Resplot.h:663
const std::string & Name() const
Definition Resplot.h:342
static TF1 * FitCentralGaussian(TH1D *s, double a=-999, double b=-999)
Definition Resplot.cxx:1079
Int_t Write(const char *=0, Int_t=0, Int_t=0)
Definition Resplot.h:455
std::vector< TH1D * > m_slices
Definition Resplot.h:665
bool m_Set
Definition Resplot.h:640
static TF1 * FitInternal(TH1D *s, double a=-999, double b=-999, TF1 *f1=0)
Definition Resplot.cxx:1050
static TH1D * rebin(const TH1 *h, const std::vector< double > &bins)
Definition Resplot.cxx:890
static TF1 * FitNull95New(TH1D *s, double frac=0.95, bool useroot=false)
Definition Resplot.cxx:1686
void SetXAxis(const std::string &xaxis)
Definition Resplot.h:311
static const std::string s_rversion
Definition Resplot.h:638
static TF1 * FitGaussian(TH1D *s, double a=-999, double b=-999)
Definition Resplot.cxx:1024
static TF1 * FitRBreit(TH1D *s, double a=-999, double b=-999)
Definition Resplot.cxx:1035
int Finalise(double a=-999, double b=-999, TF1 *(*func)(TH1D *s, double a, double b)=Resplot::FitGaussian)
Definition Resplot.cxx:387
TDirectory * Dir()
Definition Resplot.h:448
std::string m_xaxis
Definition Resplot.h:662
const std::string & Name(const std::string &s)
Definition Resplot.h:344
Resplot & operator+=(const Resplot &r)
operators
Definition Resplot.h:468
static bool setscalerms95(bool b)
Definition Resplot.h:556
std::string m_name
Definition Resplot.h:642
StatVal m_g_mean
Definition Resplot.h:652
Int_t Write(const char *=0, Int_t=0, Int_t=0) const
Hooray, this stupidity is to overwride both the const and non-const TObject Write methods Fixme: shou...
Definition Resplot.h:454
Resplot(const std::string &name)
Definition Resplot.h:209
std::vector< double > GetPrimaryCentres() const
Definition Resplot.h:336
void AddMean(TH1D *h, int i)
Definition Resplot.h:617
TH1D * Chi2()
Definition Resplot.h:354
void SetYAxis(const std::string &yaxis)
Definition Resplot.h:322
static TF1 * FitBreit(TH1D *s, double a=-999, double b=-999)
Definition Resplot.cxx:1158
static bool AddDirectoryStatus()
Definition Resplot.h:458
Resplot(const std::string &name, int n1, double a1, double b1, int n2, double a2, double b2, const std::string &xaxis="")
Definition Resplot.h:84
void SetSecondary(int n, double a, double b)
Definition Resplot.h:596
TH1D * m_mean
Definition Resplot.h:645
void delskip(TH2D *t)
Definition Resplot.h:590
Resplot()
Definition Resplot.h:70
static TF1 * FitLandauGauss(TH1D *s, double a=-999, double b=-999)
Definition Resplot.cxx:2081
static TF1 * FitXExp(TH1D *s, double a=-999, double b=-999)
Definition Resplot.cxx:1965
Resplot(const std::string &name, const std::vector< double > &a, const std::vector< double > &b, const std::string &xaxis="")
Definition Resplot.h:124
int Refit(TF1 *(*func)(TH1D *s, double a, double b))
Definition Resplot.h:442
TH1D * m_h1d
Definition Resplot.h:650
TH1D * m_Nentries
Definition Resplot.h:644
static bool s_oldrms95
temporarily allow toggeling between old and new rms95 error estimates
Definition Resplot.h:675
static void AddDirectory(bool t=false)
Definition Resplot.h:459
void SetDirectory(TDirectory *=0)
Definition Resplot.h:461
TH2D * H2D()
Definition Resplot.h:362
Resplot(const std::string &name, TH2 *hin, const bool flip=false)
Definition Resplot.h:161
double m_b_secondary
Definition Resplot.h:660
StatVal m_g_sigma
Definition Resplot.h:653
const std::string & FitName() const
Definition Resplot.h:377
static const std::string & version()
Definition Resplot.h:554
static TF1 * FitNull(TH1D *s, double a=-999, double b=-999)
Definition Resplot.cxx:1287
void clear()
Definition Resplot.h:625
static TF1 * FitNull95(TH1D *s, double a=0, double b=0)
Definition Resplot.cxx:1672
static bool s_interpolate_flag
Definition Resplot.h:636
Resplot & operator*=(double d)
Definition Resplot.h:499
void AddEfficiency(TH1D *h, int i, double lower, double upper)
Definition Resplot.h:605
int m_n_primary
Definition Resplot.h:657
void SetPrimary(int n, double, double)
Definition Resplot.h:595
int Finalise(TF1 *(*func)(TH1D *s, double a, double b), double a=-999, double b=-999)
Definition Resplot.h:433
static TF1 * FitNull95Obsolete(TH1D *s, double frac=0.95, bool useroot=false)
Definition Resplot.cxx:1407
bool m_uniform
Definition Resplot.h:671
const TH1D * Uncertainty() const
Definition Resplot.h:367
static bool setoldrms95(bool b)
Definition Resplot.h:555
Resplot(const std::string &name, const std::vector< double > &a, int n2, double a2, double b2, const std::string &xaxis="")
Definition Resplot.h:111
TH1D * m_sigma
Definition Resplot.h:646
void skip(TH2D *t)
Definition Resplot.h:589
StatVal GetEfficiency(TH1D *h, double lower, double upper)
Definition Resplot.cxx:931
@ BINWIDTH
Definition Resplot.h:59
@ HISTOWIDTH
Definition Resplot.h:59
@ EMPTY
Definition Resplot.h:59
Resplot(const std::string &name, int n1, const double *a1, int n2, double a2, double b2, const std::string &xaxis="")
Definition Resplot.h:98
StatVal GetGlobalEfficiency(double lower, double upper)
Definition Resplot.h:295
void SetPrimary(int n, const double *)
Definition Resplot.h:594
void Initialise(const std::string &name, int n1, double a1, double b1, int n2, double a2, double b2)
Definition Resplot.cxx:193
Resplot(const Resplot &r, const std::string &tag="")
Definition Resplot.h:139
static TH2D * combine(const TH2 *h, double x, int N)
combine bins along the x axis after value x, combine each N bins into a single bin
Definition Resplot.cxx:605
const TH1D * Mean() const
Definition Resplot.h:348
void MakeSlices()
Definition Resplot.h:580
void skip(TH1D *t)
Definition Resplot.h:585
Resplot operator+(const Resplot &r) const
Definition Resplot.h:539
StatVal get_mean()
Definition Resplot.h:601
TH1D * m_chi2
Definition Resplot.h:647
void AddResolution(TH1D *h, int i)
Definition Resplot.h:611
static TF1 * FitPoisson(TH1D *s, double a=-999, double b=-999)
Definition Resplot.cxx:1925
double m_a_secondary
Definition Resplot.h:660
Int_t DWrite(TDirectory *g=0) const
boooo, need to use the stupid Int_t class because I foolishly gave this function the same name as TOb...
Definition Resplot.cxx:341
bool finalised() const
Definition Resplot.h:369
void deletehist(TH1D *t)
Definition Resplot.h:587
static ERROR s_ErrorSet
Definition Resplot.h:681
TH1D * Uncertainty()
Definition Resplot.h:366
const TH1D * H1D() const
Definition Resplot.h:359
static void setInterpolateFlag(bool b)
Definition Resplot.h:463
std::string m_fitname
Definition Resplot.h:666
int Fit(TF1 *(*func)(TH1D *s, double a, double b))
Definition Resplot.h:437
void Integrate()
Definition Resplot.h:545
Resplot operator*(double d) const
Definition Resplot.h:534
TDirectory * m_slicedir
Definition Resplot.h:669
TDirectory * m_dir
Definition Resplot.h:655
int Fill(double x, double y, double w=1)
Definition Resplot.h:281
static bool s_scalerms95
Definition Resplot.h:676
int m_n_secondary
Definition Resplot.h:659
static bool s_mAddDirectoryStatus
Definition Resplot.h:635
TH1D * Sigma()
Definition Resplot.h:351
const TH1D * Chi2() const
Definition Resplot.h:355
void setUniform(bool t=false)
Definition Resplot.h:552
void delskip(TH1D *t)
Definition Resplot.h:586
static TF1 * FitATan(TH1D *s, double a=-999, double b=-999)
Definition Resplot.cxx:1219
bool m_finalised
Definition Resplot.h:668
static TF1 * FitNull95Central(TH1D *s)
Definition Resplot.cxx:1753
StatVal get_sigma()
Definition Resplot.h:602
virtual ~Resplot()
Definition Resplot.cxx:173
TH1D * Mean()
Definition Resplot.h:347
TH1D * GetEfficiencies(const std::string &hname, double lower, double upper)
Definition Resplot.cxx:957
void deletehist(TH2D *t)
Definition Resplot.h:591
const std::vector< TH1D * > & Slices() const
Definition Resplot.h:372
static bool setnofit(bool b)
Definition Resplot.h:557
static std::vector< double > findbins(const TH1 *h, double epsilon)
Definition Resplot.cxx:837
simple struct to hold a value and it's associated uncertainty.
Definition StatVal.h:26
int r
Definition globals.cxx:22