ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitCommon/DataFormats/src/TH3DAsymErr.cc
Revision: 1.1
Committed: Sat Mar 27 13:19:45 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
Log Message:
Add 3D histograms with systematics

File Contents

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