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