1 #include "AliForwardMultDists.h"
2 #include <AliForwardUtil.h>
3 #include <AliAODForwardMult.h>
4 #include <AliAODCentralMult.h>
5 #include <AliAODEvent.h>
11 #include <TParameter.h>
16 //====================================================================
27 kDownTriangle = 0x008,
33 * Get a ROOT marker style from bit options
35 * @param bits Bit mask of options
37 * @return ROOT marker style
39 Int_t GetMarkerStyle(UShort_t bits)
41 Int_t base = bits & (0xFE);
42 Bool_t hollow = bits & kHollow;
44 case kCircle: return (hollow ? 24 : 20);
45 case kSquare: return (hollow ? 25 : 21);
46 case kUpTriangle: return (hollow ? 26 : 22);
47 case kDownTriangle: return (hollow ? 32 : 23);
48 case kDiamond: return (hollow ? 27 : 33);
49 case kCross: return (hollow ? 28 : 34);
50 case kStar: return (hollow ? 30 : 29);
56 * Get the marker option bits from a ROOT style
58 * @param style ROOT style
60 * @return Pattern of marker options
62 UShort_t GetMarkerBits(Int_t style)
66 case 24: case 25: case 26: case 27: case 28: case 30: case 32:
67 bits |= kHollow; break;
70 case 20: case 24: bits |= kCircle; break;
71 case 21: case 25: bits |= kSquare; break;
72 case 22: case 26: bits |= kUpTriangle; break;
73 case 23: case 32: bits |= kDownTriangle; break;
74 case 27: case 33: bits |= kDiamond; break;
75 case 28: case 34: bits |= kCross; break;
76 case 29: case 30: bits |= kStar; break;
81 static Int_t GetIndexMarker(Int_t idx)
83 const UShort_t nMarkers = 7;
84 UShort_t markers[] = {
94 return markers[idx % nMarkers];
98 * Flip the 'hollow-ness' of a marker
100 * @param style ROOT Style
104 Int_t FlipHollowStyle(Int_t style)
106 UShort_t bits = GetMarkerBits(style);
107 Int_t ret = GetMarkerStyle(bits ^ kHollow);
113 //====================================================================
114 AliForwardMultDists::BinSpec::BinSpec(Double_t etaMin,
117 : fEtaMin(etaMin), fEtaMax(etaMax), fLow(nchLow), fN(0), fD(0), fAxis(1,0,1)
120 //____________________________________________________________________
122 AliForwardMultDists::BinSpec::Push(UShort_t n, Double_t d)
124 Int_t l = fN.GetSize();
125 fN.Set(l+1); // Not terribly efficient, but that's ok because we do
126 fD.Set(l+1); // this infrequently
130 //____________________________________________________________________
132 AliForwardMultDists::BinSpec::Axis() const
134 if (fAxis.GetNbins() > 1) return fAxis;
135 if (fN.GetSize() <= 0) return fAxis;
136 if (fN.GetSize() == 1) {
138 fAxis.Set(fN[0], fLow, fN[0]*fD[0]+fLow);
141 Int_t n = Int_t(fN.GetSum());
142 Int_t l = fN.GetSize();
146 for (Int_t j = 0; j < l; j++) {
147 for (Int_t k = 0; k < fN[j]; k++) {
148 b[i+1] = b[i] + fD[j];
153 ::Warning("Axis", "Assigned bins, and number of bins not equal");
154 n = TMath::Min(i, n);
156 fAxis.Set(n, b.GetArray());
161 //====================================================================
162 AliForwardMultDists::AliForwardMultDists()
177 //____________________________________________________________________
178 AliForwardMultDists::AliForwardMultDists(const char* name)
179 : AliBaseAODTask(name,"AliForwardMultDists"),
195 * @param name Name of the task
200 //____________________________________________________________________
202 AliForwardMultDists::Book()
205 * Create output objects - called at start of job in slave
210 //____________________________________________________________________
212 AliForwardMultDists::PreData()
215 * Set-up internal structures on first seen event
218 AliAODEvent* aod = AliForwardUtil::GetAODEvent(this);
219 AliAODForwardMult* forward = GetForward(*aod);
220 const TH2D& hist = forward->GetHistogram();
221 Bool_t useMC = GetPrimary(*aod) != 0;
223 fSums->Add(AliForwardUtil::MakeParameter("minIpZ", fMinIpZ));
224 fSums->Add(AliForwardUtil::MakeParameter("maxIpZ", fMaxIpZ));
226 const TAxis* xaxis = hist.GetXaxis();
227 if (!xaxis->GetXbins() || xaxis->GetXbins()->GetSize() <= 0) {
228 fForwardCache = new TH1D("forwardCache", "Projection of Forward data",
229 xaxis->GetNbins(), xaxis->GetXmin(),
231 fCentralCache = new TH1D("centralCache", "Projection of Central data",
232 xaxis->GetNbins(), xaxis->GetXmin(),
235 fMCCache = new TH1D("mcCache", "Projection of Mc data",
236 xaxis->GetNbins(), xaxis->GetXmin(),
240 fForwardCache = new TH1D("forwardCache", "Projection of Forward data",
241 xaxis->GetNbins(),xaxis->GetXbins()->GetArray());
242 fCentralCache = new TH1D("centralCache", "Projection of Central data",
243 xaxis->GetNbins(),xaxis->GetXbins()->GetArray());
245 fMCCache = new TH1D("mcCache", "Projection of Mc data",
246 xaxis->GetNbins(),xaxis->GetXbins()->GetArray());
248 fForwardCache->SetDirectory(0);
249 fForwardCache->GetXaxis()->SetTitle("#eta");
250 fForwardCache->GetYaxis()->SetTitle("#sum#frac{d^{2}N}{d#etadphi}");
251 fForwardCache->Sumw2();
252 fCentralCache->SetDirectory(0);
253 fCentralCache->GetXaxis()->SetTitle("#eta");
254 fCentralCache->GetYaxis()->SetTitle("#sum#frac{d^{2}N}{d#etadphi}");
255 fCentralCache->Sumw2();
258 fMCCache->SetDirectory(0);
259 fMCCache->GetXaxis()->SetTitle("#eta");
260 fMCCache->GetYaxis()->SetTitle("#sum#frac{d^{2}N}{d#etadphi}");
263 fMCVertex = static_cast<TH1*>(fVertex->Clone("mcVertex"));
264 fMCVertex->SetTitle("Vertex distribution from MC");
265 fMCVertex->SetDirectory(0);
266 fMCVertex->SetFillColor(kBlue+2);
267 fSums->Add(fMCVertex);
270 UShort_t xBase = kTrigger-1;
271 UShort_t yBase = kAnalysis-1;
272 fDiag = new TH2I("diagnostics", "Event selection",
273 kTriggerVertex-xBase, kTrigger-.5, kTriggerVertex+.5,
274 kTriggerVertex-yBase, kAnalysis-.5, kTriggerVertex+.5);
275 fDiag->SetDirectory(0);
276 fDiag->GetXaxis()->SetTitle("Selection");
277 fDiag->GetXaxis()->SetBinLabel(kTrigger -xBase, "Trigger");
278 fDiag->GetXaxis()->SetBinLabel(kVertex -xBase, "Vertex");
279 fDiag->GetXaxis()->SetBinLabel(kTriggerVertex-xBase, "Trigger+Vertex");
280 fDiag->GetYaxis()->SetTitle("Type/MC selection");
281 fDiag->GetYaxis()->SetBinLabel(kAnalysis -yBase, "Analysis");
282 fDiag->GetYaxis()->SetBinLabel(kMC -yBase, "MC");
283 fDiag->GetYaxis()->SetBinLabel(kTrigger -yBase, "MC Trigger");
284 fDiag->GetYaxis()->SetBinLabel(kVertex -yBase, "MC Vertex");
285 fDiag->GetYaxis()->SetBinLabel(kTriggerVertex-yBase, "MC Trigger+Vertex");
286 fDiag->SetMarkerSize(3);
287 fDiag->SetMarkerColor(kWhite);
292 while ((bin = static_cast<EtaBin*>(next()))) {
293 bin->SetupForData(fSums, hist, useMC);
297 //____________________________________________________________________
299 AliForwardMultDists::Event(AliAODEvent& aod)
302 * Analyse a single event
304 * @param aod Input event
306 AliAODForwardMult* forward = GetForward(aod, false, true);
307 if (!forward) return false;
309 AliAODCentralMult* central = GetCentral(aod, false, true);
310 if (!central) return false;
312 TH2* primary = GetPrimary(aod);
314 const TH2& forwardData = forward->GetHistogram();
315 const TH2& centralData = central->GetHistogram();
317 Double_t vz = forward->GetIpZ();
318 Bool_t trg = forward->IsTriggerBits(fTriggerMask);
319 Bool_t vtx = (vz <= fMaxIpZ && vz >= fMinIpZ);
320 Bool_t ok = true; // Should bins process this event?
321 Bool_t mcTrg = false;
322 Bool_t mcVtx = false;
323 // If we have MC inpunt
325 // For MC, we need to check if we should process the event for
326 // MC information or not.
327 if ((fTriggerMask & (AliAODForwardMult::kV0AND|AliAODForwardMult::kNSD))
328 && !forward->IsTriggerBits(AliAODForwardMult::kMCNSD))
329 // Bail out if this event is not MC NSD event
333 Double_t mcVz = primary->GetBinContent(0,0);
334 fMCVertex->Fill(mcVz);
335 if (mcVz > fMaxIpZ || mcVz < fMinIpZ)
336 // Bail out if this event was not in the valid range
343 fDiag->Fill(kTrigger, kAnalysis);
344 if (mcTrg) fDiag->Fill(kTrigger, kTrigger);
345 if (mcVtx) fDiag->Fill(kTrigger, kVertex);
346 if (mcTrg && mcVtx) fDiag->Fill(kTrigger, kTriggerVertex);
349 fDiag->Fill(kVertex, kAnalysis);
350 if (mcTrg) fDiag->Fill(kVertex, kTrigger);
351 if (mcVtx) fDiag->Fill(kVertex, kVertex);
352 if (mcTrg && mcVtx) fDiag->Fill(kVertex, kTriggerVertex);
355 fDiag->Fill(kTriggerVertex, kAnalysis);
356 if (mcTrg) fDiag->Fill(kTriggerVertex, kTrigger);
357 if (mcVtx) fDiag->Fill(kTriggerVertex, kVertex);
358 if (mcTrg && mcVtx) fDiag->Fill(kTriggerVertex, kTriggerVertex);
361 if (mcTrg) fDiag->Fill(kTrigger, kMC);
362 if (mcVtx) fDiag->Fill(kVertex, kMC);
363 if (mcTrg && mcVtx) fDiag->Fill(kTriggerVertex, kMC);
365 if (!fIsSelected && !ok) {
366 // Printf("Event is neither accepted by analysis nor by MC");
371 // Info("", "Event vz=%f", forward->GetIpZ());
373 ProjectX(forwardData, *fForwardCache, fUsePhiAcc);
374 ProjectX(centralData, *fCentralCache, fUsePhiAcc);
375 ProjectX(primary, fMCCache);
379 while ((bin = static_cast<EtaBin*>(next()))) {
380 bin->Process(*fForwardCache, *fCentralCache,
381 forwardData, centralData,
382 fIsSelected, fMCCache);
388 //_____________________________________________________________________
390 AliForwardMultDists::CheckEvent(const AliAODForwardMult& fwd)
392 fIsSelected = AliBaseAODTask::CheckEvent(fwd);
393 // We always return true, so that we can process MC truth;
397 //____________________________________________________________________
399 AliForwardMultDists::Finalize()
402 * Called at the end of the final processing of the job on the
403 * full data set (merged data)
405 fResults->Add(fSums->FindObject("triggers")->Clone());
406 fResults->Add(fSums->FindObject("status")->Clone());
407 fResults->Add(fSums->FindObject("diagnostics")->Clone());
409 THStack* sym = new THStack("all", "All distributions");
410 THStack* pos = new THStack("all", "All distributions");
411 THStack* neg = new THStack("all", "All distributions");
412 THStack* oth = new THStack("all", "All distributions");
416 while ((bin = static_cast<EtaBin*>(next()))) {
417 bin->Terminate(fSums, fResults);
420 if (bin->IsSymmetric()) sta = sym;
421 else if (bin->IsNegative()) sta = neg;
422 else if (bin->IsPositive()) sta = pos;
424 TH1* hh[] = { bin->fSum, bin->fTruth, bin->fTruthAccepted, 0 };
427 Int_t idx = sta->GetHists() ? sta->GetHists()->GetEntries() : 0;
428 if (bin->fTruth) idx /= 2;
430 Int_t mkrBits = GetIndexMarker(idx);
432 Int_t factor = Int_t(TMath::Power(10, idx));
433 TH1* h = static_cast<TH1*>((*ph)->Clone());
436 h->SetTitle(Form("%s (#times%d)", h->GetTitle(), Int_t(factor)));
437 h->SetMarkerStyle(GetMarkerStyle(mkrBits));
444 TList* lsym = static_cast<TList*>(fResults->FindObject("symmetric"));
445 TList* lneg = static_cast<TList*>(fResults->FindObject("negative"));
446 TList* lpos = static_cast<TList*>(fResults->FindObject("positive"));
447 TList* loth = static_cast<TList*>(fResults->FindObject("other"));
449 if (lsym) lsym->Add(sym);
450 if (lneg) lneg->Add(neg);
451 if (lpos) lpos->Add(pos);
452 if (loth) loth->Add(oth);
457 //____________________________________________________________________
459 AliForwardMultDists::ProjectX(const TH2& input, TH1& cache, Bool_t usePhiAcc)
462 * Project a 2D histogram into a 1D histogram taking care to use
463 * either the @f$\phi@f$ acceptance stored in the overflow bins, or
464 * the @f$\eta@f$ coverage stored in the underflow bins.
466 * @param input 2D histogram to project
467 * @param cache 1D histogram to project into
468 * @param usePhiAcc If true, use the @f$\phi@f$ acceptance stored in
469 * the overflow bins, or if false the @f$\eta@f$ coverage stored in
470 * the underflow bins.
474 Int_t nPhi = input.GetNbinsY();
475 Int_t nEta = input.GetNbinsX();
477 for (Int_t iEta = 1; iEta <= nEta; iEta++) {
478 Double_t phiAcc = input.GetBinContent(iEta, nPhi+1);
479 Double_t etaCov = input.GetBinContent(iEta, 0);
480 Double_t factor = usePhiAcc ? phiAcc : etaCov;
482 if (factor < 1e-3) continue;
485 for (Int_t iPhi = 1; iPhi <= nPhi; iPhi++) {
486 Double_t c = input.GetBinContent(iEta, iPhi);
487 Double_t e = input.GetBinError(iEta, iPhi);
492 cache.SetBinContent(iEta, factor * sum);
493 cache.SetBinError(iEta, factor * TMath::Sqrt(e2sum));
496 //____________________________________________________________________
498 AliForwardMultDists::ProjectX(const TH2* input, TH1* cache)
501 * Project on @f$\eta@f$ axis. If any of the pointers passed is
507 if (!input || !cache) return;
510 Int_t nPhi = input->GetNbinsY();
511 Int_t nEta = input->GetNbinsX();
513 for (Int_t iEta = 1; iEta <= nEta; iEta++) {
516 for (Int_t iPhi = 1; iPhi <= nPhi; iPhi++) {
517 Double_t c = input->GetBinContent(iEta, iPhi);
518 Double_t e = input->GetBinError(iEta, iPhi);
523 cache->SetBinContent(iEta, sum);
524 cache->SetBinError(iEta, TMath::Sqrt(e2sum));
527 //____________________________________________________________________
529 AliForwardMultDists::AddBin(const BinSpec& spec)
531 AddBin(spec.fEtaMin, spec.fEtaMax, spec.Axis());
534 //____________________________________________________________________
536 AliForwardMultDists::AddBin(Double_t etaLow, Double_t etaMax,
540 * Add an @f$\eta@f$ bin
542 * @param etaLow Low cut on @f$\eta@f$
543 * @param etaMax High cut on @f$\eta@f$
546 if (etaMax >= kInvalidEta) {
547 etaLow = -TMath::Abs(etaLow);
548 etaMax = +TMath::Abs(etaLow);
550 EtaBin* bin = new EtaBin(etaLow, etaMax, mAxis);
551 // AliInfoF("Adding bin %f, %f: %s", etaLow, etaMax, bin->GetName());
554 //____________________________________________________________________
556 AliForwardMultDists::AddBin(Double_t etaLow, Double_t etaMax,
557 UShort_t nMax, UShort_t nDiv)
560 * Add an @f$\eta@f$ bin
562 * @param etaLow Low cut on @f$\eta@f$
563 * @param etaMax High cut on @f$\eta@f$
566 if (etaMax >= kInvalidEta) {
567 etaLow = -TMath::Abs(etaLow);
568 etaMax = +TMath::Abs(etaLow);
570 TAxis mAxis((nMax+1)/nDiv, -.5, nMax+.5);
571 EtaBin* bin = new EtaBin(etaLow, etaMax, mAxis);
572 // AliInfoF("Adding bin %f, %f: %s", etaLow, etaMax, bin->GetName());
575 #define PFV(N,VALUE) \
577 AliForwardUtil::PrintName(N); \
578 std::cout << (VALUE) << std::endl; } while(false)
579 #define PFB(N,FLAG) \
581 AliForwardUtil::PrintName(N); \
582 std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
585 //____________________________________________________________________
587 AliForwardMultDists::Print(Option_t* option) const
592 * @param option Not used
594 AliBaseAODTask::Print(option);
595 gROOT->IncreaseDirLevel();
596 PFB("Use phi acceptance", fUsePhiAcc);
597 // AliForwardUtil::PrintName("Bins");
602 while ((bin = static_cast<EtaBin*>(next()))) {
603 PFV(first ? "Bins" : "", bin->GetName());
606 gROOT->DecreaseDirLevel();
609 //====================================================================
610 AliForwardMultDists::EtaBin::EtaBin()
630 //____________________________________________________________________
631 AliForwardMultDists::EtaBin::EtaBin(Double_t minEta, Double_t maxEta,
650 * @param minEta Least @f$\eta@f$ to consider
651 * @param maxEta Largest @f$\eta@f$ to consider
653 fName = TString::Format("%+05.2f_%+05.2f", fMinEta, fMaxEta);
654 fName.ReplaceAll("-", "m");
655 fName.ReplaceAll("+", "p");
656 fName.ReplaceAll(".", "d");
658 // Copy to other our object
661 if (mAxis.GetXbins() && mAxis.GetXbins()->GetArray()) {
662 const TArrayD& mA = *(mAxis.GetXbins());
663 TArrayD tA(mA.GetSize());
665 Double_t min = mA[0];
667 for (Int_t i = 1; i < mA.GetSize(); i++) {
668 Double_t d = mA[i] - min;
670 // Not full integer bin
672 tA[j+1] = tA[j] + Int_t(d);
676 fTAxis.Set(j, tA.GetArray());
679 // Rounded down maximum and minimum
680 Int_t max = Int_t(mAxis.GetXmax());
681 Int_t min = Int_t(mAxis.GetXmin());
682 fTAxis.Set((max-min)+1, min-.5, max+.5);
685 //____________________________________________________________________
686 AliForwardMultDists::EtaBin::EtaBin(const EtaBin& o)
697 fResponse(o.fResponse),
699 fTruthAccepted(o.fTruthAccepted),
700 fCoverage(o.fCoverage)
702 //____________________________________________________________________
703 AliForwardMultDists::EtaBin&
704 AliForwardMultDists::EtaBin::operator=(const EtaBin& o)
706 if (&o == this) return *this;
717 fResponse = o.fResponse;
719 fTruthAccepted = o.fTruthAccepted;
720 fCoverage = o.fCoverage;
724 //____________________________________________________________________
726 AliForwardMultDists::EtaBin::IsSymmetric() const
728 return TMath::Abs(fMaxEta + fMinEta) < 1e-6;
730 //____________________________________________________________________
732 AliForwardMultDists::EtaBin::IsNegative() const
734 return TMath::Abs(fMaxEta) < 1e-6 && fMinEta < 0;
736 //____________________________________________________________________
738 AliForwardMultDists::EtaBin::IsPositive() const
740 return TMath::Abs(fMinEta) < 1e-6 && fMaxEta > 0;
742 //____________________________________________________________________
744 AliForwardMultDists::EtaBin::ParentName() const
746 if (IsSymmetric()) return "symmetric";
747 else if (IsNegative()) return "negative";
748 else if (IsPositive()) return "positive";
751 //____________________________________________________________________
753 AliForwardMultDists::EtaBin::FindParent(TList* l, Bool_t create) const
755 const char* parent = ParentName();
756 TObject* op = l->FindObject(parent);
758 if (op) return static_cast<TList*>(op);
759 if (!create) return 0;
761 // Info("FindParent", "Parent %s not found in %s, creating and adding",
762 // parent, l->GetName());
763 TList* p = new TList;
768 TList* lowEdges = new TList;
769 lowEdges->SetName("lowEdges");
770 lowEdges->SetOwner();
773 TList* highEdges = new TList;
774 highEdges->SetName("highEdges");
775 highEdges->SetOwner();
781 //____________________________________________________________________
783 AliForwardMultDists::EtaBin::CreateH1(const char* name,
789 if (xAxis.GetXbins() && xAxis.GetXbins()->GetArray())
790 ret = new TH1D(name,title,xAxis.GetNbins(), xAxis.GetXbins()->GetArray());
792 ret = new TH1D(name,title,xAxis.GetNbins(),xAxis.GetXmin(),xAxis.GetXmax());
795 //____________________________________________________________________
797 AliForwardMultDists::EtaBin::CreateH2(const char* name,
804 if (xAxis.GetXbins() && xAxis.GetXbins()->GetArray()) {
805 if (yAxis.GetXbins() && yAxis.GetXbins()->GetArray())
807 ret = new TH2D(name,title,
808 xAxis.GetNbins(), xAxis.GetXbins()->GetArray(),
809 yAxis.GetNbins(), yAxis.GetXbins()->GetArray());
812 ret = new TH2D(name,title,
813 xAxis.GetNbins(), xAxis.GetXbins()->GetArray(),
814 yAxis.GetNbins(),yAxis.GetXmin(),yAxis.GetXmax());
817 if (yAxis.GetXbins() && yAxis.GetXbins()->GetArray())
819 ret = new TH2D(name,title,
820 xAxis.GetNbins(), xAxis.GetXmin(), xAxis.GetXmax(),
821 yAxis.GetNbins(), yAxis.GetXbins()->GetArray());
824 ret = new TH2D(name,title,
825 xAxis.GetNbins(), xAxis.GetXmin(), xAxis.GetXmax(),
826 yAxis.GetNbins(), yAxis.GetXmin(), yAxis.GetXmax());
831 //____________________________________________________________________
833 AliForwardMultDists::EtaBin::SetupForData(TList* list, const TH2& hist,
837 * Set-up internal structures on first event.
839 * @param list List to add information to
840 * @param hist Template histogram
841 * @param max Maximum number of particles
842 * @param useMC Whether to set-up for MC input
844 TList* p = FindParent(list, true);
845 TList* l = new TList;
846 l->SetName(GetName());
849 TList* le = static_cast<TList*>(p->FindObject("lowEdges"));
850 TList* he = static_cast<TList*>(p->FindObject("highEdges"));
852 AliError("Failed to get bin edge lists from parent");
856 Int_t n = le->GetEntries();
857 TParameter<double>* lp =
858 new TParameter<double>(Form("minEta%02d", n), fMinEta);
859 TParameter<double>* hp =
860 new TParameter<double>(Form("maxEta%02d", n), fMaxEta);
861 lp->SetMergeMode('f');
862 hp->SetMergeMode('f');
867 const TAxis * xax = hist.GetXaxis();
868 fMinBin = xax->FindFixBin(fMinEta);
869 fMaxBin = xax->FindFixBin(fMaxEta-.00001);
871 TString t(Form("%+5.2f<#eta<%+5.2f", fMinEta, fMaxEta));
872 fSum = CreateH1("rawDist",Form("Raw P(#it{N}_{ch}) in %s",t.Data()),fMAxis);
873 fSum->SetDirectory(0);
874 fSum->GetXaxis()->SetTitle("#it{N}_{ch}");
875 fSum->GetYaxis()->SetTitle("Raw P(#it{N}_{ch})");
876 fSum->SetFillColor(kRed+1);
877 fSum->SetFillStyle(0);
878 // fSum->SetOption("hist e");
879 fSum->SetMarkerStyle(20);
880 fSum->SetMarkerColor(kRed+1);
881 fSum->SetLineColor(kBlack);
885 fCorr = CreateH2("corr",Form("C_{SPD,FMD} in %s", t.Data()),fTAxis,fTAxis);
886 fCorr->SetDirectory(0);
887 fCorr->GetXaxis()->SetTitle("Forward");
888 fCorr->GetYaxis()->SetTitle("Central");
889 fCorr->SetOption("colz");
892 fCoverage = new TH1D("coverage", "Fraction of bins with coverage",
894 fCoverage->SetDirectory(0);
895 fCoverage->SetXTitle("Fraction of bins [%]");
896 fCoverage->SetFillStyle(3001);
897 fCoverage->SetFillColor(kGreen+1);
901 fResponse = CreateH2("response", Form("Reponse matrix in %s", t.Data()),
903 fResponse->SetDirectory(0);
904 fResponse->SetYTitle("MC");
905 fResponse->SetXTitle("Signal");
906 fResponse->SetOption("colz");
909 fTruth = CreateH1("truth",Form("True P(#it{N}_{ch}) in %s",t.Data()),fTAxis);
910 fTruth->SetXTitle(fSum->GetXaxis()->GetTitle());
911 fTruth->SetYTitle(fSum->GetYaxis()->GetTitle());
912 fTruth->SetLineColor(kBlack);
913 fTruth->SetFillColor(kBlue+1);
914 fTruth->SetFillStyle(0);
915 fTruth->SetDirectory(0);
916 /// fTruth->SetOption("");
917 fTruth->SetMarkerColor(kBlue+1);
918 fTruth->SetMarkerStyle(24);
922 fTruthAccepted = static_cast<TH1D*>(fTruth->Clone("truthAccepted"));
923 fTruthAccepted->SetTitle(Form("True (accepted) P(#it{N}_{ch}) in %s",
925 fTruthAccepted->SetLineColor(kGray+2);
926 fTruthAccepted->SetFillColor(kOrange+2);
927 fTruthAccepted->SetDirectory(0);
928 /// fTruth->SetOption("");
929 fTruthAccepted->SetMarkerColor(kOrange+2);
930 l->Add(fTruthAccepted);
932 //____________________________________________________________________
934 AliForwardMultDists::EtaBin::Process(const TH1& sumForward,
935 const TH1& sumCentral,
942 * Process a single event
944 * @param sumForward Projection of forward data
945 * @param sumCentral Projection of the central data
946 * @param forward The original forward data
947 * @param central The original central data
949 if (!mc && !accepted)
950 // If we're not looking at MC data, and the event wasn't selected,
951 // we bail out - this check is already done, but we do it again
961 Double_t mce2sum = 0;
962 for (Int_t iEta = fMinBin; iEta <= fMaxBin; iEta++) {
964 Double_t cM = mc->GetBinContent(iEta);
965 Double_t eM = mc->GetBinError(iEta);
970 // Event wasn't selected, but we still need to get the rest of
974 Double_t cF = sumForward.GetBinContent(iEta);
975 Double_t eF = sumForward.GetBinError(iEta);
976 Bool_t bF = forward.GetBinContent(iEta, 0) > 0;
977 Double_t cC = sumCentral.GetBinContent(iEta);
978 Double_t eC = sumCentral.GetBinError(iEta);
979 Bool_t bC = central.GetBinContent(iEta, 0) > 0;
983 // If we have an overlap - as given by the eta-coverage,
984 // calculate the mean
987 e = TMath::Sqrt(eF*eF + eC*eC);
990 // Else, if we have coverage from forward, use that
996 // Else, if we have covrage from central, use that
1002 // Else, we have incomplete coverage
1005 if (fsum < 0) fsum = 0;
1009 if (csum < 0) csum = 0;
1018 // Only update the histograms if the event was triggered.
1020 Double_t w = 1; // e2sum > 0 ? 1/TMath::Sqrt(e2sum) : 1
1022 fCorr->Fill((fsum<0?0:fsum), (csum<0?0:csum));
1024 Int_t nTotal = fMaxBin - fMinBin + 1;
1025 fCoverage->Fill(100*float(covered) / nTotal);
1029 Double_t w = 1; // mce2sum > 0 ? 1/TMath::Sqrt(mce2sum) : 1
1031 fTruth->Fill(mcsum, w);
1035 // Only fill response matrix for accepted events
1036 fResponse->Fill(sum, mcsum);
1038 fTruthAccepted->Fill(mcsum, w);
1042 //____________________________________________________________________
1044 AliForwardMultDists::EtaBin::Terminate(TList* in, TList* out)
1047 * Called at the end of the final processing of the job on the
1048 * full data set (merged data)
1050 * @param in Input list
1051 * @param out Output list
1052 * @param maxN Maximum number of @f$N_{ch}@f$ to consider
1054 TList* ip = FindParent(in, false);
1056 AliErrorF("Parent folder %s not found in input", ParentName());
1060 TList* i = dynamic_cast<TList*>(ip->FindObject(GetName()));
1062 AliErrorF("List %s not found in input", GetName());
1066 TList* op = FindParent(out, true);
1067 TList* o = static_cast<TList*>(i->Clone());
1071 fSum = static_cast<TH1*>(o->FindObject("rawDist"));
1072 fTruth = static_cast<TH1*>(o->FindObject("truth"));
1073 fTruthAccepted = static_cast<TH1*>(o->FindObject("truthAccepted"));
1075 TH1* hists[] = { fSum, fTruth, fTruthAccepted, 0 };
1076 TH1** phist = hists;
1080 Int_t maxN = h->GetNbinsX();
1081 Double_t intg = h->Integral(1, maxN);
1082 h->Scale(1. / intg, "width");
1087 if (fTruth && fTruthAccepted) {
1088 TH1* trgVtx = static_cast<TH1*>(fTruthAccepted->Clone("triggerVertex"));
1089 TString tit(fTruth->GetTitle());
1090 tit.ReplaceAll("True P(#it{N}_{ch})", "C_{trigger,vertex}");
1091 trgVtx->SetTitle(tit);
1092 trgVtx->SetYTitle("P_{MC}(#it{N}_{ch})/P_{MC,accepted}(#it{N}_{ch})");
1093 trgVtx->Divide(fTruth);
1094 trgVtx->SetDirectory(0);
1099 //====================================================================