87320812a5fb80460f8a5b83036976fb9ea45254
[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 {
19   
20   
21   
22 }
23
24
25 //____________________________________________________________________
26 AliFMDAnaCalibBackgroundCorrection::AliFMDAnaCalibBackgroundCorrection(const AliFMDAnaCalibBackgroundCorrection& o)
27   : TObject(o), fArray(o.fArray), fAxis(o.fAxis), fIsInit(o.fIsInit), fListOfDoubleHitCorrection()
28 {
29   // Copy ctor 
30 }
31 //____________________________________________________________________
32 AliFMDAnaCalibBackgroundCorrection&
33 AliFMDAnaCalibBackgroundCorrection::operator=(const AliFMDAnaCalibBackgroundCorrection& o) 
34 {
35   // Assignment operator 
36   
37   fArray     = o.fArray;
38   
39   return (*this);
40 }
41
42 //____________________________________________________________________
43 TH2F* AliFMDAnaCalibBackgroundCorrection::GetBgCorrection(Int_t det, 
44                                                           Char_t ring, 
45                                                           Int_t vtxbin) {
46   TObjArray* ringArray = GetRingArray(det,ring);
47   TH2F* hCorrection    = (TH2F*)ringArray->At(vtxbin);
48   return hCorrection;
49 }
50
51 //____________________________________________________________________
52 void AliFMDAnaCalibBackgroundCorrection::SetBgCorrection(Int_t det, 
53                                                          Char_t ring, 
54                                                          Int_t vtxbin, 
55                                                          TH2F* hCorrection) {
56   if(!fIsInit)
57     Init();
58   
59   TObjArray* ringArray = GetRingArray(det,ring);
60   ringArray->AddAtAndExpand(hCorrection,vtxbin);
61   
62 }
63 //____________________________________________________________________
64 TH1F* AliFMDAnaCalibBackgroundCorrection::GetDoubleHitCorrection(Int_t  det, 
65                                                                  Char_t ring) {
66   
67   
68   TH1F* hCorrection    = (TH1F*)fListOfDoubleHitCorrection.FindObject(Form("hDoubleHitCorrection_FMD%d%c",det,ring));
69   return hCorrection;
70 }
71
72 //____________________________________________________________________
73 void AliFMDAnaCalibBackgroundCorrection::SetDoubleHitCorrection(Int_t det, 
74                                                                 Char_t ring, 
75                                                                 TH1F* hCorrection) {
76   hCorrection->SetName(Form("hDoubleHitCorrection_FMD%d%c",det,ring));
77   fListOfDoubleHitCorrection.Add(hCorrection);    
78 }
79 //____________________________________________________________________
80 TH1F* AliFMDAnaCalibBackgroundCorrection::GetSPDDeadCorrection(Int_t  vtxbin) {
81   
82   TH1F* hCorrection    = (TH1F*)fListOfDoubleHitCorrection.FindObject(Form("hSPDDeadCorrection_vtx%d",vtxbin));
83   return hCorrection;
84 }
85
86 //____________________________________________________________________
87 void AliFMDAnaCalibBackgroundCorrection::SetSPDDeadCorrection(Int_t vtxbin, 
88                                                               TH1F* hCorrection) {
89   hCorrection->SetName(Form("hSPDDeadCorrection_vtx%d",vtxbin));
90   fListOfDoubleHitCorrection.Add(hCorrection);    
91 }
92 //____________________________________________________________________
93 void AliFMDAnaCalibBackgroundCorrection::SetRefAxis(TAxis* axis) {
94   
95  
96   fAxis.Set(axis->GetNbins(),axis->GetXmin(),axis->GetXmax());
97     
98 }
99 //____________________________________________________________________
100 void AliFMDAnaCalibBackgroundCorrection::Init() {
101   
102   fArray.SetOwner();
103   
104   TObjArray* spdArray = new TObjArray();
105   spdArray->SetOwner();
106   fArray.AddAtAndExpand(spdArray,0);
107   
108   for(Int_t det = 1; det<=3;det++) {
109     TObjArray* detArray = new TObjArray();
110     detArray->SetOwner();
111     fArray.AddAtAndExpand(detArray,det);
112     Int_t nRings = (det == 1 ? 1 : 2);
113     for(Int_t ring = 0;ring<nRings;ring++) {
114       TObjArray* ringArray = new TObjArray();
115       ringArray->SetOwner();
116       detArray->AddAtAndExpand(ringArray,ring);
117       
118     }
119   }
120   fIsInit = kTRUE;
121   
122 }
123 //____________________________________________________________________
124 TObjArray* AliFMDAnaCalibBackgroundCorrection::GetRingArray(Int_t det, 
125                                                             Char_t ring) {
126   
127   if(det==0 || det == 4) {
128     TObjArray* spdArray  = (TObjArray*)fArray.At(det);
129     return spdArray;
130   }
131   Int_t ringNumber      = (ring == 'I' ? 0 : 1);
132   TObjArray* detArray  = (TObjArray*)fArray.At(det);
133   TObjArray* ringArray = (TObjArray*)detArray->At(ringNumber);
134   
135   return ringArray;
136 }
137 //____________________________________________________________________
138 Int_t AliFMDAnaCalibBackgroundCorrection::GetNvtxBins() {
139   
140   return fAxis.GetNbins();
141   
142 }
143 //____________________________________________________________________
144 Float_t AliFMDAnaCalibBackgroundCorrection::GetVtxCutZ() {
145   
146   return fAxis.GetXmax();
147   
148 }
149
150 //____________________________________________________________________
151 void
152 AliFMDAnaCalibBackgroundCorrection::Browse(TBrowser* b)
153 {
154   b->Add(&fAxis, "Vertex bins");
155   b->Add(&fArray, "Array of histograms w/BG corrections");
156 }
157
158 //____________________________________________________________________
159 //
160 // EOF
161 //