Various upgrades and bug fixes etc
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis / AliFMDAnaCalibBackgroundCorrection.cxx
1
2 #include "AliFMDAnaCalibBackgroundCorrection.h"
3 #include <TH2F.h>
4 #include <TH1F.h>
5 #include <TBrowser.h>
6
7 ClassImp(AliFMDAnaCalibBackgroundCorrection)
8 #if 0
9 ; // For Emacs
10 #endif 
11
12 //____________________________________________________________________
13 AliFMDAnaCalibBackgroundCorrection::AliFMDAnaCalibBackgroundCorrection() : TObject(),
14                                                                            fArray(),
15                                                                            fAxis(),
16                                                                            fIsInit(kFALSE),
17                                                                            fListOfDoubleHitCorrection(),
18                                                                            fListOfNSDBgMaps()
19 {
20   
21   
22   
23 }
24
25
26 //____________________________________________________________________
27 AliFMDAnaCalibBackgroundCorrection::AliFMDAnaCalibBackgroundCorrection(const AliFMDAnaCalibBackgroundCorrection& o)
28   : TObject(o), fArray(o.fArray), fAxis(o.fAxis), fIsInit(o.fIsInit), fListOfDoubleHitCorrection(), fListOfNSDBgMaps()
29 {
30   // Copy ctor 
31 }
32 //____________________________________________________________________
33 AliFMDAnaCalibBackgroundCorrection&
34 AliFMDAnaCalibBackgroundCorrection::operator=(const AliFMDAnaCalibBackgroundCorrection& o) 
35 {
36   // Assignment operator 
37   
38   fArray     = o.fArray;
39   
40   return (*this);
41 }
42
43 //____________________________________________________________________
44 TH2F* AliFMDAnaCalibBackgroundCorrection::GetBgCorrection(Int_t det, 
45                                                           Char_t ring, 
46                                                           Int_t vtxbin) {
47   TObjArray* ringArray = GetRingArray(det,ring);
48   TH2F* hCorrection    = (TH2F*)ringArray->At(vtxbin);
49   return hCorrection;
50 }
51 //____________________________________________________________________
52 void AliFMDAnaCalibBackgroundCorrection::SetNSDBgCorrection(Int_t det, 
53                                                             Char_t ring, 
54                                                             Int_t vtxbin, 
55                                                             TH2F* hCorrection) {
56   if(!fIsInit)
57     Init();
58   hCorrection->SetName(Form("FMDNSD%d%c_vtxbin_%d_correction",det,ring,vtxbin));
59   fListOfNSDBgMaps.Add(hCorrection);
60     
61 }
62 //____________________________________________________________________
63 TH2F* AliFMDAnaCalibBackgroundCorrection::GetNSDBgCorrection(Int_t det, 
64                                                              Char_t ring, 
65                                                              Int_t vtxbin) {
66   TH2F* hCorrection    = (TH2F*)fListOfNSDBgMaps.FindObject(Form("FMDNSD%d%c_vtxbin_%d_correction",det,ring,vtxbin));
67   return hCorrection;
68 }
69 //____________________________________________________________________
70 void AliFMDAnaCalibBackgroundCorrection::SetBgCorrection(Int_t det, 
71                                                          Char_t ring, 
72                                                          Int_t vtxbin, 
73                                                          TH2F* hCorrection) {
74   if(!fIsInit)
75     Init();
76   
77   TObjArray* ringArray = GetRingArray(det,ring);
78   ringArray->AddAtAndExpand(hCorrection,vtxbin);
79   
80 }
81 //____________________________________________________________________
82 TH1F* AliFMDAnaCalibBackgroundCorrection::GetDoubleHitCorrection(Int_t  det, 
83                                                                  Char_t ring) {
84   
85   
86   TH1F* hCorrection    = (TH1F*)fListOfDoubleHitCorrection.FindObject(Form("hDoubleHitCorrection_FMD%d%c",det,ring));
87   return hCorrection;
88 }
89
90 //____________________________________________________________________
91 void AliFMDAnaCalibBackgroundCorrection::SetDoubleHitCorrection(Int_t det, 
92                                                                 Char_t ring, 
93                                                                 TH1F* hCorrection) {
94   hCorrection->SetName(Form("hDoubleHitCorrection_FMD%d%c",det,ring));
95   fListOfDoubleHitCorrection.Add(hCorrection);    
96 }
97 //____________________________________________________________________
98 TH1F* AliFMDAnaCalibBackgroundCorrection::GetSPDDeadCorrection(Int_t  vtxbin) {
99   
100   TH1F* hCorrection    = (TH1F*)fListOfDoubleHitCorrection.FindObject(Form("hSPDDeadCorrection_vtx%d",vtxbin));
101   return hCorrection;
102 }
103
104 //____________________________________________________________________
105 void AliFMDAnaCalibBackgroundCorrection::SetSPDDeadCorrection(Int_t vtxbin, 
106                                                               TH1F* hCorrection) {
107   hCorrection->SetName(Form("hSPDDeadCorrection_vtx%d",vtxbin));
108   fListOfDoubleHitCorrection.Add(hCorrection);    
109 }
110 //____________________________________________________________________
111 void AliFMDAnaCalibBackgroundCorrection::SetRefAxis(TAxis* axis) {
112   
113  
114   fAxis.Set(axis->GetNbins(),axis->GetXmin(),axis->GetXmax());
115     
116 }
117 //____________________________________________________________________
118 void AliFMDAnaCalibBackgroundCorrection::Init() {
119   
120   fArray.SetOwner();
121   
122   TObjArray* spdArray = new TObjArray();
123   spdArray->SetOwner();
124   fArray.AddAtAndExpand(spdArray,0);
125   
126   for(Int_t det = 1; det<=3;det++) {
127     TObjArray* detArray = new TObjArray();
128     detArray->SetOwner();
129     fArray.AddAtAndExpand(detArray,det);
130     Int_t nRings = (det == 1 ? 1 : 2);
131     for(Int_t ring = 0;ring<nRings;ring++) {
132       TObjArray* ringArray = new TObjArray();
133       ringArray->SetOwner();
134       detArray->AddAtAndExpand(ringArray,ring);
135       
136     }
137   }
138   fIsInit = kTRUE;
139   
140 }
141 //____________________________________________________________________
142 TObjArray* AliFMDAnaCalibBackgroundCorrection::GetRingArray(Int_t det, 
143                                                             Char_t ring) {
144   
145   if(det==0 || det == 4) {
146     TObjArray* spdArray  = (TObjArray*)fArray.At(det);
147     return spdArray;
148   }
149   Int_t ringNumber      = (ring == 'I' ? 0 : 1);
150   TObjArray* detArray  = (TObjArray*)fArray.At(det);
151   TObjArray* ringArray = (TObjArray*)detArray->At(ringNumber);
152   
153   return ringArray;
154 }
155 //____________________________________________________________________
156 Int_t AliFMDAnaCalibBackgroundCorrection::GetNvtxBins() {
157   
158   return fAxis.GetNbins();
159   
160 }
161 //____________________________________________________________________
162 Float_t AliFMDAnaCalibBackgroundCorrection::GetVtxCutZ() {
163   
164   return fAxis.GetXmax();
165   
166 }
167
168 //____________________________________________________________________
169 void
170 AliFMDAnaCalibBackgroundCorrection::Browse(TBrowser* b)
171 {
172   b->Add(&fAxis, "Vertex bins");
173   b->Add(&fArray, "Array of histograms w/BG corrections");
174 }
175
176 //____________________________________________________________________
177 //
178 // EOF
179 //