]>
Commit | Line | Data |
---|---|---|
7984e5f7 | 1 | // |
2 | // This class calculates the exclusive charged particle density | |
3 | // in each for the 5 FMD rings. | |
4 | // | |
72cc12cd | 5 | #include "AliFMDCorrector.h" |
7e4038b5 | 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 | |
72cc12cd | 17 | ClassImp(AliFMDCorrector) |
7e4038b5 | 18 | #if 0 |
19 | ; // For Emacs | |
20 | #endif | |
21 | ||
22 | //____________________________________________________________________ | |
72cc12cd | 23 | AliFMDCorrector::AliFMDCorrector() |
7e4038b5 | 24 | : TNamed(), |
25 | fRingHistos(), | |
81eda625 | 26 | fUseMergingEfficiency(true), |
ea3e5d95 | 27 | fDebug(0) |
7984e5f7 | 28 | { |
29 | // Constructor | |
30 | } | |
7e4038b5 | 31 | |
32 | //____________________________________________________________________ | |
72cc12cd | 33 | AliFMDCorrector::AliFMDCorrector(const char* title) |
cc83fca2 | 34 | : TNamed("fmdCorrector", title), |
7e4038b5 | 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 | //____________________________________________________________________ | |
72cc12cd | 52 | AliFMDCorrector::AliFMDCorrector(const AliFMDCorrector& o) |
7e4038b5 | 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 | //____________________________________________________________________ | |
72cc12cd | 68 | AliFMDCorrector::~AliFMDCorrector() |
7e4038b5 | 69 | { |
7984e5f7 | 70 | // Destructor |
71 | // | |
72 | // | |
7e4038b5 | 73 | fRingHistos.Delete(); |
74 | } | |
75 | ||
76 | //____________________________________________________________________ | |
72cc12cd | 77 | AliFMDCorrector& |
78 | AliFMDCorrector::operator=(const AliFMDCorrector& o) | |
7e4038b5 | 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 | //____________________________________________________________________ | |
72cc12cd | 97 | AliFMDCorrector::RingHistos* |
98 | AliFMDCorrector::GetRingHistos(UShort_t d, Char_t r) const | |
7e4038b5 | 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 | |
72cc12cd | 122 | AliFMDCorrector::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++) { | |
72cc12cd | 140 | Char_t r = (q == 0 ? 'I' : 'O'); |
141 | TH2D* h = hists.Get(d,r); | |
142 | RingHistos* rh = GetRingHistos(d,r); | |
143 | TH2D* bg = fcm.GetSecondaryMap()->GetCorrection(d, r, uvb); | |
144 | TH2D* ef = fcm.GetVertexBias()->GetCorrection(r, uvb); | |
145 | TH2D* ac = fcm.GetAcceptance()->GetCorrection(d, r, uvb); | |
7e4038b5 | 146 | if (!bg) { |
147 | AliWarning(Form("No secondary correction for FMDM%d%c in vertex bin %d", | |
0bd4b00f | 148 | d, r, uvb)); |
7e4038b5 | 149 | continue; |
150 | } | |
151 | if (!ef) { | |
72cc12cd | 152 | AliWarning(Form("No event %s vertex bias correction in vertex bin %d", |
153 | (r == 'I' || r == 'i' ? "inner" : "outer"), uvb)); | |
154 | continue; | |
155 | } | |
156 | if (!ac) { | |
157 | AliWarning(Form("No acceptance correction for FMD%d%c in vertex bin %d", | |
158 | d, r, uvb)); | |
7e4038b5 | 159 | continue; |
160 | } | |
161 | ||
162 | // Divide by primary/total ratio | |
163 | h->Divide(bg); | |
164 | ||
165 | // Divide by the event selection efficiency | |
166 | h->Divide(ef); | |
167 | ||
72cc12cd | 168 | // Divide by the acceptance correction |
169 | h->Divide(ac); | |
170 | ||
81eda625 | 171 | if (fUseMergingEfficiency) { |
172 | if (!fcm.GetMergingEfficiency()) { | |
173 | AliWarning("No merging efficiencies"); | |
174 | continue; | |
175 | } | |
176 | TH1D* sf = fcm.GetMergingEfficiency()->GetCorrection(d,r,uvb); | |
177 | if (!fcm.GetMergingEfficiency()->GetCorrection(d,r,uvb)) { | |
178 | AliWarning(Form("No merging efficiency for FMD%d%c at vertex bin %d", | |
179 | d, r, uvb)); | |
180 | continue; | |
181 | } | |
7e4038b5 | 182 | |
81eda625 | 183 | |
184 | for (Int_t ieta = 1; ieta <= h->GetNbinsX(); ieta++) { | |
185 | Float_t c = sf->GetBinContent(ieta); | |
186 | Float_t ec = sf->GetBinError(ieta); | |
187 | ||
188 | if (c == 0) continue; | |
7e4038b5 | 189 | |
81eda625 | 190 | for (Int_t iphi = 1; iphi <= h->GetNbinsY(); iphi++) { |
191 | Double_t m = h->GetBinContent(ieta, iphi) / c; | |
192 | Double_t em = h->GetBinError(ieta, iphi); | |
7e4038b5 | 193 | |
81eda625 | 194 | Double_t e = TMath::Sqrt(em * em + (m * ec) * (m * ec)); |
195 | ||
196 | h->SetBinContent(ieta,iphi,m); | |
197 | h->SetBinError(ieta,iphi,e); | |
198 | } | |
7e4038b5 | 199 | } |
200 | } | |
7e4038b5 | 201 | rh->fDensity->Add(h); |
202 | } | |
203 | } | |
204 | ||
205 | return kTRUE; | |
206 | } | |
207 | ||
208 | //____________________________________________________________________ | |
209 | void | |
72cc12cd | 210 | AliFMDCorrector::ScaleHistograms(TList* dir, Int_t nEvents) |
7e4038b5 | 211 | { |
7984e5f7 | 212 | // |
213 | // Scale the histograms to the total number of events | |
214 | // Parameters: | |
215 | // dir Where the output is stored | |
216 | // nEvents Number of events | |
217 | // | |
7e4038b5 | 218 | if (nEvents <= 0) return; |
9d99b0dd | 219 | TList* d = static_cast<TList*>(dir->FindObject(GetName())); |
220 | if (!d) return; | |
7e4038b5 | 221 | |
222 | TIter next(&fRingHistos); | |
223 | RingHistos* o = 0; | |
9d99b0dd | 224 | while ((o = static_cast<RingHistos*>(next()))) |
225 | o->ScaleHistograms(d, nEvents); | |
7e4038b5 | 226 | } |
7e4038b5 | 227 | //____________________________________________________________________ |
228 | void | |
72cc12cd | 229 | AliFMDCorrector::DefineOutput(TList* dir) |
7e4038b5 | 230 | { |
231 | TList* d = new TList; | |
232 | d->SetName(GetName()); | |
233 | dir->Add(d); | |
234 | TIter next(&fRingHistos); | |
235 | RingHistos* o = 0; | |
236 | while ((o = static_cast<RingHistos*>(next()))) { | |
237 | o->Output(d); | |
238 | } | |
239 | } | |
240 | ||
0bd4b00f | 241 | //____________________________________________________________________ |
242 | void | |
72cc12cd | 243 | AliFMDCorrector::Print(Option_t* /* option */) const |
0bd4b00f | 244 | { |
7984e5f7 | 245 | // |
246 | // Print information | |
247 | // Parameters: | |
248 | // option Not used | |
249 | // | |
0bd4b00f | 250 | char ind[gROOT->GetDirLevel()+1]; |
251 | for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' '; | |
252 | ind[gROOT->GetDirLevel()] = '\0'; | |
72cc12cd | 253 | std::cout << ind << "AliFMDCorrector: " << GetName() << std::endl; |
0bd4b00f | 254 | } |
255 | ||
7e4038b5 | 256 | //==================================================================== |
72cc12cd | 257 | AliFMDCorrector::RingHistos::RingHistos() |
9d99b0dd | 258 | : AliForwardUtil::RingHistos(), |
7e4038b5 | 259 | fDensity(0) |
7984e5f7 | 260 | { |
261 | // Constructor | |
262 | // | |
263 | // | |
264 | } | |
7e4038b5 | 265 | |
266 | //____________________________________________________________________ | |
72cc12cd | 267 | AliFMDCorrector::RingHistos::RingHistos(UShort_t d, Char_t r) |
9d99b0dd | 268 | : AliForwardUtil::RingHistos(d,r), |
7e4038b5 | 269 | fDensity(0) |
270 | { | |
7984e5f7 | 271 | // |
272 | // Constructor | |
273 | // Parameters: | |
274 | // d detector | |
275 | // r ring | |
276 | // | |
7e4038b5 | 277 | fDensity = new TH2D(Form("FMD%d%c_Primary_Density", d, r), |
278 | Form("in FMD%d%c", d, r), | |
279 | 200, -4, 6, (r == 'I' || r == 'i' ? 20 : 40), | |
280 | 0, 2*TMath::Pi()); | |
281 | fDensity->SetDirectory(0); | |
282 | fDensity->SetXTitle("#eta"); | |
283 | fDensity->SetYTitle("#phi [radians]"); | |
284 | fDensity->SetZTitle("Primary N_{ch} density"); | |
285 | } | |
286 | //____________________________________________________________________ | |
72cc12cd | 287 | AliFMDCorrector::RingHistos::RingHistos(const RingHistos& o) |
9d99b0dd | 288 | : AliForwardUtil::RingHistos(o), |
7e4038b5 | 289 | fDensity(o.fDensity) |
7984e5f7 | 290 | { |
291 | // | |
292 | // Copy constructor | |
293 | // Parameters: | |
294 | // o Object to copy from | |
295 | // | |
296 | } | |
7e4038b5 | 297 | |
298 | //____________________________________________________________________ | |
72cc12cd | 299 | AliFMDCorrector::RingHistos& |
300 | AliFMDCorrector::RingHistos::operator=(const RingHistos& o) | |
7e4038b5 | 301 | { |
7984e5f7 | 302 | // |
303 | // Assignment operator | |
304 | // Parameters: | |
305 | // o Object to assign from | |
306 | // | |
307 | // Return: | |
308 | // Reference to this | |
309 | // | |
9d99b0dd | 310 | AliForwardUtil::RingHistos::operator=(o); |
7e4038b5 | 311 | |
312 | if (fDensity) delete fDensity; | |
313 | ||
314 | fDensity = static_cast<TH2D*>(o.fDensity->Clone()); | |
315 | ||
316 | return *this; | |
317 | } | |
318 | //____________________________________________________________________ | |
72cc12cd | 319 | AliFMDCorrector::RingHistos::~RingHistos() |
7e4038b5 | 320 | { |
7984e5f7 | 321 | // |
322 | // Destructor | |
323 | // | |
7e4038b5 | 324 | if (fDensity) delete fDensity; |
325 | } | |
326 | ||
327 | //____________________________________________________________________ | |
328 | void | |
72cc12cd | 329 | AliFMDCorrector::RingHistos::Output(TList* dir) |
7e4038b5 | 330 | { |
7984e5f7 | 331 | // |
332 | // Make output | |
333 | // Parameters: | |
334 | // dir Where to put it | |
335 | // | |
9d99b0dd | 336 | TList* d = DefineOutputList(dir); |
7e4038b5 | 337 | d->Add(fDensity); |
9d99b0dd | 338 | } |
339 | ||
340 | //____________________________________________________________________ | |
341 | void | |
72cc12cd | 342 | AliFMDCorrector::RingHistos::ScaleHistograms(TList* dir, Int_t nEvents) |
9d99b0dd | 343 | { |
7984e5f7 | 344 | // |
345 | // Scale the histograms to the total number of events | |
346 | // Parameters: | |
347 | // dir where the output is stored | |
348 | // nEvents Number of events | |
349 | // | |
9d99b0dd | 350 | TList* l = GetOutputList(dir); |
351 | if (!l) return; | |
352 | ||
353 | TH1* density = GetOutputHist(l,Form("%s_Primary_Density", fName.Data())); | |
354 | if (density) density->Scale(1./nEvents); | |
7e4038b5 | 355 | } |
356 | ||
357 | //____________________________________________________________________ | |
358 | // | |
359 | // EOF | |
360 | // | |
361 | ||
362 | ||
363 |