]>
Commit | Line | Data |
---|---|---|
2da09763 | 1 | // |
2 | // Emcal base analysis task. | |
3 | // | |
9239b066 | 4 | // Author: S.Aiola, M. Verweij |
219799d0 | 5 | |
2da09763 | 6 | #include "AliAnalysisTaskEmcal.h" |
7 | ||
2da09763 | 8 | #include <TClonesArray.h> |
9 | #include <TList.h> | |
09ca054b | 10 | #include <TObject.h> |
159802e2 | 11 | #include <TH1F.h> |
ed0243d8 | 12 | #include <TProfile.h> |
13 | #include <TSystem.h> | |
14 | #include <TFile.h> | |
15 | #include <TChain.h> | |
16 | #include <TKey.h> | |
2da09763 | 17 | |
d29ed625 | 18 | #include "AliAODEvent.h" |
2da09763 | 19 | #include "AliAnalysisManager.h" |
20 | #include "AliCentrality.h" | |
09ca054b | 21 | #include "AliEMCALGeometry.h" |
22 | #include "AliESDEvent.h" | |
09ca054b | 23 | #include "AliEmcalParticle.h" |
d29ed625 | 24 | #include "AliEventplane.h" |
25 | #include "AliInputEventHandler.h" | |
2da09763 | 26 | #include "AliLog.h" |
09ca054b | 27 | #include "AliMCParticle.h" |
28 | #include "AliVCluster.h" | |
29 | #include "AliVEventHandler.h" | |
30 | #include "AliVParticle.h" | |
00c77045 | 31 | #include "AliVCaloTrigger.h" |
ed0243d8 | 32 | #include "AliGenPythiaEventHeader.h" |
33 | #include "AliAODMCHeader.h" | |
34 | #include "AliMCEvent.h" | |
9239b066 | 35 | #include "AliAnalysisUtils.h" |
37a63fdf | 36 | #include "AliEmcalTriggerPatchInfo.h" |
9239b066 | 37 | |
38 | #include "AliParticleContainer.h" | |
39 | #include "AliClusterContainer.h" | |
2da09763 | 40 | |
41 | ClassImp(AliAnalysisTaskEmcal) | |
42 | ||
43 | //________________________________________________________________________ | |
44 | AliAnalysisTaskEmcal::AliAnalysisTaskEmcal() : | |
45 | AliAnalysisTaskSE("AliAnalysisTaskEmcal"), | |
159802e2 | 46 | fForceBeamType(kNA), |
47 | fGeneralHistograms(kFALSE), | |
2da09763 | 48 | fInitialized(kFALSE), |
49 | fCreateHisto(kTRUE), | |
f660c2d6 | 50 | fCaloCellsName(), |
00c77045 | 51 | fCaloTriggersName(), |
37a63fdf | 52 | fCaloTriggerPatchInfoName(), |
2ac8ca4f | 53 | fMinCent(-999), |
54 | fMaxCent(-999), | |
55 | fMinVz(-999), | |
56 | fMaxVz(-999), | |
9239b066 | 57 | fTrackPtCut(0), |
58 | fMinNTrack(0), | |
59 | fUseAliAnaUtils(kFALSE), | |
60 | fAliAnalysisUtils(0x0), | |
2ac8ca4f | 61 | fOffTrigger(AliVEvent::kAny), |
b4339010 | 62 | fTrigClass(), |
8e49a788 | 63 | fTriggerTypeSel(kND), |
2da09763 | 64 | fNbins(500), |
65 | fMinBinPt(0), | |
66 | fMaxBinPt(250), | |
6c41fc8c | 67 | fMinPtTrackInEmcal(0), |
6f6dc2ba | 68 | fEventPlaneVsEmcal(-1), |
254370e1 | 69 | fMinEventPlane(-1e6), |
70 | fMaxEventPlane(1e6), | |
a52de945 | 71 | fCentEst("V0M"), |
8c0d179d | 72 | fIsEmbedded(kFALSE), |
ed0243d8 | 73 | fIsPythia(kFALSE), |
74 | fSelectPtHardBin(-999), | |
75 | fMinMCLabel(0), | |
76 | fMCLabelShift(0), | |
2130abba | 77 | fNcentBins(4), |
78a69392 | 78 | fNeedEmcalGeom(kTRUE), |
1876c758 | 79 | fIsEsd(kFALSE), |
159802e2 | 80 | fGeom(0), |
2da09763 | 81 | fTracks(0), |
82 | fCaloClusters(0), | |
f660c2d6 | 83 | fCaloCells(0), |
00c77045 | 84 | fCaloTriggers(0), |
37a63fdf | 85 | fTriggerPatchInfo(0), |
2da09763 | 86 | fCent(0), |
87 | fCentBin(-1), | |
3c124212 | 88 | fEPV0(-1.0), |
89 | fEPV0A(-1.0), | |
90 | fEPV0C(-1.0), | |
b4339010 | 91 | fNVertCont(0), |
1f6fff78 | 92 | fBeamType(kNA), |
ed0243d8 | 93 | fPythiaHeader(0), |
94 | fPtHard(0), | |
95 | fPtHardBin(0), | |
96 | fNTrials(0), | |
8c34a1cc | 97 | fXsection(0), |
9239b066 | 98 | fParticleCollArray(), |
99 | fClusterCollArray(), | |
37a63fdf | 100 | fMainTriggerPatch(0x0), |
f9a1843e | 101 | fTriggers(0), |
a4e91fed | 102 | fOutput(0), |
219799d0 | 103 | fHistEventCount(0), |
ed0243d8 | 104 | fHistTrialsAfterSel(0), |
105 | fHistEventsAfterSel(0), | |
6da81bde | 106 | fHistXsectionAfterSel(0), |
ed0243d8 | 107 | fHistTrials(0), |
ed0243d8 | 108 | fHistEvents(0), |
6da81bde | 109 | fHistXsection(0), |
ed0243d8 | 110 | fHistPtHard(0), |
a4e91fed | 111 | fHistCentrality(0), |
6f6dc2ba | 112 | fHistZVertex(0), |
8e49a788 | 113 | fHistEventPlane(0), |
114 | fHistEventRejection(0) | |
2da09763 | 115 | { |
116 | // Default constructor. | |
117 | ||
118 | fVertex[0] = 0; | |
119 | fVertex[1] = 0; | |
120 | fVertex[2] = 0; | |
9239b066 | 121 | |
122 | fParticleCollArray.SetOwner(kTRUE); | |
123 | fClusterCollArray.SetOwner(kTRUE); | |
2da09763 | 124 | } |
125 | ||
126 | //________________________________________________________________________ | |
127 | AliAnalysisTaskEmcal::AliAnalysisTaskEmcal(const char *name, Bool_t histo) : | |
128 | AliAnalysisTaskSE(name), | |
159802e2 | 129 | fForceBeamType(kNA), |
130 | fGeneralHistograms(kFALSE), | |
2da09763 | 131 | fInitialized(kFALSE), |
132 | fCreateHisto(histo), | |
f660c2d6 | 133 | fCaloCellsName(), |
00c77045 | 134 | fCaloTriggersName(), |
37a63fdf | 135 | fCaloTriggerPatchInfoName(), |
2ac8ca4f | 136 | fMinCent(-999), |
137 | fMaxCent(-999), | |
138 | fMinVz(-999), | |
139 | fMaxVz(-999), | |
9239b066 | 140 | fTrackPtCut(0), |
141 | fMinNTrack(0), | |
142 | fUseAliAnaUtils(kFALSE), | |
143 | fAliAnalysisUtils(0x0), | |
2ac8ca4f | 144 | fOffTrigger(AliVEvent::kAny), |
b4339010 | 145 | fTrigClass(), |
8e49a788 | 146 | fTriggerTypeSel(kND), |
2da09763 | 147 | fNbins(500), |
148 | fMinBinPt(0), | |
149 | fMaxBinPt(250), | |
6c41fc8c | 150 | fMinPtTrackInEmcal(0), |
6f6dc2ba | 151 | fEventPlaneVsEmcal(-1), |
254370e1 | 152 | fMinEventPlane(-1e6), |
153 | fMaxEventPlane(1e6), | |
a52de945 | 154 | fCentEst("V0M"), |
8c0d179d | 155 | fIsEmbedded(kFALSE), |
ed0243d8 | 156 | fIsPythia(kFALSE), |
157 | fSelectPtHardBin(-999), | |
158 | fMinMCLabel(0), | |
159 | fMCLabelShift(0), | |
2130abba | 160 | fNcentBins(4), |
78a69392 | 161 | fNeedEmcalGeom(kTRUE), |
1876c758 | 162 | fIsEsd(kFALSE), |
159802e2 | 163 | fGeom(0), |
2da09763 | 164 | fTracks(0), |
165 | fCaloClusters(0), | |
f660c2d6 | 166 | fCaloCells(0), |
00c77045 | 167 | fCaloTriggers(0), |
37a63fdf | 168 | fTriggerPatchInfo(0), |
2da09763 | 169 | fCent(0), |
170 | fCentBin(-1), | |
3c124212 | 171 | fEPV0(-1.0), |
172 | fEPV0A(-1.0), | |
173 | fEPV0C(-1.0), | |
b4339010 | 174 | fNVertCont(0), |
1f6fff78 | 175 | fBeamType(kNA), |
ed0243d8 | 176 | fPythiaHeader(0), |
177 | fPtHard(0), | |
178 | fPtHardBin(0), | |
179 | fNTrials(0), | |
8c34a1cc | 180 | fXsection(0), |
9239b066 | 181 | fParticleCollArray(), |
182 | fClusterCollArray(), | |
37a63fdf | 183 | fMainTriggerPatch(0x0), |
f9a1843e | 184 | fTriggers(0), |
a4e91fed | 185 | fOutput(0), |
219799d0 | 186 | fHistEventCount(0), |
ed0243d8 | 187 | fHistTrialsAfterSel(0), |
188 | fHistEventsAfterSel(0), | |
6da81bde | 189 | fHistXsectionAfterSel(0), |
ed0243d8 | 190 | fHistTrials(0), |
ed0243d8 | 191 | fHistEvents(0), |
6da81bde | 192 | fHistXsection(0), |
ed0243d8 | 193 | fHistPtHard(0), |
a4e91fed | 194 | fHistCentrality(0), |
6f6dc2ba | 195 | fHistZVertex(0), |
8e49a788 | 196 | fHistEventPlane(0), |
197 | fHistEventRejection(0) | |
2da09763 | 198 | { |
199 | // Standard constructor. | |
200 | ||
201 | fVertex[0] = 0; | |
202 | fVertex[1] = 0; | |
203 | fVertex[2] = 0; | |
204 | ||
9239b066 | 205 | fParticleCollArray.SetOwner(kTRUE); |
206 | fClusterCollArray.SetOwner(kTRUE); | |
207 | ||
2da09763 | 208 | if (fCreateHisto) { |
2da09763 | 209 | DefineOutput(1, TList::Class()); |
210 | } | |
211 | } | |
212 | ||
213 | //________________________________________________________________________ | |
214 | AliAnalysisTaskEmcal::~AliAnalysisTaskEmcal() | |
215 | { | |
216 | // Destructor | |
217 | } | |
218 | ||
9239b066 | 219 | //________________________________________________________________________ |
220 | void AliAnalysisTaskEmcal::SetClusPtCut(Double_t cut, Int_t c) | |
221 | { | |
222 | AliClusterContainer *cont = GetClusterContainer(c); | |
223 | if (cont) cont->SetClusPtCut(cut); | |
224 | else AliError(Form("%s in SetClusPtCut(...): container %d not found",GetName(),c)); | |
225 | } | |
226 | ||
227 | //________________________________________________________________________ | |
228 | void AliAnalysisTaskEmcal::SetClusTimeCut(Double_t min, Double_t max, Int_t c) | |
229 | { | |
230 | AliClusterContainer *cont = GetClusterContainer(c); | |
231 | if (cont) cont->SetClusTimeCut(min,max); | |
232 | else AliError(Form("%s in SetClusTimeCut(...): container %d not found",GetName(),c)); | |
233 | } | |
234 | ||
235 | //________________________________________________________________________ | |
236 | void AliAnalysisTaskEmcal::SetTrackPtCut(Double_t cut, Int_t c) | |
237 | { | |
238 | AliParticleContainer *cont = GetParticleContainer(c); | |
239 | if (cont) cont->SetParticlePtCut(cut); | |
240 | else AliError(Form("%s in SetTrackPtCut(...): container %d not found",GetName(),c)); | |
241 | ||
242 | fTrackPtCut = cut; | |
243 | } | |
244 | ||
245 | //________________________________________________________________________ | |
246 | void AliAnalysisTaskEmcal::SetTrackEtaLimits(Double_t min, Double_t max, Int_t c) | |
247 | { | |
248 | AliParticleContainer *cont = GetParticleContainer(c); | |
249 | if (cont) cont->SetParticleEtaLimits(min,max); | |
250 | else AliError(Form("%s in SetTrackPtCut(...): container %d not found",GetName(),c)); | |
251 | } | |
252 | ||
253 | //________________________________________________________________________ | |
254 | void AliAnalysisTaskEmcal::SetTrackPhiLimits(Double_t min, Double_t max, Int_t c) | |
255 | { | |
256 | AliParticleContainer *cont = GetParticleContainer(c); | |
257 | if (cont) cont->SetParticlePhiLimits(min,max); | |
258 | else AliError(Form("%s in SetTrackPhiLimits(...): container %d not found",GetName(),c)); | |
259 | } | |
260 | ||
159802e2 | 261 | //________________________________________________________________________ |
262 | void AliAnalysisTaskEmcal::UserCreateOutputObjects() | |
263 | { | |
264 | // Create user output. | |
1876c758 | 265 | |
266 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
267 | if (mgr) { | |
268 | AliVEventHandler *evhand = mgr->GetInputEventHandler(); | |
269 | if (evhand) { | |
270 | if (evhand->InheritsFrom("AliESDInputHandler")) { | |
271 | fIsEsd = kTRUE; | |
272 | } | |
273 | else { | |
274 | fIsEsd = kFALSE; | |
275 | } | |
276 | } | |
277 | else { | |
278 | AliError("Event handler not found!"); | |
279 | } | |
280 | } | |
281 | else { | |
282 | AliError("Analysis manager not found!"); | |
283 | } | |
284 | ||
159802e2 | 285 | if (!fCreateHisto) |
286 | return; | |
287 | ||
288 | OpenFile(1); | |
289 | fOutput = new TList(); | |
290 | fOutput->SetOwner(); | |
291 | ||
2130abba | 292 | if (fForceBeamType == kpp) |
293 | fNcentBins = 1; | |
294 | ||
159802e2 | 295 | if (!fGeneralHistograms) |
296 | return; | |
297 | ||
ed0243d8 | 298 | if (fIsPythia) { |
299 | fHistTrialsAfterSel = new TH1F("fHistTrialsAfterSel", "fHistTrialsAfterSel", 11, 0, 11); | |
300 | fHistTrialsAfterSel->GetXaxis()->SetTitle("p_{T} hard bin"); | |
301 | fHistTrialsAfterSel->GetYaxis()->SetTitle("trials"); | |
302 | fOutput->Add(fHistTrialsAfterSel); | |
303 | ||
304 | fHistEventsAfterSel = new TH1F("fHistEventsAfterSel", "fHistEventsAfterSel", 11, 0, 11); | |
305 | fHistEventsAfterSel->GetXaxis()->SetTitle("p_{T} hard bin"); | |
306 | fHistEventsAfterSel->GetYaxis()->SetTitle("total events"); | |
307 | fOutput->Add(fHistEventsAfterSel); | |
6da81bde | 308 | |
309 | fHistXsectionAfterSel = new TProfile("fHistXsectionAfterSel", "fHistXsectionAfterSel", 11, 0, 11); | |
310 | fHistXsectionAfterSel->GetXaxis()->SetTitle("p_{T} hard bin"); | |
311 | fHistXsectionAfterSel->GetYaxis()->SetTitle("xsection"); | |
312 | fOutput->Add(fHistXsectionAfterSel); | |
ed0243d8 | 313 | |
314 | fHistTrials = new TH1F("fHistTrials", "fHistTrials", 11, 0, 11); | |
315 | fHistTrials->GetXaxis()->SetTitle("p_{T} hard bin"); | |
316 | fHistTrials->GetYaxis()->SetTitle("trials"); | |
317 | fOutput->Add(fHistTrials); | |
318 | ||
ed0243d8 | 319 | fHistEvents = new TH1F("fHistEvents", "fHistEvents", 11, 0, 11); |
320 | fHistEvents->GetXaxis()->SetTitle("p_{T} hard bin"); | |
321 | fHistEvents->GetYaxis()->SetTitle("total events"); | |
322 | fOutput->Add(fHistEvents); | |
323 | ||
6da81bde | 324 | fHistXsection = new TProfile("fHistXsection", "fHistXsection", 11, 0, 11); |
325 | fHistXsection->GetXaxis()->SetTitle("p_{T} hard bin"); | |
326 | fHistXsection->GetYaxis()->SetTitle("xsection"); | |
327 | fOutput->Add(fHistXsection); | |
328 | ||
ed0243d8 | 329 | const Int_t ptHardLo[11] = { 0, 5,11,21,36,57, 84,117,152,191,234}; |
330 | const Int_t ptHardHi[11] = { 5,11,21,36,57,84,117,152,191,234,1000000}; | |
331 | ||
332 | for (Int_t i = 1; i < 12; i++) { | |
333 | fHistTrialsAfterSel->GetXaxis()->SetBinLabel(i, Form("%d-%d",ptHardLo[i-1],ptHardHi[i-1])); | |
334 | fHistEventsAfterSel->GetXaxis()->SetBinLabel(i, Form("%d-%d",ptHardLo[i-1],ptHardHi[i-1])); | |
335 | ||
336 | fHistTrials->GetXaxis()->SetBinLabel(i, Form("%d-%d",ptHardLo[i-1],ptHardHi[i-1])); | |
337 | fHistXsection->GetXaxis()->SetBinLabel(i, Form("%d-%d",ptHardLo[i-1],ptHardHi[i-1])); | |
338 | fHistEvents->GetXaxis()->SetBinLabel(i, Form("%d-%d",ptHardLo[i-1],ptHardHi[i-1])); | |
339 | } | |
340 | ||
341 | fHistPtHard = new TH1F("fHistPtHard", "fHistPtHard", fNbins*2, fMinBinPt, fMaxBinPt*4); | |
342 | fHistPtHard->GetXaxis()->SetTitle("p_{T,hard} (GeV/c)"); | |
343 | fHistPtHard->GetYaxis()->SetTitle("counts"); | |
344 | fOutput->Add(fHistPtHard); | |
345 | } | |
346 | ||
159802e2 | 347 | fHistCentrality = new TH1F("fHistCentrality","Event centrality distribution", 200, 0, 100); |
348 | fHistCentrality->GetXaxis()->SetTitle("Centrality (%)"); | |
349 | fHistCentrality->GetYaxis()->SetTitle("counts"); | |
350 | fOutput->Add(fHistCentrality); | |
351 | ||
352 | fHistZVertex = new TH1F("fHistZVertex","Z vertex position", 60, -30, 30); | |
353 | fHistZVertex->GetXaxis()->SetTitle("z"); | |
354 | fHistZVertex->GetYaxis()->SetTitle("counts"); | |
355 | fOutput->Add(fHistZVertex); | |
356 | ||
6f6dc2ba | 357 | fHistEventPlane = new TH1F("fHistEventPlane","Event plane", 120, -TMath::Pi(), TMath::Pi()); |
358 | fHistEventPlane->GetXaxis()->SetTitle("event plane"); | |
359 | fHistEventPlane->GetYaxis()->SetTitle("counts"); | |
360 | fOutput->Add(fHistEventPlane); | |
361 | ||
219799d0 | 362 | fHistEventRejection = new TH1F("fHistEventRejection","Reasons to reject event",20,0,20); |
363 | fHistEventRejection->GetXaxis()->SetBinLabel(1,"PhysSel"); | |
364 | fHistEventRejection->GetXaxis()->SetBinLabel(2,"trigger"); | |
365 | fHistEventRejection->GetXaxis()->SetBinLabel(3,"trigTypeSel"); | |
366 | fHistEventRejection->GetXaxis()->SetBinLabel(4,"Cent"); | |
367 | fHistEventRejection->GetXaxis()->SetBinLabel(5,"vertex contr."); | |
368 | fHistEventRejection->GetXaxis()->SetBinLabel(6,"Vz"); | |
369 | fHistEventRejection->GetXaxis()->SetBinLabel(7,"trackInEmcal"); | |
370 | fHistEventRejection->GetXaxis()->SetBinLabel(8,"minNTrack"); | |
371 | fHistEventRejection->GetXaxis()->SetBinLabel(9,"VtxSel2013pA"); | |
372 | fHistEventRejection->GetXaxis()->SetBinLabel(10,"PileUp"); | |
373 | fHistEventRejection->GetXaxis()->SetBinLabel(11,"EvtPlane"); | |
374 | fHistEventRejection->GetXaxis()->SetBinLabel(12,"SelPtHardBin"); | |
8e49a788 | 375 | fHistEventRejection->GetYaxis()->SetTitle("counts"); |
376 | fOutput->Add(fHistEventRejection); | |
377 | ||
219799d0 | 378 | fHistEventCount = new TH1F("fHistEventCount","fHistEventCount",2,0,2); |
379 | fHistEventCount->GetXaxis()->SetBinLabel(1,"Accepted"); | |
380 | fHistEventCount->GetXaxis()->SetBinLabel(2,"Rejected"); | |
381 | fHistEventCount->GetYaxis()->SetTitle("counts"); | |
382 | fOutput->Add(fHistEventCount); | |
383 | ||
159802e2 | 384 | PostData(1, fOutput); |
385 | } | |
386 | ||
387 | //________________________________________________________________________ | |
388 | Bool_t AliAnalysisTaskEmcal::FillGeneralHistograms() | |
389 | { | |
ed0243d8 | 390 | if (fIsPythia) { |
6da81bde | 391 | fHistEventsAfterSel->Fill(fPtHardBin, 1); |
392 | fHistTrialsAfterSel->Fill(fPtHardBin, fNTrials); | |
393 | fHistXsectionAfterSel->Fill(fPtHardBin, fXsection); | |
ed0243d8 | 394 | fHistPtHard->Fill(fPtHard); |
395 | } | |
396 | ||
159802e2 | 397 | fHistCentrality->Fill(fCent); |
398 | fHistZVertex->Fill(fVertex[2]); | |
6f6dc2ba | 399 | fHistEventPlane->Fill(fEPV0); |
159802e2 | 400 | |
401 | return kTRUE; | |
402 | } | |
403 | ||
2da09763 | 404 | //________________________________________________________________________ |
629c7ac0 | 405 | void AliAnalysisTaskEmcal::UserExec(Option_t *) |
406 | { | |
407 | // Main loop, called for each event. | |
408 | ||
6c3aa659 | 409 | fMainTriggerPatch = NULL; |
410 | ||
e44e8726 | 411 | if (!fInitialized) |
b3376347 | 412 | ExecOnce(); |
629c7ac0 | 413 | |
e44e8726 | 414 | if (!fInitialized) |
415 | return; | |
416 | ||
629c7ac0 | 417 | if (!RetrieveEventObjects()) |
418 | return; | |
419 | ||
219799d0 | 420 | if (IsEventSelected()) { |
421 | if (fGeneralHistograms) fHistEventCount->Fill("Accepted",1); | |
422 | } | |
423 | else { | |
424 | if (fGeneralHistograms) fHistEventCount->Fill("Rejected",1); | |
2ac8ca4f | 425 | return; |
219799d0 | 426 | } |
2ac8ca4f | 427 | |
159802e2 | 428 | if (fGeneralHistograms && fCreateHisto) { |
429 | if (!FillGeneralHistograms()) | |
430 | return; | |
431 | } | |
432 | ||
629c7ac0 | 433 | if (!Run()) |
434 | return; | |
435 | ||
159802e2 | 436 | if (fCreateHisto) { |
437 | if (!FillHistograms()) | |
438 | return; | |
439 | } | |
629c7ac0 | 440 | |
2ac8ca4f | 441 | if (fCreateHisto && fOutput) { |
629c7ac0 | 442 | // information for this iteration of the UserExec in the container |
443 | PostData(1, fOutput); | |
444 | } | |
445 | } | |
446 | ||
447 | //________________________________________________________________________ | |
a56383df | 448 | Bool_t AliAnalysisTaskEmcal::AcceptCluster(AliVCluster *clus, Int_t c) const |
2da09763 | 449 | { |
629c7ac0 | 450 | // Return true if cluster is accepted. |
451 | ||
452 | if (!clus) | |
453 | return kFALSE; | |
454 | ||
9239b066 | 455 | AliClusterContainer *cont = GetClusterContainer(c); |
157b926a | 456 | if (!cont) { |
9239b066 | 457 | AliError(Form("%s:Container %d not found",GetName(),c)); |
458 | return 0; | |
507f74bc | 459 | } |
629c7ac0 | 460 | |
9239b066 | 461 | return cont->AcceptCluster(clus); |
629c7ac0 | 462 | } |
463 | ||
464 | //________________________________________________________________________ | |
9239b066 | 465 | Bool_t AliAnalysisTaskEmcal::AcceptTrack(AliVParticle *track, Int_t c) const |
629c7ac0 | 466 | { |
159802e2 | 467 | // Return true if track is accepted. |
629c7ac0 | 468 | |
159802e2 | 469 | if (!track) |
629c7ac0 | 470 | return kFALSE; |
471 | ||
9239b066 | 472 | AliParticleContainer *cont = GetParticleContainer(c); |
157b926a | 473 | if (!cont) { |
9239b066 | 474 | AliError(Form("%s:Container %d not found",GetName(),c)); |
475 | return 0; | |
159802e2 | 476 | } |
477 | ||
9239b066 | 478 | return cont->AcceptParticle(track); |
2da09763 | 479 | } |
480 | ||
ed0243d8 | 481 | //________________________________________________________________________ |
482 | Bool_t AliAnalysisTaskEmcal::PythiaInfoFromFile(const char* currFile, Float_t &fXsec, Float_t &fTrials, Int_t &pthard) | |
483 | { | |
484 | // | |
485 | // Get the cross section and the trails either from pyxsec.root or from pysec_hists.root | |
486 | // Get the pt hard bin from the file path | |
487 | // This is to called in Notify and should provide the path to the AOD/ESD file | |
488 | // (Partially copied from AliAnalysisHelperJetTasks) | |
489 | ||
490 | TString file(currFile); | |
491 | fXsec = 0; | |
492 | fTrials = 1; | |
493 | ||
157b926a | 494 | if (file.Contains(".zip#")) { |
ed0243d8 | 495 | Ssiz_t pos1 = file.Index("root_archive",12,0,TString::kExact); |
496 | Ssiz_t pos = file.Index("#",1,pos1,TString::kExact); | |
497 | Ssiz_t pos2 = file.Index(".root",5,TString::kExact); | |
498 | file.Replace(pos+1,pos2-pos1,""); | |
dbd1583b | 499 | } else { |
ed0243d8 | 500 | // not an archive take the basename.... |
501 | file.ReplaceAll(gSystem->BaseName(file.Data()),""); | |
502 | } | |
9239b066 | 503 | AliDebug(1,Form("File name: %s",file.Data())); |
ed0243d8 | 504 | |
505 | // Get the pt hard bin | |
506 | TString strPthard(file); | |
507 | ||
508 | strPthard.Remove(strPthard.Last('/')); | |
509 | strPthard.Remove(strPthard.Last('/')); | |
510 | if (strPthard.Contains("AOD")) strPthard.Remove(strPthard.Last('/')); | |
511 | strPthard.Remove(0,strPthard.Last('/')+1); | |
512 | if (strPthard.IsDec()) | |
513 | pthard = strPthard.Atoi(); | |
514 | else | |
515 | AliWarning(Form("Could not extract file number from path %s", strPthard.Data())); | |
516 | ||
9239b066 | 517 | // problem that we cannot really test the existance of a file in a archive so we have to live with open error message from root |
518 | TFile *fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec.root")); | |
519 | ||
157b926a | 520 | if (!fxsec) { |
ed0243d8 | 521 | // next trial fetch the histgram file |
522 | fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec_hists.root")); | |
157b926a | 523 | if (!fxsec) { |
ed0243d8 | 524 | // not a severe condition but inciate that we have no information |
525 | return kFALSE; | |
dbd1583b | 526 | } else { |
ed0243d8 | 527 | // find the tlist we want to be independtent of the name so use the Tkey |
528 | TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0); | |
157b926a | 529 | if (!key) { |
ed0243d8 | 530 | fxsec->Close(); |
531 | return kFALSE; | |
532 | } | |
533 | TList *list = dynamic_cast<TList*>(key->ReadObj()); | |
157b926a | 534 | if (!list) { |
ed0243d8 | 535 | fxsec->Close(); |
536 | return kFALSE; | |
537 | } | |
538 | fXsec = ((TProfile*)list->FindObject("h1Xsec"))->GetBinContent(1); | |
539 | fTrials = ((TH1F*)list->FindObject("h1Trials"))->GetBinContent(1); | |
540 | fxsec->Close(); | |
541 | } | |
dbd1583b | 542 | } else { // no tree pyxsec.root |
ed0243d8 | 543 | TTree *xtree = (TTree*)fxsec->Get("Xsection"); |
157b926a | 544 | if (!xtree) { |
ed0243d8 | 545 | fxsec->Close(); |
546 | return kFALSE; | |
547 | } | |
548 | UInt_t ntrials = 0; | |
549 | Double_t xsection = 0; | |
550 | xtree->SetBranchAddress("xsection",&xsection); | |
551 | xtree->SetBranchAddress("ntrials",&ntrials); | |
552 | xtree->GetEntry(0); | |
553 | fTrials = ntrials; | |
554 | fXsec = xsection; | |
555 | fxsec->Close(); | |
556 | } | |
557 | return kTRUE; | |
558 | } | |
559 | ||
560 | //________________________________________________________________________ | |
561 | Bool_t AliAnalysisTaskEmcal::UserNotify() | |
562 | { | |
b8aeed95 | 563 | // Called when file changes. |
564 | ||
ed0243d8 | 565 | if (!fIsPythia || !fGeneralHistograms || !fCreateHisto) |
566 | return kTRUE; | |
567 | ||
568 | TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree(); | |
569 | if (!tree) { | |
570 | AliError(Form("%s - UserNotify: No current tree!",GetName())); | |
571 | return kFALSE; | |
572 | } | |
573 | ||
6da81bde | 574 | Float_t xsection = 0; |
575 | Float_t trials = 0; | |
576 | Int_t pthardbin = 0; | |
ed0243d8 | 577 | |
578 | TFile *curfile = tree->GetCurrentFile(); | |
579 | if (!curfile) { | |
580 | AliError(Form("%s - UserNotify: No current file!",GetName())); | |
581 | return kFALSE; | |
582 | } | |
583 | ||
584 | TChain *chain = dynamic_cast<TChain*>(tree); | |
6da81bde | 585 | if (chain) tree = chain->GetTree(); |
ed0243d8 | 586 | |
587 | Int_t nevents = tree->GetEntriesFast(); | |
588 | ||
6da81bde | 589 | PythiaInfoFromFile(curfile->GetName(), xsection, trials, pthardbin); |
ed0243d8 | 590 | |
413c4f06 | 591 | // TODO: Workaround |
6da81bde | 592 | if ((pthardbin < 0) || (pthardbin > 10)) pthardbin = 0; |
593 | ||
594 | fHistTrials->Fill(pthardbin, trials); | |
595 | fHistXsection->Fill(pthardbin, xsection); | |
596 | fHistEvents->Fill(pthardbin, nevents); | |
ed0243d8 | 597 | |
598 | return kTRUE; | |
599 | } | |
600 | ||
629c7ac0 | 601 | //________________________________________________________________________ |
b3376347 | 602 | void AliAnalysisTaskEmcal::ExecOnce() |
8a28ded1 | 603 | { |
604 | // Init the analysis. | |
2ac8ca4f | 605 | |
b3376347 | 606 | if (!InputEvent()) { |
607 | AliError(Form("%s: Could not retrieve event! Returning!", GetName())); | |
608 | return; | |
609 | } | |
610 | ||
78a69392 | 611 | if (fNeedEmcalGeom) { |
612 | fGeom = AliEMCALGeometry::GetInstance(); | |
613 | if (!fGeom) { | |
614 | AliError(Form("%s: Can not create geometry", GetName())); | |
615 | return; | |
616 | } | |
bb98e333 | 617 | } |
159802e2 | 618 | |
78a69392 | 619 | |
6f6dc2ba | 620 | if (fEventPlaneVsEmcal >= 0) { |
78a69392 | 621 | if (fGeom) { |
622 | Double_t ep = (fGeom->GetArm1PhiMax() + fGeom->GetArm1PhiMin()) / 2 * TMath::DegToRad() + fEventPlaneVsEmcal - TMath::Pi(); | |
623 | fMinEventPlane = ep - TMath::Pi() / 4; | |
624 | fMaxEventPlane = ep + TMath::Pi() / 4; | |
625 | } | |
626 | else { | |
627 | AliWarning("Could not set event plane limits because EMCal geometry was not loaded!"); | |
628 | } | |
6f6dc2ba | 629 | } |
630 | ||
9239b066 | 631 | //Load all requested track branches - each container knows name already |
157b926a | 632 | for (Int_t i =0; i<fParticleCollArray.GetEntriesFast(); i++) { |
9239b066 | 633 | AliParticleContainer *cont = static_cast<AliParticleContainer*>(fParticleCollArray.At(i)); |
634 | cont->SetArray(InputEvent()); | |
635 | } | |
636 | ||
637 | if (fParticleCollArray.GetEntriesFast()>0) { | |
638 | fTracks = GetParticleArray(0); | |
157b926a | 639 | if (!fTracks) { |
9239b066 | 640 | AliError(Form("%s: Could not retrieve first track branch!", GetName())); |
b3376347 | 641 | return; |
b3376347 | 642 | } |
643 | } | |
644 | ||
9239b066 | 645 | //Load all requested cluster branches - each container knows name already |
157b926a | 646 | for (Int_t i =0; i<fClusterCollArray.GetEntriesFast(); i++) { |
9239b066 | 647 | AliClusterContainer *cont = static_cast<AliClusterContainer*>(fClusterCollArray.At(i)); |
648 | cont->SetArray(InputEvent()); | |
649 | } | |
650 | ||
157b926a | 651 | if (fClusterCollArray.GetEntriesFast()>0) { |
9239b066 | 652 | fCaloClusters = GetClusterArray(0); |
157b926a | 653 | if (!fCaloClusters) { |
9239b066 | 654 | AliError(Form("%s: Could not retrieve first cluster branch!", GetName())); |
b3376347 | 655 | return; |
b3376347 | 656 | } |
657 | } | |
159802e2 | 658 | |
f660c2d6 | 659 | if (!fCaloCellsName.IsNull() && !fCaloCells) { |
660 | fCaloCells = dynamic_cast<AliVCaloCells*>(InputEvent()->FindListObject(fCaloCellsName)); | |
661 | if (!fCaloCells) { | |
507f74bc | 662 | AliError(Form("%s: Could not retrieve cells %s!", GetName(), fCaloCellsName.Data())); |
f660c2d6 | 663 | return; |
664 | } | |
665 | } | |
666 | ||
00c77045 | 667 | if (!fCaloTriggersName.IsNull() && !fCaloTriggers) { |
668 | fCaloTriggers = dynamic_cast<AliVCaloTrigger*>(InputEvent()->FindListObject(fCaloTriggersName)); | |
669 | if (!fCaloTriggers) { | |
670 | AliError(Form("%s: Could not retrieve calo triggers %s!", GetName(), fCaloTriggersName.Data())); | |
671 | return; | |
672 | } | |
673 | } | |
674 | ||
37a63fdf | 675 | if (!fCaloTriggerPatchInfoName.IsNull() && !fTriggerPatchInfo) { |
37a63fdf | 676 | fTriggerPatchInfo = GetArrayFromEvent(fCaloTriggerPatchInfoName.Data(),"AliEmcalTriggerPatchInfo"); |
8e49a788 | 677 | if (!fTriggerPatchInfo) { |
678 | AliError(Form("%s: Could not retrieve calo trigger patch info %s!", GetName(), fCaloTriggerPatchInfoName.Data())); | |
679 | return; | |
680 | } | |
37a63fdf | 681 | |
682 | } | |
683 | ||
159802e2 | 684 | fInitialized = kTRUE; |
8a28ded1 | 685 | } |
686 | ||
2ac8ca4f | 687 | //_____________________________________________________ |
688 | AliAnalysisTaskEmcal::BeamType AliAnalysisTaskEmcal::GetBeamType() | |
689 | { | |
690 | // Get beam type : pp-AA-pA | |
691 | // ESDs have it directly, AODs get it from hardcoded run number ranges | |
692 | ||
159802e2 | 693 | if (fForceBeamType != kNA) |
694 | return fForceBeamType; | |
695 | ||
2ac8ca4f | 696 | AliESDEvent *esd = dynamic_cast<AliESDEvent*>(InputEvent()); |
697 | if (esd) { | |
698 | const AliESDRun *run = esd->GetESDRun(); | |
699 | TString beamType = run->GetBeamType(); | |
700 | if (beamType == "p-p") | |
701 | return kpp; | |
702 | else if (beamType == "A-A") | |
703 | return kAA; | |
704 | else if (beamType == "p-A") | |
705 | return kpA; | |
706 | else | |
707 | return kNA; | |
708 | } else { | |
709 | Int_t runNumber = InputEvent()->GetRunNumber(); | |
710 | if ((runNumber >= 136851 && runNumber <= 139517) || // LHC10h | |
dbd1583b | 711 | (runNumber >= 166529 && runNumber <= 170593)) { // LHC11h |
2ac8ca4f | 712 | return kAA; |
dbd1583b | 713 | } else if ((runNumber>=188365 && runNumber <= 188366) || // LHC12g |
714 | (runNumber >= 195344 && runNumber <= 196608)) { // LHC13b-f | |
493d6e49 | 715 | return kpA; |
2ac8ca4f | 716 | } else { |
717 | return kpp; | |
718 | } | |
719 | } | |
720 | } | |
721 | ||
f9a1843e | 722 | //________________________________________________________________________ |
219799d0 | 723 | ULong_t AliAnalysisTaskEmcal::GetTriggerList() |
724 | { | |
725 | if (!fTriggerPatchInfo) | |
726 | return 0; | |
727 | ||
728 | //number of patches in event | |
729 | Int_t nPatch = fTriggerPatchInfo->GetEntries(); | |
730 | ||
731 | //loop over patches to define trigger type of event | |
732 | Int_t nG1 = 0; | |
733 | Int_t nG2 = 0; | |
734 | Int_t nJ1 = 0; | |
735 | Int_t nJ2 = 0; | |
736 | AliEmcalTriggerPatchInfo *patch; | |
737 | for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) { | |
738 | patch = (AliEmcalTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch ); | |
739 | if (patch->IsGammaHigh()) nG1++; | |
740 | if (patch->IsGammaLow()) nG2++; | |
741 | if (patch->IsJetHigh()) nJ1++; | |
742 | if (patch->IsJetLow()) nJ2++; | |
743 | } | |
744 | ||
745 | AliDebug(2, "Patch summary: "); | |
746 | AliDebug(2, Form("Number of patches: %d", nPatch)); | |
747 | AliDebug(2, Form("Jet: low[%d], high[%d]" ,nJ2, nJ1)); | |
748 | AliDebug(2, Form("Gamma: low[%d], high[%d]" ,nG2, nG1)); | |
749 | ||
750 | ULong_t triggers(0); | |
751 | if (nG1>0) | |
752 | SETBIT(triggers, kG1); | |
753 | if (nG2>0) | |
754 | SETBIT(triggers, kG2); | |
755 | if (nJ1>0) | |
756 | SETBIT(triggers, kJ1); | |
757 | if (nJ2>0) | |
758 | SETBIT(triggers, kJ2); | |
759 | return triggers; | |
f9a1843e | 760 | } |
8e49a788 | 761 | |
f9a1843e | 762 | //________________________________________________________________________ |
219799d0 | 763 | Bool_t AliAnalysisTaskEmcal::HasTriggerType(TriggerType t) |
764 | { | |
765 | // Check if event has a given trigger type | |
766 | if(t == kND){ | |
767 | return fTriggers == 0; | |
768 | } | |
769 | return TESTBIT(fTriggers, int(t)); | |
8e49a788 | 770 | } |
771 | ||
2ac8ca4f | 772 | //________________________________________________________________________ |
d29ed625 | 773 | Bool_t AliAnalysisTaskEmcal::IsEventSelected() |
2ac8ca4f | 774 | { |
775 | // Check if event is selected | |
776 | ||
777 | if (fOffTrigger != AliVEvent::kAny) { | |
d29ed625 | 778 | UInt_t res = 0; |
779 | const AliESDEvent *eev = dynamic_cast<const AliESDEvent*>(InputEvent()); | |
780 | if (eev) { | |
781 | res = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected(); | |
782 | } else { | |
783 | const AliAODEvent *aev = dynamic_cast<const AliAODEvent*>(InputEvent()); | |
784 | if (aev) { | |
0a918d8d | 785 | res = ((AliVAODHeader*)aev->GetHeader())->GetOfflineTrigger(); |
d29ed625 | 786 | } |
787 | } | |
8e49a788 | 788 | if ((res & fOffTrigger) == 0) { |
219799d0 | 789 | if (fGeneralHistograms) fHistEventRejection->Fill("PhysSel",1); |
b4339010 | 790 | return kFALSE; |
8e49a788 | 791 | } |
b4339010 | 792 | } |
793 | ||
794 | if (!fTrigClass.IsNull()) { | |
795 | TString fired; | |
796 | const AliESDEvent *eev = dynamic_cast<const AliESDEvent*>(InputEvent()); | |
797 | if (eev) { | |
798 | fired = eev->GetFiredTriggerClasses(); | |
799 | } else { | |
800 | const AliAODEvent *aev = dynamic_cast<const AliAODEvent*>(InputEvent()); | |
801 | if (aev) { | |
802 | fired = aev->GetFiredTriggerClasses(); | |
803 | } | |
804 | } | |
8e49a788 | 805 | if (!fired.Contains("-B-")) { |
219799d0 | 806 | if (fGeneralHistograms) fHistEventRejection->Fill("trigger",1); |
b4339010 | 807 | return kFALSE; |
8e49a788 | 808 | } |
b4339010 | 809 | TObjArray *arr = fTrigClass.Tokenize("|"); |
8e49a788 | 810 | if (!arr) { |
219799d0 | 811 | if (fGeneralHistograms) fHistEventRejection->Fill("trigger",1); |
b4339010 | 812 | return kFALSE; |
8e49a788 | 813 | } |
b4339010 | 814 | Bool_t match = 0; |
815 | for (Int_t i=0;i<arr->GetEntriesFast();++i) { | |
816 | TObject *obj = arr->At(i); | |
817 | if (!obj) | |
818 | continue; | |
819 | if (fired.Contains(obj->GetName())) { | |
820 | match = 1; | |
821 | break; | |
822 | } | |
823 | } | |
824 | delete arr; | |
8e49a788 | 825 | if (!match) { |
219799d0 | 826 | if (fGeneralHistograms) fHistEventRejection->Fill("trigger",1); |
2ac8ca4f | 827 | return kFALSE; |
8e49a788 | 828 | } |
2ac8ca4f | 829 | } |
830 | ||
8e49a788 | 831 | if (fTriggerTypeSel != kND) { |
f9a1843e | 832 | if (!HasTriggerType(fTriggerTypeSel)) { |
219799d0 | 833 | if (fGeneralHistograms) fHistEventRejection->Fill("trigTypeSel",1); |
2ac8ca4f | 834 | return kFALSE; |
8e49a788 | 835 | } |
836 | } | |
8e49a788 | 837 | |
838 | if ((fMinCent != -999) && (fMaxCent != -999)) { | |
839 | if (fCent<fMinCent || fCent>fMaxCent) { | |
219799d0 | 840 | if (fGeneralHistograms) fHistEventRejection->Fill("Cent",1); |
2ac8ca4f | 841 | return kFALSE; |
8e49a788 | 842 | } |
2ac8ca4f | 843 | } |
844 | ||
6cc60022 | 845 | if (fUseAliAnaUtils) { |
846 | if (!fAliAnalysisUtils) | |
847 | fAliAnalysisUtils = new AliAnalysisUtils(); | |
848 | fAliAnalysisUtils->SetMinVtxContr(2); | |
9b299cdd | 849 | fAliAnalysisUtils->SetMaxVtxZ(999); |
6cc60022 | 850 | if(fMinVz<-10.) fMinVz = -10.; |
851 | if(fMinVz>10.) fMaxVz = 10.; | |
852 | ||
853 | if (!fAliAnalysisUtils->IsVertexSelected2013pA(InputEvent())) { | |
219799d0 | 854 | if (fGeneralHistograms) fHistEventRejection->Fill("VtxSel2013pA",1); |
6cc60022 | 855 | return kFALSE; |
856 | } | |
857 | ||
858 | if (fAliAnalysisUtils->IsPileUpEvent(InputEvent())) { | |
219799d0 | 859 | if (fGeneralHistograms) fHistEventRejection->Fill("PileUp",1); |
6cc60022 | 860 | return kFALSE; |
861 | } | |
862 | } | |
863 | ||
2ac8ca4f | 864 | if ((fMinVz != -999) && (fMaxVz != -999)) { |
8e49a788 | 865 | if (fNVertCont == 0 ) { |
219799d0 | 866 | if (fGeneralHistograms) fHistEventRejection->Fill("vertex contr.",1); |
b4339010 | 867 | return kFALSE; |
8e49a788 | 868 | } |
2ac8ca4f | 869 | Double_t vz = fVertex[2]; |
8e49a788 | 870 | if (vz<fMinVz || vz>fMaxVz) { |
219799d0 | 871 | if (fGeneralHistograms) fHistEventRejection->Fill("Vz",1); |
254370e1 | 872 | return kFALSE; |
873 | } | |
2ac8ca4f | 874 | } |
875 | ||
8e49a788 | 876 | if (fMinPtTrackInEmcal > 0 && fGeom) { |
6c41fc8c | 877 | Bool_t trackInEmcalOk = kFALSE; |
9239b066 | 878 | Int_t ntracks = GetNParticles(0); |
6c41fc8c | 879 | for (Int_t i = 0; i < ntracks; i++) { |
9239b066 | 880 | AliVParticle *track = GetAcceptParticleFromArray(i,0); |
157b926a | 881 | if (!track) |
6c41fc8c | 882 | continue; |
9239b066 | 883 | |
884 | Double_t phiMin = fGeom->GetArm1PhiMin() * TMath::DegToRad(); | |
885 | Double_t phiMax = fGeom->GetArm1PhiMax() * TMath::DegToRad(); | |
886 | Int_t runNumber = InputEvent()->GetRunNumber(); | |
157b926a | 887 | if (runNumber>=177295 && runNumber<=197470) { //small SM masked in 2012 and 2013 |
9239b066 | 888 | phiMin = 1.4; |
889 | phiMax = TMath::Pi(); | |
890 | } | |
891 | ||
892 | if (track->Eta() < fGeom->GetArm1EtaMin() || track->Eta() > fGeom->GetArm1EtaMax() || track->Phi() < phiMin || track->Phi() > phiMax) | |
6c41fc8c | 893 | continue; |
894 | if (track->Pt() > fMinPtTrackInEmcal) { | |
895 | trackInEmcalOk = kTRUE; | |
896 | break; | |
897 | } | |
898 | } | |
8e49a788 | 899 | if (!trackInEmcalOk) { |
219799d0 | 900 | if (fGeneralHistograms) fHistEventRejection->Fill("trackInEmcal",1); |
6c41fc8c | 901 | return kFALSE; |
8e49a788 | 902 | } |
6c41fc8c | 903 | } |
904 | ||
8e49a788 | 905 | if (fMinNTrack > 0) { |
9239b066 | 906 | Int_t nTracksAcc = 0; |
907 | Int_t ntracks = GetNParticles(0); | |
908 | for (Int_t i = 0; i < ntracks; i++) { | |
909 | AliVParticle *track = GetAcceptParticleFromArray(i,0); | |
157b926a | 910 | if (!track) |
9239b066 | 911 | continue; |
912 | if (track->Pt() > fTrackPtCut) { | |
913 | nTracksAcc++; | |
157b926a | 914 | if (nTracksAcc>=fMinNTrack) |
9239b066 | 915 | break; |
916 | } | |
917 | } | |
8e49a788 | 918 | if (nTracksAcc<fMinNTrack) { |
219799d0 | 919 | if (fGeneralHistograms) fHistEventRejection->Fill("minNTrack",1); |
9239b066 | 920 | return kFALSE; |
8e49a788 | 921 | } |
9239b066 | 922 | } |
923 | ||
6f6dc2ba | 924 | if (!(fEPV0 > fMinEventPlane && fEPV0 <= fMaxEventPlane) && |
925 | !(fEPV0 + TMath::Pi() > fMinEventPlane && fEPV0 + TMath::Pi() <= fMaxEventPlane) && | |
926 | !(fEPV0 - TMath::Pi() > fMinEventPlane && fEPV0 - TMath::Pi() <= fMaxEventPlane)) | |
8e49a788 | 927 | { |
219799d0 | 928 | if (fGeneralHistograms) fHistEventRejection->Fill("EvtPlane",1); |
8e49a788 | 929 | return kFALSE; |
930 | } | |
6f6dc2ba | 931 | |
8e49a788 | 932 | if (fSelectPtHardBin != -999 && fSelectPtHardBin != fPtHardBin) { |
219799d0 | 933 | if (fGeneralHistograms) fHistEventRejection->Fill("SelPtHardBin",1); |
8e49a788 | 934 | return kFALSE; |
935 | } | |
219799d0 | 936 | |
2ac8ca4f | 937 | return kTRUE; |
938 | } | |
939 | ||
c596bd28 | 940 | //________________________________________________________________________ |
941 | TClonesArray *AliAnalysisTaskEmcal::GetArrayFromEvent(const char *name, const char *clname) | |
942 | { | |
943 | // Get array from event. | |
944 | ||
945 | TClonesArray *arr = 0; | |
946 | TString sname(name); | |
947 | if (!sname.IsNull()) { | |
948 | arr = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(sname)); | |
949 | if (!arr) { | |
950 | AliWarning(Form("%s: Could not retrieve array with name %s!", GetName(), name)); | |
951 | return 0; | |
952 | } | |
af0280a9 | 953 | } else { |
954 | return 0; | |
c596bd28 | 955 | } |
af0280a9 | 956 | |
c596bd28 | 957 | if (!clname) |
958 | return arr; | |
959 | ||
960 | TString objname(arr->GetClass()->GetName()); | |
961 | TClass cls(objname); | |
962 | if (!cls.InheritsFrom(clname)) { | |
963 | AliWarning(Form("%s: Objects of type %s in %s are not inherited from %s!", | |
964 | GetName(), cls.GetName(), name, clname)); | |
965 | return 0; | |
966 | } | |
967 | return arr; | |
968 | } | |
969 | ||
2da09763 | 970 | //________________________________________________________________________ |
971 | Bool_t AliAnalysisTaskEmcal::RetrieveEventObjects() | |
972 | { | |
973 | // Retrieve objects from event. | |
974 | ||
2da09763 | 975 | fVertex[0] = 0; |
976 | fVertex[1] = 0; | |
977 | fVertex[2] = 0; | |
b4339010 | 978 | fNVertCont = 0; |
979 | ||
980 | const AliVVertex *vert = InputEvent()->GetPrimaryVertex(); | |
981 | if (vert) { | |
982 | vert->GetXYZ(fVertex); | |
983 | fNVertCont = vert->GetNContributors(); | |
984 | } | |
2da09763 | 985 | |
1f6fff78 | 986 | fBeamType = GetBeamType(); |
987 | ||
a52de945 | 988 | if (fBeamType == kAA || fBeamType == kpA ) { |
2da09763 | 989 | AliCentrality *aliCent = InputEvent()->GetCentrality(); |
990 | if (aliCent) { | |
9239b066 | 991 | fCent = aliCent->GetCentralityPercentile(fCentEst.Data()); |
157b926a | 992 | if (fNcentBins==4) { |
e304c410 | 993 | if (fCent >= 0 && fCent < 10) fCentBin = 0; |
994 | else if (fCent >= 10 && fCent < 30) fCentBin = 1; | |
995 | else if (fCent >= 30 && fCent < 50) fCentBin = 2; | |
996 | else if (fCent >= 50 && fCent <= 100) fCentBin = 3; | |
997 | else { | |
998 | AliWarning(Form("%s: Negative centrality: %f. Assuming 99", GetName(), fCent)); | |
53e07ba4 | 999 | fCentBin = fNcentBins-1; |
e304c410 | 1000 | } |
dbd1583b | 1001 | } else { |
e304c410 | 1002 | Double_t centWidth = (fMaxCent-fMinCent)/(Double_t)fNcentBins; |
1781a0e2 | 1003 | if(centWidth>0.) |
1004 | fCentBin = TMath::FloorNint(fCent/centWidth); | |
1005 | else | |
1006 | fCentBin = 0; | |
157b926a | 1007 | if (fCentBin>=fNcentBins) { |
53e07ba4 | 1008 | AliWarning(Form("%s: fCentBin too large: cent = %f fCentBin = %d. Assuming 99", GetName(),fCent,fCentBin)); |
1009 | fCentBin = fNcentBins-1; | |
1010 | } | |
2da09763 | 1011 | } |
901cc837 | 1012 | } else { |
1013 | AliWarning(Form("%s: Could not retrieve centrality information! Assuming 99", GetName())); | |
4c4a0fc7 | 1014 | fCentBin = fNcentBins-1; |
2da09763 | 1015 | } |
3c124212 | 1016 | AliEventplane *aliEP = InputEvent()->GetEventplane(); |
1017 | if (aliEP) { | |
1018 | fEPV0 = aliEP->GetEventplane("V0" ,InputEvent()); | |
1019 | fEPV0A = aliEP->GetEventplane("V0A",InputEvent()); | |
1020 | fEPV0C = aliEP->GetEventplane("V0C",InputEvent()); | |
1021 | } else { | |
1022 | AliWarning(Form("%s: Could not retrieve event plane information!", GetName())); | |
1023 | } | |
901cc837 | 1024 | } else { |
2da09763 | 1025 | fCent = 99; |
1026 | fCentBin = 0; | |
1027 | } | |
1028 | ||
ed0243d8 | 1029 | if (fIsPythia) { |
1030 | ||
1031 | if (MCEvent()) { | |
1032 | fPythiaHeader = dynamic_cast<AliGenPythiaEventHeader*>(MCEvent()->GenEventHeader()); | |
1033 | if (!fPythiaHeader) { | |
1034 | // Check if AOD | |
1035 | AliAODMCHeader* aodMCH = dynamic_cast<AliAODMCHeader*>(InputEvent()->FindListObject(AliAODMCHeader::StdBranchName())); | |
1036 | ||
1037 | if (aodMCH) { | |
157b926a | 1038 | for (UInt_t i = 0;i<aodMCH->GetNCocktailHeaders();i++) { |
ed0243d8 | 1039 | fPythiaHeader = dynamic_cast<AliGenPythiaEventHeader*>(aodMCH->GetCocktailHeader(i)); |
1040 | if (fPythiaHeader) break; | |
1041 | } | |
1042 | } | |
1043 | } | |
1044 | } | |
1045 | ||
1046 | if (fPythiaHeader) { | |
1047 | fPtHard = fPythiaHeader->GetPtHard(); | |
6a322f03 | 1048 | |
ed0243d8 | 1049 | const Int_t ptHardLo[11] = { 0, 5,11,21,36,57, 84,117,152,191,234}; |
1050 | const Int_t ptHardHi[11] = { 5,11,21,36,57,84,117,152,191,234,1000000}; | |
1051 | for (fPtHardBin = 0; fPtHardBin < 11; fPtHardBin++) { | |
1052 | if (fPtHard >= ptHardLo[fPtHardBin] && fPtHard < ptHardHi[fPtHardBin]) | |
1053 | break; | |
1054 | } | |
6da81bde | 1055 | |
1056 | fXsection = fPythiaHeader->GetXsection(); | |
ed0243d8 | 1057 | fNTrials = fPythiaHeader->Trials(); |
1058 | } | |
1059 | } | |
1060 | ||
f9a1843e | 1061 | fTriggers = GetTriggerList(); |
8e49a788 | 1062 | |
2da09763 | 1063 | return kTRUE; |
1064 | } | |
9239b066 | 1065 | |
1066 | //________________________________________________________________________ | |
b8aeed95 | 1067 | AliParticleContainer* AliAnalysisTaskEmcal::AddParticleContainer(const char *n) |
1068 | { | |
9239b066 | 1069 | // Add particle container |
1070 | // will be called in AddTask macro | |
1071 | ||
1072 | TString tmp = TString(n); | |
157b926a | 1073 | if (tmp.IsNull()) return 0; |
9239b066 | 1074 | |
1075 | AliParticleContainer *cont = 0x0; | |
1076 | cont = new AliParticleContainer(); | |
1077 | cont->SetArrayName(n); | |
1078 | TString contName = cont->GetArrayName(); | |
1079 | ||
1080 | fParticleCollArray.Add(cont); | |
1081 | ||
1082 | return cont; | |
1083 | } | |
1084 | ||
1085 | //________________________________________________________________________ | |
b8aeed95 | 1086 | AliClusterContainer* AliAnalysisTaskEmcal::AddClusterContainer(const char *n) |
1087 | { | |
9239b066 | 1088 | // Add cluster container |
1089 | // will be called in AddTask macro | |
1090 | ||
1091 | TString tmp = TString(n); | |
157b926a | 1092 | if (tmp.IsNull()) return 0; |
9239b066 | 1093 | |
1094 | AliClusterContainer *cont = 0x0; | |
1095 | cont = new AliClusterContainer(); | |
1096 | cont->SetArrayName(n); | |
1097 | ||
1098 | fClusterCollArray.Add(cont); | |
1099 | ||
1100 | return cont; | |
1101 | } | |
1102 | ||
1103 | //________________________________________________________________________ | |
b8aeed95 | 1104 | AliParticleContainer* AliAnalysisTaskEmcal::GetParticleContainer(Int_t i) const |
1105 | { | |
9239b066 | 1106 | // Get i^th particle container |
1107 | ||
157b926a | 1108 | if (i<0 || i>fParticleCollArray.GetEntriesFast()) return 0; |
9239b066 | 1109 | AliParticleContainer *cont = static_cast<AliParticleContainer*>(fParticleCollArray.At(i)); |
1110 | return cont; | |
1111 | } | |
1112 | ||
1113 | //________________________________________________________________________ | |
b8aeed95 | 1114 | AliClusterContainer* AliAnalysisTaskEmcal::GetClusterContainer(Int_t i) const |
1115 | { | |
9239b066 | 1116 | // Get i^th cluster container |
1117 | ||
157b926a | 1118 | if (i<0 || i>fClusterCollArray.GetEntriesFast()) return 0; |
9239b066 | 1119 | AliClusterContainer *cont = static_cast<AliClusterContainer*>(fClusterCollArray.At(i)); |
1120 | return cont; | |
1121 | } | |
1122 | ||
1123 | //________________________________________________________________________ | |
b8aeed95 | 1124 | AliParticleContainer* AliAnalysisTaskEmcal::GetParticleContainer(const char *name) const |
1125 | { | |
9239b066 | 1126 | // Get particle container with name |
1127 | ||
1128 | AliParticleContainer *cont = static_cast<AliParticleContainer*>(fParticleCollArray.FindObject(name)); | |
1129 | return cont; | |
1130 | } | |
1131 | ||
1132 | //________________________________________________________________________ | |
b8aeed95 | 1133 | AliClusterContainer* AliAnalysisTaskEmcal::GetClusterContainer(const char *name) const |
1134 | { | |
9239b066 | 1135 | // Get cluster container with name |
1136 | ||
1137 | AliClusterContainer *cont = static_cast<AliClusterContainer*>(fClusterCollArray.FindObject(name)); | |
1138 | return cont; | |
1139 | } | |
1140 | ||
1141 | //________________________________________________________________________ | |
b8aeed95 | 1142 | TClonesArray* AliAnalysisTaskEmcal::GetParticleArray(Int_t i) const |
1143 | { | |
9239b066 | 1144 | // Get i^th TClonesArray with AliVParticle |
1145 | ||
1146 | AliParticleContainer *cont = GetParticleContainer(i); | |
157b926a | 1147 | if (!cont) { |
9239b066 | 1148 | AliError(Form("%s: Particle container %d not found",GetName(),i)); |
1149 | return 0; | |
1150 | } | |
1151 | TString contName = cont->GetArrayName(); | |
1152 | return cont->GetArray(); | |
1153 | } | |
1154 | ||
1155 | //________________________________________________________________________ | |
b8aeed95 | 1156 | TClonesArray* AliAnalysisTaskEmcal::GetClusterArray(Int_t i) const |
1157 | { | |
9239b066 | 1158 | // Get i^th TClonesArray with AliVCluster |
1159 | ||
1160 | AliClusterContainer *cont = GetClusterContainer(i); | |
157b926a | 1161 | if (!cont) { |
9239b066 | 1162 | AliError(Form("%s:Cluster container %d not found",GetName(),i)); |
1163 | return 0; | |
1164 | } | |
1165 | return cont->GetArray(); | |
1166 | } | |
1167 | ||
1168 | //________________________________________________________________________ | |
b8aeed95 | 1169 | AliVParticle* AliAnalysisTaskEmcal::GetAcceptParticleFromArray(Int_t p, Int_t c) const |
1170 | { | |
9239b066 | 1171 | // Get particle p if accepted from container c |
1172 | // If particle not accepted return 0 | |
1173 | ||
1174 | AliParticleContainer *cont = GetParticleContainer(c); | |
157b926a | 1175 | if (!cont) { |
9239b066 | 1176 | AliError(Form("%s: Particle container %d not found",GetName(),c)); |
1177 | return 0; | |
1178 | } | |
1179 | AliVParticle *vp = cont->GetAcceptParticle(p); | |
1180 | ||
1181 | return vp; | |
1182 | } | |
1183 | ||
1184 | //________________________________________________________________________ | |
b8aeed95 | 1185 | AliVCluster* AliAnalysisTaskEmcal::GetAcceptClusterFromArray(Int_t cl, Int_t c) const |
1186 | { | |
9239b066 | 1187 | // Get particle p if accepted from container c |
1188 | // If particle not accepted return 0 | |
1189 | ||
1190 | AliClusterContainer *cont = GetClusterContainer(c); | |
157b926a | 1191 | if (!cont) { |
9239b066 | 1192 | AliError(Form("%s: Cluster container %d not found",GetName(),c)); |
1193 | return 0; | |
1194 | } | |
1195 | AliVCluster *vc = cont->GetAcceptCluster(cl); | |
1196 | ||
1197 | return vc; | |
1198 | } | |
1199 | ||
1200 | //________________________________________________________________________ | |
b8aeed95 | 1201 | Int_t AliAnalysisTaskEmcal::GetNParticles(Int_t i) const |
1202 | { | |
9239b066 | 1203 | // Get number of entries in particle array i |
1204 | ||
1205 | AliParticleContainer *cont = GetParticleContainer(i); | |
157b926a | 1206 | if (!cont) { |
9239b066 | 1207 | AliError(Form("%s: Particle container %d not found",GetName(),i)); |
1208 | return 0; | |
1209 | } | |
1210 | return cont->GetNEntries(); | |
1211 | } | |
1212 | ||
1213 | //________________________________________________________________________ | |
b8aeed95 | 1214 | Int_t AliAnalysisTaskEmcal::GetNClusters(Int_t i) const |
1215 | { | |
9239b066 | 1216 | // Get number of entries in cluster array i |
1217 | ||
1218 | AliClusterContainer *cont = GetClusterContainer(i); | |
157b926a | 1219 | if (!cont) { |
9239b066 | 1220 | AliError(Form("%s: Cluster container %d not found",GetName(),i)); |
1221 | return 0; | |
1222 | } | |
1223 | return cont->GetNEntries(); | |
1224 | } | |
1225 | ||
37a63fdf | 1226 | //________________________________________________________________________ |
b8aeed95 | 1227 | AliEmcalTriggerPatchInfo* AliAnalysisTaskEmcal::GetMainTriggerPatch() |
1228 | { | |
37a63fdf | 1229 | //get main trigger match; if not known yet, look for it and cache |
1230 | ||
157b926a | 1231 | if (fMainTriggerPatch) |
37a63fdf | 1232 | return fMainTriggerPatch; |
1233 | ||
157b926a | 1234 | if (!fTriggerPatchInfo) { |
37a63fdf | 1235 | AliError(Form("%s: fTriggerPatchInfo not available",GetName())); |
1236 | return 0; | |
1237 | } | |
1238 | ||
1239 | //number of patches in event | |
1240 | Int_t nPatch = fTriggerPatchInfo->GetEntries(); | |
1241 | ||
1242 | //extract main trigger patch | |
1243 | AliEmcalTriggerPatchInfo *patch; | |
157b926a | 1244 | for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) { |
37a63fdf | 1245 | |
1246 | patch = (AliEmcalTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch ); | |
157b926a | 1247 | if (patch->IsMainTrigger()) { |
37a63fdf | 1248 | fMainTriggerPatch = patch; |
1249 | break; | |
1250 | } | |
1251 | } | |
1252 | ||
1253 | return fMainTriggerPatch; | |
37a63fdf | 1254 | } |
b8aeed95 | 1255 | |
1256 | //________________________________________________________________________ | |
1257 | void AliAnalysisTaskEmcal::AddObjectToEvent(TObject *obj) | |
1258 | { | |
1259 | // Add object to event | |
1260 | ||
1261 | if (!(InputEvent()->FindListObject(obj->GetName()))) { | |
1262 | InputEvent()->AddObject(obj); | |
1263 | } else { | |
1264 | AliFatal(Form("%s: Container with name %s already present. Aborting", GetName(), obj->GetName())); | |
1265 | } | |
1266 | } | |
9dc6ae4b | 1267 | |
1268 | //________________________________________________________________________ | |
1269 | void AliAnalysisTaskEmcal::GenerateFixedBinArray(Int_t n, Double_t min, Double_t max, Double_t* array) const | |
1270 | { | |
1271 | Double_t binWidth = (max-min)/n; | |
1272 | array[0] = min; | |
1273 | for (Int_t i = 1; i <= n; i++) { | |
1274 | array[i] = array[i-1]+binWidth; | |
1275 | } | |
1276 | } | |
1277 | ||
1278 | //________________________________________________________________________ | |
1279 | Double_t* AliAnalysisTaskEmcal::GenerateFixedBinArray(Int_t n, Double_t min, Double_t max) const | |
1280 | { | |
1281 | Double_t *array = new Double_t[n+1]; | |
1282 | ||
1283 | GenerateFixedBinArray(n, min, max, array); | |
1284 | ||
1285 | return array; | |
1286 | } | |
68e03fc3 | 1287 | |
1288 | //________________________________________________________________________ | |
1289 | void AliAnalysisTaskEmcal::SetRejectionReasonLabels(TAxis* axis) | |
1290 | { | |
1291 | axis->SetBinLabel(1, "NullObject"); | |
1292 | axis->SetBinLabel(2, "Pt"); | |
1293 | axis->SetBinLabel(3, "Acceptance"); | |
1294 | axis->SetBinLabel(4, "BitMap"); | |
1295 | axis->SetBinLabel(5, "Bit4"); | |
1296 | axis->SetBinLabel(6, "Bit5"); | |
1297 | axis->SetBinLabel(7, "Bit6"); | |
1298 | axis->SetBinLabel(8, "Bit7"); | |
1299 | axis->SetBinLabel(9, "MCFlag"); | |
1300 | axis->SetBinLabel(10, "MCGenerator"); | |
1301 | axis->SetBinLabel(11, "ChargeCut"); | |
1302 | axis->SetBinLabel(12, "Bit11"); | |
1303 | axis->SetBinLabel(13, "Bit12"); | |
1304 | axis->SetBinLabel(14, "IsEMCal"); | |
1305 | axis->SetBinLabel(15, "Time"); | |
1306 | axis->SetBinLabel(16, "Energy"); | |
1307 | axis->SetBinLabel(17, "Bit16"); | |
1308 | axis->SetBinLabel(18, "Bit17"); | |
1309 | axis->SetBinLabel(19, "Area"); | |
1310 | axis->SetBinLabel(20, "AreaEmc"); | |
1311 | axis->SetBinLabel(21, "ZLeadingCh"); | |
1312 | axis->SetBinLabel(22, "ZLeadingEmc"); | |
1313 | axis->SetBinLabel(23, "NEF"); | |
1314 | axis->SetBinLabel(24, "MinLeadPt"); | |
1315 | axis->SetBinLabel(25, "MaxTrackPt"); | |
1316 | axis->SetBinLabel(26, "MaxClusterPt"); | |
1317 | axis->SetBinLabel(27, "Flavour"); | |
1318 | axis->SetBinLabel(28, "TagStatus"); | |
1319 | axis->SetBinLabel(29, "Bit28"); | |
1320 | axis->SetBinLabel(30, "Bit29"); | |
1321 | axis->SetBinLabel(31, "Bit30"); | |
1322 | axis->SetBinLabel(32, "Bit31"); | |
1323 | } |