1 |
sixie |
1.3 |
// $Id: TH2DAsymErr.cc,v 1.2 2009/08/11 09:02:24 loizides Exp $
|
2 |
phedex |
1.1 |
|
3 |
|
|
#include "MitCommon/DataFormats/interface/TH2DAsymErr.h"
|
4 |
|
|
#include <TList.h>
|
5 |
sixie |
1.3 |
#include <iostream>
|
6 |
phedex |
1.1 |
|
7 |
|
|
ClassImp(mithep::TH2DAsymErr)
|
8 |
|
|
|
9 |
|
|
using namespace mithep;
|
10 |
sixie |
1.3 |
using namespace std;
|
11 |
phedex |
1.1 |
|
12 |
|
|
//--------------------------------------------------------------------------------------------------
|
13 |
loizides |
1.2 |
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 |
phedex |
1.1 |
{
|
22 |
|
|
// Constructor.
|
23 |
|
|
}
|
24 |
|
|
|
25 |
loizides |
1.2 |
TH2DAsymErr::TH2DAsymErr(const TH2D &h2d) :
|
26 |
|
|
TH2D(h2d),
|
27 |
|
|
fStatErrorLow(fNcells),
|
28 |
|
|
fStatErrorHigh(fNcells),
|
29 |
|
|
fSysErrorLow(fNcells),
|
30 |
|
|
fSysErrorHigh(fNcells)
|
31 |
phedex |
1.1 |
{
|
32 |
|
|
// Constructor.
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
//--------------------------------------------------------------------------------------------------
|
36 |
loizides |
1.2 |
Double_t TH2DAsymErr::GetError(Double_t x, Double_t y, EErrType t)
|
37 |
phedex |
1.1 |
{
|
38 |
loizides |
1.2 |
// Get error corresponding to x and y for given error type.
|
39 |
phedex |
1.1 |
|
40 |
sixie |
1.3 |
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 |
loizides |
1.2 |
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 |
phedex |
1.1 |
}
|
61 |
|
|
|
62 |
|
|
//--------------------------------------------------------------------------------------------------
|
63 |
loizides |
1.2 |
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 |
phedex |
1.1 |
{
|
67 |
loizides |
1.2 |
// Set bin content for given bin and value.
|
68 |
phedex |
1.1 |
|
69 |
loizides |
1.2 |
Int_t bin = GetBin(binx,biny);
|
70 |
|
|
SetBinContent(bin,value);
|
71 |
phedex |
1.1 |
|
72 |
loizides |
1.2 |
fStatErrorLow.fArray[bin] = statErrorLow;
|
73 |
|
|
fStatErrorHigh.fArray[bin] = statErrorHigh;
|
74 |
|
|
fSysErrorLow.fArray[bin] = sysErrorLow;
|
75 |
|
|
fSysErrorHigh.fArray[bin] = sysErrorHigh;
|
76 |
sixie |
1.3 |
return;
|
77 |
phedex |
1.1 |
}
|
78 |
|
|
|
79 |
|
|
//--------------------------------------------------------------------------------------------------
|
80 |
loizides |
1.2 |
void TH2DAsymErr::SetBinError(Int_t binx, Int_t biny,
|
81 |
|
|
Double_t statErrorLow, Double_t statErrorHigh,
|
82 |
|
|
Double_t sysErrorLow, Double_t sysErrorHigh)
|
83 |
phedex |
1.1 |
{
|
84 |
loizides |
1.2 |
// Set bin error for asymetric errors.
|
85 |
phedex |
1.1 |
|
86 |
loizides |
1.2 |
Int_t bin = GetBin(binx,biny);
|
87 |
phedex |
1.1 |
|
88 |
loizides |
1.2 |
fStatErrorLow.fArray[bin] = statErrorLow;
|
89 |
|
|
fStatErrorHigh.fArray[bin] = statErrorHigh;
|
90 |
|
|
fSysErrorLow.fArray[bin] = sysErrorLow;
|
91 |
|
|
fSysErrorHigh.fArray[bin] = sysErrorHigh;
|
92 |
sixie |
1.3 |
return;
|
93 |
phedex |
1.1 |
}
|