1 |
sixie |
1.1 |
// $Id: TH3DAsymErr.cc,v 1.3 2009/10/21 15:05:22 sixie Exp $
|
2 |
|
|
|
3 |
|
|
#include "MitCommon/DataFormats/interface/TH3DAsymErr.h"
|
4 |
|
|
#include <TList.h>
|
5 |
|
|
#include <iostream>
|
6 |
|
|
|
7 |
|
|
ClassImp(mithep::TH3DAsymErr)
|
8 |
|
|
|
9 |
|
|
using namespace mithep;
|
10 |
|
|
using namespace std;
|
11 |
|
|
|
12 |
|
|
//--------------------------------------------------------------------------------------------------
|
13 |
|
|
TH3DAsymErr::TH3DAsymErr(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 |
|
|
Int_t nbinsz, Double_t zlow, Double_t zup) :
|
17 |
|
|
TH3D(name, title, nbinsx, xlow, xup , nbinsy, ylow, yup, nbinsz, zlow, zup),
|
18 |
|
|
fStatErrorLow(fNcells),
|
19 |
|
|
fStatErrorHigh(fNcells),
|
20 |
|
|
fSysErrorLow(fNcells),
|
21 |
|
|
fSysErrorHigh(fNcells)
|
22 |
|
|
{
|
23 |
|
|
// Constructor.
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
TH3DAsymErr::TH3DAsymErr(const TH3D &h3d) :
|
27 |
|
|
TH3D(h3d),
|
28 |
|
|
fStatErrorLow(fNcells),
|
29 |
|
|
fStatErrorHigh(fNcells),
|
30 |
|
|
fSysErrorLow(fNcells),
|
31 |
|
|
fSysErrorHigh(fNcells)
|
32 |
|
|
{
|
33 |
|
|
// Constructor.
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
//--------------------------------------------------------------------------------------------------
|
37 |
|
|
Double_t TH3DAsymErr::GetError(Double_t x, Double_t y, Double_t z, TH2DAsymErr::EErrType t)
|
38 |
|
|
{
|
39 |
|
|
// Get error corresponding to x,y,z for given error type.
|
40 |
|
|
|
41 |
|
|
Int_t nx = fXaxis.GetNbins()+2;
|
42 |
|
|
Int_t ny = fYaxis.GetNbins()+2;
|
43 |
|
|
Int_t binx = fXaxis.FindFixBin(x);
|
44 |
|
|
Int_t biny = fYaxis.FindFixBin(y);
|
45 |
|
|
Int_t binz = fZaxis.FindFixBin(z);
|
46 |
|
|
Int_t bin = binx + nx*(biny + ny*binz);
|
47 |
|
|
|
48 |
|
|
switch (t) {
|
49 |
|
|
case TH2DAsymErr::kStatErrLow:
|
50 |
|
|
return fStatErrorLow.fArray[bin];
|
51 |
|
|
break;
|
52 |
|
|
case TH2DAsymErr::kStatErrHigh:
|
53 |
|
|
return fStatErrorHigh.fArray[bin];
|
54 |
|
|
break;
|
55 |
|
|
case TH2DAsymErr::kSysErrLow:
|
56 |
|
|
return fSysErrorLow.fArray[bin];
|
57 |
|
|
break;
|
58 |
|
|
case TH2DAsymErr::kSysErrHigh:
|
59 |
|
|
return fSysErrorHigh.fArray[bin];
|
60 |
|
|
break;
|
61 |
|
|
}
|
62 |
|
|
return 0;
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
//--------------------------------------------------------------------------------------------------
|
66 |
|
|
Double_t TH3DAsymErr::GetBinError(Int_t b, Int_t c, Int_t d, TH2DAsymErr::EErrType t)
|
67 |
|
|
{
|
68 |
|
|
// Get error corresponding to bin (b,c) for given error type.
|
69 |
|
|
|
70 |
|
|
Int_t nx = fXaxis.GetNbins()+2;
|
71 |
|
|
Int_t ny = fYaxis.GetNbins()+2;
|
72 |
|
|
Int_t bin = b + nx*(c + ny*d);
|
73 |
|
|
|
74 |
|
|
switch (t) {
|
75 |
|
|
case TH2DAsymErr::kStatErrLow:
|
76 |
|
|
return fStatErrorLow.fArray[bin];
|
77 |
|
|
break;
|
78 |
|
|
case TH2DAsymErr::kStatErrHigh:
|
79 |
|
|
return fStatErrorHigh.fArray[bin];
|
80 |
|
|
break;
|
81 |
|
|
case TH2DAsymErr::kSysErrLow:
|
82 |
|
|
return fSysErrorLow.fArray[bin];
|
83 |
|
|
break;
|
84 |
|
|
case TH2DAsymErr::kSysErrHigh:
|
85 |
|
|
return fSysErrorHigh.fArray[bin];
|
86 |
|
|
break;
|
87 |
|
|
}
|
88 |
|
|
return 0;
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
//--------------------------------------------------------------------------------------------------
|
93 |
|
|
void TH3DAsymErr::SetBinContent(Int_t binx, Int_t biny, Int_t binz, Double_t value,
|
94 |
|
|
Double_t statErrorLow, Double_t statErrorHigh,
|
95 |
|
|
Double_t sysErrorLow, Double_t sysErrorHigh)
|
96 |
|
|
{
|
97 |
|
|
// Set bin content for given bin and value.
|
98 |
|
|
|
99 |
|
|
Int_t bin = GetBin(binx,biny,binz);
|
100 |
|
|
SetBinContent(bin,value);
|
101 |
|
|
|
102 |
|
|
fStatErrorLow.fArray[bin] = statErrorLow;
|
103 |
|
|
fStatErrorHigh.fArray[bin] = statErrorHigh;
|
104 |
|
|
fSysErrorLow.fArray[bin] = sysErrorLow;
|
105 |
|
|
fSysErrorHigh.fArray[bin] = sysErrorHigh;
|
106 |
|
|
return;
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
//--------------------------------------------------------------------------------------------------
|
110 |
|
|
void TH3DAsymErr::SetBinError(Int_t binx, Int_t biny, Int_t binz,
|
111 |
|
|
Double_t statErrorLow, Double_t statErrorHigh,
|
112 |
|
|
Double_t sysErrorLow, Double_t sysErrorHigh)
|
113 |
|
|
{
|
114 |
|
|
// Set bin error for asymetric errors.
|
115 |
|
|
|
116 |
|
|
Int_t bin = GetBin(binx,biny,binz);
|
117 |
|
|
|
118 |
|
|
fStatErrorLow.fArray[bin] = statErrorLow;
|
119 |
|
|
fStatErrorHigh.fArray[bin] = statErrorHigh;
|
120 |
|
|
fSysErrorLow.fArray[bin] = sysErrorLow;
|
121 |
|
|
fSysErrorHigh.fArray[bin] = sysErrorHigh;
|
122 |
|
|
|
123 |
|
|
return;
|
124 |
|
|
}
|