2 // Calculate the multiplicity in the forward regions event-by-event
14 #include "AliForwardMultiplicityTask.h"
15 #include "AliTriggerAnalysis.h"
16 #include "AliPhysicsSelection.h"
18 #include "AliESDEvent.h"
19 #include "AliAODHandler.h"
20 #include "AliMultiplicity.h"
21 #include "AliInputEventHandler.h"
22 #include "AliForwardCorrectionManager.h"
23 #include "AliAnalysisManager.h"
26 #include <TDirectory.h>
31 //====================================================================
32 AliForwardMultiplicityTask::AliForwardMultiplicityTask()
33 : AliForwardMultiplicityBase(),
58 DGUARD(fDebug, 3,"Default CTOR of AliForwardMultiplicityTask");
61 //____________________________________________________________________
62 AliForwardMultiplicityTask::AliForwardMultiplicityTask(const char* name)
63 : AliForwardMultiplicityBase(name),
70 fEventInspector("event"),
71 fSharingFilter("sharing"),
72 fDensityCalculator("density"),
73 fCorrections("corrections"),
74 fHistCollector("collector"),
75 fEventPlaneFinder("eventplane"),
92 DGUARD(fDebug, 3,"named CTOR of AliForwardMultiplicityTask: %s", name);
93 DefineOutput(1, TList::Class());
94 DefineOutput(2, TList::Class());
97 //____________________________________________________________________
98 AliForwardMultiplicityTask::AliForwardMultiplicityTask(const AliForwardMultiplicityTask& o)
99 : AliForwardMultiplicityBase(o),
105 fRingSums(o.fRingSums),
106 fEventInspector(o.fEventInspector),
107 fSharingFilter(o.fSharingFilter),
108 fDensityCalculator(o.fDensityCalculator),
109 fCorrections(o.fCorrections),
110 fHistCollector(o.fHistCollector),
111 fEventPlaneFinder(o.fEventPlaneFinder),
112 fFMD1icent(o.fFMD1icent),
113 fFMD2icent(o.fFMD2icent),
114 fFMD2ocent(o.fFMD2ocent),
115 fFMD3icent(o.fFMD3icent),
116 fFMD3ocent(o.fFMD3ocent),
118 fListVertexBins(o.fListVertexBins)
125 // o Object to copy from
127 DGUARD(fDebug, 3,"Copy CTOR of AliForwardMultiplicityTask");
128 DefineOutput(1, TList::Class());
129 DefineOutput(2, TList::Class());
132 //____________________________________________________________________
133 AliForwardMultiplicityTask&
134 AliForwardMultiplicityTask::operator=(const AliForwardMultiplicityTask& o)
137 // Assignment operator
140 // o Object to assign from
143 // Reference to this object
145 DGUARD(fDebug,3,"Assignment to AliForwardMultiplicityTask");
146 if (&o == this) return *this;
147 AliForwardMultiplicityBase::operator=(o);
150 fEventInspector = o.fEventInspector;
151 fSharingFilter = o.fSharingFilter;
152 fDensityCalculator = o.fDensityCalculator;
153 fCorrections = o.fCorrections;
154 fHistCollector = o.fHistCollector;
155 fEventPlaneFinder = o.fEventPlaneFinder;
159 fRingSums = o.fRingSums;
160 fFMD1icent = o.fFMD1icent;
161 fFMD2icent = o.fFMD2icent;
162 fFMD2ocent = o.fFMD2ocent;
163 fFMD3icent = o.fFMD3icent;
164 fFMD3ocent = o.fFMD3ocent;
166 fListVertexBins =o.fListVertexBins;
171 //____________________________________________________________________
173 AliForwardMultiplicityTask::SetDebug(Int_t dbg)
181 fEventInspector.SetDebug(dbg);
182 fSharingFilter.SetDebug(dbg);
183 fDensityCalculator.SetDebug(dbg);
184 fCorrections.SetDebug(dbg);
185 fHistCollector.SetDebug(dbg);
186 fEventPlaneFinder.SetDebug(dbg);
189 //____________________________________________________________________
191 AliForwardMultiplicityTask::SetupForData()
194 // Initialise the sub objects and stuff. Called on first event
197 DGUARD(fDebug,1,"Initialize sub-algorithms");
201 if (!ReadCorrections(pe,pv)) return false;
208 fHData = static_cast<TH2D*>(fAODFMD.GetHistogram().Clone("d2Ndetadphi"));
210 fHData->SetDirectory(0);
213 TList* rings = new TList;
214 rings->SetName("ringSums");
218 rings->Add(fRingSums.Get(1, 'I'));
219 rings->Add(fRingSums.Get(2, 'I'));
220 rings->Add(fRingSums.Get(2, 'O'));
221 rings->Add(fRingSums.Get(3, 'I'));
222 rings->Add(fRingSums.Get(3, 'O'));
223 fRingSums.Get(1, 'I')->SetMarkerColor(AliForwardUtil::RingColor(1, 'I'));
224 fRingSums.Get(2, 'I')->SetMarkerColor(AliForwardUtil::RingColor(2, 'I'));
225 fRingSums.Get(2, 'O')->SetMarkerColor(AliForwardUtil::RingColor(2, 'O'));
226 fRingSums.Get(3, 'I')->SetMarkerColor(AliForwardUtil::RingColor(3, 'I'));
227 fRingSums.Get(3, 'O')->SetMarkerColor(AliForwardUtil::RingColor(3, 'O'));
229 for(int i=1;i<=pv->GetNbins();i++)
231 TString nametmp=Form("vtxbin%03d",i);
232 //TList* lbin= new TList();
233 //lbin->SetName(nametmp.Data());
235 //fListVertexBins->Add(lbin);
236 AliForwardUtil::Histos* bin=new AliForwardUtil::Histos();
238 bin->Get(1, 'I')->SetName(Form("%s%s",bin->Get(1, 'I')->GetName(),nametmp.Data()));
239 bin->Get(2, 'I')->SetName(Form("%s%s",bin->Get(2, 'I')->GetName(),nametmp.Data()));
240 bin->Get(2, 'O')->SetName(Form("%s%s",bin->Get(2, 'O')->GetName(),nametmp.Data()));
241 bin->Get(3, 'I')->SetName(Form("%s%s",bin->Get(3, 'I')->GetName(),nametmp.Data()));
242 bin->Get(3, 'O')->SetName(Form("%s%s",bin->Get(3, 'O')->GetName(),nametmp.Data()));
243 fList->Add(bin->Get(1, 'I'));
244 fList->Add(bin->Get(2, 'I'));
245 fList->Add(bin->Get(2, 'O'));
246 fList->Add(bin->Get(3, 'I'));
247 fList->Add(bin->Get(3, 'O'));
248 fListVertexBins->Add(bin);
253 fEventInspector.SetupForData(*pv);
254 fSharingFilter.SetupForData(*pe);
255 fDensityCalculator.SetupForData(*pe);
256 fCorrections.SetupForData(*pe);
257 fHistCollector.SetupForData(*pv,*pe);
258 fEventPlaneFinder.SetupForData(*pe);
260 fFMD1icent=new TH3D("FMD1Ietavcent","FMD1ietavcent;#eta;cent",pe->GetNbins(),pe->GetXmin(),pe->GetXmax(),101,-0.5,100.5,1,0,1);
261 fFMD2icent=new TH3D("FMD2Ietavcent","FMD2ietavcent;#eta;cent",pe->GetNbins(),pe->GetXmin(),pe->GetXmax(),101,-0.5,100.5,1,0,1);
262 fFMD2ocent=new TH3D("FMD2Oetavcent","FMD2oetavcent;#eta;cent",pe->GetNbins(),pe->GetXmin(),pe->GetXmax(),101,-0.5,100.5,1,0,1);
263 fFMD3icent=new TH3D("FMD3Ietavcent","FMD3ietavcent;#eta;cent",pe->GetNbins(),pe->GetXmin(),pe->GetXmax(),101,-0.5,100.5,1,0,1);
264 fFMD3ocent=new TH3D("FMD3Oetavcent","FMD3oetavcent;#eta;cent",pe->GetNbins(),pe->GetXmin(),pe->GetXmax(),101,-0.5,100.5,1,0,1);
265 fList->Add(fFMD1icent);
266 fList->Add(fFMD2icent);
267 fList->Add(fFMD2ocent);
268 fList->Add(fFMD3icent);
269 fList->Add(fFMD3ocent);
277 //____________________________________________________________________
279 AliForwardMultiplicityTask::UserCreateOutputObjects()
282 // Create output objects
285 DGUARD(fDebug,1,"Create user ouput");
288 fListVertexBins=new TList();
289 fListVertexBins->SetOwner();
291 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
293 dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
294 if (!ah) AliFatal("No AOD output handler set in analysis manager");
297 TObject* obj = &fAODFMD;
298 ah->AddBranch("AliAODForwardMult", &obj);
299 TObject* epobj = &fAODEP;
300 ah->AddBranch("AliAODForwardEP", &epobj);
302 fEventInspector.CreateOutputObjects(fList);
303 fSharingFilter.CreateOutputObjects(fList);
304 fDensityCalculator.CreateOutputObjects(fList);
305 fCorrections.CreateOutputObjects(fList);
306 fHistCollector.CreateOutputObjects(fList);
307 fEventPlaneFinder.CreateOutputObjects(fList);
311 //____________________________________________________________________
313 AliForwardMultiplicityTask::UserExec(Option_t*)
316 // Process each event
322 DGUARD(fDebug,1,"Process the input event");
323 // static Int_t cnt = 0;
325 // Get the input data
326 AliESDEvent* esd = GetESDEvent();
335 Bool_t lowFlux = kFALSE;
340 UShort_t nClusters = 0;
341 UInt_t found = fEventInspector.Process(esd, triggers, lowFlux,
342 ivz, ip, cent, nClusters);
344 if (found & AliFMDEventInspector::kNoEvent) return;
345 if (found & AliFMDEventInspector::kNoTriggers) return;
347 // Set trigger bits, and mark this event for storage
348 fAODFMD.SetTriggerBits(triggers);
349 fAODFMD.SetSNN(fEventInspector.GetEnergy());
350 fAODFMD.SetSystem(fEventInspector.GetCollisionSystem());
351 fAODFMD.SetCentrality(cent);
352 fAODFMD.SetNClusters(nClusters);
355 if (found & AliFMDEventInspector::kNoSPD) return;
356 if (found & AliFMDEventInspector::kNoFMD) return;
357 if (found & AliFMDEventInspector::kNoVertex) return;
359 if (triggers & AliAODForwardMult::kPileUp) return;
361 fAODFMD.SetIpZ(ip.Z());
363 if (found & AliFMDEventInspector::kBadVertex) return;
365 // We we do not want to use low flux specific code, we disable it here.
366 if (!fEnableLowFlux) lowFlux = false;
369 AliESDFMD* esdFMD = esd->GetFMDData();
370 // // Apply the sharing filter (or hit merging or clustering if you like)
371 if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, ip.Z())) {
372 AliWarning("Sharing filter failed!");
376 // Calculate the inclusive charged particle density
377 if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) {
378 // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) {
379 AliWarning("Density calculator failed!");
383 if (fEventInspector.GetCollisionSystem() == AliFMDEventInspector::kPbPb) {
384 if (!fEventPlaneFinder.FindEventplane(esd, fAODEP,
385 &(fAODFMD.GetHistogram()), &fHistos))
386 AliWarning("Eventplane finder failed!");
389 // Do the secondary and other corrections.
390 if (!fCorrections.Correct(fHistos, ivz)) {
391 AliWarning("Corrections failed");
395 if (!fHistCollector.Collect(fHistos, fRingSums,
396 ivz, fAODFMD.GetHistogram(),fList,fAODFMD.GetCentrality(),fListVertexBins)) {
397 AliWarning("Histogram collector failed");
401 if (fAODFMD.IsTriggerBits(AliAODForwardMult::kInel))
402 fHData->Add(&(fAODFMD.GetHistogram()));
407 //____________________________________________________________________
409 AliForwardMultiplicityTask::FinishTaskOutput()
412 Warning("FinishTaskOutput", "No list defined");
417 AliAnalysisTaskSE::FinishTaskOutput();
420 //____________________________________________________________________
422 AliForwardMultiplicityTask::Terminate(Option_t*)
430 DGUARD(fDebug,1,"Processing the merged results");
432 TList* list = dynamic_cast<TList*>(GetOutputData(1));
434 AliError(Form("No output list defined (%p)", GetOutputData(1)));
435 if (GetOutputData(1)) GetOutputData(1)->Print();
439 TList* output = new TList;
440 output->SetName(Form("%sResults", GetName()));
443 Double_t nTr = 0, nTrVtx = 0, nAcc = 0;
444 MakeSimpledNdeta(list, output, nTr, nTrVtx, nAcc);
445 MakeRingdNdeta(list, "ringSums", output, "ringResults");
447 fSharingFilter.Terminate(list,output,Int_t(nTr));
448 fDensityCalculator.Terminate(list,output,Int_t(nTrVtx));
449 fCorrections.Terminate(list,output,Int_t(nTrVtx));