]>
Commit | Line | Data |
---|---|---|
2da09763 | 1 | // $Id: AliAnalysisTaskEmcal.cxx 56756 2012-05-30 05:03:02Z loizides $ |
2 | // | |
3 | // Emcal base analysis task. | |
4 | // | |
5 | // Author: S.Aiola | |
6 | ||
7 | #include "AliAnalysisTaskEmcal.h" | |
8 | ||
2da09763 | 9 | #include <TChain.h> |
10 | #include <TClonesArray.h> | |
11 | #include <TList.h> | |
09ca054b | 12 | #include <TObject.h> |
2da09763 | 13 | |
d29ed625 | 14 | #include "AliAODEvent.h" |
2da09763 | 15 | #include "AliAnalysisManager.h" |
16 | #include "AliCentrality.h" | |
09ca054b | 17 | #include "AliEMCALGeometry.h" |
18 | #include "AliESDEvent.h" | |
2da09763 | 19 | #include "AliEmcalJet.h" |
09ca054b | 20 | #include "AliEmcalParticle.h" |
d29ed625 | 21 | #include "AliEventplane.h" |
22 | #include "AliInputEventHandler.h" | |
2da09763 | 23 | #include "AliLog.h" |
09ca054b | 24 | #include "AliMCParticle.h" |
25 | #include "AliVCluster.h" | |
26 | #include "AliVEventHandler.h" | |
27 | #include "AliVParticle.h" | |
2da09763 | 28 | |
29 | ClassImp(AliAnalysisTaskEmcal) | |
30 | ||
31 | //________________________________________________________________________ | |
32 | AliAnalysisTaskEmcal::AliAnalysisTaskEmcal() : | |
33 | AliAnalysisTaskSE("AliAnalysisTaskEmcal"), | |
34 | fAnaType(kTPC), | |
35 | fInitialized(kFALSE), | |
36 | fCreateHisto(kTRUE), | |
20f79d37 | 37 | fTracksName(), |
38 | fCaloName(), | |
2ac8ca4f | 39 | fMinCent(-999), |
40 | fMaxCent(-999), | |
41 | fMinVz(-999), | |
42 | fMaxVz(-999), | |
43 | fOffTrigger(AliVEvent::kAny), | |
b4339010 | 44 | fTrigClass(), |
2da09763 | 45 | fNbins(500), |
46 | fMinBinPt(0), | |
47 | fMaxBinPt(250), | |
e44e8726 | 48 | fClusPtCut(0.15), |
49 | fTrackPtCut(0.15), | |
9733b37f | 50 | fMinTrackEta(-0.9), |
51 | fMaxTrackEta(0.9), | |
52 | fMinTrackPhi(-10), | |
53 | fMaxTrackPhi(10), | |
8210e4cb | 54 | fClusTimeCutLow(-10), |
55 | fClusTimeCutUp(10), | |
2da09763 | 56 | fTracks(0), |
57 | fCaloClusters(0), | |
58 | fCent(0), | |
59 | fCentBin(-1), | |
3c124212 | 60 | fEPV0(-1.0), |
61 | fEPV0A(-1.0), | |
62 | fEPV0C(-1.0), | |
b4339010 | 63 | fNVertCont(0), |
1f6fff78 | 64 | fBeamType(kNA), |
2da09763 | 65 | fOutput(0) |
66 | { | |
67 | // Default constructor. | |
68 | ||
69 | fVertex[0] = 0; | |
70 | fVertex[1] = 0; | |
71 | fVertex[2] = 0; | |
2da09763 | 72 | } |
73 | ||
74 | //________________________________________________________________________ | |
75 | AliAnalysisTaskEmcal::AliAnalysisTaskEmcal(const char *name, Bool_t histo) : | |
76 | AliAnalysisTaskSE(name), | |
77 | fAnaType(kTPC), | |
78 | fInitialized(kFALSE), | |
79 | fCreateHisto(histo), | |
20f79d37 | 80 | fTracksName(), |
81 | fCaloName(), | |
2ac8ca4f | 82 | fMinCent(-999), |
83 | fMaxCent(-999), | |
84 | fMinVz(-999), | |
85 | fMaxVz(-999), | |
86 | fOffTrigger(AliVEvent::kAny), | |
b4339010 | 87 | fTrigClass(), |
2da09763 | 88 | fNbins(500), |
89 | fMinBinPt(0), | |
90 | fMaxBinPt(250), | |
e44e8726 | 91 | fClusPtCut(0.15), |
92 | fTrackPtCut(0.15), | |
9733b37f | 93 | fMinTrackEta(-0.9), |
94 | fMaxTrackEta(0.9), | |
95 | fMinTrackPhi(-10), | |
96 | fMaxTrackPhi(10), | |
8210e4cb | 97 | fClusTimeCutLow(-10), |
98 | fClusTimeCutUp(10), | |
2da09763 | 99 | fTracks(0), |
100 | fCaloClusters(0), | |
101 | fCent(0), | |
102 | fCentBin(-1), | |
3c124212 | 103 | fEPV0(-1.0), |
104 | fEPV0A(-1.0), | |
105 | fEPV0C(-1.0), | |
b4339010 | 106 | fNVertCont(0), |
1f6fff78 | 107 | fBeamType(kNA), |
2da09763 | 108 | fOutput(0) |
109 | { | |
110 | // Standard constructor. | |
111 | ||
112 | fVertex[0] = 0; | |
113 | fVertex[1] = 0; | |
114 | fVertex[2] = 0; | |
115 | ||
116 | if (fCreateHisto) { | |
2da09763 | 117 | DefineOutput(1, TList::Class()); |
118 | } | |
119 | } | |
120 | ||
121 | //________________________________________________________________________ | |
122 | AliAnalysisTaskEmcal::~AliAnalysisTaskEmcal() | |
123 | { | |
124 | // Destructor | |
125 | } | |
126 | ||
127 | //________________________________________________________________________ | |
629c7ac0 | 128 | void AliAnalysisTaskEmcal::UserExec(Option_t *) |
129 | { | |
130 | // Main loop, called for each event. | |
131 | ||
e44e8726 | 132 | if (!fInitialized) |
b3376347 | 133 | ExecOnce(); |
629c7ac0 | 134 | |
e44e8726 | 135 | if (!fInitialized) |
136 | return; | |
137 | ||
629c7ac0 | 138 | if (!RetrieveEventObjects()) |
139 | return; | |
140 | ||
2ac8ca4f | 141 | if (!IsEventSelected()) |
142 | return; | |
143 | ||
629c7ac0 | 144 | if (!Run()) |
145 | return; | |
146 | ||
147 | if (!FillHistograms()) | |
148 | return; | |
149 | ||
2ac8ca4f | 150 | if (fCreateHisto && fOutput) { |
629c7ac0 | 151 | // information for this iteration of the UserExec in the container |
152 | PostData(1, fOutput); | |
153 | } | |
154 | } | |
155 | ||
156 | //________________________________________________________________________ | |
157 | Bool_t AliAnalysisTaskEmcal::AcceptCluster(AliVCluster *clus, Bool_t acceptMC) const | |
2da09763 | 158 | { |
629c7ac0 | 159 | // Return true if cluster is accepted. |
160 | ||
161 | if (!clus) | |
162 | return kFALSE; | |
163 | ||
164 | if (!clus->IsEMCAL()) | |
165 | return kFALSE; | |
166 | ||
167 | if (!acceptMC && clus->Chi2() == 100) | |
168 | return kFALSE; | |
169 | ||
090a0c3e | 170 | if (clus->GetTOF() > fClusTimeCutUp || clus->GetTOF() < fClusTimeCutLow) |
171 | return kFALSE; | |
172 | ||
629c7ac0 | 173 | TLorentzVector nPart; |
174 | clus->GetMomentum(nPart, const_cast<Double_t*>(fVertex)); | |
175 | ||
e44e8726 | 176 | if (nPart.Et() < fClusPtCut) |
629c7ac0 | 177 | return kFALSE; |
178 | ||
179 | return kTRUE; | |
180 | } | |
181 | ||
182 | //________________________________________________________________________ | |
183 | Bool_t AliAnalysisTaskEmcal::AcceptEmcalPart(AliEmcalParticle *part, Bool_t acceptMC) const | |
184 | { | |
185 | // Return true if EMCal particle is accepted. | |
186 | ||
187 | if (!part) | |
188 | return kFALSE; | |
189 | ||
190 | if (fAnaType == kEMCAL && !part->IsEMCAL()) | |
191 | return kFALSE; | |
192 | ||
e44e8726 | 193 | if ((part->IsTrack() && part->Pt() < fTrackPtCut) || (part->IsCluster() && part->Pt() < fClusPtCut)) |
629c7ac0 | 194 | return kFALSE; |
195 | ||
196 | if (!acceptMC && part->IsMC()) | |
197 | return kFALSE; | |
198 | ||
199 | return kTRUE; | |
200 | } | |
201 | ||
202 | //________________________________________________________________________ | |
203 | Bool_t AliAnalysisTaskEmcal::AcceptTrack(AliVTrack *track, Bool_t acceptMC) const | |
204 | { | |
205 | // Return true if track is accepted. | |
206 | ||
207 | if (!track) | |
208 | return kFALSE; | |
209 | ||
210 | if (!acceptMC && track->GetLabel() == 100) | |
211 | return kFALSE; | |
212 | ||
e44e8726 | 213 | if (track->Pt() < fTrackPtCut) |
629c7ac0 | 214 | return kFALSE; |
9733b37f | 215 | |
216 | if (track->Eta() < fMinTrackEta || track->Eta() > fMaxTrackEta || | |
217 | track->Phi() < fMinTrackPhi || track->Phi() > fMaxTrackPhi) | |
218 | return kFALSE; | |
629c7ac0 | 219 | |
220 | return kTRUE; | |
2da09763 | 221 | } |
222 | ||
629c7ac0 | 223 | //________________________________________________________________________ |
b3376347 | 224 | void AliAnalysisTaskEmcal::ExecOnce() |
8a28ded1 | 225 | { |
226 | // Init the analysis. | |
2ac8ca4f | 227 | |
b3376347 | 228 | if (!InputEvent()) { |
229 | AliError(Form("%s: Could not retrieve event! Returning!", GetName())); | |
230 | return; | |
231 | } | |
232 | ||
a5621834 | 233 | if (!fCaloName.IsNull() && (fAnaType == kEMCAL || fAnaType == kEMCALOnly) && !fCaloClusters) { |
b3376347 | 234 | fCaloClusters = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fCaloName)); |
235 | if (!fCaloClusters) { | |
236 | AliError(Form("%s: Could not retrieve clusters %s!", GetName(), fCaloName.Data())); | |
237 | return; | |
238 | } else { | |
239 | TClass *cl = fCaloClusters->GetClass(); | |
240 | if (!cl->GetBaseClass("AliVCluster") && !cl->GetBaseClass("AliEmcalParticle")) { | |
241 | AliError(Form("%s: Collection %s does not contain AliVCluster nor AliEmcalParticle objects!", GetName(), fCaloName.Data())); | |
242 | fCaloClusters = 0; | |
243 | return; | |
244 | } | |
245 | } | |
246 | } | |
247 | ||
a5621834 | 248 | if (!fTracksName.IsNull() && fAnaType != kEMCALOnly && !fTracks) { |
b3376347 | 249 | fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksName)); |
250 | if (!fTracks) { | |
251 | AliError(Form("%s: Could not retrieve tracks %s!", GetName(), fTracksName.Data())); | |
252 | return; | |
253 | } else { | |
254 | TClass *cl = fTracks->GetClass(); | |
255 | if (!cl->GetBaseClass("AliVParticle") && !cl->GetBaseClass("AliEmcalParticle")) { | |
256 | AliError(Form("%s: Collection %s does not contain AliVParticle nor AliEmcalParticle objects!", GetName(), fTracksName.Data())); | |
257 | fTracks = 0; | |
258 | return; | |
259 | } | |
260 | } | |
261 | } | |
8a28ded1 | 262 | SetInitialized(); |
263 | } | |
264 | ||
2ac8ca4f | 265 | //_____________________________________________________ |
266 | AliAnalysisTaskEmcal::BeamType AliAnalysisTaskEmcal::GetBeamType() | |
267 | { | |
268 | // Get beam type : pp-AA-pA | |
269 | // ESDs have it directly, AODs get it from hardcoded run number ranges | |
270 | ||
271 | AliESDEvent *esd = dynamic_cast<AliESDEvent*>(InputEvent()); | |
272 | if (esd) { | |
273 | const AliESDRun *run = esd->GetESDRun(); | |
274 | TString beamType = run->GetBeamType(); | |
275 | if (beamType == "p-p") | |
276 | return kpp; | |
277 | else if (beamType == "A-A") | |
278 | return kAA; | |
279 | else if (beamType == "p-A") | |
280 | return kpA; | |
281 | else | |
282 | return kNA; | |
283 | } else { | |
284 | Int_t runNumber = InputEvent()->GetRunNumber(); | |
285 | if ((runNumber >= 136851 && runNumber <= 139517) || // LHC10h | |
286 | (runNumber >= 166529 && runNumber <= 170593)) // LHC11h | |
287 | { | |
288 | return kAA; | |
289 | } else { | |
290 | return kpp; | |
291 | } | |
292 | } | |
293 | } | |
294 | ||
295 | //________________________________________________________________________ | |
d29ed625 | 296 | Bool_t AliAnalysisTaskEmcal::IsEventSelected() |
2ac8ca4f | 297 | { |
298 | // Check if event is selected | |
299 | ||
300 | if (fOffTrigger != AliVEvent::kAny) { | |
d29ed625 | 301 | UInt_t res = 0; |
302 | const AliESDEvent *eev = dynamic_cast<const AliESDEvent*>(InputEvent()); | |
303 | if (eev) { | |
304 | res = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected(); | |
305 | } else { | |
306 | const AliAODEvent *aev = dynamic_cast<const AliAODEvent*>(InputEvent()); | |
307 | if (aev) { | |
308 | res = aev->GetHeader()->GetOfflineTrigger(); | |
309 | } | |
310 | } | |
b4339010 | 311 | if ((res & fOffTrigger) == 0) |
312 | return kFALSE; | |
313 | } | |
314 | ||
315 | if (!fTrigClass.IsNull()) { | |
316 | TString fired; | |
317 | const AliESDEvent *eev = dynamic_cast<const AliESDEvent*>(InputEvent()); | |
318 | if (eev) { | |
319 | fired = eev->GetFiredTriggerClasses(); | |
320 | } else { | |
321 | const AliAODEvent *aev = dynamic_cast<const AliAODEvent*>(InputEvent()); | |
322 | if (aev) { | |
323 | fired = aev->GetFiredTriggerClasses(); | |
324 | } | |
325 | } | |
326 | if (!fired.Contains("-B-")) | |
327 | return kFALSE; | |
328 | TObjArray *arr = fTrigClass.Tokenize("|"); | |
329 | if (!arr) | |
330 | return kFALSE; | |
331 | Bool_t match = 0; | |
332 | for (Int_t i=0;i<arr->GetEntriesFast();++i) { | |
333 | TObject *obj = arr->At(i); | |
334 | if (!obj) | |
335 | continue; | |
336 | if (fired.Contains(obj->GetName())) { | |
337 | match = 1; | |
338 | break; | |
339 | } | |
340 | } | |
341 | delete arr; | |
342 | if (!match) | |
2ac8ca4f | 343 | return kFALSE; |
344 | } | |
345 | ||
346 | if ((fMinCent != -999) && (fMaxCent != -999)) { | |
347 | if (fCent<fMinCent) | |
348 | return kFALSE; | |
349 | if (fCent>fMaxCent) | |
350 | return kFALSE; | |
351 | } | |
352 | ||
353 | if ((fMinVz != -999) && (fMaxVz != -999)) { | |
b4339010 | 354 | if (fNVertCont == 0 ) |
355 | return kFALSE; | |
2ac8ca4f | 356 | Double_t vz = fVertex[2]; |
357 | if (vz<fMinVz) | |
358 | return kFALSE; | |
359 | if (vz>fMaxVz) | |
360 | return kFALSE; | |
361 | } | |
362 | ||
363 | return kTRUE; | |
364 | } | |
365 | ||
c596bd28 | 366 | //________________________________________________________________________ |
367 | TClonesArray *AliAnalysisTaskEmcal::GetArrayFromEvent(const char *name, const char *clname) | |
368 | { | |
369 | // Get array from event. | |
370 | ||
371 | TClonesArray *arr = 0; | |
372 | TString sname(name); | |
373 | if (!sname.IsNull()) { | |
374 | arr = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(sname)); | |
375 | if (!arr) { | |
376 | AliWarning(Form("%s: Could not retrieve array with name %s!", GetName(), name)); | |
377 | return 0; | |
378 | } | |
af0280a9 | 379 | } else { |
380 | return 0; | |
c596bd28 | 381 | } |
af0280a9 | 382 | |
c596bd28 | 383 | if (!clname) |
384 | return arr; | |
385 | ||
386 | TString objname(arr->GetClass()->GetName()); | |
387 | TClass cls(objname); | |
388 | if (!cls.InheritsFrom(clname)) { | |
389 | AliWarning(Form("%s: Objects of type %s in %s are not inherited from %s!", | |
390 | GetName(), cls.GetName(), name, clname)); | |
391 | return 0; | |
392 | } | |
393 | return arr; | |
394 | } | |
395 | ||
2da09763 | 396 | //________________________________________________________________________ |
397 | Bool_t AliAnalysisTaskEmcal::RetrieveEventObjects() | |
398 | { | |
399 | // Retrieve objects from event. | |
400 | ||
2da09763 | 401 | fVertex[0] = 0; |
402 | fVertex[1] = 0; | |
403 | fVertex[2] = 0; | |
b4339010 | 404 | fNVertCont = 0; |
405 | ||
406 | const AliVVertex *vert = InputEvent()->GetPrimaryVertex(); | |
407 | if (vert) { | |
408 | vert->GetXYZ(fVertex); | |
409 | fNVertCont = vert->GetNContributors(); | |
410 | } | |
2da09763 | 411 | |
1f6fff78 | 412 | fBeamType = GetBeamType(); |
413 | ||
414 | if (fBeamType == kAA) { | |
2da09763 | 415 | AliCentrality *aliCent = InputEvent()->GetCentrality(); |
416 | if (aliCent) { | |
417 | fCent = aliCent->GetCentralityPercentile("V0M"); | |
418 | if (fCent >= 0 && fCent < 10) fCentBin = 0; | |
419 | else if (fCent >= 10 && fCent < 30) fCentBin = 1; | |
420 | else if (fCent >= 30 && fCent < 50) fCentBin = 2; | |
421 | else if (fCent >= 50 && fCent <= 100) fCentBin = 3; | |
422 | else { | |
901cc837 | 423 | AliWarning(Form("%s: Negative centrality: %f. Assuming 99", GetName(), fCent)); |
2da09763 | 424 | fCentBin = 3; |
425 | } | |
901cc837 | 426 | } else { |
427 | AliWarning(Form("%s: Could not retrieve centrality information! Assuming 99", GetName())); | |
2da09763 | 428 | fCentBin = 3; |
429 | } | |
3c124212 | 430 | AliEventplane *aliEP = InputEvent()->GetEventplane(); |
431 | if (aliEP) { | |
432 | fEPV0 = aliEP->GetEventplane("V0" ,InputEvent()); | |
433 | fEPV0A = aliEP->GetEventplane("V0A",InputEvent()); | |
434 | fEPV0C = aliEP->GetEventplane("V0C",InputEvent()); | |
435 | } else { | |
436 | AliWarning(Form("%s: Could not retrieve event plane information!", GetName())); | |
437 | } | |
901cc837 | 438 | } else { |
2da09763 | 439 | fCent = 99; |
440 | fCentBin = 0; | |
441 | } | |
442 | ||
2da09763 | 443 | return kTRUE; |
444 | } |