ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitCommon/DataFormats/src/TH2DAsymErr.cc
Revision: 1.1
Committed: Mon Aug 10 16:04:51 2009 UTC (15 years, 8 months ago) by phedex
Content type: text/plain
Branch: MAIN
Log Message:
Add custom 2D histogram class that stores asymmetric statistical and systematic errors. Used for Fake Rate calculations.

File Contents

# User Rev Content
1 phedex 1.1 // $Id: $
2    
3     #include "MitCommon/DataFormats/interface/TH2DAsymErr.h"
4     #include <TList.h>
5     #include <iostream>
6    
7    
8     ClassImp(mithep::TH2DAsymErr)
9    
10     using namespace mithep;
11    
12     //--------------------------------------------------------------------------------------------------
13     TH2DAsymErr::TH2DAsymErr(const char *name, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup
14     ,Int_t nbinsy, Double_t ylow, Double_t yup) :
15     TH2D(name, title, nbinsx, xlow, xup , nbinsy, ylow, yup)
16     {
17     // Constructor.
18     fStatErrorLow = TArrayD(fNcells);
19     fStatErrorHigh = TArrayD(fNcells);
20     fSysErrorLow = TArrayD(fNcells);
21     fSysErrorHigh = TArrayD(fNcells);
22     }
23    
24     TH2DAsymErr::TH2DAsymErr(const TH2D &h2d) : TH2D(h2d)
25     {
26     // Constructor.
27     fStatErrorLow = TArrayD(fNcells);
28     fStatErrorHigh = TArrayD(fNcells);
29     fSysErrorLow = TArrayD(fNcells);
30     fSysErrorHigh = TArrayD(fNcells);
31     }
32    
33     //--------------------------------------------------------------------------------------------------
34     void TH2DAsymErr::SetBinContent(Int_t binx, Int_t biny, Double_t value,
35     Double_t statErrorLow, Double_t statErrorHigh,
36     Double_t sysErrorLow, Double_t sysErrorHigh)
37     {
38     // Fill histograms.
39    
40     Int_t bin;
41     fEntries++;
42     bin = biny*(fXaxis.GetNbins()+2) + binx;
43    
44     SetBinContent(bin,value);
45     if (fStatErrorLow.fN) fStatErrorLow.fArray[bin] = statErrorLow;
46     if (fStatErrorHigh.fN) fStatErrorHigh.fArray[bin] = statErrorHigh;
47     if (fSysErrorLow.fN) fSysErrorLow.fArray[bin] = sysErrorLow;
48     if (fSysErrorHigh.fN) fSysErrorHigh.fArray[bin] = sysErrorHigh;
49     }
50    
51     //--------------------------------------------------------------------------------------------------
52     void TH2DAsymErr::SetBinError(Int_t binx, Int_t biny,
53     Double_t statErrorLow, Double_t statErrorHigh,
54     Double_t sysErrorLow, Double_t sysErrorHigh)
55     {
56     // Fill histograms.
57    
58     Int_t bin;
59     fEntries++;
60     bin = biny*(fXaxis.GetNbins()+2) + binx;
61    
62     if (fStatErrorLow.fN) fStatErrorLow.fArray[bin] = statErrorLow;
63     if (fStatErrorHigh.fN) fStatErrorHigh.fArray[bin] = statErrorHigh;
64     if (fSysErrorLow.fN) fSysErrorLow.fArray[bin] = sysErrorLow;
65     if (fSysErrorHigh.fN) fSysErrorHigh.fArray[bin] = sysErrorHigh;
66     }
67    
68     //--------------------------------------------------------------------------------------------------
69     Double_t TH2DAsymErr::GetStatErrorLow(Double_t x, Double_t y)
70     {
71     // Fill histograms.
72     Int_t binx, biny, bin;
73    
74     binx = fXaxis.FindBin(x);
75     biny = fYaxis.FindBin(y);
76     bin = biny*(fXaxis.GetNbins()+2) + binx;
77     return fStatErrorLow.fArray[bin];
78     }
79    
80    
81     //--------------------------------------------------------------------------------------------------
82     Double_t TH2DAsymErr::GetStatErrorHigh(Double_t x, Double_t y)
83     {
84     // Fill histograms.
85     Int_t binx, biny, bin;
86     binx = fXaxis.FindBin(x);
87     biny = fYaxis.FindBin(y);
88     bin = biny*(fXaxis.GetNbins()+2) + binx;
89     return fStatErrorHigh.fArray[bin];
90     }
91    
92    
93     //--------------------------------------------------------------------------------------------------
94     Double_t TH2DAsymErr::GetSysErrorLow(Double_t x, Double_t y)
95     {
96     // Fill histograms.
97     Int_t binx, biny, bin;
98     binx = fXaxis.FindBin(x);
99     biny = fYaxis.FindBin(y);
100     bin = biny*(fXaxis.GetNbins()+2) + binx;
101     return fSysErrorLow.fArray[bin];
102     }
103    
104    
105     //--------------------------------------------------------------------------------------------------
106     Double_t TH2DAsymErr::GetSysErrorHigh(Double_t x, Double_t y)
107     {
108     // Fill histograms.
109     Int_t binx, biny, bin;
110     binx = fXaxis.FindBin(x);
111     biny = fYaxis.FindBin(y);
112     bin = biny*(fXaxis.GetNbins()+2) + binx;
113     return fSysErrorHigh.fArray[bin];
114     }