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