]>
Commit | Line | Data |
---|---|---|
7984e5f7 | 1 | // |
2 | // This class calculates the exclusive charged particle density | |
3 | // in each for the 5 FMD rings. | |
4 | // | |
7e4038b5 | 5 | #include "AliFMDCorrections.h" |
6 | #include <AliESDFMD.h> | |
7 | #include <TAxis.h> | |
8 | #include <TList.h> | |
9 | #include <TMath.h> | |
0bd4b00f | 10 | #include "AliForwardCorrectionManager.h" |
7e4038b5 | 11 | #include "AliLog.h" |
12 | #include <TH2D.h> | |
0bd4b00f | 13 | #include <TROOT.h> |
14 | #include <iostream> | |
15 | #include <iomanip> | |
7e4038b5 | 16 | |
17 | ClassImp(AliFMDCorrections) | |
18 | #if 0 | |
19 | ; // For Emacs | |
20 | #endif | |
21 | ||
22 | //____________________________________________________________________ | |
23 | AliFMDCorrections::AliFMDCorrections() | |
24 | : TNamed(), | |
25 | fRingHistos(), | |
81eda625 | 26 | fUseMergingEfficiency(true), |
ea3e5d95 | 27 | fDebug(0) |
7984e5f7 | 28 | { |
29 | // Constructor | |
30 | } | |
7e4038b5 | 31 | |
32 | //____________________________________________________________________ | |
33 | AliFMDCorrections::AliFMDCorrections(const char* title) | |
34 | : TNamed("fmdCorrections", title), | |
35 | fRingHistos(), | |
81eda625 | 36 | fUseMergingEfficiency(true), |
ea3e5d95 | 37 | fDebug(0) |
7e4038b5 | 38 | { |
7984e5f7 | 39 | // Constructor |
40 | // | |
41 | // Parameters: | |
42 | // title Title | |
7e4038b5 | 43 | fRingHistos.SetName(GetName()); |
44 | fRingHistos.Add(new RingHistos(1, 'I')); | |
45 | fRingHistos.Add(new RingHistos(2, 'I')); | |
46 | fRingHistos.Add(new RingHistos(2, 'O')); | |
47 | fRingHistos.Add(new RingHistos(3, 'I')); | |
48 | fRingHistos.Add(new RingHistos(3, 'O')); | |
49 | } | |
50 | ||
51 | //____________________________________________________________________ | |
52 | AliFMDCorrections::AliFMDCorrections(const AliFMDCorrections& o) | |
53 | : TNamed(o), | |
54 | fRingHistos(), | |
81eda625 | 55 | fUseMergingEfficiency(o.fUseMergingEfficiency), |
ea3e5d95 | 56 | fDebug(o.fDebug) |
7e4038b5 | 57 | { |
7984e5f7 | 58 | // Copy constructor |
59 | // | |
60 | // Parameters: | |
61 | // o Object to copy from | |
7e4038b5 | 62 | TIter next(&o.fRingHistos); |
63 | TObject* obj = 0; | |
64 | while ((obj = next())) fRingHistos.Add(obj); | |
65 | } | |
66 | ||
67 | //____________________________________________________________________ | |
68 | AliFMDCorrections::~AliFMDCorrections() | |
69 | { | |
7984e5f7 | 70 | // Destructor |
71 | // | |
72 | // | |
7e4038b5 | 73 | fRingHistos.Delete(); |
74 | } | |
75 | ||
76 | //____________________________________________________________________ | |
77 | AliFMDCorrections& | |
78 | AliFMDCorrections::operator=(const AliFMDCorrections& o) | |
79 | { | |
7984e5f7 | 80 | // Assignment operator |
81 | // | |
82 | // Parameters: | |
83 | // o Object to assign from | |
ea3e5d95 | 84 | TNamed::operator=(o); |
7e4038b5 | 85 | |
ea3e5d95 | 86 | fDebug = o.fDebug; |
7e4038b5 | 87 | fRingHistos.Delete(); |
81eda625 | 88 | fUseMergingEfficiency = o.fUseMergingEfficiency; |
7e4038b5 | 89 | TIter next(&o.fRingHistos); |
90 | TObject* obj = 0; | |
91 | while ((obj = next())) fRingHistos.Add(obj); | |
92 | ||
93 | return *this; | |
94 | } | |
95 | ||
96 | //____________________________________________________________________ | |
97 | AliFMDCorrections::RingHistos* | |
98 | AliFMDCorrections::GetRingHistos(UShort_t d, Char_t r) const | |
99 | { | |
7984e5f7 | 100 | // |
101 | // Get the ring histogram container | |
102 | // Parameters: | |
103 | // d Detector | |
104 | // r Ring | |
105 | // | |
106 | // Return: | |
107 | // Ring histogram container | |
108 | // | |
7e4038b5 | 109 | Int_t idx = -1; |
110 | switch (d) { | |
111 | case 1: idx = 0; break; | |
112 | case 2: idx = 1 + (r == 'I' || r == 'i' ? 0 : 1); break; | |
113 | case 3: idx = 3 + (r == 'I' || r == 'i' ? 0 : 1); break; | |
114 | } | |
115 | if (idx < 0 || idx >= fRingHistos.GetEntries()) return 0; | |
116 | ||
117 | return static_cast<RingHistos*>(fRingHistos.At(idx)); | |
118 | } | |
119 | ||
120 | //____________________________________________________________________ | |
121 | Bool_t | |
122 | AliFMDCorrections::Correct(AliForwardUtil::Histos& hists, | |
0bd4b00f | 123 | UShort_t vtxbin) |
7e4038b5 | 124 | { |
7984e5f7 | 125 | // |
126 | // Do the calculations | |
127 | // Parameters: | |
128 | // hists Cache of histograms | |
129 | // vtxBin Vertex bin | |
130 | // | |
131 | // Return: | |
132 | // true on successs | |
133 | // | |
0bd4b00f | 134 | AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance(); |
7e4038b5 | 135 | |
0bd4b00f | 136 | UShort_t uvb = vtxbin; |
7e4038b5 | 137 | for (UShort_t d=1; d<=3; d++) { |
138 | UShort_t nr = (d == 1 ? 1 : 2); | |
139 | for (UShort_t q=0; q<nr; q++) { | |
140 | Char_t r = (q == 0 ? 'I' : 'O'); | |
141 | TH2D* h = hists.Get(d,r); | |
142 | RingHistos* rh= GetRingHistos(d,r); | |
0bd4b00f | 143 | TH2D* bg = fcm.GetSecondaryMap()->GetCorrection(d,r,uvb); |
144 | TH2D* ef = fcm.GetVertexBias()->GetCorrection(r, uvb); | |
7e4038b5 | 145 | if (!bg) { |
146 | AliWarning(Form("No secondary correction for FMDM%d%c in vertex bin %d", | |
0bd4b00f | 147 | d, r, uvb)); |
7e4038b5 | 148 | continue; |
149 | } | |
150 | if (!ef) { | |
0bd4b00f | 151 | AliWarning(Form("No event vertex bias correction in vertex bin %d", |
152 | uvb)); | |
7e4038b5 | 153 | continue; |
154 | } | |
155 | ||
156 | // Divide by primary/total ratio | |
157 | h->Divide(bg); | |
158 | ||
159 | // Divide by the event selection efficiency | |
160 | h->Divide(ef); | |
161 | ||
81eda625 | 162 | if (fUseMergingEfficiency) { |
163 | if (!fcm.GetMergingEfficiency()) { | |
164 | AliWarning("No merging efficiencies"); | |
165 | continue; | |
166 | } | |
167 | TH1D* sf = fcm.GetMergingEfficiency()->GetCorrection(d,r,uvb); | |
168 | if (!fcm.GetMergingEfficiency()->GetCorrection(d,r,uvb)) { | |
169 | AliWarning(Form("No merging efficiency for FMD%d%c at vertex bin %d", | |
170 | d, r, uvb)); | |
171 | continue; | |
172 | } | |
7e4038b5 | 173 | |
81eda625 | 174 | |
175 | for (Int_t ieta = 1; ieta <= h->GetNbinsX(); ieta++) { | |
176 | Float_t c = sf->GetBinContent(ieta); | |
177 | Float_t ec = sf->GetBinError(ieta); | |
178 | ||
179 | if (c == 0) continue; | |
7e4038b5 | 180 | |
81eda625 | 181 | for (Int_t iphi = 1; iphi <= h->GetNbinsY(); iphi++) { |
182 | Double_t m = h->GetBinContent(ieta, iphi) / c; | |
183 | Double_t em = h->GetBinError(ieta, iphi); | |
7e4038b5 | 184 | |
81eda625 | 185 | Double_t e = TMath::Sqrt(em * em + (m * ec) * (m * ec)); |
186 | ||
187 | h->SetBinContent(ieta,iphi,m); | |
188 | h->SetBinError(ieta,iphi,e); | |
189 | } | |
7e4038b5 | 190 | } |
191 | } | |
7e4038b5 | 192 | rh->fDensity->Add(h); |
193 | } | |
194 | } | |
195 | ||
196 | return kTRUE; | |
197 | } | |
198 | ||
199 | //____________________________________________________________________ | |
200 | void | |
9d99b0dd | 201 | AliFMDCorrections::ScaleHistograms(TList* dir, Int_t nEvents) |
7e4038b5 | 202 | { |
7984e5f7 | 203 | // |
204 | // Scale the histograms to the total number of events | |
205 | // Parameters: | |
206 | // dir Where the output is stored | |
207 | // nEvents Number of events | |
208 | // | |
7e4038b5 | 209 | if (nEvents <= 0) return; |
9d99b0dd | 210 | TList* d = static_cast<TList*>(dir->FindObject(GetName())); |
211 | if (!d) return; | |
7e4038b5 | 212 | |
213 | TIter next(&fRingHistos); | |
214 | RingHistos* o = 0; | |
9d99b0dd | 215 | while ((o = static_cast<RingHistos*>(next()))) |
216 | o->ScaleHistograms(d, nEvents); | |
7e4038b5 | 217 | } |
7e4038b5 | 218 | //____________________________________________________________________ |
219 | void | |
9d99b0dd | 220 | AliFMDCorrections::DefineOutput(TList* dir) |
7e4038b5 | 221 | { |
222 | TList* d = new TList; | |
223 | d->SetName(GetName()); | |
224 | dir->Add(d); | |
225 | TIter next(&fRingHistos); | |
226 | RingHistos* o = 0; | |
227 | while ((o = static_cast<RingHistos*>(next()))) { | |
228 | o->Output(d); | |
229 | } | |
230 | } | |
231 | ||
0bd4b00f | 232 | //____________________________________________________________________ |
233 | void | |
234 | AliFMDCorrections::Print(Option_t* /* option */) const | |
235 | { | |
7984e5f7 | 236 | // |
237 | // Print information | |
238 | // Parameters: | |
239 | // option Not used | |
240 | // | |
0bd4b00f | 241 | char ind[gROOT->GetDirLevel()+1]; |
242 | for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' '; | |
243 | ind[gROOT->GetDirLevel()] = '\0'; | |
244 | std::cout << ind << "AliFMDCorrections: " << GetName() << std::endl; | |
245 | } | |
246 | ||
7e4038b5 | 247 | //==================================================================== |
248 | AliFMDCorrections::RingHistos::RingHistos() | |
9d99b0dd | 249 | : AliForwardUtil::RingHistos(), |
7e4038b5 | 250 | fDensity(0) |
7984e5f7 | 251 | { |
252 | // Constructor | |
253 | // | |
254 | // | |
255 | } | |
7e4038b5 | 256 | |
257 | //____________________________________________________________________ | |
258 | AliFMDCorrections::RingHistos::RingHistos(UShort_t d, Char_t r) | |
9d99b0dd | 259 | : AliForwardUtil::RingHistos(d,r), |
7e4038b5 | 260 | fDensity(0) |
261 | { | |
7984e5f7 | 262 | // |
263 | // Constructor | |
264 | // Parameters: | |
265 | // d detector | |
266 | // r ring | |
267 | // | |
7e4038b5 | 268 | fDensity = new TH2D(Form("FMD%d%c_Primary_Density", d, r), |
269 | Form("in FMD%d%c", d, r), | |
270 | 200, -4, 6, (r == 'I' || r == 'i' ? 20 : 40), | |
271 | 0, 2*TMath::Pi()); | |
272 | fDensity->SetDirectory(0); | |
273 | fDensity->SetXTitle("#eta"); | |
274 | fDensity->SetYTitle("#phi [radians]"); | |
275 | fDensity->SetZTitle("Primary N_{ch} density"); | |
276 | } | |
277 | //____________________________________________________________________ | |
278 | AliFMDCorrections::RingHistos::RingHistos(const RingHistos& o) | |
9d99b0dd | 279 | : AliForwardUtil::RingHistos(o), |
7e4038b5 | 280 | fDensity(o.fDensity) |
7984e5f7 | 281 | { |
282 | // | |
283 | // Copy constructor | |
284 | // Parameters: | |
285 | // o Object to copy from | |
286 | // | |
287 | } | |
7e4038b5 | 288 | |
289 | //____________________________________________________________________ | |
290 | AliFMDCorrections::RingHistos& | |
291 | AliFMDCorrections::RingHistos::operator=(const RingHistos& o) | |
292 | { | |
7984e5f7 | 293 | // |
294 | // Assignment operator | |
295 | // Parameters: | |
296 | // o Object to assign from | |
297 | // | |
298 | // Return: | |
299 | // Reference to this | |
300 | // | |
9d99b0dd | 301 | AliForwardUtil::RingHistos::operator=(o); |
7e4038b5 | 302 | |
303 | if (fDensity) delete fDensity; | |
304 | ||
305 | fDensity = static_cast<TH2D*>(o.fDensity->Clone()); | |
306 | ||
307 | return *this; | |
308 | } | |
309 | //____________________________________________________________________ | |
310 | AliFMDCorrections::RingHistos::~RingHistos() | |
311 | { | |
7984e5f7 | 312 | // |
313 | // Destructor | |
314 | // | |
7e4038b5 | 315 | if (fDensity) delete fDensity; |
316 | } | |
317 | ||
318 | //____________________________________________________________________ | |
319 | void | |
320 | AliFMDCorrections::RingHistos::Output(TList* dir) | |
321 | { | |
7984e5f7 | 322 | // |
323 | // Make output | |
324 | // Parameters: | |
325 | // dir Where to put it | |
326 | // | |
9d99b0dd | 327 | TList* d = DefineOutputList(dir); |
7e4038b5 | 328 | d->Add(fDensity); |
9d99b0dd | 329 | } |
330 | ||
331 | //____________________________________________________________________ | |
332 | void | |
333 | AliFMDCorrections::RingHistos::ScaleHistograms(TList* dir, Int_t nEvents) | |
334 | { | |
7984e5f7 | 335 | // |
336 | // Scale the histograms to the total number of events | |
337 | // Parameters: | |
338 | // dir where the output is stored | |
339 | // nEvents Number of events | |
340 | // | |
9d99b0dd | 341 | TList* l = GetOutputList(dir); |
342 | if (!l) return; | |
343 | ||
344 | TH1* density = GetOutputHist(l,Form("%s_Primary_Density", fName.Data())); | |
345 | if (density) density->Scale(1./nEvents); | |
7e4038b5 | 346 | } |
347 | ||
348 | //____________________________________________________________________ | |
349 | // | |
350 | // EOF | |
351 | // | |
352 | ||
353 | ||
354 |