ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitCommon/DataFormats/src/TH2DAsymErr.cc
Revision: 1.3
Committed: Wed Oct 21 15:05:22 2009 UTC (15 years, 6 months ago) by sixie
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_013, Mit_013pre1, Mit_012i, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012
Changes since 1.2: +10 -2 lines
Log Message:
Compute bins ourselves instead of using FindBin(x,y)

File Contents

# Content
1 // $Id: TH2DAsymErr.cc,v 1.2 2009/08/11 09:02:24 loizides Exp $
2
3 #include "MitCommon/DataFormats/interface/TH2DAsymErr.h"
4 #include <TList.h>
5 #include <iostream>
6
7 ClassImp(mithep::TH2DAsymErr)
8
9 using namespace mithep;
10 using namespace std;
11
12 //--------------------------------------------------------------------------------------------------
13 TH2DAsymErr::TH2DAsymErr(const char *name, const char *title,
14 Int_t nbinsx, Double_t xlow, Double_t xup
15 ,Int_t nbinsy, Double_t ylow, Double_t yup) :
16 TH2D(name, title, nbinsx, xlow, xup , nbinsy, ylow, yup),
17 fStatErrorLow(fNcells),
18 fStatErrorHigh(fNcells),
19 fSysErrorLow(fNcells),
20 fSysErrorHigh(fNcells)
21 {
22 // Constructor.
23 }
24
25 TH2DAsymErr::TH2DAsymErr(const TH2D &h2d) :
26 TH2D(h2d),
27 fStatErrorLow(fNcells),
28 fStatErrorHigh(fNcells),
29 fSysErrorLow(fNcells),
30 fSysErrorHigh(fNcells)
31 {
32 // Constructor.
33 }
34
35 //--------------------------------------------------------------------------------------------------
36 Double_t TH2DAsymErr::GetError(Double_t x, Double_t y, EErrType t)
37 {
38 // Get error corresponding to x and y for given error type.
39
40 Int_t nx = fXaxis.GetNbins()+2;
41 Int_t binx = fXaxis.FindFixBin(x);
42 Int_t biny = fYaxis.FindFixBin(y);
43 Int_t bin = binx + nx*biny;
44
45 switch (t) {
46 case kStatErrLow:
47 return fStatErrorLow.fArray[bin];
48 break;
49 case kStatErrHigh:
50 return fStatErrorHigh.fArray[bin];
51 break;
52 case kSysErrLow:
53 return fSysErrorLow.fArray[bin];
54 break;
55 case kSysErrHigh:
56 return fSysErrorHigh.fArray[bin];
57 break;
58 }
59 return 0;
60 }
61
62 //--------------------------------------------------------------------------------------------------
63 void TH2DAsymErr::SetBinContent(Int_t binx, Int_t biny, Double_t value,
64 Double_t statErrorLow, Double_t statErrorHigh,
65 Double_t sysErrorLow, Double_t sysErrorHigh)
66 {
67 // Set bin content for given bin and value.
68
69 Int_t bin = GetBin(binx,biny);
70 SetBinContent(bin,value);
71
72 fStatErrorLow.fArray[bin] = statErrorLow;
73 fStatErrorHigh.fArray[bin] = statErrorHigh;
74 fSysErrorLow.fArray[bin] = sysErrorLow;
75 fSysErrorHigh.fArray[bin] = sysErrorHigh;
76 return;
77 }
78
79 //--------------------------------------------------------------------------------------------------
80 void TH2DAsymErr::SetBinError(Int_t binx, Int_t biny,
81 Double_t statErrorLow, Double_t statErrorHigh,
82 Double_t sysErrorLow, Double_t sysErrorHigh)
83 {
84 // Set bin error for asymetric errors.
85
86 Int_t bin = GetBin(binx,biny);
87
88 fStatErrorLow.fArray[bin] = statErrorLow;
89 fStatErrorHigh.fArray[bin] = statErrorHigh;
90 fSysErrorLow.fArray[bin] = sysErrorLow;
91 fSysErrorHigh.fArray[bin] = sysErrorHigh;
92 return;
93 }