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 |
}
|