1 //====================================================================
2 #include "AliForwarddNdetaTask.h"
8 #include <AliAnalysisManager.h>
9 #include <AliAODEvent.h>
10 #include <AliAODHandler.h>
11 #include <AliAODInputHandler.h>
12 #include "AliForwardUtil.h"
13 #include "AliAODForwardMult.h"
15 //____________________________________________________________________
16 AliForwarddNdetaTask::AliForwarddNdetaTask()
24 //____________________________________________________________________
25 AliForwarddNdetaTask::AliForwarddNdetaTask(const char* /* name */)
26 : AliBasedNdetaTask("Forward")
35 //____________________________________________________________________
36 AliForwarddNdetaTask::AliForwarddNdetaTask(const AliForwarddNdetaTask& o)
37 : AliBasedNdetaTask(o)
44 //____________________________________________________________________
45 AliBasedNdetaTask::CentralityBin*
46 AliForwarddNdetaTask::MakeCentralityBin(const char* name, Short_t l, Short_t h)
50 // Make a new centrality bin
53 // name Histogram names
58 // Newly allocated object (of our type)
60 return new AliForwarddNdetaTask::CentralityBin(name, l, h);
63 //____________________________________________________________________
65 AliForwarddNdetaTask::UserExec(Option_t* option)
68 // Called at each event
70 // This is called once in the master
75 AliBasedNdetaTask::UserExec(option);
77 AliAODEvent* aod = dynamic_cast<AliAODEvent*>(InputEvent());
79 AliError("Cannot get the AOD event");
83 TObject* obj = aod->FindListObject("Forward");
85 AliWarning("No forward object found");
88 AliAODForwardMult* forward = static_cast<AliAODForwardMult*>(obj);
90 TObject* oPrimary = aod->FindListObject("primary");
91 if (!oPrimary) return;
93 TH2D* primary = static_cast<TH2D*>(oPrimary);
95 // Loop over centrality bins
96 TIter next(fListOfCentralities);
97 CentralityBin* bin = 0;
98 while ((bin = static_cast<CentralityBin*>(next())))
99 bin->ProcessPrimary(forward, fTriggerMask, fVtxMin, fVtxMax, primary);
103 //____________________________________________________________________
105 AliForwarddNdetaTask::GetHistogram(const AliAODEvent* aod, Bool_t mc)
108 // Retrieve the histogram
112 // mc Whether to get the MC histogram or not
115 // Retrieved histogram or null
118 if (mc) obj = aod->FindListObject("ForwardMC");
119 else obj = aod->FindListObject("Forward");
121 // We should have a forward object at least
123 if (!mc) AliWarning("No Forward object found AOD");
126 AliAODForwardMult* forward = static_cast<AliAODForwardMult*>(obj);
127 return &(forward->GetHistogram());
130 //========================================================================
132 AliForwarddNdetaTask::CentralityBin::ProcessPrimary(const AliAODForwardMult*
139 // Check the centrality class unless this is the 'all' bin
141 Double_t centrality = forward->GetCentrality();
142 if (centrality < fLow || centrality >= fHigh) return;
146 fSumPrimary = static_cast<TH2D*>(primary->Clone("truth"));
147 fSumPrimary->SetDirectory(0);
148 fSumPrimary->Reset();
149 fSums->Add(fSumPrimary);
151 if (triggerMask == AliAODForwardMult::kInel ||
152 (triggerMask == AliAODForwardMult::kNSD &&
153 forward->IsTriggerBits(AliAODForwardMult::kMCNSD)))
154 fSumPrimary->Add(primary);
156 // Check if we have an event of interest.
157 if (!forward->IsTriggerBits(triggerMask)) return;
160 if (forward->IsTriggerBits(AliAODForwardMult::kPileUp)) return;
162 // Check that we have a valid vertex
163 if (!forward->HasIpZ()) return;
165 // Check that vertex is within cuts
166 if (!forward->InRange(vzMin, vzMax)) return;
172 //________________________________________________________________________
174 AliForwarddNdetaTask::CentralityBin::End(TList* sums,
177 const TH1* shapeCorr,
189 AliBasedNdetaTask::CentralityBin::End(sums, results, scheme,
191 symmetrice, rebin, corrEmpty, cutEdges,
192 vzMin, vzMax, triggerMask,
195 fSumPrimary = static_cast<TH2D*>(fSums->FindObject("truth"));
197 if (!fSumPrimary) return;
198 Int_t n = (triggerMask == AliAODForwardMult::kNSD ?
199 Int_t(fTriggers->GetBinContent(AliAODForwardMult::kBinMCNSD)) :
200 Int_t(fTriggers->GetBinContent(AliAODForwardMult::kBinAll)));
203 TH1D* dndetaTruth = fSumPrimary->ProjectionX("dndetaTruth",1,
204 fSumPrimary->GetNbinsY(),"e");
205 dndetaTruth->Scale(1./n, "width");
207 SetHistogramAttributes(dndetaTruth, color-2, marker+4, "Monte-Carlo truth");
209 fOutput->Add(dndetaTruth);
210 fOutput->Add(Rebin(dndetaTruth, rebin, cutEdges));
213 //________________________________________________________________________