]>
Commit | Line | Data |
---|---|---|
7984e5f7 | 1 | // |
2 | // This class collects the event histograms into single histograms, | |
3 | // one for each ring in each vertex bin. | |
4 | // | |
5 | // Input: | |
6 | // - AliESDFMD object possibly corrected for sharing | |
7 | // | |
8 | // Output: | |
9 | // - 5 RingHistos objects - each with a number of vertex dependent | |
10 | // 2D histograms of the inclusive charge particle density | |
11 | // | |
12 | // HistCollector used: | |
13 | // - AliFMDCorrSecondaryMap | |
14 | // | |
7e4038b5 | 15 | #include "AliFMDHistCollector.h" |
16 | #include <AliESDFMD.h> | |
17 | #include <TAxis.h> | |
18 | #include <TList.h> | |
19 | #include <TMath.h> | |
0bd4b00f | 20 | #include "AliForwardCorrectionManager.h" |
7e4038b5 | 21 | #include "AliLog.h" |
22 | #include <TH2D.h> | |
23 | #include <TH1I.h> | |
24 | #include <TProfile.h> | |
25 | #include <TProfile2D.h> | |
26 | #include <TArrayI.h> | |
0bd4b00f | 27 | #include <TROOT.h> |
28 | #include <iostream> | |
29 | #include <iomanip> | |
7e4038b5 | 30 | |
31 | ClassImp(AliFMDHistCollector) | |
32 | #if 0 | |
33 | ; // For Emacs | |
34 | #endif | |
35 | ||
5bb5d1f6 | 36 | //____________________________________________________________________ |
37 | AliFMDHistCollector::AliFMDHistCollector() | |
38 | : fNCutBins(0), | |
39 | fCorrectionCut(0), | |
40 | fFirstBins(), | |
41 | fLastBins(), | |
42 | fDebug(0), | |
43 | fList(0), | |
44 | fSumRings(0), | |
45 | fCoverage(0), | |
46 | fMergeMethod(kStraightMean), | |
47 | fFiducialMethod(kByCut) | |
48 | {} | |
49 | ||
50 | //____________________________________________________________________ | |
51 | AliFMDHistCollector::AliFMDHistCollector(const char* title) | |
52 | : TNamed("fmdHistCollector", title), | |
53 | fNCutBins(2), | |
54 | fCorrectionCut(0.5), | |
55 | fFirstBins(1), | |
56 | fLastBins(1), | |
57 | fDebug(0), | |
58 | fList(0), | |
59 | fSumRings(0), | |
60 | fCoverage(0), | |
61 | fMergeMethod(kStraightMean), | |
62 | fFiducialMethod(kByCut) | |
63 | { | |
64 | } | |
65 | //____________________________________________________________________ | |
66 | AliFMDHistCollector::AliFMDHistCollector(const AliFMDHistCollector& o) | |
67 | : TNamed(o), | |
68 | fNCutBins(o.fNCutBins), | |
69 | fCorrectionCut(o.fCorrectionCut), | |
70 | fFirstBins(o.fFirstBins), | |
71 | fLastBins(o.fLastBins), | |
72 | fDebug(o.fDebug), | |
73 | fList(o.fList), | |
74 | fSumRings(o.fSumRings), | |
75 | fCoverage(o.fCoverage), | |
76 | fMergeMethod(o.fMergeMethod), | |
77 | fFiducialMethod(o.fFiducialMethod) | |
78 | {} | |
79 | ||
12fffad7 | 80 | //____________________________________________________________________ |
81 | AliFMDHistCollector::~AliFMDHistCollector() | |
82 | { | |
83 | if (fList) delete fList; | |
84 | } | |
7e4038b5 | 85 | //____________________________________________________________________ |
86 | AliFMDHistCollector& | |
87 | AliFMDHistCollector::operator=(const AliFMDHistCollector& o) | |
88 | { | |
7984e5f7 | 89 | // |
90 | // Assignement operator | |
91 | // | |
92 | // Parameters: | |
93 | // o Object to assign from | |
94 | // | |
95 | // Return: | |
96 | // Reference to this object | |
97 | // | |
d015ecfe | 98 | if (&o == this) return *this; |
ea3e5d95 | 99 | TNamed::operator=(o); |
7e4038b5 | 100 | |
101 | fNCutBins = o.fNCutBins; | |
102 | fCorrectionCut = o.fCorrectionCut; | |
103 | fFirstBins = o.fFirstBins; | |
104 | fLastBins = o.fLastBins; | |
ea3e5d95 | 105 | fDebug = o.fDebug; |
12fffad7 | 106 | fList = o.fList; |
107 | fSumRings = o.fSumRings; | |
108 | fCoverage = o.fCoverage; | |
e1f47419 | 109 | fMergeMethod = o.fMergeMethod; |
110 | fFiducialMethod = o.fFiducialMethod; | |
5bb5d1f6 | 111 | |
7e4038b5 | 112 | return *this; |
113 | } | |
114 | ||
115 | //____________________________________________________________________ | |
116 | void | |
12fffad7 | 117 | AliFMDHistCollector::Init(const TAxis& vtxAxis, |
118 | const TAxis& etaAxis) | |
7e4038b5 | 119 | { |
7984e5f7 | 120 | // |
121 | // Intialise | |
122 | // | |
123 | // Parameters: | |
124 | // vtxAxis Vertex axis | |
125 | // | |
126 | ||
0bd4b00f | 127 | AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance(); |
7e4038b5 | 128 | |
12fffad7 | 129 | fSumRings = new TH2D("sumRings", "Sum in individual rings", |
130 | etaAxis.GetNbins(), etaAxis.GetXmin(), etaAxis.GetXmax(), | |
131 | 5, 1, 6); | |
132 | fSumRings->Sumw2(); | |
133 | fSumRings->SetDirectory(0); | |
134 | fSumRings->SetXTitle("#eta"); | |
135 | fSumRings->GetYaxis()->SetBinLabel(1,"FMD1i"); | |
136 | fSumRings->GetYaxis()->SetBinLabel(2,"FMD2i"); | |
137 | fSumRings->GetYaxis()->SetBinLabel(3,"FMD2o"); | |
138 | fSumRings->GetYaxis()->SetBinLabel(4,"FMD3i"); | |
139 | fSumRings->GetYaxis()->SetBinLabel(5,"FMD3o"); | |
140 | fList->Add(fSumRings); | |
141 | ||
142 | fCoverage = new TH2D("coverage", "#eta coverage per v_{z}", | |
e1f47419 | 143 | etaAxis.GetNbins(),etaAxis.GetXmin(),etaAxis.GetXmax(), |
144 | vtxAxis.GetNbins(),vtxAxis.GetXmin(),vtxAxis.GetXmax()); | |
12fffad7 | 145 | fCoverage->SetDirectory(0); |
146 | fCoverage->SetXTitle("#eta"); | |
147 | fCoverage->SetYTitle("v_{z} [cm]"); | |
148 | fCoverage->SetZTitle("n_{bins}"); | |
149 | fList->Add(fCoverage); | |
150 | ||
0bd4b00f | 151 | UShort_t nVz = vtxAxis.GetNbins(); |
7e4038b5 | 152 | fFirstBins.Set(5*nVz); |
153 | fLastBins.Set(5*nVz); | |
154 | ||
155 | // Find the eta bin ranges | |
0bd4b00f | 156 | for (UShort_t iVz = 1; iVz <= nVz; iVz++) { |
e1f47419 | 157 | TList* vtxList = new TList; |
158 | Double_t vMin = vtxAxis.GetBinLowEdge(iVz); | |
159 | Double_t vMax = vtxAxis.GetBinUpEdge(iVz); | |
160 | vtxList->SetName(Form("%c%02d_%c%02d", | |
161 | vMin < 0 ? 'm' : 'p', int(TMath::Abs(vMin)), | |
162 | vMax < 0 ? 'm' : 'p', int(TMath::Abs(vMax)))); | |
163 | fList->Add(vtxList); | |
164 | ||
7e4038b5 | 165 | // Find the first and last eta bin to use for each ring for |
166 | // each vertex bin. This is instead of using the methods | |
167 | // provided by AliFMDAnaParameters | |
168 | for (Int_t iIdx = 0; iIdx < 5; iIdx++) { | |
169 | UShort_t d = 0; | |
170 | Char_t r = 0; | |
171 | GetDetRing(iIdx, d, r); | |
172 | ||
173 | // Get the background object | |
0bd4b00f | 174 | // TH2F* bg = pars->GetBackgroundCorrection(d,r,iVz); |
175 | TH2D* bg = fcm.GetSecondaryMap()->GetCorrection(d,r,iVz); | |
7e4038b5 | 176 | Int_t nEta = bg->GetNbinsX(); |
177 | Int_t first = nEta+1; | |
178 | Int_t last = 0; | |
179 | ||
180 | // Loop over the eta bins | |
181 | for (Int_t ie = 1; ie <= nEta; ie++) { | |
7e4038b5 | 182 | // Loop over the phi bins to make sure that we |
183 | // do not have holes in the coverage | |
184 | bool ok = true; | |
185 | for (Int_t ip = 1; ip <= bg->GetNbinsY(); ip++) { | |
e1f47419 | 186 | if (!CheckCorrection(bg, ie, ip)) { |
7e4038b5 | 187 | ok = false; |
188 | continue; | |
189 | } | |
190 | } | |
191 | if (!ok) continue; | |
192 | ||
193 | first = TMath::Min(ie, first); | |
194 | last = TMath::Max(ie, last); | |
195 | } | |
196 | ||
197 | // Store the result for later use | |
0bd4b00f | 198 | fFirstBins[(iVz-1)*5+iIdx] = first; |
199 | fLastBins[(iVz-1)*5+iIdx] = last; | |
5bb5d1f6 | 200 | TH2D* obg = static_cast<TH2D*>(bg->Clone(Form("secMapFMD%d%c", d, r))); |
e1f47419 | 201 | obg->SetDirectory(0); |
202 | obg->Reset(); | |
203 | vtxList->Add(obg); | |
73e536c6 | 204 | |
205 | TH2D* hitmap = static_cast<TH2D*>(bg->Clone(Form("hitMapFMD%d%c", d, r))); | |
206 | if(r == 'O') hitmap->RebinY(2); | |
207 | hitmap->SetDirectory(0); | |
208 | hitmap->GetZaxis()->SetTitle(""); | |
209 | hitmap->Reset(); | |
210 | vtxList->Add(hitmap); | |
e1f47419 | 211 | |
212 | // Fill diagnostics histograms | |
213 | for (Int_t ie = first+fNCutBins; ie <= last-fNCutBins; ie++) { | |
214 | Double_t old = fCoverage->GetBinContent(ie, iVz); | |
215 | fCoverage->SetBinContent(ie, iVz, old+1); | |
216 | for (Int_t ip = 1; ip <= bg->GetNbinsY(); ip++) { | |
217 | obg->SetBinContent(ie, ip, bg->GetBinContent(ie, ip)); | |
218 | obg->SetBinError(ie, ip, bg->GetBinError(ie, ip)); | |
219 | } | |
12fffad7 | 220 | } |
7e4038b5 | 221 | } // for j |
222 | } | |
223 | } | |
224 | ||
e1f47419 | 225 | //____________________________________________________________________ |
226 | Bool_t | |
227 | AliFMDHistCollector::CheckCorrection(const TH2D* bg, Int_t ie, Int_t ip) const | |
228 | { | |
229 | // | |
230 | // Check if we should include the bin in the data range | |
231 | // | |
232 | // Parameters: | |
233 | // bg Secondary map histogram | |
234 | // ie Eta bin | |
235 | // ip Phi bin | |
236 | // | |
237 | // Return: | |
238 | // True if to be used | |
239 | // | |
240 | Double_t c = bg->GetBinContent(ie,ip); | |
241 | switch (fFiducialMethod) { | |
242 | case kByCut: | |
243 | return c >= fCorrectionCut; | |
244 | case kDistance: | |
245 | if (2 * c < bg->GetBinContent(ie+1,ip) || | |
246 | 2 * c < bg->GetBinContent(ie-1,ip)) return false; | |
247 | return true; | |
248 | default: | |
249 | AliError("No fiducal cut method defined"); | |
250 | } | |
251 | return false; | |
252 | } | |
253 | ||
12fffad7 | 254 | //____________________________________________________________________ |
255 | void | |
256 | AliFMDHistCollector::DefineOutput(TList* dir) | |
257 | { | |
258 | // | |
259 | // Output diagnostic histograms to directory | |
260 | // | |
261 | // Parameters: | |
262 | // dir List to write in | |
263 | // | |
264 | fList = new TList; | |
265 | fList->SetOwner(); | |
266 | fList->SetName(GetName()); | |
267 | dir->Add(fList); | |
5bb5d1f6 | 268 | |
12fffad7 | 269 | } |
270 | ||
5bb5d1f6 | 271 | |
7e4038b5 | 272 | //____________________________________________________________________ |
273 | Int_t | |
274 | AliFMDHistCollector::GetIdx(UShort_t d, Char_t r) const | |
275 | { | |
7984e5f7 | 276 | // |
277 | // Get the ring index from detector number and ring identifier | |
278 | // | |
279 | // Parameters: | |
280 | // d Detector | |
281 | // r Ring identifier | |
282 | // | |
283 | // Return: | |
284 | // ring index or -1 in case of problems | |
285 | // | |
7e4038b5 | 286 | Int_t idx = -1; |
287 | switch (d) { | |
288 | case 1: idx = 0; break; | |
289 | case 2: idx = 1 + (r == 'I' || r == 'i' ? 0 : 1); break; | |
290 | case 3: idx = 3 + (r == 'I' || r == 'i' ? 0 : 1); break; | |
291 | } | |
292 | return idx; | |
293 | } | |
294 | //____________________________________________________________________ | |
295 | void | |
296 | AliFMDHistCollector::GetDetRing(Int_t idx, UShort_t& d, Char_t& r) const | |
297 | { | |
7984e5f7 | 298 | // |
299 | // Get the detector and ring from the ring index | |
300 | // | |
301 | // Parameters: | |
302 | // idx Ring index | |
303 | // d On return, the detector or 0 in case of errors | |
304 | // r On return, the ring id or '0' in case of errors | |
305 | // | |
7e4038b5 | 306 | d = 0; |
307 | r = '\0'; | |
308 | switch (idx) { | |
309 | case 0: d = 1; r = 'I'; break; | |
310 | case 1: d = 2; r = 'I'; break; | |
311 | case 2: d = 2; r = 'O'; break; | |
312 | case 3: d = 3; r = 'I'; break; | |
313 | case 4: d = 3; r = 'O'; break; | |
314 | } | |
315 | } | |
316 | ||
317 | //____________________________________________________________________ | |
318 | void | |
0bd4b00f | 319 | AliFMDHistCollector::GetFirstAndLast(Int_t idx, UShort_t vtxbin, |
7e4038b5 | 320 | Int_t& first, Int_t& last) const |
321 | { | |
7984e5f7 | 322 | // |
323 | // Get the first and last eta bin to use for a given ring and vertex | |
324 | // | |
325 | // Parameters: | |
326 | // idx Ring index as given by GetIdx | |
327 | // vtxBin Vertex bin (1 based) | |
328 | // first On return, the first eta bin to use | |
329 | // last On return, the last eta bin to use | |
330 | // | |
7e4038b5 | 331 | first = 0; |
332 | last = 0; | |
333 | ||
0bd4b00f | 334 | if (idx < 0) return; |
335 | if (vtxbin <= 0) return; | |
336 | idx += (vtxbin-1) * 5; | |
7e4038b5 | 337 | |
338 | if (idx < 0 || idx >= fFirstBins.GetSize()) return; | |
339 | ||
340 | first = fFirstBins.At(idx)+fNCutBins; | |
341 | last = fLastBins.At(idx)-fNCutBins; | |
342 | } | |
343 | ||
344 | //____________________________________________________________________ | |
345 | Int_t | |
0bd4b00f | 346 | AliFMDHistCollector::GetFirst(Int_t idx, UShort_t v) const |
7e4038b5 | 347 | { |
7984e5f7 | 348 | // |
349 | // Get the first eta bin to use for a given ring and vertex | |
350 | // | |
351 | // Parameters: | |
352 | // idx Ring index as given by GetIdx | |
353 | // v vertex bin (1 based) | |
354 | // | |
355 | // Return: | |
356 | // First eta bin to use, or -1 in case of problems | |
357 | // | |
7e4038b5 | 358 | Int_t f, l; |
359 | GetFirstAndLast(idx,v,f,l); | |
360 | return f; | |
361 | } | |
362 | ||
363 | ||
364 | //____________________________________________________________________ | |
365 | Int_t | |
0bd4b00f | 366 | AliFMDHistCollector::GetLast(Int_t idx, UShort_t v) const |
7e4038b5 | 367 | { |
7984e5f7 | 368 | // |
369 | // Get the last eta bin to use for a given ring and vertex | |
370 | // | |
371 | // Parameters: | |
372 | // idx Ring index as given by GetIdx | |
373 | // v vertex bin (1 based) | |
374 | // | |
375 | // Return: | |
376 | // Last eta bin to use, or -1 in case of problems | |
377 | // | |
7e4038b5 | 378 | Int_t f, l; |
379 | GetFirstAndLast(idx,v,f,l); | |
380 | return l; | |
381 | } | |
382 | ||
383 | //____________________________________________________________________ | |
384 | Int_t | |
385 | AliFMDHistCollector::GetOverlap(UShort_t d, Char_t r, | |
0bd4b00f | 386 | Int_t bin, UShort_t vtxbin) const |
7e4038b5 | 387 | { |
7984e5f7 | 388 | // |
389 | // Get the possibly overlapping histogram of eta bin @a e in | |
390 | // detector and ring | |
391 | // | |
392 | // Parameters: | |
393 | // d Detector | |
394 | // r Ring | |
395 | // e Eta bin | |
396 | // v Vertex bin (1 based) | |
397 | // | |
398 | // Return: | |
399 | // Overlapping histogram index or -1 | |
400 | // | |
401 | ||
7e4038b5 | 402 | Int_t other = -1; |
403 | if (d == 1) { | |
404 | if (bin <= GetLast(2,'I',vtxbin)) other = GetIdx(2,'I'); | |
405 | } | |
406 | else if (d == 2 && r == 'I') { | |
407 | if (bin <= GetLast(2, 'O', vtxbin)) other = GetIdx(2, 'O'); | |
408 | else if (bin >= GetFirst(1, 'I', vtxbin)) other = GetIdx(1, 'I'); | |
409 | } | |
410 | else if (d == 2 && r == 'O') { | |
411 | if (bin >= GetFirst(2, 'I', vtxbin)) other = GetIdx(2,'I'); | |
412 | } | |
413 | else if (d == 3 && r == 'O') { | |
414 | if (bin <= GetLast(3, 'I', vtxbin)) other = GetIdx(3, 'I'); | |
415 | } | |
416 | else if (d == 3 && r == 'I') { | |
417 | if (bin >= GetFirst(3, 'O', vtxbin)) other = GetIdx(3, 'O'); | |
418 | } | |
419 | // AliInfo(Form("FMD%d%c (%d) -> %d", d, r, GetIdx(d,r), other)); | |
420 | return other; | |
421 | } | |
422 | //____________________________________________________________________ | |
423 | Int_t | |
0bd4b00f | 424 | AliFMDHistCollector::GetOverlap(Int_t idx, Int_t bin, UShort_t vtxbin) const |
7e4038b5 | 425 | { |
7984e5f7 | 426 | // |
427 | // Get the possibly overlapping histogram of eta bin @a e in | |
428 | // detector and ring | |
429 | // | |
430 | // Parameters: | |
431 | // i Ring index | |
432 | // e Eta bin | |
433 | // v Vertex bin (1 based) | |
434 | // | |
435 | // Return: | |
436 | // Overlapping histogram index or -1 | |
437 | // | |
7e4038b5 | 438 | UShort_t d = 0; |
439 | Char_t r = '\0'; | |
440 | GetDetRing(idx, d, r); | |
441 | if (d == 0 || r == '\0') return 0; | |
442 | ||
443 | return GetOverlap(d, r, bin, vtxbin); | |
444 | } | |
445 | ||
446 | ||
e1f47419 | 447 | //____________________________________________________________________ |
448 | void | |
449 | AliFMDHistCollector::MergeBins(Double_t c, Double_t e, | |
450 | Double_t oc, Double_t oe, | |
451 | Double_t& rc, Double_t& re) const | |
452 | { | |
453 | // | |
454 | // Merge bins accoring to set method | |
455 | // | |
456 | // Parameters: | |
457 | // c Current content | |
458 | // e Current error | |
459 | // oc Old content | |
460 | // oe Old error | |
461 | // rc On return, the new content | |
462 | // re On return, tne new error | |
463 | // | |
464 | rc = re = 0; | |
465 | switch (fMergeMethod) { | |
466 | case kStraightMean: | |
467 | // calculate the average of old value (half the original), | |
468 | // and this value, as well as the summed squared errors | |
469 | // of the existing content (sqrt((e_1/2)^2=sqrt(e_1^2/4)=e_1/2) | |
470 | // and half the error of this. | |
471 | // | |
472 | // So, on the first overlapping histogram we get | |
473 | // | |
474 | // c = c_1 / 2 | |
475 | // e = sqrt((e_1 / 2)^2) = e_1/2 | |
476 | // | |
477 | // On the second we get | |
478 | // | |
479 | // c' = c_2 / 2 + c = c_2 / 2 + c_1 / 2 = (c_1+c_2)/2 | |
480 | // e' = sqrt(e^2 + (e_2/2)^2) | |
481 | // = sqrt(e_1^2/4 + e_2^2/4) | |
482 | // = sqrt(1/4 * (e_1^2+e_2^2)) | |
483 | // = 1/2 * sqrt(e_1^2 + e_2^2) | |
484 | rc = oc + c/2; | |
485 | re = TMath::Sqrt(oe*oe+(e*e)/4); | |
486 | break; | |
487 | case kStraightMeanNoZero: | |
488 | // If there's data in the overlapping histogram, | |
489 | // calculate the average and add the errors in | |
490 | // quadrature. | |
491 | // | |
492 | // If there's no data in the overlapping histogram, | |
493 | // then just fill in the data | |
494 | if (oe > 0) { | |
495 | rc = (oc + c)/2; | |
496 | re = TMath::Sqrt(oe*oe + e*e)/2; | |
497 | } | |
498 | else { | |
499 | rc = c; | |
500 | re = e; | |
501 | } | |
502 | break; | |
503 | case kWeightedMean: { | |
504 | // Calculate the weighted mean | |
505 | Double_t w = 1/(e*e); | |
506 | Double_t sc = w * c; | |
507 | Double_t sw = w; | |
508 | if (oe > 0) { | |
509 | Double_t ow = 1/(oe*oe); | |
510 | sc += ow * oc; | |
511 | sw += ow; | |
512 | } | |
513 | rc = sc / sw; | |
514 | re = TMath::Sqrt(1 / sw); | |
515 | } | |
516 | break; | |
517 | case kLeastError: | |
518 | if (e < oe) { | |
519 | rc = c; | |
520 | re = e; | |
521 | } | |
522 | else { | |
523 | rc = oc; | |
524 | re = oe; | |
525 | } | |
526 | break; | |
527 | default: | |
528 | AliError("No method for defining content of overlapping bins defined"); | |
529 | return; | |
530 | } | |
531 | } | |
532 | ||
7e4038b5 | 533 | //____________________________________________________________________ |
534 | Bool_t | |
5bb5d1f6 | 535 | AliFMDHistCollector::Collect(const AliForwardUtil::Histos& hists, |
536 | AliForwardUtil::Histos& sums, | |
0bd4b00f | 537 | UShort_t vtxbin, |
7e4038b5 | 538 | TH2D& out) |
539 | { | |
7984e5f7 | 540 | // |
541 | // Do the calculations | |
542 | // | |
543 | // Parameters: | |
544 | // hists Cache of histograms | |
545 | // vtxBin Vertex bin (1 based) | |
546 | // out Output histogram | |
547 | // | |
548 | // Return: | |
549 | // true on successs | |
550 | // | |
73e536c6 | 551 | AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance(); |
552 | const TAxis* vtxAxis = fcm.GetVertexAxis(); | |
553 | Double_t vMin = vtxAxis->GetBinLowEdge(vtxbin); | |
554 | Double_t vMax = vtxAxis->GetBinUpEdge(vtxbin); | |
555 | TList* vtxList | |
556 | = static_cast<TList*>(fList->FindObject(Form("%c%02d_%c%02d", | |
557 | vMin < 0 ? 'm' : 'p', | |
558 | int(TMath::Abs(vMin)), | |
559 | vMax < 0 ? 'm' : 'p', | |
560 | int(TMath::Abs(vMax))))); | |
561 | ||
562 | ||
7e4038b5 | 563 | for (UShort_t d=1; d<=3; d++) { |
564 | UShort_t nr = (d == 1 ? 1 : 2); | |
565 | for (UShort_t q=0; q<nr; q++) { | |
566 | Char_t r = (q == 0 ? 'I' : 'O'); | |
567 | TH2D* h = hists.Get(d,r); | |
568 | TH2D* t = static_cast<TH2D*>(h->Clone(Form("FMD%d%c_tmp",d,r))); | |
12fffad7 | 569 | Int_t i = (d == 1 ? 1 : 2*d + (q == 0 ? -2 : -1)); |
5bb5d1f6 | 570 | TH2D* o = sums.Get(d, r); |
12fffad7 | 571 | |
5bb5d1f6 | 572 | // Get valid range |
7e4038b5 | 573 | Int_t first = 0; |
574 | Int_t last = 0; | |
575 | GetFirstAndLast(d, r, vtxbin, first, last); | |
5bb5d1f6 | 576 | |
577 | // Zero outside valid range | |
578 | for (Int_t iPhi = 0; iPhi <= t->GetNbinsY()+1; iPhi++) { | |
579 | // Lower range | |
580 | for (Int_t iEta = 1; iEta < first; iEta++) { | |
581 | t->SetBinContent(iEta,iPhi,0); | |
582 | t->SetBinError(iEta,iPhi,0); | |
583 | } | |
584 | for (Int_t iEta = last+1; iEta <= t->GetNbinsX(); iEta++) { | |
585 | t->SetBinContent(iEta,iPhi,0); | |
586 | t->SetBinError(iEta,iPhi,0); | |
587 | } | |
588 | } | |
589 | for (Int_t iEta = first; iEta <= last; iEta++) | |
590 | t->SetBinContent(iEta,0,1); | |
591 | // Add to our per-ring sum | |
592 | o->Add(t); | |
593 | ||
594 | // Outer rings have better phi segmentation - rebin to same as inner. | |
595 | if (q == 1) t->RebinY(2); | |
7e4038b5 | 596 | |
597 | // Now update profile output | |
598 | for (Int_t iEta = first; iEta <= last; iEta++) { | |
599 | ||
600 | // Get the possibly overlapping histogram | |
601 | Int_t overlap = GetOverlap(d,r,iEta,vtxbin); | |
602 | ||
603 | // Fill eta acceptance for this event into the phi underlow bin | |
604 | Float_t ooc = out.GetBinContent(iEta,0); | |
605 | Float_t noc = overlap >= 0? 0.5 : 1; | |
606 | out.SetBinContent(iEta, 0, ooc + noc); | |
607 | ||
5bb5d1f6 | 608 | // Should we loop over h or t Y bins - I think it's t |
609 | for (Int_t iPhi = 1; iPhi <= t->GetNbinsY(); iPhi++) { | |
12fffad7 | 610 | Double_t c = t->GetBinContent(iEta,iPhi); |
611 | Double_t e = t->GetBinError(iEta,iPhi); | |
612 | Double_t ee = t->GetXaxis()->GetBinCenter(iEta); | |
613 | fSumRings->Fill(ee, i, c); | |
7e4038b5 | 614 | |
615 | // If there's no signal, continue | |
616 | // if (e <= 0) continue; | |
617 | if (c <= 0 || e <= 0) continue; | |
618 | ||
619 | // If there's no overlapping histogram (ring), then | |
620 | // fill in data and continue to the next phi bin | |
621 | if (overlap < 0) { | |
622 | out.SetBinContent(iEta,iPhi,c); | |
623 | out.SetBinError(iEta,iPhi,e); | |
624 | continue; | |
625 | } | |
626 | ||
627 | // Get the current bin content and error | |
628 | Double_t oc = out.GetBinContent(iEta,iPhi); | |
629 | Double_t oe = out.GetBinError(iEta,iPhi); | |
630 | ||
e1f47419 | 631 | Double_t rc, re; |
632 | MergeBins(c, e, oc, oe, rc, re); | |
633 | out.SetBinContent(iEta,iPhi, rc); | |
634 | out.SetBinError(iEta,iPhi, re); | |
7e4038b5 | 635 | } |
636 | } | |
637 | // Remove temporary histogram | |
73e536c6 | 638 | TH2D* hRingSumVtx |
639 | = static_cast<TH2D*>(vtxList->FindObject(Form("hitMapFMD%d%c", d, r))); | |
640 | hRingSumVtx->Add(t); | |
7e4038b5 | 641 | delete t; |
642 | } // for r | |
643 | } // for d | |
644 | return kTRUE; | |
645 | } | |
646 | ||
0bd4b00f | 647 | //____________________________________________________________________ |
648 | void | |
649 | AliFMDHistCollector::Print(Option_t* /* option */) const | |
650 | { | |
7984e5f7 | 651 | // |
652 | // Print information | |
653 | // | |
654 | // Parameters: | |
655 | // option Not used | |
656 | // | |
0bd4b00f | 657 | char ind[gROOT->GetDirLevel()+1]; |
658 | for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' '; | |
659 | ind[gROOT->GetDirLevel()] = '\0'; | |
1f480471 | 660 | std::cout << ind << ClassName() << ": " << GetName() << '\n' |
0bd4b00f | 661 | << ind << " # of cut bins: " << fNCutBins << '\n' |
662 | << ind << " Correction cut: " << fCorrectionCut << '\n' | |
e1f47419 | 663 | << ind << " Merge method: "; |
664 | switch (fMergeMethod) { | |
665 | case kStraightMean: std::cout << "straight mean\n"; break; | |
666 | case kStraightMeanNoZero: std::cout << "straight mean (no zeros)\n"; break; | |
667 | case kWeightedMean: std::cout << "weighted mean\n"; break; | |
668 | case kLeastError: std::cout << "least error\n"; break; | |
669 | } | |
670 | ||
5bb5d1f6 | 671 | std::cout << ind << " Bin ranges:\n" << ind << " rings "; |
0bd4b00f | 672 | Int_t nVz = fFirstBins.fN / 5; |
0bd4b00f | 673 | for (Int_t iIdx = 0; iIdx < 5; iIdx++) { |
674 | UShort_t d = 0; | |
675 | Char_t r = 0; | |
676 | GetDetRing(iIdx, d, r); | |
5bb5d1f6 | 677 | std::cout << ind << " | FMD" << d << r << " "; |
678 | } | |
679 | std::cout << '\n' << ind << " /vz_bin "; | |
680 | for (Int_t iIdx = 0; iIdx < 5; iIdx++) | |
681 | std::cout << "-+--------"; | |
682 | std::cout << std::endl; | |
683 | ||
684 | for (UShort_t iVz = 1; iVz <= nVz; iVz++) { | |
685 | std::cout << " " << std::setw(7) << iVz << " "; | |
686 | for (Int_t iIdx = 0; iIdx < 5; iIdx++) { | |
687 | UShort_t d = 0; | |
688 | Char_t r = 0; | |
689 | GetDetRing(iIdx, d, r); | |
0bd4b00f | 690 | |
0bd4b00f | 691 | Int_t first, last; |
692 | GetFirstAndLast(iIdx, iVz, first, last); | |
693 | std::cout << " | " << std::setw(3) << first << "-" | |
694 | << std::setw(3) << last; | |
695 | } | |
696 | std::cout << std::endl; | |
697 | } | |
698 | } | |
7e4038b5 | 699 | |
700 | //____________________________________________________________________ | |
701 | // | |
702 | // EOF | |
703 | // | |
704 | ||
705 | ||
706 |