ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitCommon/DataFormats/src/TH2DAsymErr.cc
Revision: 1.4
Committed: Sat Mar 27 13:20:00 2010 UTC (15 years, 1 month ago) by sixie
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, V07-05-00, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, ConvRejection-10-06-09, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, HEAD
Branch point for: Mit_025c_branch
Changes since 1.3: +27 -1 lines
Log Message:
add some accessors to get bin content by bin number

File Contents

# Content
1 // $Id: TH2DAsymErr.cc,v 1.3 2009/10/21 15:05:22 sixie 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 Double_t TH2DAsymErr::GetBinError(Int_t b, Int_t c, EErrType t)
64 {
65 // Get error corresponding to bin (b,c) for given error type.
66
67 Int_t nx = fXaxis.GetNbins()+2;
68 Int_t bin = b + nx*c;
69
70 switch (t) {
71 case kStatErrLow:
72 return fStatErrorLow.fArray[bin];
73 break;
74 case kStatErrHigh:
75 return fStatErrorHigh.fArray[bin];
76 break;
77 case kSysErrLow:
78 return fSysErrorLow.fArray[bin];
79 break;
80 case kSysErrHigh:
81 return fSysErrorHigh.fArray[bin];
82 break;
83 }
84 return 0;
85 }
86
87
88 //--------------------------------------------------------------------------------------------------
89 void TH2DAsymErr::SetBinContent(Int_t binx, Int_t biny, Double_t value,
90 Double_t statErrorLow, Double_t statErrorHigh,
91 Double_t sysErrorLow, Double_t sysErrorHigh)
92 {
93 // Set bin content for given bin and value.
94
95 Int_t bin = GetBin(binx,biny);
96 SetBinContent(bin,value);
97
98 fStatErrorLow.fArray[bin] = statErrorLow;
99 fStatErrorHigh.fArray[bin] = statErrorHigh;
100 fSysErrorLow.fArray[bin] = sysErrorLow;
101 fSysErrorHigh.fArray[bin] = sysErrorHigh;
102 return;
103 }
104
105 //--------------------------------------------------------------------------------------------------
106 void TH2DAsymErr::SetBinError(Int_t binx, Int_t biny,
107 Double_t statErrorLow, Double_t statErrorHigh,
108 Double_t sysErrorLow, Double_t sysErrorHigh)
109 {
110 // Set bin error for asymetric errors.
111
112 Int_t bin = GetBin(binx,biny);
113
114 fStatErrorLow.fArray[bin] = statErrorLow;
115 fStatErrorHigh.fArray[bin] = statErrorHigh;
116 fSysErrorLow.fArray[bin] = sysErrorLow;
117 fSysErrorHigh.fArray[bin] = sysErrorHigh;
118 return;
119 }