]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis/AliFMDAnaCalibBackgroundCorrection.cxx
Added 2012 geom
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis / AliFMDAnaCalibBackgroundCorrection.cxx
1 //
2 // Calibration/Correction object that stores the secondary to primary
3 // correction used in the FMD analysis.
4 // 
5 #include "AliFMDAnaCalibBackgroundCorrection.h"
6 #include <TH2F.h>
7 #include <TH1F.h>
8 #include <TBrowser.h>
9
10 ClassImp(AliFMDAnaCalibBackgroundCorrection)
11 #if 0
12 ; // For Emacs
13 #endif 
14
15 //____________________________________________________________________
16 AliFMDAnaCalibBackgroundCorrection::AliFMDAnaCalibBackgroundCorrection() 
17   : TObject(),
18     fArray(),
19     fAxis(),
20     fIsInit(kFALSE),
21     fListOfDoubleHitCorrection(),
22     fListOfNSDBgMaps()
23 {
24 }
25
26
27 //____________________________________________________________________
28 AliFMDAnaCalibBackgroundCorrection::AliFMDAnaCalibBackgroundCorrection(const AliFMDAnaCalibBackgroundCorrection& o)
29   : TObject(o), 
30     fArray(o.fArray), 
31     fAxis(o.fAxis), 
32     fIsInit(o.fIsInit), 
33     fListOfDoubleHitCorrection(), 
34     fListOfNSDBgMaps()
35 {
36   // Copy ctor 
37 }
38 //____________________________________________________________________
39 AliFMDAnaCalibBackgroundCorrection&
40 AliFMDAnaCalibBackgroundCorrection::operator=(const AliFMDAnaCalibBackgroundCorrection& o) 
41 {
42   // Assignment operator 
43   
44   fArray     = o.fArray;
45   
46   return (*this);
47 }
48
49 //____________________________________________________________________
50 void 
51 AliFMDAnaCalibBackgroundCorrection::SetBgCorrection(Int_t det, 
52                                                     Char_t ring, 
53                                                     Int_t vtxbin, 
54                                                     TH2F* hCorrection) 
55 {
56   if(!fIsInit) Init();
57   
58   TObjArray* ringArray = GetRingArray(det,ring);
59   if (!ringArray) return;
60
61   ringArray->AddAtAndExpand(hCorrection,vtxbin);
62   
63 }
64 //____________________________________________________________________
65 TH2F* 
66 AliFMDAnaCalibBackgroundCorrection::GetBgCorrection(Int_t det, 
67                                                     Char_t ring, 
68                                                     Int_t vtxbin) const
69 {
70   TObjArray* ringArray   = GetRingArray(det,ring);
71   if (!ringArray) return 0;
72
73   TH2F*      hCorrection = static_cast<TH2F*>(ringArray->At(vtxbin));
74   return hCorrection;
75 }
76 //____________________________________________________________________
77 void 
78 AliFMDAnaCalibBackgroundCorrection::SetNSDBgCorrection(Int_t det, 
79                                                        Char_t ring, 
80                                                        Int_t vtxbin, 
81                                                        TH2F* hCorrection) 
82 {
83   if(!fIsInit)  Init();
84   hCorrection->SetName(Form("FMDNSD%d%c_vtxbin_%d_correction",det,ring,vtxbin));
85   fListOfNSDBgMaps.Add(hCorrection);
86     
87 }
88 //____________________________________________________________________
89 TH2F* 
90 AliFMDAnaCalibBackgroundCorrection::GetNSDBgCorrection(Int_t det, 
91                                                        Char_t ring, 
92                                                        Int_t vtxbin) const
93 {
94   TH2F* hCorrection    = 
95     static_cast<TH2F*>(fListOfNSDBgMaps
96                        .FindObject(Form("FMDNSD%d%c_vtxbin_%d_correction",
97                                         det,ring,vtxbin)));
98   return hCorrection;
99 }
100 //____________________________________________________________________
101 TH1F* 
102 AliFMDAnaCalibBackgroundCorrection::GetDoubleHitCorrection(Int_t  det, 
103                                                            Char_t ring) const
104 {  
105   TH1F* hCorrection    = 
106     static_cast<TH1F*>(fListOfDoubleHitCorrection
107                        .FindObject(Form("hDoubleHitCorrection_FMD%d%c",
108                                         det,ring)));
109   return hCorrection;
110 }
111
112 //____________________________________________________________________
113 void 
114 AliFMDAnaCalibBackgroundCorrection::SetDoubleHitCorrection(Int_t det, 
115                                                            Char_t ring, 
116                                                            TH1F* hCorrection) 
117 {
118   hCorrection->SetName(Form("hDoubleHitCorrection_FMD%d%c",det,ring));
119   fListOfDoubleHitCorrection.Add(hCorrection);    
120 }
121 //____________________________________________________________________
122 TH1F* 
123 AliFMDAnaCalibBackgroundCorrection::GetSPDDeadCorrection(Int_t  vtxbin) const
124 {
125   TH1F* hCorrection    = 
126     static_cast<TH1F*>(fListOfDoubleHitCorrection
127                        .FindObject(Form("hSPDDeadCorrection_vtx%d",vtxbin)));
128   return hCorrection;
129 }
130
131 //____________________________________________________________________
132 void 
133 AliFMDAnaCalibBackgroundCorrection::SetSPDDeadCorrection(Int_t vtxbin, 
134                                                          TH1F* hCorrection) 
135 {
136   hCorrection->SetName(Form("hSPDDeadCorrection_vtx%d",vtxbin));
137   fListOfDoubleHitCorrection.Add(hCorrection);    
138 }
139
140 //____________________________________________________________________
141 TH1F* 
142 AliFMDAnaCalibBackgroundCorrection::GetFMDDeadCorrection(Int_t  vtxbin) 
143 {
144   TH1F* hCorrection    = 
145     static_cast<TH1F*>(fListOfDoubleHitCorrection
146                        .FindObject(Form("hFMDDeadCorrection_vtx%d",vtxbin)));
147   return hCorrection;
148 }
149
150 //____________________________________________________________________
151 void 
152 AliFMDAnaCalibBackgroundCorrection::SetFMDDeadCorrection(Int_t vtxbin, 
153                                                          TH1F* hCorrection) 
154 {
155   hCorrection->SetName(Form("hFMDDeadCorrection_vtx%d",vtxbin));
156   fListOfDoubleHitCorrection.Add(hCorrection);    
157 }
158
159 //____________________________________________________________________
160 void 
161 AliFMDAnaCalibBackgroundCorrection::SetRefAxis(TAxis* axis) 
162 {
163   // Set the reference axis 
164   fAxis.Set(axis->GetNbins(),axis->GetXmin(),axis->GetXmax());
165 }
166 //____________________________________________________________________
167 void AliFMDAnaCalibBackgroundCorrection::Init() 
168 {
169   // Initialize 
170   fArray.SetOwner();
171   
172   TObjArray* spdArray = new TObjArray();
173   spdArray->SetOwner();
174   fArray.AddAtAndExpand(spdArray,0);
175   
176   for(Int_t det = 1; det<=3;det++) {
177     TObjArray* detArray = new TObjArray();
178     detArray->SetOwner();
179     detArray->SetName(Form("FMD%d", det));
180     // detArray->SetTitle(Form("Array of FMD%d corrections", det));
181     fArray.AddAtAndExpand(detArray,det);
182     Int_t nRings = (det == 1 ? 1 : 2);
183     for(Int_t ring = 0;ring<nRings;ring++) {
184       TObjArray* ringArray = new TObjArray();
185       Char_t r = (ring == 0 ? 'I' : 'O');
186       ringArray->SetOwner();
187       ringArray->SetName(Form("FMD%d%c", det, r));
188       // ringArray->SetTitle(Form("Array of FMD%d%c corrections", det, r));
189       detArray->AddAtAndExpand(ringArray,ring);
190       
191     }
192   }
193   fIsInit = kTRUE;
194   
195 }
196 //____________________________________________________________________
197 TObjArray* AliFMDAnaCalibBackgroundCorrection::GetRingArray(Int_t det, 
198                                                             Char_t ring) const
199 {
200   // Find array corresponding to det, ring.  
201   // Note, 0 and 4 refers to the SPD arrays 
202   if(det==0 || det == 4) {
203     TObjArray* spdArray  = (TObjArray*)fArray.At(det);
204     return spdArray;
205   }
206
207   if (det < 0 || det >= fArray.GetEntriesFast()) return 0; 
208
209   Int_t      ringNumber = (ring == 'I' ? 0 : 1);
210   TObjArray* detArray   = static_cast<TObjArray*>(fArray.At(det));
211   TObjArray* ringArray  = static_cast<TObjArray*>(detArray->At(ringNumber));
212   
213   return ringArray;
214 }
215
216 //____________________________________________________________________
217 void
218 AliFMDAnaCalibBackgroundCorrection::Browse(TBrowser* b)
219 {
220   // Browse 
221   b->Add(&fAxis, "Vertex bins");
222   b->Add(&fArray, "Array of histograms w/BG corrections");
223 }
224
225 //____________________________________________________________________
226 //
227 // EOF
228 //