1 #include "AliFMDDensityCalculator.h"
6 #include "AliForwardCorrectionManager.h"
7 // #include "AliFMDAnaParameters.h"
15 ClassImp(AliFMDDensityCalculator)
20 //____________________________________________________________________
21 AliFMDDensityCalculator::AliFMDDensityCalculator()
34 //____________________________________________________________________
35 AliFMDDensityCalculator::AliFMDDensityCalculator(const char* title)
36 : TNamed("fmdDensityCalculator", title),
47 fRingHistos.SetName(GetName());
48 fRingHistos.Add(new RingHistos(1, 'I'));
49 fRingHistos.Add(new RingHistos(2, 'I'));
50 fRingHistos.Add(new RingHistos(2, 'O'));
51 fRingHistos.Add(new RingHistos(3, 'I'));
52 fRingHistos.Add(new RingHistos(3, 'O'));
53 fSumOfWeights = new TH1D("sumOfWeights", "Sum of Landau weights",
55 fSumOfWeights->SetFillColor(kRed+1);
56 fSumOfWeights->SetXTitle("#sum_{i} a_{i} f_{i}(#Delta)");
57 fWeightedSum = new TH1D("weightedSum", "Weighted sum of Landau propability",
59 fWeightedSum->SetFillColor(kBlue+1);
60 fWeightedSum->SetXTitle("#sum_{i} i a_{i} f_{i}(#Delta)");
61 fCorrections = new TH1D("corrections", "Distribution of corrections",
63 fCorrections->SetFillColor(kBlue+1);
64 fCorrections->SetXTitle("correction");
66 fAccI = GenerateAcceptanceCorrection('I');
67 fAccO = GenerateAcceptanceCorrection('O');
70 //____________________________________________________________________
71 AliFMDDensityCalculator::AliFMDDensityCalculator(const
72 AliFMDDensityCalculator& o)
76 fSumOfWeights(o.fSumOfWeights),
77 fWeightedSum(o.fWeightedSum),
78 fCorrections(o.fCorrections),
79 fMaxParticles(o.fMaxParticles),
84 TIter next(&o.fRingHistos);
86 while ((obj = next())) fRingHistos.Add(obj);
89 //____________________________________________________________________
90 AliFMDDensityCalculator::~AliFMDDensityCalculator()
95 //____________________________________________________________________
96 AliFMDDensityCalculator&
97 AliFMDDensityCalculator::operator=(const AliFMDDensityCalculator& o)
101 fMultCut = o.fMultCut;
103 fMaxParticles = o.fMaxParticles;
107 fRingHistos.Delete();
108 TIter next(&o.fRingHistos);
110 while ((obj = next())) fRingHistos.Add(obj);
115 //____________________________________________________________________
116 AliFMDDensityCalculator::RingHistos*
117 AliFMDDensityCalculator::GetRingHistos(UShort_t d, Char_t r) const
121 case 1: idx = 0; break;
122 case 2: idx = 1 + (r == 'I' || r == 'i' ? 0 : 1); break;
123 case 3: idx = 3 + (r == 'I' || r == 'i' ? 0 : 1); break;
125 if (idx < 0 || idx >= fRingHistos.GetEntries()) return 0;
127 return static_cast<RingHistos*>(fRingHistos.At(idx));
130 //____________________________________________________________________
132 AliFMDDensityCalculator::GetMultCut() const
134 if (fMultCut > 0) return fMultCut;
136 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
137 AliFMDCorrELossFit* fits = fcm.GetELossFit();
138 return fits->GetLowCut();
141 //____________________________________________________________________
143 AliFMDDensityCalculator::Calculate(const AliESDFMD& fmd,
144 AliForwardUtil::Histos& hists,
148 for (UShort_t d=1; d<=3; d++) {
149 UShort_t nr = (d == 1 ? 1 : 2);
150 for (UShort_t q=0; q<nr; q++) {
151 Char_t r = (q == 0 ? 'I' : 'O');
152 UShort_t ns= (q == 0 ? 20 : 40);
153 UShort_t nt= (q == 0 ? 512 : 256);
154 TH2D* h = hists.Get(d,r);
155 RingHistos* rh= GetRingHistos(d,r);
157 for (UShort_t s=0; s<ns; s++) {
158 for (UShort_t t=0; t<nt; t++) {
159 Float_t mult = fmd.Multiplicity(d,r,s,t);
161 if (mult == 0 || mult > 20) continue;
163 Float_t phi = fmd.Phi(d,r,s,t) / 180 * TMath::Pi();
164 Float_t eta = fmd.Eta(d,r,s,t);
166 Float_t n = NParticles(mult,d,r,s,t,vtxbin,eta,lowFlux);
167 rh->fEvsN->Fill(mult,n);
168 rh->fEtaVsN->Fill(eta, n);
170 Float_t c = Correction(d,r,s,t,vtxbin,eta,lowFlux);
171 fCorrections->Fill(c);
173 rh->fEvsM->Fill(mult,n);
174 rh->fEtaVsM->Fill(eta, n);
175 rh->fCorr->Fill(eta, c);
178 rh->fDensity->Fill(eta,phi,n);
187 //_____________________________________________________________________
189 AliFMDDensityCalculator::NParticles(Float_t mult,
196 Bool_t lowFlux) const
198 if (mult <= GetMultCut()) return 0;
199 if (lowFlux) return 1;
201 // AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
202 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
203 AliFMDCorrELossFit::ELossFit* fit = fcm.GetELossFit()->FindFit(d,r,eta);
205 AliWarning(Form("No energy loss fit for FMD%d%c at eta=%f", d, r, eta));
209 Int_t m = fit->FindMaxWeight();
211 AliWarning(Form("No good fits for FMD%d%c at eta=%f", d, r, eta));
214 UShort_t n = TMath::Min(fMaxParticles, UShort_t(m));
215 Double_t ret = fit->EvaluateWeighted(mult, n);
218 AliInfo(Form("FMD%d%c, eta=%7.4f, %8.5f -> %8.5f", d, r, eta, mult, ret));
221 fWeightedSum->Fill(ret);
222 fSumOfWeights->Fill(ret);
226 Float_t mpv = pars->GetMPV(d,r,eta);
227 Float_t w = pars->GetSigma(d,r,eta);
228 Float_t w2 = pars->Get2MIPWeight(d,r,eta);
229 Float_t w3 = pars->Get3MIPWeight(d,r,eta);
230 Float_t mpv2 = 2*mpv+2*w*TMath::Log(2);
231 Float_t mpv3 = 3*mpv+3*w*TMath::Log(3);
233 Float_t sum = (TMath::Landau(mult,mpv,w,kTRUE) +
234 w2 * TMath::Landau(mult,mpv2,2*w,kTRUE) +
235 w3 * TMath::Landau(mult,mpv3,3*w,kTRUE));
236 Float_t wsum = (TMath::Landau(mult,mpv,w,kTRUE) +
237 2*w2 * TMath::Landau(mult,mpv2,2*w,kTRUE) +
238 3*w3 * TMath::Landau(mult,mpv3,3*w,kTRUE));
240 fWeightedSum->Fill(wsum);
241 fSumOfWeights->Fill(sum);
242 return (sum > 0) ? wsum / sum : 1;
246 //_____________________________________________________________________
248 AliFMDDensityCalculator::Correction(UShort_t d,
254 Bool_t lowFlux) const
256 // AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
257 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
259 Float_t correction = AcceptanceCorrection(r,t);
261 // TH1F* dblHitCor = pars->GetDoubleHitCorrection(d,r);
263 if (fcm.GetDoubleHit())
264 dblHitCor = fcm.GetDoubleHit()->GetCorrection(d,r);
267 Double_t dblC = dblHitCor->GetBinContent(dblHitCor->FindBin(eta));
268 if (dblC > 0) correction *= dblC;
271 AliWarning(Form("Missing double hit correction for FMD%d%c",d,r));
276 TH1F* deadCor = pars->GetFMDDeadCorrection(v);
278 Float_t deadC = deadCor->GetBinContent(deadCor->FindBin(eta));
287 //_____________________________________________________________________
289 AliFMDDensityCalculator::GenerateAcceptanceCorrection(Char_t r) const
291 const Double_t ic1[] = { 4.9895, 15.3560 };
292 const Double_t ic2[] = { 1.8007, 17.2000 };
293 const Double_t oc1[] = { 4.2231, 26.6638 };
294 const Double_t oc2[] = { 1.8357, 27.9500 };
295 const Double_t* c1 = (r == 'I' || r == 'i' ? ic1 : oc1);
296 const Double_t* c2 = (r == 'I' || r == 'i' ? ic2 : oc2);
297 Double_t minR = (r == 'I' || r == 'i' ? 4.5213 : 15.4);
298 Double_t maxR = (r == 'I' || r == 'i' ? 17.2 : 28.0);
299 Int_t nStrips = (r == 'I' || r == 'i' ? 512 : 256);
300 Int_t nSec = (r == 'I' || r == 'i' ? 20 : 40);
301 Float_t basearc = 2 * TMath::Pi() / nSec;
302 Double_t rad = maxR - minR;
303 Float_t segment = rad / nStrips;
304 Float_t cr = TMath::Sqrt(c1[0]*c1[0]+c1[1]*c1[1]);
306 // Numbers used to find end-point of strip.
307 // (See http://mathworld.wolfram.com/Circle-LineIntersection.html)
308 Float_t D = c1[0] * c2[1] - c1[1] * c2[0];
309 Float_t dx = c2[0] - c1[0];
310 Float_t dy = c2[1] - c1[1];
311 Float_t dr = TMath::Sqrt(dx*dx+dy*dy);
313 TH1D* ret = new TH1D(Form("acc%c", r),
314 Form("Acceptance correction for FMDx%c", r),
315 nStrips, -.5, nStrips-.5);
316 ret->SetXTitle("Strip");
317 ret->SetYTitle("#varphi acceptance");
318 ret->SetDirectory(0);
319 ret->SetFillColor(r == 'I' || r == 'i' ? kRed+1 : kBlue+1);
320 ret->SetFillStyle(3001);
322 for (Int_t t = 0; t < nStrips; t++) {
323 Float_t radius = minR + t * segment;
325 // If the radius of the strip is smaller than the radius corresponding
326 // to the first corner we have a full strip length
328 ret->SetBinContent(t+1, 1);
332 // Next, we should find the end-point of the strip - that is,
333 // the coordinates where the line from c1 to c2 intersects a circle
334 // with radius given by the strip.
335 // (See http://mathworld.wolfram.com/Circle-LineIntersection.html)
336 // Calculate the determinant
337 Float_t det = radius * radius * dr * dr - D*D;
340 // <0 means No intersection
341 // =0 means Exactly tangent
342 ret->SetBinContent(t+1, 1);
346 // Calculate end-point and the corresponding opening angle
347 Float_t x = (+D * dy + dx * TMath::Sqrt(det)) / dr / dr;
348 Float_t y = (-D * dx + dy * TMath::Sqrt(det)) / dr / dr;
349 Float_t th = TMath::ATan2(x, y);
351 ret->SetBinContent(t+1, th / basearc);
356 //_____________________________________________________________________
358 AliFMDDensityCalculator::AcceptanceCorrection(Char_t r, UShort_t t) const
360 TH1D* acc = (r == 'I' || r == 'i' ? fAccI : fAccO);
361 return acc->GetBinContent(t+1);
364 const Double_t ic1[] = { 4.9895, 15.3560 };
365 const Double_t ic2[] = { 1.8007, 17.2000 };
366 const Double_t oc1[] = { 4.2231, 26.6638 };
367 const Double_t oc2[] = { 1.8357, 27.9500 };
368 const Double_t* c1 = (r == 'I' ? ic1 : oc1);
369 const Double_t* c2 = (r == 'I' ? ic2 : oc2);
370 Double_t minR = (r == 'I' ? 4.5213 : 15.4);
371 Double_t maxR = (r == 'I' ? 17.2 : 28.0);
372 Int_t nStrips = (r == 'I' ? 512 : 256);
373 Int_t nSec = (r == 'I' ? 20 : 40);
374 Float_t basearc = 2 * TMath::Pi() / nSec;
375 Double_t rad = maxR - minR;
376 Float_t segment = rad / nStrips;
377 Float_t radius = minR + t * segment;
379 // Old method - calculate full strip area and take ratio to extended
381 Float_t baselen = basearc * radius;
382 Float_t slope = (c1[1] - c2[1]) / (c1[0] - c2[0]);
383 Float_t constant = (c2[1] * c1[0] - c2[0] * c1[1]) / (c1[0]-c2[0]);
384 Float_t d = (TMath::Power(TMath::Abs(radius*slope),2) +
385 TMath::Power(radius,2) - TMath::Power(constant,2));
387 // If below corners return 1
388 if (d >= 0) return 1;
390 Float_t x = ((-TMath::Sqrt(d) - slope * constant) /
391 (1+TMath::Power(slope, 2)));
392 Float_t y = slope*x + constant;
394 // If x is larger than corner x or y less than corner y, we have full
396 if(x >= c1[0] || y <= c1[1]) return 1;
398 //One sector since theta is by definition half-hybrid
399 Float_t theta = TMath::ATan2(x,y);
400 Float_t arclen = radius * theta;
402 // Calculate the area of a strip with no cut
403 Float_t basearea1 = 0.5 * baselen * TMath::Power(radius,2);
404 Float_t basearea2 = 0.5 * baselen * TMath::Power((radius-segment),2);
405 Float_t basearea = basearea1 - basearea2;
407 // Calculate the area of a strip with cut
408 Float_t area1 = 0.5 * arclen * TMath::Power(radius,2);
409 Float_t area2 = 0.5 * arclen * TMath::Power((radius-segment),2);
410 Float_t area = area1 - area2;
412 // Acceptance is ratio
413 return area/basearea;
417 //____________________________________________________________________
419 AliFMDDensityCalculator::ScaleHistograms(TList* dir, Int_t nEvents)
421 if (nEvents <= 0) return;
422 TList* d = static_cast<TList*>(dir->FindObject(GetName()));
425 TIter next(&fRingHistos);
427 while ((o = static_cast<RingHistos*>(next())))
428 o->ScaleHistograms(d, nEvents);
431 //____________________________________________________________________
433 AliFMDDensityCalculator::DefineOutput(TList* dir)
435 TList* d = new TList;
436 d->SetName(GetName());
438 d->Add(fWeightedSum);
439 d->Add(fSumOfWeights);
440 d->Add(fCorrections);
444 TIter next(&fRingHistos);
446 while ((o = static_cast<RingHistos*>(next()))) {
450 //____________________________________________________________________
452 AliFMDDensityCalculator::Print(Option_t*) const
454 char ind[gROOT->GetDirLevel()+1];
455 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
456 ind[gROOT->GetDirLevel()] = '\0';
457 std::cout << ind << "AliFMDDensityCalculator: " << GetName() << '\n'
458 << ind << " Multiplicity cut: " << fMultCut << '\n'
459 << ind << " Max(particles): " << fMaxParticles
463 //====================================================================
464 AliFMDDensityCalculator::RingHistos::RingHistos()
465 : AliForwardUtil::RingHistos(),
474 //____________________________________________________________________
475 AliFMDDensityCalculator::RingHistos::RingHistos(UShort_t d, Char_t r)
476 : AliForwardUtil::RingHistos(d,r),
484 fEvsN = new TH2D(Form("%s_Eloss_N_nocorr", fName.Data()),
485 Form("#Delta E/#Delta E_{mip} vs uncorrected inclusive "
486 "N_{ch} in %s", fName.Data()),
487 2500, -.5, 24.5, 2500, -.5, 24.5);
488 fEvsM = new TH2D(Form("%s_Eloss_N_corr", fName.Data()),
489 Form("#Delta E/#Delta E_{mip} vs corrected inclusive "
490 "N_{ch} in %s", fName.Data()),
491 2500, -.5, 24.5, 2500, -.5, 24.5);
492 fEvsN->SetXTitle("#Delta E/#Delta E_{mip}");
493 fEvsN->SetYTitle("Inclusive N_{ch} (uncorrected)");
495 fEvsN->SetDirectory(0);
496 fEvsM->SetXTitle("#Delta E/#Delta E_{mip}");
497 fEvsM->SetYTitle("Inclusive N_{ch} (corrected)");
499 fEvsM->SetDirectory(0);
501 fEtaVsN = new TProfile(Form("%s_Eta_N_nocorr", fName.Data()),
502 Form("Average inclusive N_{ch} vs #eta (uncorrected) "
503 "in %s", fName.Data()), 200, -4, 6);
504 fEtaVsM = new TProfile(Form("%s_Eta_N_corr", fName.Data()),
505 Form("Average inclusive N_{ch} vs #eta (corrected) "
506 "in %s", fName.Data()), 200, -4, 6);
507 fEtaVsN->SetXTitle("#eta");
508 fEtaVsN->SetYTitle("#LT N_{ch,incl}#GT (uncorrected)");
509 fEtaVsN->SetDirectory(0);
510 fEtaVsN->SetLineColor(Color());
511 fEtaVsN->SetFillColor(Color());
512 fEtaVsM->SetXTitle("#eta");
513 fEtaVsM->SetYTitle("#LT N_{ch,incl}#GT (corrected)");
514 fEtaVsM->SetDirectory(0);
515 fEtaVsM->SetLineColor(Color());
516 fEtaVsM->SetFillColor(Color());
519 fCorr = new TProfile(Form("%s_corr", fName.Data()),
520 Form("Average correction in %s", fName.Data()),
522 fCorr->SetXTitle("#eta");
523 fCorr->SetYTitle("#LT correction#GT");
524 fCorr->SetDirectory(0);
525 fCorr->SetLineColor(Color());
526 fCorr->SetFillColor(Color());
528 fDensity = new TH2D(Form("%s_Incl_Density", fName.Data()),
529 Form("Inclusive N_{ch} density in %s", fName.Data()),
530 200, -4, 6, (r == 'I' || r == 'i' ? 20 : 40),
532 fDensity->SetDirectory(0);
533 fDensity->SetXTitle("#eta");
534 fDensity->SetYTitle("#phi [radians]");
535 fDensity->SetZTitle("Inclusive N_{ch} density");
537 //____________________________________________________________________
538 AliFMDDensityCalculator::RingHistos::RingHistos(const RingHistos& o)
539 : AliForwardUtil::RingHistos(o),
548 //____________________________________________________________________
549 AliFMDDensityCalculator::RingHistos&
550 AliFMDDensityCalculator::RingHistos::operator=(const RingHistos& o)
552 AliForwardUtil::RingHistos::operator=(o);
554 if (fEvsN) delete fEvsN;
555 if (fEvsM) delete fEvsM;
556 if (fEtaVsN) delete fEtaVsN;
557 if (fEtaVsM) delete fEtaVsM;
558 if (fCorr) delete fCorr;
559 if (fDensity) delete fDensity;
561 fEvsN = static_cast<TH2D*>(o.fEvsN->Clone());
562 fEvsM = static_cast<TH2D*>(o.fEvsM->Clone());
563 fEtaVsN = static_cast<TProfile*>(o.fEtaVsN->Clone());
564 fEtaVsM = static_cast<TProfile*>(o.fEtaVsM->Clone());
565 fCorr = static_cast<TProfile*>(o.fCorr->Clone());
566 fDensity = static_cast<TH2D*>(o.fDensity->Clone());
570 //____________________________________________________________________
571 AliFMDDensityCalculator::RingHistos::~RingHistos()
573 if (fEvsN) delete fEvsN;
574 if (fEvsM) delete fEvsM;
575 if (fEtaVsN) delete fEtaVsN;
576 if (fEtaVsM) delete fEtaVsM;
577 if (fCorr) delete fCorr;
578 if (fDensity) delete fDensity;
581 //____________________________________________________________________
583 AliFMDDensityCalculator::RingHistos::Output(TList* dir)
585 TList* d = DefineOutputList(dir);
594 //____________________________________________________________________
596 AliFMDDensityCalculator::RingHistos::ScaleHistograms(TList* dir, Int_t nEvents)
598 TList* l = GetOutputList(dir);
601 TH1* density = GetOutputHist(l,Form("%s_Incl_Density", fName.Data()));
602 if (density) density->Scale(1./nEvents);
605 //____________________________________________________________________