ATLAS Offline Software
Loading...
Searching...
No Matches
Resplot::Resplot Class Reference

#include <Resplot.h>

Collaboration diagram for Resplot::Resplot:

Classes

class  ResException

Public Member Functions

 Resplot ()
 Resplot (const std::string &name, int n1, double a1, double b1, int n2, double a2, double b2, const std::string &xaxis="")
 Resplot (const std::string &name, int n1, const double *a1, int n2, double a2, double b2, const std::string &xaxis="")
 Resplot (const std::string &name, const std::vector< double > &a, int n2, double a2, double b2, const std::string &xaxis="")
 Resplot (const std::string &name, const std::vector< double > &a, const std::vector< double > &b, const std::string &xaxis="")
Resplot & operator= (const Resplot &)=delete
 Resplot (const Resplot &r, const std::string &tag="")
 Resplot (const std::string &name, TH2 *hin, const bool flip=false)
 Resplot (const std::string &name)
virtual ~Resplot ()
void Initialise (const std::string &name, int n1, double a1, double b1, int n2, double a2, double b2)
void Initialise (const std::string &name, int n1, const double *a1, int n2, double a2, double b2)
void Initialise (const std::string &name, int n1, const double *a1, int n2, const double *a2)
void Initialise (const std::string &name, const std::vector< double > &a, int n2, double a2, double b2)
void Initialise (const std::string &name, const std::vector< double > &a, const std::vector< double > &b)
int Fill (double x, double y, double w=1)
StatVal GetEfficiency (TH1D *h, double lower, double upper)
StatVal GetGlobalEfficiency (double lower, double upper)
TH1D * GetEfficiencies (const std::string &hname, double lower, double upper)
TH1D * GetEfficiencies (const std::string &hname, double Nsigma)
void SetXAxis (const std::string &xaxis)
void SetYAxis (const std::string &yaxis)
std::vector< double > GetPrimaryLimits () const
std::vector< double > GetPrimaryCentres () const
const std::string & Name (const std::string &s)
const std::string & Name () const
const std::string & name () const
TH1D * Mean ()
const TH1D * Mean () const
TH1D * Sigma ()
TH1D * Chi2 ()
const TH1D * Chi2 () const
TH1D * H1D ()
const TH1D * H1D () const
TH2D * H2D ()
const TH2D * H2D () const
TH1D * Uncertainty ()
const TH1D * Uncertainty () const
bool finalised () const
const std::vector< TH1D * > & Slices () const
const std::string & FitName () const
int Finalise (double a=-999, double b=-999, TF1 *(*func)(TH1D *s, double a, double b)=FitGaussian)
int Finalise (TF1 *(*func)(TH1D *s, double a, double b), double a=-999, double b=-999)
int Fit (TF1 *(*func)(TH1D *s, double a, double b))
int Refit (TF1 *(*func)(TH1D *s, double a, double b))
TDirectory * Dir ()
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: should probably remove all of these so root can write out using the dictionary but I could never get that to work.
Int_t Write (const char *=0, Int_t=0, Int_t=0)
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 TObject::Write
void SetDirectory (TDirectory *=0)
Resplot & operator+= (const Resplot &r)
 operators
Resplot & operator*= (double d)
Resplot operator* (double d) const
Resplot operator+ (const Resplot &r) const
void Integrate ()
void setUniform (bool t=false)

Static Public Member Functions

static std::vector< double > getLimits (const TAxis *axis)
 projection utilities ... NB: In athena, for some reason the destuctors for histograms created using TH2D::ProjectX/Y take ~ 13 ms to be deleted, around 300 times slower than a normal TH1 delete, so we implement our own projectionX/Y
static std::vector< double > getxLimits (TH2 *h)
static std::vector< double > getyLimits (TH2 *h)
static TH1D * projectionY (TH2 *h2d, int col, const std::vector< double > &ylimits, const std::string &tagname)
 actual local projections ...
static TH1D * projectionY (TH2 *h2d, int col0, int col1, const std::vector< double > &ylimits, const std::string &tagname)
static TH1D * projectionX (TH2 *h2d, int row, const std::vector< double > &xlimits, const std::string &tagname)
static TH1D * projectionX (TH2 *h2d, int row0, int row1, const std::vector< double > &xlimits, const std::string &tagname)
static double sum (TH1 *h)
static bool AddDirectoryStatus ()
static void AddDirectory (bool t=false)
static const std::string & version ()
static TH2D * rotate (const TH2 *h, const std::string &s="")
 flip the x and y axes
static TH2D * copy (const TH2 *h, const std::string &s="")
 copy a TH2
static std::vector< double > findbins (const TH1 *h, double epsilon)
static TH1D * rebin (const TH1 *h, const std::vector< double > &bins)
static std::vector< double > getbins (const TH1 *h)

Private Types

enum  ERROR { OK , HISTOWIDTH , BINWIDTH , EMPTY }

Private Member Functions

void MakeSlices ()
void skip (TH1D *t)
void delskip (TH1D *t)
void deletehist (TH1D *t)
void skip (TH2D *t)
void delskip (TH2D *t)
void deletehist (TH2D *t)
void SetPrimary (int n, const double *)
void SetPrimary (int n, double, double)
void SetSecondary (int n, double a, double b)
StatVal get_mean ()
StatVal get_sigma ()
void AddEfficiency (TH1D *h, int i, double lower, double upper)
void AddResolution (TH1D *h, int i)
void AddMean (TH1D *h, int i)
void clear ()

Private Attributes

bool m_Set
std::string m_name
TH1D * m_Nentries = 0
TH1D * m_mean = 0
TH1D * m_sigma = 0
TH1D * m_chi2 = 0
TH2D * m_h2d = 0
TH1D * m_h1d = 0
StatVal m_g_mean
StatVal m_g_sigma
TDirectory * m_dir = 0
int m_n_primary
int m_n_secondary
double m_a_secondary
double m_b_secondary
std::string m_xaxis
std::string m_yaxis
std::vector< TH1D * > m_slices
std::string m_fitname
bool m_finalised
bool m_uniform

Static Private Attributes

static const std::string s_rversion = "resplot-v29"

Detailed Description

Definition at line 50 of file Resplot.h.

Member Enumeration Documentation

◆ ERROR

Enumerator
OK 
HISTOWIDTH 
BINWIDTH 
EMPTY 

Definition at line 59 of file Resplot.h.

Constructor & Destructor Documentation

◆ Resplot() [1/8]

Resplot::Resplot::Resplot ( )
inline

Definition at line 70 of file Resplot.h.

70 :
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 { }
TDirectory * m_dir
Definition Resplot.h:682
double m_a_secondary
Definition Resplot.h:687
std::string m_xaxis
Definition Resplot.h:689
TH1D * m_Nentries
Definition Resplot.h:671
double m_b_secondary
Definition Resplot.h:687
std::string m_fitname
Definition Resplot.h:693
std::string m_yaxis
Definition Resplot.h:690

◆ Resplot() [2/8]

Resplot::Resplot::Resplot ( const std::string & name,
int n1,
double a1,
double b1,
int n2,
double a2,
double b2,
const std::string & xaxis = "" )
inline

Definition at line 84 of file Resplot.h.

86 :
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); }
std::string m_name
Definition Resplot.h:669
const std::string & name() const
Definition Resplot.h:349
void Initialise(const std::string &name, int n1, double a1, double b1, int n2, double a2, double b2)
Definition Resplot.cxx:226

◆ Resplot() [3/8]

Resplot::Resplot::Resplot ( const std::string & name,
int n1,
const double * a1,
int n2,
double a2,
double b2,
const std::string & xaxis = "" )
inline

Definition at line 98 of file Resplot.h.

100 :
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); }

◆ Resplot() [4/8]

Resplot::Resplot::Resplot ( const std::string & name,
const std::vector< double > & a,
int n2,
double a2,
double b2,
const std::string & xaxis = "" )
inline

Definition at line 111 of file Resplot.h.

113 :
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); }
static Double_t a
std::vector< TH1D * > m_slices
Definition Resplot.h:692

◆ Resplot() [5/8]

Resplot::Resplot::Resplot ( const std::string & name,
const std::vector< double > & a,
const std::vector< double > & b,
const std::string & xaxis = "" )
inline

Definition at line 124 of file Resplot.h.

127 :
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); }

◆ Resplot() [6/8]

Resplot::Resplot::Resplot ( const Resplot & r,
const std::string & tag = "" )
inline

Definition at line 145 of file Resplot.h.

145 :
146 // TH2D( (TH2D)r ),
147 // TObject(r),
148 m_Set(r.m_Set), m_name(r.m_name+tag),
149 m_Nentries(new TH1D(*r.m_Nentries)),
150 m_mean(new TH1D(*r.m_mean)), m_sigma(new TH1D(*r.m_sigma)), m_chi2(new TH1D(*r.m_chi2)),
151 m_h2d(new TH2D(*r.m_h2d)), m_h1d(new TH1D(*r.m_h1d)),
152 m_dir(NULL),
153 m_n_primary(r.m_n_primary), // a_primary(r.a_primary), b_primary(r.b_primary),
154 m_n_secondary(r.m_n_secondary), m_a_secondary(r.m_a_secondary), m_b_secondary(r.m_b_secondary),
155 m_xaxis(r.m_xaxis), m_yaxis(r.m_yaxis), m_fitname(""), m_finalised(false),
156 m_uniform(true)
157 {
158 // TH2D::SetDirectory(0);
159 skip(m_h2d);
160 skip(m_h1d);
161 skip(m_mean);
162 skip(m_sigma);
163 skip(m_chi2);
165 }
int r
Definition globals.cxx:22

◆ Resplot() [7/8]

Resplot::Resplot::Resplot ( const std::string & name,
TH2 * hin,
const bool flip = false )
inline

Definition at line 168 of file Resplot.h.

168 :
169 m_Set(false), m_name(name),
170 m_Nentries(NULL),
171 m_mean(NULL), m_sigma(NULL), m_chi2(NULL),
172 m_h2d(NULL), m_h1d(NULL),
173 m_dir(NULL),
174 m_xaxis(""), m_yaxis(""), m_fitname(""), m_finalised(false),
175 m_uniform(true)
176 {
177
178 TH2D* h = 0;
179
180 if ( flip ) h = rotate( hin );
181 else h = static_cast<TH2D*>(hin);
182
183 // get the major bin edges
184 std::vector<double> xlimits = getLimits( h->GetXaxis() );;
185 std::vector<double> ylimits = getLimits( h->GetYaxis() );
186
187 int n2 = ylimits.size()-1;;
188 double a2 = ylimits[0];;
189 double b2 = ylimits.back();
190
191 Initialise(name, xlimits, n2, a2, b2 );
192
193 // replace default histograms
194 delete m_h2d;
195 m_h2d = copy(h, "2d");
196 skip(m_h2d);
197
198 delete m_h1d;
199 // m_h1d = h->ProjectionY("1d", 1, h->GetNbinsX(), "e");
200 m_h1d = projectionY( h, 1, h->GetNbinsX(), ylimits, "1d" );
201 m_h1d->SetTitle("1d");
202
203 skip(m_h1d);
204 }
static TH2D * rotate(const TH2 *h, const std::string &s="")
flip the x and y axes
Definition Resplot.cxx:604
static TH2D * copy(const TH2 *h, const std::string &s="")
copy a TH2
Definition Resplot.cxx:633
static TH1D * projectionY(TH2 *h2d, int col, const std::vector< double > &ylimits, const std::string &tagname)
actual local projections ...
Definition Resplot.h:410
static std::vector< double > getLimits(const TAxis *axis)
projection utilities ... NB: In athena, for some reason the destuctors for histograms created using T...
Definition Resplot.h:398

◆ Resplot() [8/8]

Resplot::Resplot::Resplot ( const std::string & name)
inline

Definition at line 210 of file Resplot.h.

210 :
211 m_Set(false),
212 m_name(name),
213 m_dir(NULL),
214 m_n_secondary(0),
215 m_a_secondary(0.0),
216 m_b_secondary(0.0),
217 m_xaxis(""), m_yaxis(""), m_fitname(""), m_finalised(true),
218 m_uniform(true)
219 // m_Nentries ( new TH1D(*(TH1D*)gDirectory->Get((name+"/fractional uncertainty").c_str())) ),
220 // m_mean ( new TH1D(*(TH1D*)gDirectory->Get((name+"/1d").c_str())) ),
221 // m_sigma ( new TH1D(*(TH1D*)gDirectory->Get((name+"/sigma").c_str())) ),
222 // m_chi2 ( new TH1D(*(TH1D*)gDirectory->Get((name+"/chi2").c_str())) ),
223 // m_h2d ( new TH2D(*(TH2D*)gDirectory->Get((name+"/2d").c_str())) ),
224 // m_h1d ( new TH1D(*(TH1D*)gDirectory->Get((name+"/1d").c_str())) )
225 {
226
227 m_Nentries = new TH1D(*(TH1D*)gDirectory->Get((name+"/fractional uncertainty").c_str()));
228 m_mean = new TH1D(*(TH1D*)gDirectory->Get((name+"/mean").c_str()));
229 m_sigma = new TH1D(*(TH1D*)gDirectory->Get((name+"/sigma").c_str()));
230 m_chi2 = new TH1D(*(TH1D*)gDirectory->Get((name+"/chi2").c_str()));
231 m_h2d = new TH2D(*(TH2D*)gDirectory->Get((name+"/2d").c_str()));
232 m_h1d = new TH1D(*(TH1D*)gDirectory->Get((name+"/1d").c_str()));
233
234 skip(m_h2d);
235 skip(m_h1d);
236 skip(m_mean);
237 skip(m_sigma);
238 skip(m_chi2);
240
241 m_n_primary = m_h2d->GetNbinsX();
242
243 // std::cout << "Resplot(std::string)" << name << "\t m_n_primary " << m_n_primary << std::endl;
244
245 // deep copy
246 for ( int i=1 ; i<=m_h2d->GetNbinsX() ; i++ ) {
247 char slicename[512];
248 sprintf(slicename, "/slices/slice[%03d]", i);
249 // std::cout << i << " " << (name+slicename) << std::endl;
250 m_slices.push_back((TH1D*)gDirectory->Get((name+slicename).c_str()));
251 skip(m_slices.back()); //->SetDirectory(0);
252 }
253
254 }

◆ ~Resplot()

Resplot::Resplot::~Resplot ( )
virtual

Definition at line 208 of file Resplot.cxx.

208 {
209
210 // struct timeval st = simpletimer_start();
211
213 delskip( m_h2d );
214 delskip( m_h1d );
215 delskip( m_mean );
216 delskip( m_sigma );
217 delskip( m_chi2 );
218
219 for ( unsigned i=0 ; i<m_slices.size() ; i++ ) delskip(m_slices[i]);
220
221 // TH2D::SetDirectory(0);
222}
void delskip(TH1D *t)
Definition Resplot.h:616

Member Function Documentation

◆ AddDirectory()

void Resplot::Resplot::AddDirectory ( bool t = false)
inlinestatic

Definition at line 501 of file Resplot.h.

◆ AddDirectoryStatus()

bool Resplot::Resplot::AddDirectoryStatus ( )
inlinestatic

Definition at line 500 of file Resplot.h.

500{ return s_mAddDirectoryStatus; }

◆ AddEfficiency()

void Resplot::Resplot::AddEfficiency ( TH1D * h,
int i,
double lower,
double upper )
inlineprivate

Definition at line 635 of file Resplot.h.

635 {
636 StatVal v = GetGlobalEfficiency( lower, upper);
637 h->SetBinContent(i, v.value);
638 h->SetBinError(i, v.error);
639 }
int upper(int c)
StatVal GetGlobalEfficiency(double lower, double upper)
Definition Resplot.h:299

◆ AddMean()

void Resplot::Resplot::AddMean ( TH1D * h,
int i )
inlineprivate

Definition at line 647 of file Resplot.h.

647 {
648 StatVal v = get_mean();
649 h->SetBinContent(i, v.value);
650 h->SetBinError(i, v.error);
651 }
StatVal get_mean()
Definition Resplot.h:631

◆ AddResolution()

void Resplot::Resplot::AddResolution ( TH1D * h,
int i )
inlineprivate

Definition at line 641 of file Resplot.h.

641 {
642 StatVal v = get_sigma();
643 h->SetBinContent(i, v.value);
644 h->SetBinError(i, v.error);
645 }
StatVal get_sigma()
Definition Resplot.h:632

◆ Chi2() [1/2]

TH1D * Resplot::Resplot::Chi2 ( )
inline

Definition at line 359 of file Resplot.h.

359{ return m_chi2; }

◆ Chi2() [2/2]

const TH1D * Resplot::Resplot::Chi2 ( ) const
inline

Definition at line 360 of file Resplot.h.

360{ return m_chi2; }

◆ clear()

void Resplot::Resplot::clear ( )
inlineprivate

Definition at line 655 of file Resplot.h.

655 {
656 // std::cout << "clear " << m_slices.size() << std::endl;
657 m_finalised = false;
658 for ( int i=m_slices.size() ; i-- ; ) if ( m_slices[i] ) delete m_slices[i];
659 m_slices.clear();
660 // std::cout << "cleared" << std::endl;
661 }

◆ copy()

TH2D * Resplot::Resplot::copy ( const TH2 * h,
const std::string & s = "" )
static

copy a TH2

Definition at line 633 of file Resplot.cxx.

633 {
634
635 std::vector<double> xbins = getLimits( h->GetXaxis() );
636 std::vector<double> ybins = getLimits( h->GetYaxis() );
637
638 // std::cout << "copy:" << std::endl;
639 // std::cout << "x: " << xbins[0] << " - " << xbins.back() << std::endl;
640 // std::cout << "y: " << ybins[0] << " - " << ybins.back() << std::endl;
641
642 std::string name = s;
643 if ( s.empty() ) name = "duff";
644
645 TH2D* h2 = new TH2D( name.c_str(), "", xbins.size()-1, &xbins[0], ybins.size()-1, &ybins[0] );
646 h2->SetDirectory(0);
647
648 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
649 for ( int j=1 ; j<=h->GetNbinsY() ; j++ ) {
650 h2->SetBinContent(i,j, h->GetBinContent(i,j));
651 h2->SetBinError(i,j, h->GetBinError(i,j));
652 }
653 }
654
655 h2->SetEntries( h->GetEntries() );
656
657 return h2;
658}
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)

◆ deletehist() [1/2]

void Resplot::Resplot::deletehist ( TH1D * t)
inlineprivate

Definition at line 617 of file Resplot.h.

617{ if ( t ) delete t; }

◆ deletehist() [2/2]

void Resplot::Resplot::deletehist ( TH2D * t)
inlineprivate

Definition at line 621 of file Resplot.h.

621{ if ( t ) delete t; }

◆ delskip() [1/2]

void Resplot::Resplot::delskip ( TH1D * t)
inlineprivate

Definition at line 616 of file Resplot.h.

616{ if ( t ) { t->SetDirectory(0); delete t; } }

◆ delskip() [2/2]

void Resplot::Resplot::delskip ( TH2D * t)
inlineprivate

Definition at line 620 of file Resplot.h.

620{ if ( t ) { t->SetDirectory(0); delete t; } }

◆ Dir()

TDirectory * Resplot::Resplot::Dir ( )
inline

Definition at line 488 of file Resplot.h.

488{ return m_dir; }

◆ DWrite()

Int_t Resplot::Resplot::DWrite ( TDirectory * g = 0) const

boooo, need to use the stupid Int_t class because I foolishly gave this function the same name as TObject::Write

Definition at line 376 of file Resplot.cxx.

376 {
377
378 // std::cout << "Resplot::Write() Name " << Name() << "; " << gDirectory->GetName();
379
380 TDirectory* cwd = gDirectory;
381 if ( g ) g->cd();
382 Directory d(Name());
383 d.push();
384
385 // std::cout << "/" << gDirectory->GetName() << std::endl;
386
387 // TH2D::Write();
388 m_h2d->Write();
389 m_h1d->Write();
390 m_mean->Write();
391 m_sigma->Write();
392 m_chi2->Write();
393 m_Nentries->Write();
394 // std::cout << "Resplot::Write() Name() " << Name() << " " << m_slices.size() << std::endl;
395 gDirectory->mkdir("slices")->cd();
396 for ( unsigned i=0 ; i<m_slices.size() ; i++ ) m_slices[i]->Write();
397 d.pop();
398 cwd->cd();
399
400 return 0;
401}
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:496
const std::string & Name() const
Definition Resplot.h:348
std::string cwd
Definition listroot.cxx:38

◆ Fill()

int Resplot::Resplot::Fill ( double x,
double y,
double w = 1 )
inline

Definition at line 285 of file Resplot.h.

285 {
286 // m_h2d->Fill(x, y, w);
287 // TH2D::Fill(x, y, w);
288 m_h2d->Fill(x, y, w);
289 m_h1d->Fill(y, w);
290 return 0;
291 }
#define y
#define x

◆ Finalise() [1/2]

int Resplot::Resplot::Finalise ( double a = -999,
double b = -999,
TF1 *(* func )(TH1D *s, double a, double b) = FitGaussian )

Definition at line 425 of file Resplot.cxx.

425 {
426
427 // gDirectory->pwd();
428 // std::cout << "Resplot::Finalise() Name " << Name() << "\tm_n_primary " << m_n_primary << std::endl;
429
430 // gStyle->SetOptFit(1111);
431 // gStyle->SetOptStat(2211);
432
433 if ( m_finalised ) {
434 std::cerr << "Resplot::Finalise() " << m_name << " already called" << std::endl;
435 return -1;
436 }
437
438 // std::cout << "Resplot::Finalise() " << m_name << std::endl;
439
440 clear();
441
442 m_mean->SetStats(false);
443 m_sigma->SetStats(false);
444
445#if 1
446
447 std::vector<double> ylimits = getLimits( m_h2d->GetYaxis() );
448
449 for ( int i=1 ; i<=m_n_primary ; i++ ) {
450
451 if ( i%1000==0 ) std::cout << "slice " << i << " of " << m_n_primary << std::endl;
452
453 // std::string projname = tagname(m_name,i).c_str();
454 double pllim = m_mean->GetBinLowEdge(i);
455 double pulim = m_mean->GetBinLowEdge(i+1);
456
457 // std::cout << "Finalise " << i << " : " << pllim << " - " << pulim << std::endl;
458
459 std::string projname;
460 if ( m_xaxis=="" ) projname = "[ " + number(pllim) + " - " + number(pulim) + " ]";
461 else projname = "[ " + number(pllim) + " < " + m_xaxis + " < " + number(pulim) + " ]";
462
463 TH1D* s;
464 if ( !m_finalised ) {
465 // s = m_h2d->ProjectionY(tagname("slice",i), i, i, "e");
466
467 s = projectionY( m_h2d, i, ylimits, tagname("slice", i) );
468
469 // std::cout << i << " fitnull " << getWeights( s ) << std::endl;
470
471 if ( !m_uniform ) binwidth(s);
472 s->SetTitle(projname.c_str());
473 if ( m_yaxis!="" ) s->SetXTitle(m_yaxis.c_str());
474 }
475 else s = (TH1D*)gDirectory->Get(tagname(m_name,i));
476 skip(s);
477
478 // ZeroErrors(s);
479
480 TF1* f1 = 0;
481
482
483 if ( !s_nofit ) f1 = func(s, a, b);
484
485 // std::cout << "nofit " << s_nofit << "\tf1 " << f1 << std::endl;
486
487
488 // unZeroErrors(s);
489
490
491 if ( f1!=0 ) {
492
493 f1->SetLineWidth(1);
494 f1->SetNpx(5000);
495 m_fitname = f1->GetName();
496
497 // double N = NCounter(s);
498 double N = s->GetEffectiveEntries();
499
500 if ( N!=0 ) {
501 m_Nentries->SetBinContent(i,1/sqrt(N));
502 m_Nentries->SetBinError(i,0);
503 }
504 else {
505 m_Nentries->SetBinContent(i,0);
506 m_Nentries->SetBinError(i,0);
507 }
508
509 m_mean->SetBinContent(i, f1->GetParameter(1) );
510 m_mean->SetBinError(i, f1->GetParError(1) );
511
512 m_sigma->SetBinContent(i, std::fabs(f1->GetParameter(2)) );
513 m_sigma->SetBinError(i, f1->GetParError(2) );
514
515 int Ndof = f1->GetNDF();
516 if ( Ndof ) m_chi2->SetBinContent( i, std::fabs(f1->GetChisquare())/Ndof );
517 m_chi2->SetBinError(i, 0 );
518 delete f1;
519 }
520 else {
521 m_Nentries->SetBinContent(i,0);
522 m_mean->SetBinContent(i,0);
523 m_mean->SetBinError(i,0);
524 m_sigma->SetBinContent(i,0);
525 m_sigma->SetBinError(i,0);
526 m_chi2->SetBinContent(i,0);
527 m_chi2->SetBinError(i,0);
528 }
529
530 // std::cout << "Resplot::Finalise() slice " << s->GetName() << std::endl;
531
532 m_slices.push_back(s);
533 }
534
535
536#endif
537
538
539 m_chi2->SetMinimum(1e-5);
540
541 // get the overall resolution and offset
542
543 if ( !m_uniform ) binwidth(m_h1d);
544
545 TF1* f2 = 0;
546
547 if ( !s_nofit ) {
549 f2 = func(m_h1d, a, b);
551 }
552
553 if ( f2!=0 ) {
554
555 // std::cout << " fit = " << f2 << std::endl;
556 f2->SetLineWidth(1);
557 f2->SetNpx(5000);
558
559 m_g_mean = StatVal( f2->GetParameter(1), f2->GetParError(1) );
560 m_g_sigma = StatVal( f2->GetParameter(2), f2->GetParError(2) );
561
562 // std::cout << gDirectory->GetName() << "\tgmean " << m_g_mean << "\tgsigma " << g_sigma << std::endl;
563
564 std::string mname = std::string(f2->GetParName(1));
565 std::string sname = std::string(f2->GetParName(2));
566
567 // if ( mname!=std::string("") ) { m_mean->SetName(mname.c_str()); m_mean->SetTitle(mname.c_str()); }
568 // if ( sname!=std::string("") ) { m_sigma->SetName(sname.c_str()); m_sigma->SetTitle(sname.c_str()); }
569 if ( mname!=std::string("") ) { m_mean->SetTitle(mname.c_str()); }
570 if ( sname!=std::string("") ) { m_sigma->SetTitle(sname.c_str()); }
571
572 delete f2;
573 }
574 else {
575 if ( !s_nofit ) std::cerr << "\tnull overall fit Resplot:" << m_name << std::endl;
576 m_g_mean = StatVal(0,0);
577 m_g_sigma = StatVal(0,0);
578 }
579
580
581 // if ( AddDirectoryStatus() ) SetDirectory(gDirectory);
582
583 m_finalised = true;
584
585
586#if 0
587 if ( s_ErrorSet!=OK ) {
588 if ( s_ErrorSet == HISTOWIDTH ) {
589 std::cerr << __FUNCTION__ << " for " << m_name
590 << " :\tdistribution wider than histogram width " << std::endl;
591 }
592 if ( s_ErrorSet == BINWIDTH ) {
593 std::cerr << __FUNCTION__ << " for " << m_name
594 << " :\tbins too wide: cannot calculate rms95 " << std::endl;
595 }
596 }
597#endif
598
599 return 0;
600}
StatVal m_g_sigma
Definition Resplot.h:680
StatVal m_g_mean
Definition Resplot.h:679
bool binwidth
Definition listroot.cxx:58
constexpr std::size_t N
bool s_nofit
Definition Resplot.cxx:43
void unZeroErrors(TH1D *h)
Definition Resplot.cxx:75
void ZeroErrors(TH1D *h)
Definition Resplot.cxx:69
std::string number(const double &x)
Definition Resplot.cxx:410
str tagname
Definition defineDB.py:18

◆ Finalise() [2/2]

int Resplot::Resplot::Finalise ( TF1 *(* func )(TH1D *s, double a, double b),
double a = -999,
double b = -999 )
inline

Definition at line 473 of file Resplot.h.

473 {
474 return Finalise( a, b, func);
475 }
int Finalise(double a=-999, double b=-999, TF1 *(*func)(TH1D *s, double a, double b)=FitGaussian)
Definition Resplot.cxx:425

◆ finalised()

bool Resplot::Resplot::finalised ( ) const
inline

Definition at line 374 of file Resplot.h.

374{ return m_finalised; }

◆ findbins()

std::vector< double > Resplot::Resplot::findbins ( const TH1 * h,
double epsilon )
static

Definition at line 662 of file Resplot.cxx.

662 {
663
664 // std::cout << "findbins" << std::endl;
665
666 // if ( epsilon==0 ) return 0;
667
668 std::vector<double> xbins;
669
670 // hy->SetDirectory(0);
671 // hx->SetDirectory(0);
672
673 // double inveps2 = 1/(epsilon*epsilon);
674
675 double N = 0;
676
677 bool newbin = true;
678
679 // std::cout << "combining bins " << std::endl;
680
681 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
682
683 N += h->GetBinContent(i);
684
685 if ( xbins.size()==0 ) {
686 if ( N==0 ) continue;
687 else xbins.push_back( h->GetBinLowEdge(i) );
688 }
689
690 if ( newbin ) xbins.push_back( h->GetBinLowEdge(i+1) );
691 else xbins.back() = h->GetBinLowEdge(i+1);
692
693 newbin = false;
694
695 //if ( xbins.size()>0 ) std::cout << i << "\tN " << N << " " << " (" << inveps2 << ")" << "\t" << xbins.back() << std::endl;
696
697 if ( N >= inveps2 ) {
698 newbin = true;
699 N = 0;
700 }
701 }
702
703 // std::cout << "finishsed " << xbins.size() << std::endl;
704
705 // std::cout << "combine" << std::endl;
706 // std::cout << "x bins " << h->GetNbinsX() << std::endl;
707
708 //std::cout << "x: " << xbins.size() << " " << xbins[0] << " - " << xbins.back() << std::endl;
709
710 return xbins;
711}

◆ Fit()

int Resplot::Resplot::Fit ( TF1 *(* func )(TH1D *s, double a, double b))
inline

Definition at line 477 of file Resplot.h.

477 {
478 if ( m_finalised ) return -1;
479 return Finalise( func );
480 }

◆ FitName()

const std::string & Resplot::Resplot::FitName ( ) const
inline

Definition at line 382 of file Resplot.h.

382{ return m_fitname; }

◆ get_mean()

StatVal Resplot::Resplot::get_mean ( )
inlineprivate

Definition at line 631 of file Resplot.h.

631{ return m_g_mean; }

◆ get_sigma()

StatVal Resplot::Resplot::get_sigma ( )
inlineprivate

Definition at line 632 of file Resplot.h.

632{ return m_g_sigma; }

◆ getbins()

std::vector< double > Resplot::Resplot::getbins ( const TH1 * h)
static

Definition at line 744 of file Resplot.cxx.

744 {
745 std::vector<double> bins(h->GetNbinsX()+1);
746 for ( int i=0 ; i<h->GetNbinsX()+1 ; i++ ) bins[i] = h->GetBinLowEdge(i+1);
747 return bins;
748}
static const std::vector< std::string > bins

◆ GetEfficiencies() [1/2]

TH1D * Resplot::Resplot::GetEfficiencies ( const std::string & hname,
double lower,
double upper )

Definition at line 781 of file Resplot.cxx.

781 {
782 // TDirectory* cwd = cd();
783
784 // push();
785
786 TH1D* e = (TH1D*) m_mean->Clone();
787 e->SetName(hname.c_str()); e->SetMarkerStyle(20);
788 if ( m_xaxis!="" ) e->SetXTitle(m_xaxis.c_str());
789
790 std::vector<double> ylimits = getLimits( m_h2d->GetYaxis() );
791
792 for ( int i=1 ; i<=m_n_primary ; i++ ) {
793 // TH1D* s = m_h2d->ProjectionY(tagname(hname,i), i, i, "e");
794 TH1D* s = projectionY( m_h2d, i, ylimits, tagname(hname, i) );
795 StatVal v = GetEfficiency(s, lower, upper);
796 e->SetBinContent(i, v.value);
797 e->SetBinError(i, v.error);
798 delete s;
799 }
800
801 // cwd->cd();
802
803 // pop();
804
805 return e;
806}
StatVal GetEfficiency(TH1D *h, double lower, double upper)
Definition Resplot.cxx:755

◆ GetEfficiencies() [2/2]

TH1D * Resplot::Resplot::GetEfficiencies ( const std::string & hname,
double Nsigma )

Definition at line 814 of file Resplot.cxx.

814 {
815 // TDirectory* cwd = cd();
816 // push();
817
818 // check that the fits have been done for this
819 // plot
820 if ( !m_finalised ) Finalise();
821
822 TH1D* e = (TH1D*) m_mean->Clone();
823 e->SetName(hname.c_str()); e->SetMarkerStyle(20);
824 if ( m_xaxis!="" ) e->SetXTitle(m_xaxis.c_str());
825
826 std::vector<double> ylimits = getLimits( m_h2d->GetYaxis() );
827
828 for ( int i=1 ; i<=m_n_primary ; i++ ) {
829
830 double mean = m_mean->GetBinContent(i);
831 double sigma = m_sigma->GetBinContent(i);
832
833 // TH1D* s = m_h2d->ProjectionY(tagname(hname,i), i, i, "e");
834 TH1D* s = projectionY( m_h2d, i, ylimits, tagname(hname, i) );
835 StatVal v = GetEfficiency(s, mean-Nsigma*sigma, mean+Nsigma*sigma);
836 e->SetBinContent(i, v.value);
837 e->SetBinError(i, v.error);
838 delete s;
839 }
840
841 // cwd->cd();
842
843 // pop();
844
845 return e;
846}
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")

◆ GetEfficiency()

StatVal Resplot::Resplot::GetEfficiency ( TH1D * h,
double lower,
double upper )

Definition at line 755 of file Resplot.cxx.

755 {
756 double total = 0;
757 double good = 0;
758 StatVal v;
759
760 for (int i=0 ; i<=h->GetNbinsX()+1 ; i++ ) {
761 total += h->GetBinContent(i);
762 }
763 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
764 double x = h->GetBinCenter(i);
765 if ( x>lower && x<= upper ) {
766 good += h->GetBinContent(i);
767 }
768 }
769 if ( total>0 ) {
770 v.value = good/total;
771 v.error = sqrt(v.value*(1-v.value)/total);
772 }
773
774 return v;
775}

◆ GetGlobalEfficiency()

StatVal Resplot::Resplot::GetGlobalEfficiency ( double lower,
double upper )
inline

Definition at line 299 of file Resplot.h.

299 {
300 return GetEfficiency(m_h1d, lower, upper);
301 }

◆ getLimits()

std::vector< double > Resplot::Resplot::getLimits ( const TAxis * axis)
inlinestatic

projection utilities ... NB: In athena, for some reason the destuctors for histograms created using TH2D::ProjectX/Y take ~ 13 ms to be deleted, around 300 times slower than a normal TH1 delete, so we implement our own projectionX/Y

Definition at line 398 of file Resplot.h.

398 {
399 std::vector<double> limits( axis->GetNbins()+1, 0 );
400 for ( size_t i=axis->GetNbins()+1 ; i-- ; ) limits[i] = axis->GetBinLowEdge(i+1);
401 return limits;
402 }

◆ GetPrimaryCentres()

std::vector< double > Resplot::Resplot::GetPrimaryCentres ( ) const
inline

Definition at line 340 of file Resplot.h.

340 {
341 std::vector<double> d;
342 for ( int i=1 ; i<=m_mean->GetNbinsX() ; i++ ) d.push_back(m_mean->GetBinCenter(i));
343 return d;
344 }

◆ GetPrimaryLimits()

std::vector< double > Resplot::Resplot::GetPrimaryLimits ( ) const
inline

Definition at line 333 of file Resplot.h.

333 {
334 std::vector<double> d;
335 for ( int i=1 ; i<=m_mean->GetNbinsX()+1 ; i++ ) d.push_back(m_mean->GetBinLowEdge(i));
336 return d;
337 }

◆ getxLimits()

std::vector< double > Resplot::Resplot::getxLimits ( TH2 * h)
inlinestatic

Definition at line 404 of file Resplot.h.

404{ return getLimits( h->GetXaxis() ); }

◆ getyLimits()

std::vector< double > Resplot::Resplot::getyLimits ( TH2 * h)
inlinestatic

Definition at line 406 of file Resplot.h.

406{ return getLimits( h->GetYaxis() ); }

◆ H1D() [1/2]

TH1D * Resplot::Resplot::H1D ( )
inline

Definition at line 363 of file Resplot.h.

363{ return m_h1d; }

◆ H1D() [2/2]

const TH1D * Resplot::Resplot::H1D ( ) const
inline

Definition at line 364 of file Resplot.h.

364{ return m_h1d; }

◆ H2D() [1/2]

TH2D * Resplot::Resplot::H2D ( )
inline

Definition at line 367 of file Resplot.h.

367{ return m_h2d; }

◆ H2D() [2/2]

const TH2D * Resplot::Resplot::H2D ( ) const
inline

Definition at line 368 of file Resplot.h.

368{ return m_h2d; }

◆ Initialise() [1/5]

void Resplot::Resplot::Initialise ( const std::string & name,
const std::vector< double > & a,
const std::vector< double > & b )

Definition at line 275 of file Resplot.cxx.

277 {
278 Initialise(name, a.size()-1, &a[0], b.size()-1, &b[0] );
279}

◆ Initialise() [2/5]

void Resplot::Resplot::Initialise ( const std::string & name,
const std::vector< double > & a,
int n2,
double a2,
double b2 )

Definition at line 268 of file Resplot.cxx.

270 {
271 Initialise(name, a.size()-1, &a[0], n2, a2, b2);
272}

◆ Initialise() [3/5]

void Resplot::Resplot::Initialise ( const std::string & name,
int n1,
const double * a1,
int n2,
const double * a2 )

Definition at line 328 of file Resplot.cxx.

330 {
331 SetPrimary(n1, a1);
332 SetSecondary(n2, a2[0], a2[n2+1]);
333
334 m_Set = true;
335
336 m_name = name;
337 const std::string name_2d = "2d";
338 const std::string name_1d = "1d";
339
340 // std::cout << "Resplot::Initialise() Name " << Name() << std::endl;
341
342 // TH2D::SetDirectory(0);
343
344 m_h2d = new TH2D( name_2d.c_str(), name_2d.c_str(), n1, a1, n2, a2 );
345 m_h1d = new TH1D( name_1d.c_str(), name_1d.c_str(), n2, a2 );
346 m_h1d->Sumw2();
347 skip(m_h2d);
348 skip(m_h1d);
349
350 const std::string name_mean = "mean";
351 const std::string name_sigma = "sigma";
352 const std::string name_chi2 = "chi2";
353
354 m_mean = new TH1D( name_mean.c_str(), name_mean.c_str(), n1, a1 );
355 m_sigma = new TH1D( name_sigma.c_str(), name_sigma.c_str(), n1, a1 );
356 m_chi2 = new TH1D( name_chi2.c_str(), name_chi2.c_str(), n1, a1);
357
358 skip(m_mean);
359 skip(m_sigma);
360 skip(m_chi2);
361
362 // const std::string name_entries = "significance";
363 const std::string name_entries = "fractional uncertainty";
364
365 m_Nentries = new TH1D( name_entries.c_str(), name_entries.c_str(), n1, a1 );
367
368}
void SetSecondary(int n, double a, double b)
Definition Resplot.h:626
void SetPrimary(int n, const double *)
Definition Resplot.h:624

◆ Initialise() [4/5]

void Resplot::Resplot::Initialise ( const std::string & name,
int n1,
const double * a1,
int n2,
double a2,
double b2 )

Definition at line 283 of file Resplot.cxx.

285 {
286 SetPrimary(n1, a1);
287 SetSecondary(n2, a2, b2);
288
289 m_Set = true;
290
291 m_name = name;
292 const std::string name_2d = "2d";
293 const std::string name_1d = "1d";
294
295 // std::cout << "Resplot::Initialise() Name " << Name() << std::endl;
296
297 // TH2D::SetDirectory(0);
298
299 m_h2d = new TH2D( name_2d.c_str(), name_2d.c_str(), n1, a1, n2, a2, b2);
300 m_h1d = new TH1D( name_1d.c_str(), name_1d.c_str(), n2, a2, b2);
301 m_h1d->Sumw2();
302 skip(m_h2d);
303 skip(m_h1d);
304
305 const std::string name_mean = "mean";
306 const std::string name_sigma = "sigma";
307 const std::string name_chi2 = "chi2";
308
309 m_mean = new TH1D( name_mean.c_str(), name_mean.c_str(), n1, a1 );
310 m_sigma = new TH1D( name_sigma.c_str(), name_sigma.c_str(), n1, a1 );
311 m_chi2 = new TH1D( name_chi2.c_str(), name_chi2.c_str(), n1, a1);
312
313 skip(m_mean);
314 skip(m_sigma);
315 skip(m_chi2);
316
317 // const std::string name_entries = "significance";
318 const std::string name_entries = "fractional uncertainty";
319
320 m_Nentries = new TH1D( name_entries.c_str(), name_entries.c_str(), n1, a1 );
322
323}

◆ Initialise() [5/5]

void Resplot::Resplot::Initialise ( const std::string & name,
int n1,
double a1,
double b1,
int n2,
double a2,
double b2 )

Definition at line 226 of file Resplot.cxx.

228 {
229
230 SetPrimary(n1, a1, b1);
231 SetSecondary(n2, a2, b2);
232
233 m_Set = true;
234 // TH2D::SetDirectory(0);
235
236 m_name = name;
237 const std::string name_2d = "2d";
238 const std::string name_1d = "1d";
239
240 // std::cout << "Resplot::Initialise() Name " << Name() << std::endl;
241
242 m_h2d = new TH2D( name_2d.c_str(), name_2d.c_str(), n1, a1, b1, n2, a2, b2);
243 m_h1d = new TH1D( name_1d.c_str(), name_1d.c_str(), n2, a2, b2);
244 m_h1d->Sumw2();
245 skip(m_h2d);
246 skip(m_h1d);
247
248 const std::string name_mean = "mean";
249 const std::string name_sigma = "sigma";
250 const std::string name_chi2 = "chi2";
251 // const std::string name_entries = "significance";
252 const std::string name_entries = "fractional uncertainty";
253
254 m_Nentries = new TH1D( name_entries.c_str(), name_entries.c_str(), n1, a1, b1 );
256
257 m_mean = new TH1D( name_mean.c_str(), name_mean.c_str(), n1, a1, b1 );
258 m_sigma = new TH1D( name_sigma.c_str(), name_sigma.c_str(), n1, a1, b1 );
259 m_chi2 = new TH1D( name_chi2.c_str(), name_chi2.c_str(), n1, a1, b1 );
260 skip(m_mean);
261 skip(m_sigma);
262 skip(m_chi2);
263
264}

◆ Integrate()

void Resplot::Resplot::Integrate ( )
inline

integrate all the slices and refit the mean etc. not yet ...

Definition at line 588 of file Resplot.h.

588 {
589 if ( !m_finalised ) return;
590
593 }

◆ MakeSlices()

void Resplot::Resplot::MakeSlices ( )
inlineprivate

Definition at line 610 of file Resplot.h.

610{ }

◆ Mean() [1/2]

TH1D * Resplot::Resplot::Mean ( )
inline

Definition at line 352 of file Resplot.h.

352{ return m_mean; }

◆ Mean() [2/2]

const TH1D * Resplot::Resplot::Mean ( ) const
inline

Definition at line 353 of file Resplot.h.

353{ return m_mean; }

◆ Name() [1/2]

const std::string & Resplot::Resplot::Name ( ) const
inline

Definition at line 348 of file Resplot.h.

348{ return m_name; }

◆ Name() [2/2]

const std::string & Resplot::Resplot::Name ( const std::string & s)
inline

Definition at line 346 of file Resplot.h.

346{ return m_name=s; }

◆ name()

const std::string & Resplot::Resplot::name ( ) const
inline

Definition at line 349 of file Resplot.h.

349{ return m_name; }

◆ operator*()

Resplot Resplot::Resplot::operator* ( double d) const
inline

Definition at line 577 of file Resplot.h.

577 {
578 Resplot r(*this);
579 return (r*=d);
580 }

◆ operator*=()

Resplot & Resplot::Resplot::operator*= ( double d)
inline

Definition at line 542 of file Resplot.h.

542 {
543
544 // std::cout << "Resplot::operator*= " << Name() << " " << m_finalised << " " << m_slices.size() << std::endl;
545
546 clear();
547
548 // std::cout << "Resplot::operator*= " << Name() << " " << m_finalised << " " << m_slices.size() << std::endl;
549 // std::cout << "Resplot::operator*= " << Name() << "\tH2D " << H2D() << std::endl;
550
551 // H2D()->DrawCopy();
552
553 // std::cout << "Resplot::operator*= " << Name() << "\tDraw " << std::endl;
554
555 for ( int i=0 ; i<=H2D()->GetNbinsX()+1 ; i++ ) {
556 for ( int j=0 ; j<=H2D()->GetNbinsY()+1 ; j++ ) {
557 H2D()->SetBinContent( i, j, H2D()->GetBinContent(i,j)*d);
558 H2D()->SetBinError( i, j, H2D()->GetBinError(i,j)*d);
559 }
560 }
561
562
563 // std::cout << "Resplot::operator*= " << Name() << "\tH1D " << H1D() << std::endl;
564
565 for ( int i=0 ; i<=H1D()->GetNbinsX()+1 ; i++ ) {
566 H1D()->SetBinContent( i, H1D()->GetBinContent(i)*d );
567 H1D()->SetBinError( i, H1D()->GetBinError(i)*d );
568 }
569
570 m_finalised = false;
571
572 // std::cout << "Resplot::operator*= done" << std::endl;
573
574 return *this;
575 }
TH1D * H1D()
Definition Resplot.h:363
TH2D * H2D()
Definition Resplot.h:367

◆ operator+()

Resplot Resplot::Resplot::operator+ ( const Resplot & r) const
inline

Definition at line 582 of file Resplot.h.

582 {
583 Resplot r0(*this);
584 return (r0+=r);
585 }
const double r0
electron radius{cm}

◆ operator+=()

Resplot & Resplot::Resplot::operator+= ( const Resplot & r)
inline

operators

Definition at line 511 of file Resplot.h.

511 {
512
513 clear();
514
515 // std::cout << "Resplot::operator+= " << Name() << std::endl;
516
517 if ( r.H1D()->GetNbinsX()!=H1D()->GetNbinsX()) throw ResException("histogram limits do not match");
518 if ( r.H2D()->GetNbinsX()!=H2D()->GetNbinsX()) throw ResException("histogram limits do not match");
519 if ( r.H2D()->GetNbinsY()!=H2D()->GetNbinsY()) throw ResException("histogram limits do not match");
520
521 for ( int i=0 ; i<=r.H2D()->GetNbinsX()+1 ; i++ ) {
522 for ( int j=0 ; j<=r.H2D()->GetNbinsY()+1 ; j++ ) {
523 H2D()->SetBinContent( i, j, H2D()->GetBinContent(i,j) + r.H2D()->GetBinContent(i,j) );
524 H2D()->SetBinError( i, j, std::sqrt(H2D()->GetBinError(i,j)*H2D()->GetBinError(i,j) + r.H2D()->GetBinError(i,j)*r.H2D()->GetBinError(i,j) ) );
525 }
526 }
527
528 for ( int i=0 ; i<=r.H1D()->GetNbinsX()+1 ; i++ ) {
529 H1D()->SetBinContent( i, H1D()->GetBinContent(i) + r.H1D()->GetBinContent(i) );
530 H1D()->SetBinError( i, std::sqrt(H1D()->GetBinError(i)*H1D()->GetBinError(i) + r.H1D()->GetBinError(i)*r.H1D()->GetBinError(i) ) );
531 }
532
533 m_finalised = false;
534
535 // std::cout << "Resplot::operator+= done" << std::endl;
536
537 return *this;
538 }

◆ operator=()

Resplot & Resplot::Resplot::operator= ( const Resplot & )
delete

◆ projectionX() [1/2]

TH1D * Resplot::Resplot::projectionX ( TH2 * h2d,
int row,
const std::vector< double > & xlimits,
const std::string & tagname )
inlinestatic

Definition at line 435 of file Resplot.h.

435 {
436 TH1D* h = new TH1D( tagname.c_str(), "", xlimits.size()-1, &xlimits[0] ); h->SetDirectory(0);
437 double entries = 0;
438 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
439 double v = h2d->GetBinContent( i, row );
440 h->SetBinContent( i, v );
441 entries += v;
442 }
443 h->SetEntries(entries);
444 return h;
445 }
double entries
Definition listroot.cxx:49

◆ projectionX() [2/2]

TH1D * Resplot::Resplot::projectionX ( TH2 * h2d,
int row0,
int row1,
const std::vector< double > & xlimits,
const std::string & tagname )
inlinestatic

Definition at line 447 of file Resplot.h.

447 {
448 TH1D* h = new TH1D( tagname.c_str(), "", xlimits.size()-1, &xlimits[0] ); h->SetDirectory(0);
449 double entries = 0;
450 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
451 double sum = 0;
452 for ( int row=row0 ; row<=row1 ; row++ ) sum += h2d->GetBinContent(i, row);
453 h->SetBinContent( i, sum );
454 entries += sum;
455 }
456 h->SetEntries(entries);
457 return h;
458 }
static double sum(TH1 *h)
Definition Resplot.h:460
row
Appending html table to final .html summary file.

◆ projectionY() [1/2]

TH1D * Resplot::Resplot::projectionY ( TH2 * h2d,
int col,
const std::vector< double > & ylimits,
const std::string & tagname )
inlinestatic

actual local projections ...

Definition at line 410 of file Resplot.h.

410 {
411 TH1D* h = new TH1D( tagname.c_str(), "", ylimits.size()-1, &ylimits[0] ); h->SetDirectory(0);
412 double entries = 0;
413 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
414 double v = h2d->GetBinContent(col, i);
415 h->SetBinContent( i, v );
416 entries += v;
417 }
418 h->SetEntries(entries);
419 return h;
420 }

◆ projectionY() [2/2]

TH1D * Resplot::Resplot::projectionY ( TH2 * h2d,
int col0,
int col1,
const std::vector< double > & ylimits,
const std::string & tagname )
inlinestatic

Definition at line 422 of file Resplot.h.

422 {
423 TH1D* h = new TH1D( tagname.c_str(), "", ylimits.size()-1, &ylimits[0] ); h->SetDirectory(0);
424 double entries = 0;
425 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
426 double sum = 0;
427 for ( int col=col0 ; col<=col1 ; col++ ) sum += h2d->GetBinContent(col, i);
428 h->SetBinContent( i, sum );
429 entries += sum;
430 }
431 h->SetEntries(entries);
432 return h;
433 }

◆ rebin()

TH1D * Resplot::Resplot::rebin ( const TH1 * h,
const std::vector< double > & bins )
static

Definition at line 714 of file Resplot.cxx.

714 {
715
716 if ( xbins.size()==0 ) {
717 std::cerr << "Resplot::combine() bad limits for histogram: N xbins: " << xbins.size() << std::endl;
718 return 0;
719 }
720
721 TH1D* h2 = new TH1D("duff","duff", xbins.size()-1, &xbins[0] );
722 h2->SetDirectory(0);
723
724 unsigned xbin = 0;
725 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
726
727 while ( h->GetBinCenter(i)>xbins[xbin+1] && xbin<(xbins.size()-1) ) xbin++;
728
729 if ( h->GetBinCenter(i)>=xbins[xbin] && h->GetBinCenter(i)<xbins[xbin+1] ) {
730 double n = h->GetBinContent(i);
731 double nh = h2->GetBinContent(xbin+1);
732 h2->SetBinContent(xbin+1, nh+n);
733 }
734 }
735
736 return h2;
737}

◆ Refit()

int Resplot::Resplot::Refit ( TF1 *(* func )(TH1D *s, double a, double b))
inline

Definition at line 482 of file Resplot.h.

482 {
483 clear();
484 return Finalise( func );
485 }

◆ rotate()

TH2D * Resplot::Resplot::rotate ( const TH2 * h,
const std::string & s = "" )
static

flip the x and y axes

rotate a TH2

Definition at line 604 of file Resplot.cxx.

604 {
605
606 std::vector<double> xbins = getLimits( h->GetXaxis() );
607 std::vector<double> ybins = getLimits( h->GetYaxis() );
608
609 // std::cout << "rotate:" << std::endl;
610 // std::cout << "x: " << xbins[0] << " - " << xbins.back() << std::endl;
611 // std::cout << "y: " << ybins[0] << " - " << ybins.back() << std::endl;
612
613 std::string name = s;
614 if ( s.empty() ) name = "duff";
615
616 TH2D* h2 = new TH2D( name.c_str(),"", ybins.size()-1, &ybins[0], xbins.size()-1, &xbins[0] );
617 h2->SetDirectory(0);
618
619 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
620 for ( int j=1 ; j<=h->GetNbinsY() ; j++ ) {
621 h2->SetBinContent(j,i, h->GetBinContent(i,j));
622 h2->SetBinError(j,i, h->GetBinError(i,j));
623 }
624 }
625
626 h2->SetEntries( h->GetEntries() );
627
628 return h2;
629}

◆ SetDirectory()

void Resplot::Resplot::SetDirectory ( TDirectory * = 0)
inline

Definition at line 503 of file Resplot.h.

503{ }

◆ SetPrimary() [1/2]

void Resplot::Resplot::SetPrimary ( int n,
const double *  )
inlineprivate

Definition at line 624 of file Resplot.h.

624{ m_n_primary=n; }

◆ SetPrimary() [2/2]

void Resplot::Resplot::SetPrimary ( int n,
double ,
double  )
inlineprivate

Definition at line 625 of file Resplot.h.

625{ m_n_primary=n; } // a_primary=a; b_primary=b; }

◆ SetSecondary()

void Resplot::Resplot::SetSecondary ( int n,
double a,
double b )
inlineprivate

Definition at line 626 of file Resplot.h.

◆ setUniform()

void Resplot::Resplot::setUniform ( bool t = false)
inline

Definition at line 595 of file Resplot.h.

595{ m_uniform=t; }

◆ SetXAxis()

void Resplot::Resplot::SetXAxis ( const std::string & xaxis)
inline

Definition at line 315 of file Resplot.h.

315 {
316 m_xaxis = xaxis;
317 m_mean->SetXTitle(m_xaxis.c_str());
318 m_sigma->SetXTitle(m_xaxis.c_str());
319 m_chi2->SetXTitle(m_xaxis.c_str());
320 m_Nentries->SetXTitle(m_xaxis.c_str());
321 m_h2d->SetXTitle(m_xaxis.c_str());
322 m_h1d->SetXTitle(m_xaxis.c_str());
323 }

◆ SetYAxis()

void Resplot::Resplot::SetYAxis ( const std::string & yaxis)
inline

Definition at line 326 of file Resplot.h.

326 {
327 m_yaxis = yaxis;
328 m_h2d->SetXTitle(m_yaxis.c_str());
329 m_h1d->SetXTitle(m_yaxis.c_str());
330 }

◆ Sigma()

TH1D * Resplot::Resplot::Sigma ( )
inline

Definition at line 356 of file Resplot.h.

356{ return m_sigma; }

◆ skip() [1/2]

void Resplot::Resplot::skip ( TH1D * t)
inlineprivate

Definition at line 615 of file Resplot.h.

615{ if ( t ) t->SetDirectory(0); }

◆ skip() [2/2]

void Resplot::Resplot::skip ( TH2D * t)
inlineprivate

Definition at line 619 of file Resplot.h.

619{ if ( t ) t->SetDirectory(0); }

◆ Slices()

const std::vector< TH1D * > & Resplot::Resplot::Slices ( ) const
inline

Definition at line 377 of file Resplot.h.

377{ return m_slices; }

◆ sum()

double Resplot::Resplot::sum ( TH1 * h)
inlinestatic

Definition at line 460 of file Resplot.h.

460 {
461 double sum = 0;
462 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) sum += h->GetBinContent(i);
463 //std::cout << "sum: " << sum << std::endl;
464 return sum;
465 }

◆ Uncertainty() [1/2]

TH1D * Resplot::Resplot::Uncertainty ( )
inline

Definition at line 371 of file Resplot.h.

371{ return m_Nentries; }

◆ Uncertainty() [2/2]

const TH1D * Resplot::Resplot::Uncertainty ( ) const
inline

Definition at line 372 of file Resplot.h.

372{ return m_Nentries; }

◆ version()

const std::string & Resplot::Resplot::version ( )
inlinestatic

Definition at line 597 of file Resplot.h.

597{ return s_rversion; }
static const std::string s_rversion
Definition Resplot.h:665

◆ Write() [1/2]

Int_t Resplot::Resplot::Write ( const char * = 0,
Int_t = 0,
Int_t = 0 )
inline

Definition at line 497 of file Resplot.h.

497{ return DWrite(); }
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:376

◆ Write() [2/2]

Int_t Resplot::Resplot::Write ( const char * = 0,
Int_t = 0,
Int_t = 0 ) const
inline

Hooray, this stupidity is to overwride both the const and non-const TObject Write methods Fixme: should probably remove all of these so root can write out using the dictionary but I could never get that to work.

Definition at line 496 of file Resplot.h.

496{ return DWrite(); }

Member Data Documentation

◆ m_a_secondary

double Resplot::Resplot::m_a_secondary
private

Definition at line 687 of file Resplot.h.

◆ m_b_secondary

double Resplot::Resplot::m_b_secondary
private

Definition at line 687 of file Resplot.h.

◆ m_chi2

TH1D* Resplot::Resplot::m_chi2 = 0
private

Definition at line 674 of file Resplot.h.

◆ m_dir

TDirectory* Resplot::Resplot::m_dir = 0
private

Definition at line 682 of file Resplot.h.

◆ m_finalised

bool Resplot::Resplot::m_finalised
private

Definition at line 695 of file Resplot.h.

◆ m_fitname

std::string Resplot::Resplot::m_fitname
private

Definition at line 693 of file Resplot.h.

◆ m_g_mean

StatVal Resplot::Resplot::m_g_mean
private

Definition at line 679 of file Resplot.h.

◆ m_g_sigma

StatVal Resplot::Resplot::m_g_sigma
private

Definition at line 680 of file Resplot.h.

◆ m_h1d

TH1D* Resplot::Resplot::m_h1d = 0
private

Definition at line 677 of file Resplot.h.

◆ m_h2d

TH2D* Resplot::Resplot::m_h2d = 0
private

Definition at line 676 of file Resplot.h.

◆ m_mean

TH1D* Resplot::Resplot::m_mean = 0
private

Definition at line 672 of file Resplot.h.

◆ m_n_primary

int Resplot::Resplot::m_n_primary
private

Definition at line 684 of file Resplot.h.

◆ m_n_secondary

int Resplot::Resplot::m_n_secondary
private

Definition at line 686 of file Resplot.h.

◆ m_name

std::string Resplot::Resplot::m_name
private

Definition at line 669 of file Resplot.h.

◆ m_Nentries

TH1D* Resplot::Resplot::m_Nentries = 0
private

Definition at line 671 of file Resplot.h.

◆ m_Set

bool Resplot::Resplot::m_Set
private

Definition at line 667 of file Resplot.h.

◆ m_sigma

TH1D* Resplot::Resplot::m_sigma = 0
private

Definition at line 673 of file Resplot.h.

◆ m_slices

std::vector<TH1D*> Resplot::Resplot::m_slices
private

Definition at line 692 of file Resplot.h.

◆ m_uniform

bool Resplot::Resplot::m_uniform
private

Definition at line 698 of file Resplot.h.

◆ m_xaxis

std::string Resplot::Resplot::m_xaxis
private

Definition at line 689 of file Resplot.h.

◆ m_yaxis

std::string Resplot::Resplot::m_yaxis
private

Definition at line 690 of file Resplot.h.

◆ s_rversion

const std::string Resplot::Resplot::s_rversion = "resplot-v29"
staticprivate

Definition at line 665 of file Resplot.h.


The documentation for this class was generated from the following files: