]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliForwardMultiplicityTask.cxx
Renamed some member functions for more logical names
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliForwardMultiplicityTask.cxx
CommitLineData
7984e5f7 1//
2// Calculate the multiplicity in the forward regions event-by-event
3//
4// Inputs:
5// - AliESDEvent
6//
7// Outputs:
8// - AliAODForwardMult
9//
10// Histograms
11//
12// Corrections used
13//
0bd4b00f 14#include "AliForwardMultiplicityTask.h"
7e4038b5 15#include "AliTriggerAnalysis.h"
16#include "AliPhysicsSelection.h"
17#include "AliLog.h"
7e4038b5 18#include "AliESDEvent.h"
19#include "AliAODHandler.h"
20#include "AliMultiplicity.h"
21#include "AliInputEventHandler.h"
0bd4b00f 22#include "AliForwardCorrectionManager.h"
23#include "AliAnalysisManager.h"
7e4038b5 24#include <TH1.h>
25#include <TDirectory.h>
26#include <TTree.h>
0bd4b00f 27#include <TROOT.h>
7ec4d843 28
7e4038b5 29
30//====================================================================
0bd4b00f 31AliForwardMultiplicityTask::AliForwardMultiplicityTask()
eb865a4f 32 : AliForwardMultiplicityBase(),
7e4038b5 33 fHData(0),
7e4038b5 34 fESDFMD(),
35 fHistos(),
36 fAODFMD(),
2b556440 37 fAODEP(),
5bb5d1f6 38 fRingSums(),
fffea31d 39 fEventInspector(),
7e4038b5 40 fSharingFilter(),
41 fDensityCalculator(),
42 fCorrections(),
43 fHistCollector(),
2b556440 44 fEventPlaneFinder(),
fffea31d 45 fList(0)
7e4038b5 46{
7984e5f7 47 //
48 // Constructor
49 //
5ca83fee 50 DGUARD(fDebug, 3,"Default CTOR of AliForwardMultiplicityTask");
7e4038b5 51}
52
53//____________________________________________________________________
0bd4b00f 54AliForwardMultiplicityTask::AliForwardMultiplicityTask(const char* name)
eb865a4f 55 : AliForwardMultiplicityBase(name),
7e4038b5 56 fHData(0),
7e4038b5 57 fESDFMD(),
58 fHistos(),
4cbdf467 59 fAODFMD(false),
2b556440 60 fAODEP(false),
5bb5d1f6 61 fRingSums(),
fffea31d 62 fEventInspector("event"),
7e4038b5 63 fSharingFilter("sharing"),
64 fDensityCalculator("density"),
65 fCorrections("corrections"),
66 fHistCollector("collector"),
2b556440 67 fEventPlaneFinder("eventplane"),
fffea31d 68 fList(0)
7e4038b5 69{
7984e5f7 70 //
71 // Constructor
72 //
73 // Parameters:
74 // name Name of task
75 //
5ca83fee 76 DGUARD(fDebug, 3,"named CTOR of AliForwardMultiplicityTask: %s", name);
7e4038b5 77 DefineOutput(1, TList::Class());
5934a3e3 78 DefineOutput(2, TList::Class());
7e4038b5 79}
80
81//____________________________________________________________________
0bd4b00f 82AliForwardMultiplicityTask::AliForwardMultiplicityTask(const AliForwardMultiplicityTask& o)
eb865a4f 83 : AliForwardMultiplicityBase(o),
7e4038b5 84 fHData(o.fHData),
7e4038b5 85 fESDFMD(o.fESDFMD),
86 fHistos(o.fHistos),
87 fAODFMD(o.fAODFMD),
2b556440 88 fAODEP(o.fAODEP),
5bb5d1f6 89 fRingSums(o.fRingSums),
fffea31d 90 fEventInspector(o.fEventInspector),
7e4038b5 91 fSharingFilter(o.fSharingFilter),
92 fDensityCalculator(o.fDensityCalculator),
93 fCorrections(o.fCorrections),
94 fHistCollector(o.fHistCollector),
2b556440 95 fEventPlaneFinder(o.fEventPlaneFinder),
fffea31d 96 fList(o.fList)
7e4038b5 97{
7984e5f7 98 //
99 // Copy constructor
100 //
101 // Parameters:
102 // o Object to copy from
103 //
5ca83fee 104 DGUARD(fDebug, 3,"Copy CTOR of AliForwardMultiplicityTask");
0bd4b00f 105 DefineOutput(1, TList::Class());
5934a3e3 106 DefineOutput(2, TList::Class());
7e4038b5 107}
108
109//____________________________________________________________________
0bd4b00f 110AliForwardMultiplicityTask&
111AliForwardMultiplicityTask::operator=(const AliForwardMultiplicityTask& o)
7e4038b5 112{
7984e5f7 113 //
114 // Assignment operator
115 //
116 // Parameters:
117 // o Object to assign from
118 //
119 // Return:
120 // Reference to this object
121 //
f53fb4f6 122 DGUARD(fDebug,3,"Assignment to AliForwardMultiplicityTask");
d015ecfe 123 if (&o == this) return *this;
eb865a4f 124 AliForwardMultiplicityBase::operator=(o);
fffea31d 125
7e4038b5 126 fHData = o.fHData;
fffea31d 127 fEventInspector = o.fEventInspector;
7e4038b5 128 fSharingFilter = o.fSharingFilter;
129 fDensityCalculator = o.fDensityCalculator;
130 fCorrections = o.fCorrections;
131 fHistCollector = o.fHistCollector;
2b556440 132 fEventPlaneFinder = o.fEventPlaneFinder;
7e4038b5 133 fHistos = o.fHistos;
134 fAODFMD = o.fAODFMD;
2b556440 135 fAODEP = o.fAODEP;
5bb5d1f6 136 fRingSums = o.fRingSums;
7e4038b5 137 fList = o.fList;
7e4038b5 138
139 return *this;
140}
141
fffea31d 142//____________________________________________________________________
143void
0bd4b00f 144AliForwardMultiplicityTask::SetDebug(Int_t dbg)
fffea31d 145{
7984e5f7 146 //
147 // Set debug level
148 //
149 // Parameters:
150 // dbg Debug level
151 //
fffea31d 152 fEventInspector.SetDebug(dbg);
fffea31d 153 fSharingFilter.SetDebug(dbg);
154 fDensityCalculator.SetDebug(dbg);
155 fCorrections.SetDebug(dbg);
156 fHistCollector.SetDebug(dbg);
2b556440 157 fEventPlaneFinder.SetDebug(dbg);
fffea31d 158}
159
7e4038b5 160//____________________________________________________________________
6ff251d8 161Bool_t
5934a3e3 162AliForwardMultiplicityTask::SetupForData()
7e4038b5 163{
7984e5f7 164 //
165 // Initialise the sub objects and stuff. Called on first event
166 //
167 //
f53fb4f6 168 DGUARD(fDebug,1,"Initialize sub-algorithms");
7ec4d843 169 const TAxis* pe = 0;
170 const TAxis* pv = 0;
0bd4b00f 171
6ff251d8 172 if (!ReadCorrections(pe,pv)) return false;
fffea31d 173
0bd4b00f 174 fHistos.Init(*pe);
175 fAODFMD.Init(*pe);
2b556440 176 fAODEP.Init(*pe);
5bb5d1f6 177 fRingSums.Init(*pe);
7e4038b5 178
179 fHData = static_cast<TH2D*>(fAODFMD.GetHistogram().Clone("d2Ndetadphi"));
180 fHData->SetStats(0);
181 fHData->SetDirectory(0);
9d99b0dd 182 fList->Add(fHData);
183
5bb5d1f6 184 TList* rings = new TList;
185 rings->SetName("ringSums");
186 rings->SetOwner();
187 fList->Add(rings);
188
189 rings->Add(fRingSums.Get(1, 'I'));
190 rings->Add(fRingSums.Get(2, 'I'));
191 rings->Add(fRingSums.Get(2, 'O'));
192 rings->Add(fRingSums.Get(3, 'I'));
193 rings->Add(fRingSums.Get(3, 'O'));
194 fRingSums.Get(1, 'I')->SetMarkerColor(AliForwardUtil::RingColor(1, 'I'));
195 fRingSums.Get(2, 'I')->SetMarkerColor(AliForwardUtil::RingColor(2, 'I'));
196 fRingSums.Get(2, 'O')->SetMarkerColor(AliForwardUtil::RingColor(2, 'O'));
197 fRingSums.Get(3, 'I')->SetMarkerColor(AliForwardUtil::RingColor(3, 'I'));
198 fRingSums.Get(3, 'O')->SetMarkerColor(AliForwardUtil::RingColor(3, 'O'));
199
5934a3e3 200 fEventInspector.SetupForData(*pv);
201 fSharingFilter.SetupForData(*pe);
202 fDensityCalculator.SetupForData(*pe);
203 fCorrections.SetupForData(*pe);
204 fHistCollector.SetupForData(*pv,*pe);
205 fEventPlaneFinder.SetupForData(*pe);
0bd4b00f 206
207 this->Print();
6ff251d8 208 return true;
7e4038b5 209}
210
211//____________________________________________________________________
212void
0bd4b00f 213AliForwardMultiplicityTask::UserCreateOutputObjects()
7e4038b5 214{
7984e5f7 215 //
216 // Create output objects
217 //
218 //
f53fb4f6 219 DGUARD(fDebug,1,"Create user ouput");
7e4038b5 220 fList = new TList;
9d05ffeb 221 fList->SetOwner();
7e4038b5 222
223 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
0bd4b00f 224 AliAODHandler* ah =
225 dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
fffea31d 226 if (!ah) AliFatal("No AOD output handler set in analysis manager");
7e4038b5 227
228
229 TObject* obj = &fAODFMD;
230 ah->AddBranch("AliAODForwardMult", &obj);
2b556440 231 TObject* epobj = &fAODEP;
232 ah->AddBranch("AliAODForwardEP", &epobj);
7e4038b5 233
5934a3e3 234 fEventInspector.CreateOutputObjects(fList);
235 fSharingFilter.CreateOutputObjects(fList);
236 fDensityCalculator.CreateOutputObjects(fList);
237 fCorrections.CreateOutputObjects(fList);
238 fHistCollector.CreateOutputObjects(fList);
239 fEventPlaneFinder.CreateOutputObjects(fList);
0bd4b00f 240
241 PostData(1, fList);
7e4038b5 242}
243//____________________________________________________________________
244void
0bd4b00f 245AliForwardMultiplicityTask::UserExec(Option_t*)
7e4038b5 246{
7984e5f7 247 //
248 // Process each event
249 //
250 // Parameters:
251 // option Not used
252 //
253
f53fb4f6 254 DGUARD(fDebug,1,"Process the input event");
0bd4b00f 255 // static Int_t cnt = 0;
256 // cnt++;
7e4038b5 257 // Get the input data
7ec4d843 258 AliESDEvent* esd = GetESDEvent();
6ff251d8 259 if (!esd) return;
7e4038b5 260
7e4038b5 261 // Clear stuff
262 fHistos.Clear();
263 fESDFMD.Clear();
264 fAODFMD.Clear();
2b556440 265 fAODEP.Clear();
e58000b7 266
5bb5d1f6 267 Bool_t lowFlux = kFALSE;
268 UInt_t triggers = 0;
269 UShort_t ivz = 0;
5ca83fee 270 TVector3 ip;
5bb5d1f6 271 Double_t cent = -1;
272 UShort_t nClusters = 0;
273 UInt_t found = fEventInspector.Process(esd, triggers, lowFlux,
5ca83fee 274 ivz, ip, cent, nClusters);
e58000b7 275
9bff843b 276 if (found & AliFMDEventInspector::kNoEvent) return;
277 if (found & AliFMDEventInspector::kNoTriggers) return;
278
fffea31d 279 // Set trigger bits, and mark this event for storage
9d99b0dd 280 fAODFMD.SetTriggerBits(triggers);
b2e7f2d6 281 fAODFMD.SetSNN(fEventInspector.GetEnergy());
282 fAODFMD.SetSystem(fEventInspector.GetCollisionSystem());
e58000b7 283 fAODFMD.SetCentrality(cent);
5bb5d1f6 284 fAODFMD.SetNClusters(nClusters);
7e4038b5 285 MarkEventForStore();
2b556440 286
3c5497d0 287 if (found & AliFMDEventInspector::kNoSPD) return;
288 if (found & AliFMDEventInspector::kNoFMD) return;
289 if (found & AliFMDEventInspector::kNoVertex) return;
e58000b7 290
291 if (triggers & AliAODForwardMult::kPileUp) return;
292
5ca83fee 293 fAODFMD.SetIpZ(ip.Z());
7e4038b5 294
fffea31d 295 if (found & AliFMDEventInspector::kBadVertex) return;
7e4038b5 296
0bd4b00f 297 // We we do not want to use low flux specific code, we disable it here.
298 if (!fEnableLowFlux) lowFlux = false;
299
fffea31d 300 // Get FMD data
301 AliESDFMD* esdFMD = esd->GetFMDData();
12fffad7 302 // // Apply the sharing filter (or hit merging or clustering if you like)
5ca83fee 303 if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, ip.Z())) {
fffea31d 304 AliWarning("Sharing filter failed!");
7e4038b5 305 return;
306 }
2b556440 307
7e4038b5 308 // Calculate the inclusive charged particle density
5ca83fee 309 if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) {
f7cfc454 310 // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) {
7e4038b5 311 AliWarning("Density calculator failed!");
312 return;
313 }
2b556440 314
315 if (fEventInspector.GetCollisionSystem() == AliFMDEventInspector::kPbPb) {
5ca83fee 316 if (!fEventPlaneFinder.FindEventplane(esd, fAODEP,
317 &(fAODFMD.GetHistogram()), &fHistos))
2b556440 318 AliWarning("Eventplane finder failed!");
319 }
7e4038b5 320
321 // Do the secondary and other corrections.
322 if (!fCorrections.Correct(fHistos, ivz)) {
323 AliWarning("Corrections failed");
324 return;
325 }
326
5bb5d1f6 327 if (!fHistCollector.Collect(fHistos, fRingSums,
328 ivz, fAODFMD.GetHistogram())) {
7e4038b5 329 AliWarning("Histogram collector failed");
330 return;
331 }
332
333 if (fAODFMD.IsTriggerBits(AliAODForwardMult::kInel))
334 fHData->Add(&(fAODFMD.GetHistogram()));
2d68d438 335
336 PostData(1, fList);
7e4038b5 337}
338
36ffcf83 339//____________________________________________________________________
340void
341AliForwardMultiplicityTask::FinishTaskOutput()
342{
343 if (!fList)
344 Warning("FinishTaskOutput", "No list defined");
345 else {
346 if (fDebug)
347 fList->ls();
348 }
349 AliAnalysisTaskSE::FinishTaskOutput();
350}
351
7e4038b5 352//____________________________________________________________________
353void
0bd4b00f 354AliForwardMultiplicityTask::Terminate(Option_t*)
7e4038b5 355{
7984e5f7 356 //
357 // End of job
358 //
359 // Parameters:
360 // option Not used
361 //
f53fb4f6 362 DGUARD(fDebug,1,"Processing the merged results");
7984e5f7 363
7e4038b5 364 TList* list = dynamic_cast<TList*>(GetOutputData(1));
365 if (!list) {
2d68d438 366 AliError(Form("No output list defined (%p)", GetOutputData(1)));
367 if (GetOutputData(1)) GetOutputData(1)->Print();
7e4038b5 368 return;
369 }
fffea31d 370
5934a3e3 371 TList* output = new TList;
372 output->SetName(Form("%sResults", GetName()));
373 output->SetOwner();
374
5ca83fee 375 Double_t nTr = 0, nTrVtx = 0, nAcc = 0;
5934a3e3 376 MakeSimpledNdeta(list, output, nTr, nTrVtx, nAcc);
377 MakeRingdNdeta(list, "ringSums", output, "ringResults");
378
379 fSharingFilter.Terminate(list,output,Int_t(nTr));
380 fDensityCalculator.Terminate(list,output,Int_t(nTrVtx));
381 fCorrections.Terminate(list,output,Int_t(nTrVtx));
5bb5d1f6 382
5934a3e3 383 PostData(2, output);
7e4038b5 384}
7e4038b5 385
386//
387// EOF
388//