3 // Emcal base analysis task.
5 // Author: S.Aiola, M. Verweij
7 #include "AliAnalysisTaskEmcal.h"
9 #include <TClonesArray.h>
19 #include "AliAODEvent.h"
20 #include "AliAnalysisManager.h"
21 #include "AliCentrality.h"
22 #include "AliEMCALGeometry.h"
23 #include "AliESDEvent.h"
24 #include "AliEmcalParticle.h"
25 #include "AliEventplane.h"
26 #include "AliInputEventHandler.h"
28 #include "AliMCParticle.h"
29 #include "AliVCluster.h"
30 #include "AliVEventHandler.h"
31 #include "AliVParticle.h"
32 #include "AliVCaloTrigger.h"
33 #include "AliGenPythiaEventHeader.h"
34 #include "AliAODMCHeader.h"
35 #include "AliMCEvent.h"
36 #include "AliAnalysisUtils.h"
37 #include "AliEmcalTriggerPatchInfo.h"
39 #include "AliParticleContainer.h"
40 #include "AliClusterContainer.h"
42 ClassImp(AliAnalysisTaskEmcal)
44 //________________________________________________________________________
45 AliAnalysisTaskEmcal::AliAnalysisTaskEmcal() :
46 AliAnalysisTaskSE("AliAnalysisTaskEmcal"),
48 fGeneralHistograms(kFALSE),
53 fCaloTriggerPatchInfoName(),
60 fUseAliAnaUtils(kFALSE),
61 fAliAnalysisUtils(0x0),
62 fOffTrigger(AliVEvent::kAny),
68 fMinPtTrackInEmcal(0),
69 fEventPlaneVsEmcal(-1),
75 fSelectPtHardBin(-999),
98 fMainTriggerPatch(0x0),
101 fHistTrialsAfterSel(0),
102 fHistEventsAfterSel(0),
110 fHistEventRejection(0)
112 // Default constructor.
118 fParticleCollArray.SetOwner(kTRUE);
119 fClusterCollArray.SetOwner(kTRUE);
122 //________________________________________________________________________
123 AliAnalysisTaskEmcal::AliAnalysisTaskEmcal(const char *name, Bool_t histo) :
124 AliAnalysisTaskSE(name),
126 fGeneralHistograms(kFALSE),
127 fInitialized(kFALSE),
131 fCaloTriggerPatchInfoName(),
138 fUseAliAnaUtils(kFALSE),
139 fAliAnalysisUtils(0x0),
140 fOffTrigger(AliVEvent::kAny),
142 fTriggerTypeSel(kND),
146 fMinPtTrackInEmcal(0),
147 fEventPlaneVsEmcal(-1),
148 fMinEventPlane(-1e6),
153 fSelectPtHardBin(-999),
162 fTriggerPatchInfo(0),
174 fParticleCollArray(),
176 fMainTriggerPatch(0x0),
179 fHistTrialsAfterSel(0),
180 fHistEventsAfterSel(0),
188 fHistEventRejection(0)
190 // Standard constructor.
196 fParticleCollArray.SetOwner(kTRUE);
197 fClusterCollArray.SetOwner(kTRUE);
200 DefineOutput(1, TList::Class());
204 //________________________________________________________________________
205 AliAnalysisTaskEmcal::~AliAnalysisTaskEmcal()
210 //________________________________________________________________________
211 void AliAnalysisTaskEmcal::SetClusPtCut(Double_t cut, Int_t c)
213 AliClusterContainer *cont = GetClusterContainer(c);
214 if (cont) cont->SetClusPtCut(cut);
215 else AliError(Form("%s in SetClusPtCut(...): container %d not found",GetName(),c));
218 //________________________________________________________________________
219 void AliAnalysisTaskEmcal::SetClusTimeCut(Double_t min, Double_t max, Int_t c)
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));
226 //________________________________________________________________________
227 void AliAnalysisTaskEmcal::SetTrackPtCut(Double_t cut, Int_t c)
229 AliParticleContainer *cont = GetParticleContainer(c);
230 if (cont) cont->SetParticlePtCut(cut);
231 else AliError(Form("%s in SetTrackPtCut(...): container %d not found",GetName(),c));
236 //________________________________________________________________________
237 void AliAnalysisTaskEmcal::SetTrackEtaLimits(Double_t min, Double_t max, Int_t c)
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));
244 //________________________________________________________________________
245 void AliAnalysisTaskEmcal::SetTrackPhiLimits(Double_t min, Double_t max, Int_t c)
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));
252 //________________________________________________________________________
253 void AliAnalysisTaskEmcal::UserCreateOutputObjects()
255 // Create user output.
260 fOutput = new TList();
263 if (fForceBeamType == kpp)
266 if (!fGeneralHistograms)
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);
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);
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);
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);
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);
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};
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]));
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]));
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);
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);
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);
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);
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);
344 PostData(1, fOutput);
347 //________________________________________________________________________
348 Bool_t AliAnalysisTaskEmcal::FillGeneralHistograms()
351 fHistEventsAfterSel->SetBinContent(fPtHardBin + 1, fHistEventsAfterSel->GetBinContent(fPtHardBin + 1) + 1);
352 fHistTrialsAfterSel->SetBinContent(fPtHardBin + 1, fHistTrialsAfterSel->GetBinContent(fPtHardBin + 1) + fNTrials);
353 fHistPtHard->Fill(fPtHard);
356 fHistCentrality->Fill(fCent);
357 fHistZVertex->Fill(fVertex[2]);
358 fHistEventPlane->Fill(fEPV0);
363 //________________________________________________________________________
364 void AliAnalysisTaskEmcal::UserExec(Option_t *)
366 // Main loop, called for each event.
368 fMainTriggerPatch = NULL;
376 if (!RetrieveEventObjects())
379 if (!IsEventSelected())
382 if (fGeneralHistograms && fCreateHisto) {
383 if (!FillGeneralHistograms())
391 if (!FillHistograms())
395 if (fCreateHisto && fOutput) {
396 // information for this iteration of the UserExec in the container
397 PostData(1, fOutput);
401 //________________________________________________________________________
402 Bool_t AliAnalysisTaskEmcal::AcceptCluster(AliVCluster *clus, Int_t c) const
404 // Return true if cluster is accepted.
409 AliClusterContainer *cont = GetClusterContainer(c);
411 AliError(Form("%s:Container %d not found",GetName(),c));
415 return cont->AcceptCluster(clus);
419 //________________________________________________________________________
420 Bool_t AliAnalysisTaskEmcal::AcceptTrack(AliVParticle *track, Int_t c) const
422 // Return true if track is accepted.
427 AliParticleContainer *cont = GetParticleContainer(c);
429 AliError(Form("%s:Container %d not found",GetName(),c));
433 return cont->AcceptParticle(track);
436 //________________________________________________________________________
437 Bool_t AliAnalysisTaskEmcal::PythiaInfoFromFile(const char* currFile, Float_t &fXsec, Float_t &fTrials, Int_t &pthard)
440 // Get the cross section and the trails either from pyxsec.root or from pysec_hists.root
441 // Get the pt hard bin from the file path
442 // This is to called in Notify and should provide the path to the AOD/ESD file
443 // (Partially copied from AliAnalysisHelperJetTasks)
445 TString file(currFile);
449 if (file.Contains(".zip#")) {
450 Ssiz_t pos1 = file.Index("root_archive",12,0,TString::kExact);
451 Ssiz_t pos = file.Index("#",1,pos1,TString::kExact);
452 Ssiz_t pos2 = file.Index(".root",5,TString::kExact);
453 file.Replace(pos+1,pos2-pos1,"");
456 // not an archive take the basename....
457 file.ReplaceAll(gSystem->BaseName(file.Data()),"");
459 AliDebug(1,Form("File name: %s",file.Data()));
461 // Get the pt hard bin
462 TString strPthard(file);
464 strPthard.Remove(strPthard.Last('/'));
465 strPthard.Remove(strPthard.Last('/'));
466 if (strPthard.Contains("AOD")) strPthard.Remove(strPthard.Last('/'));
467 strPthard.Remove(0,strPthard.Last('/')+1);
468 if (strPthard.IsDec())
469 pthard = strPthard.Atoi();
471 AliWarning(Form("Could not extract file number from path %s", strPthard.Data()));
473 // 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
474 TFile *fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec.root"));
477 // next trial fetch the histgram file
478 fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec_hists.root"));
480 // not a severe condition but inciate that we have no information
484 // find the tlist we want to be independtent of the name so use the Tkey
485 TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
490 TList *list = dynamic_cast<TList*>(key->ReadObj());
495 fXsec = ((TProfile*)list->FindObject("h1Xsec"))->GetBinContent(1);
496 fTrials = ((TH1F*)list->FindObject("h1Trials"))->GetBinContent(1);
499 } // no tree pyxsec.root
501 TTree *xtree = (TTree*)fxsec->Get("Xsection");
507 Double_t xsection = 0;
508 xtree->SetBranchAddress("xsection",&xsection);
509 xtree->SetBranchAddress("ntrials",&ntrials);
518 //________________________________________________________________________
519 Bool_t AliAnalysisTaskEmcal::UserNotify()
521 if (!fIsPythia || !fGeneralHistograms || !fCreateHisto)
524 TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
526 AliError(Form("%s - UserNotify: No current tree!",GetName()));
530 Float_t xsection = 0;
534 TFile *curfile = tree->GetCurrentFile();
536 AliError(Form("%s - UserNotify: No current file!",GetName()));
540 TChain *chain = dynamic_cast<TChain*>(tree);
542 tree = chain->GetTree();
544 Int_t nevents = tree->GetEntriesFast();
546 PythiaInfoFromFile(curfile->GetName(), xsection, trials, pthard);
549 if ((pthard < 0) || (pthard > 10))
551 fHistTrials->Fill(pthard, trials);
552 fHistXsection->Fill(pthard, xsection);
553 fHistEvents->Fill(pthard, nevents);
558 //________________________________________________________________________
559 void AliAnalysisTaskEmcal::ExecOnce()
561 // Init the analysis.
564 AliError(Form("%s: Could not retrieve event! Returning!", GetName()));
568 fGeom = AliEMCALGeometry::GetInstance();
570 AliError(Form("%s: Can not create geometry", GetName()));
574 if (fEventPlaneVsEmcal >= 0) {
575 Double_t ep = (fGeom->GetArm1PhiMax() + fGeom->GetArm1PhiMin()) / 2 * TMath::DegToRad() + fEventPlaneVsEmcal - TMath::Pi();
576 fMinEventPlane = ep - TMath::Pi() / 4;
577 fMaxEventPlane = ep + TMath::Pi() / 4;
580 //Load all requested track branches - each container knows name already
581 for (Int_t i =0; i<fParticleCollArray.GetEntriesFast(); i++) {
582 AliParticleContainer *cont = static_cast<AliParticleContainer*>(fParticleCollArray.At(i));
583 cont->SetArray(InputEvent());
586 if (fParticleCollArray.GetEntriesFast()>0) {
587 fTracks = GetParticleArray(0);
589 AliError(Form("%s: Could not retrieve first track branch!", GetName()));
594 //Load all requested cluster branches - each container knows name already
595 for (Int_t i =0; i<fClusterCollArray.GetEntriesFast(); i++) {
596 AliClusterContainer *cont = static_cast<AliClusterContainer*>(fClusterCollArray.At(i));
597 cont->SetArray(InputEvent());
600 if (fClusterCollArray.GetEntriesFast()>0) {
601 fCaloClusters = GetClusterArray(0);
602 if (!fCaloClusters) {
603 AliError(Form("%s: Could not retrieve first cluster branch!", GetName()));
608 if (!fCaloCellsName.IsNull() && !fCaloCells) {
609 fCaloCells = dynamic_cast<AliVCaloCells*>(InputEvent()->FindListObject(fCaloCellsName));
611 AliError(Form("%s: Could not retrieve cells %s!", GetName(), fCaloCellsName.Data()));
616 if (!fCaloTriggersName.IsNull() && !fCaloTriggers) {
617 fCaloTriggers = dynamic_cast<AliVCaloTrigger*>(InputEvent()->FindListObject(fCaloTriggersName));
618 if (!fCaloTriggers) {
619 AliError(Form("%s: Could not retrieve calo triggers %s!", GetName(), fCaloTriggersName.Data()));
624 if (!fCaloTriggerPatchInfoName.IsNull() && !fTriggerPatchInfo) {
625 fTriggerPatchInfo = GetArrayFromEvent(fCaloTriggerPatchInfoName.Data(),"AliEmcalTriggerPatchInfo");
626 if (!fTriggerPatchInfo) {
627 AliError(Form("%s: Could not retrieve calo trigger patch info %s!", GetName(), fCaloTriggerPatchInfoName.Data()));
633 fInitialized = kTRUE;
636 //_____________________________________________________
637 AliAnalysisTaskEmcal::BeamType AliAnalysisTaskEmcal::GetBeamType()
639 // Get beam type : pp-AA-pA
640 // ESDs have it directly, AODs get it from hardcoded run number ranges
642 if (fForceBeamType != kNA)
643 return fForceBeamType;
645 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(InputEvent());
647 const AliESDRun *run = esd->GetESDRun();
648 TString beamType = run->GetBeamType();
649 if (beamType == "p-p")
651 else if (beamType == "A-A")
653 else if (beamType == "p-A")
658 Int_t runNumber = InputEvent()->GetRunNumber();
659 if ((runNumber >= 136851 && runNumber <= 139517) || // LHC10h
660 (runNumber >= 166529 && runNumber <= 170593)) // LHC11h
664 else if ((runNumber>=188365 && runNumber <= 188366) || // LHC12g
665 (runNumber >= 195344 && runNumber <= 196608)) // LHC13b-f
674 //_____________________________________________________
675 AliAnalysisTaskEmcal::TriggerType AliAnalysisTaskEmcal::GetTriggerType()
677 // Get trigger type: kND, kJ1, kJ2
679 if (!fTriggerPatchInfo)
682 //number of patches in event
683 Int_t nPatch = fTriggerPatchInfo->GetEntries();
685 //loop over patches to define trigger type of event
688 AliEmcalTriggerPatchInfo *patch;
689 for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
690 patch = (AliEmcalTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
691 if (patch->IsJetHigh()) nJ1++;
692 if (patch->IsJetLow()) nJ2++;
704 //________________________________________________________________________
705 Bool_t AliAnalysisTaskEmcal::IsEventSelected()
707 // Check if event is selected
709 if (fOffTrigger != AliVEvent::kAny) {
711 const AliESDEvent *eev = dynamic_cast<const AliESDEvent*>(InputEvent());
713 res = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
715 const AliAODEvent *aev = dynamic_cast<const AliAODEvent*>(InputEvent());
717 res = aev->GetHeader()->GetOfflineTrigger();
720 if ((res & fOffTrigger) == 0) {
721 if (fGeneralHistograms)
722 fHistEventRejection->Fill("PhysSel",1);
727 if (!fTrigClass.IsNull()) {
729 const AliESDEvent *eev = dynamic_cast<const AliESDEvent*>(InputEvent());
731 fired = eev->GetFiredTriggerClasses();
733 const AliAODEvent *aev = dynamic_cast<const AliAODEvent*>(InputEvent());
735 fired = aev->GetFiredTriggerClasses();
738 if (!fired.Contains("-B-")) {
739 if (fGeneralHistograms)
740 fHistEventRejection->Fill("trigger",1);
743 TObjArray *arr = fTrigClass.Tokenize("|");
745 if (fGeneralHistograms)
746 fHistEventRejection->Fill("trigger",1);
750 for (Int_t i=0;i<arr->GetEntriesFast();++i) {
751 TObject *obj = arr->At(i);
754 if (fired.Contains(obj->GetName())) {
761 if (fGeneralHistograms)
762 fHistEventRejection->Fill("trigger",1);
767 if (fTriggerTypeSel != kND) {
768 if (fTriggerType != fTriggerTypeSel) {
769 if (fGeneralHistograms)
770 fHistEventRejection->Fill("trigTypeSel",1);
776 if ((fMinCent != -999) && (fMaxCent != -999)) {
777 if (fCent<fMinCent || fCent>fMaxCent) {
778 if (fGeneralHistograms)
779 fHistEventRejection->Fill("Cent",1);
784 if ((fMinVz != -999) && (fMaxVz != -999)) {
785 if (fNVertCont == 0 ) {
786 if (fGeneralHistograms)
787 fHistEventRejection->Fill("vertex contr.",1);
790 Double_t vz = fVertex[2];
791 if (vz<fMinVz || vz>fMaxVz) {
792 if (fGeneralHistograms)
793 fHistEventRejection->Fill("Vz",1);
798 if (fMinPtTrackInEmcal > 0 && fGeom) {
799 Bool_t trackInEmcalOk = kFALSE;
800 Int_t ntracks = GetNParticles(0);
801 for (Int_t i = 0; i < ntracks; i++) {
802 AliVParticle *track = GetAcceptParticleFromArray(i,0);
806 Double_t phiMin = fGeom->GetArm1PhiMin() * TMath::DegToRad();
807 Double_t phiMax = fGeom->GetArm1PhiMax() * TMath::DegToRad();
808 Int_t runNumber = InputEvent()->GetRunNumber();
809 if (runNumber>=177295 && runNumber<=197470) { //small SM masked in 2012 and 2013
811 phiMax = TMath::Pi();
814 if (track->Eta() < fGeom->GetArm1EtaMin() || track->Eta() > fGeom->GetArm1EtaMax() || track->Phi() < phiMin || track->Phi() > phiMax)
816 if (track->Pt() > fMinPtTrackInEmcal) {
817 trackInEmcalOk = kTRUE;
821 if (!trackInEmcalOk) {
822 if (fGeneralHistograms)
823 fHistEventRejection->Fill("trackInEmcal",1);
828 if (fMinNTrack > 0) {
829 Int_t nTracksAcc = 0;
830 Int_t ntracks = GetNParticles(0);
831 for (Int_t i = 0; i < ntracks; i++) {
832 AliVParticle *track = GetAcceptParticleFromArray(i,0);
835 if (track->Pt() > fTrackPtCut) {
837 if (nTracksAcc>=fMinNTrack)
841 if (nTracksAcc<fMinNTrack) {
842 if (fGeneralHistograms)
843 fHistEventRejection->Fill("minNTrack",1);
848 if (fUseAliAnaUtils) {
849 if (!fAliAnalysisUtils)
850 fAliAnalysisUtils = new AliAnalysisUtils();
851 fAliAnalysisUtils->SetMinVtxContr(2);
852 fAliAnalysisUtils->SetMaxVtxZ(10.);
854 if (!fAliAnalysisUtils->IsVertexSelected2013pA(InputEvent())) {
855 if (fGeneralHistograms)
856 fHistEventRejection->Fill("VtxSel2013pA",1);
860 if (fAliAnalysisUtils->IsPileUpEvent(InputEvent())) {
861 fHistEventRejection->Fill("PileUp",1);
866 if (!(fEPV0 > fMinEventPlane && fEPV0 <= fMaxEventPlane) &&
867 !(fEPV0 + TMath::Pi() > fMinEventPlane && fEPV0 + TMath::Pi() <= fMaxEventPlane) &&
868 !(fEPV0 - TMath::Pi() > fMinEventPlane && fEPV0 - TMath::Pi() <= fMaxEventPlane))
870 if (fGeneralHistograms)
871 fHistEventRejection->Fill("EvtPlane",1);
875 if (fSelectPtHardBin != -999 && fSelectPtHardBin != fPtHardBin) {
876 if (fGeneralHistograms)
877 fHistEventRejection->Fill("SelPtHardBin",1);
884 //________________________________________________________________________
885 TClonesArray *AliAnalysisTaskEmcal::GetArrayFromEvent(const char *name, const char *clname)
887 // Get array from event.
889 TClonesArray *arr = 0;
891 if (!sname.IsNull()) {
892 arr = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(sname));
894 AliWarning(Form("%s: Could not retrieve array with name %s!", GetName(), name));
904 TString objname(arr->GetClass()->GetName());
906 if (!cls.InheritsFrom(clname)) {
907 AliWarning(Form("%s: Objects of type %s in %s are not inherited from %s!",
908 GetName(), cls.GetName(), name, clname));
914 //________________________________________________________________________
915 Bool_t AliAnalysisTaskEmcal::RetrieveEventObjects()
917 // Retrieve objects from event.
924 const AliVVertex *vert = InputEvent()->GetPrimaryVertex();
926 vert->GetXYZ(fVertex);
927 fNVertCont = vert->GetNContributors();
930 fBeamType = GetBeamType();
932 if (fBeamType == kAA || fBeamType == kpA ) {
933 AliCentrality *aliCent = InputEvent()->GetCentrality();
935 fCent = aliCent->GetCentralityPercentile(fCentEst.Data());
937 if (fCent >= 0 && fCent < 10) fCentBin = 0;
938 else if (fCent >= 10 && fCent < 30) fCentBin = 1;
939 else if (fCent >= 30 && fCent < 50) fCentBin = 2;
940 else if (fCent >= 50 && fCent <= 100) fCentBin = 3;
942 AliWarning(Form("%s: Negative centrality: %f. Assuming 99", GetName(), fCent));
943 fCentBin = fNcentBins-1;
947 Double_t centWidth = (fMaxCent-fMinCent)/(Double_t)fNcentBins;
948 fCentBin = TMath::FloorNint(fCent/centWidth);
949 if (fCentBin>=fNcentBins) {
950 AliWarning(Form("%s: fCentBin too large: cent = %f fCentBin = %d. Assuming 99", GetName(),fCent,fCentBin));
951 fCentBin = fNcentBins-1;
955 AliWarning(Form("%s: Could not retrieve centrality information! Assuming 99", GetName()));
958 AliEventplane *aliEP = InputEvent()->GetEventplane();
960 fEPV0 = aliEP->GetEventplane("V0" ,InputEvent());
961 fEPV0A = aliEP->GetEventplane("V0A",InputEvent());
962 fEPV0C = aliEP->GetEventplane("V0C",InputEvent());
964 AliWarning(Form("%s: Could not retrieve event plane information!", GetName()));
974 fPythiaHeader = dynamic_cast<AliGenPythiaEventHeader*>(MCEvent()->GenEventHeader());
975 if (!fPythiaHeader) {
977 AliAODMCHeader* aodMCH = dynamic_cast<AliAODMCHeader*>(InputEvent()->FindListObject(AliAODMCHeader::StdBranchName()));
980 for (UInt_t i = 0;i<aodMCH->GetNCocktailHeaders();i++) {
981 fPythiaHeader = dynamic_cast<AliGenPythiaEventHeader*>(aodMCH->GetCocktailHeader(i));
982 if (fPythiaHeader) break;
989 fPtHard = fPythiaHeader->GetPtHard();
991 const Int_t ptHardLo[11] = { 0, 5,11,21,36,57, 84,117,152,191,234};
992 const Int_t ptHardHi[11] = { 5,11,21,36,57,84,117,152,191,234,1000000};
993 for (fPtHardBin = 0; fPtHardBin < 11; fPtHardBin++) {
994 if (fPtHard >= ptHardLo[fPtHardBin] && fPtHard < ptHardHi[fPtHardBin])
998 fNTrials = fPythiaHeader->Trials();
1002 fTriggerType = GetTriggerType();
1007 //________________________________________________________________________
1008 AliParticleContainer* AliAnalysisTaskEmcal::AddParticleContainer(const char *n) {
1010 // Add particle container
1011 // will be called in AddTask macro
1013 TString tmp = TString(n);
1014 if (tmp.IsNull()) return 0;
1016 AliParticleContainer *cont = 0x0;
1017 cont = new AliParticleContainer();
1018 cont->SetArrayName(n);
1019 TString contName = cont->GetArrayName();
1021 fParticleCollArray.Add(cont);
1026 //________________________________________________________________________
1027 AliClusterContainer* AliAnalysisTaskEmcal::AddClusterContainer(const char *n) {
1029 // Add cluster container
1030 // will be called in AddTask macro
1032 TString tmp = TString(n);
1033 if (tmp.IsNull()) return 0;
1035 AliClusterContainer *cont = 0x0;
1036 cont = new AliClusterContainer();
1037 cont->SetArrayName(n);
1039 fClusterCollArray.Add(cont);
1044 //________________________________________________________________________
1045 AliParticleContainer* AliAnalysisTaskEmcal::GetParticleContainer(Int_t i) const {
1046 // Get i^th particle container
1048 if (i<0 || i>fParticleCollArray.GetEntriesFast()) return 0;
1049 AliParticleContainer *cont = static_cast<AliParticleContainer*>(fParticleCollArray.At(i));
1053 //________________________________________________________________________
1054 AliClusterContainer* AliAnalysisTaskEmcal::GetClusterContainer(Int_t i) const {
1055 // Get i^th cluster container
1057 if (i<0 || i>fClusterCollArray.GetEntriesFast()) return 0;
1058 AliClusterContainer *cont = static_cast<AliClusterContainer*>(fClusterCollArray.At(i));
1062 //________________________________________________________________________
1063 AliParticleContainer* AliAnalysisTaskEmcal::GetParticleContainer(const char *name) const {
1064 // Get particle container with name
1066 AliParticleContainer *cont = static_cast<AliParticleContainer*>(fParticleCollArray.FindObject(name));
1070 //________________________________________________________________________
1071 AliClusterContainer* AliAnalysisTaskEmcal::GetClusterContainer(const char *name) const {
1072 // Get cluster container with name
1074 AliClusterContainer *cont = static_cast<AliClusterContainer*>(fClusterCollArray.FindObject(name));
1078 //________________________________________________________________________
1079 TClonesArray* AliAnalysisTaskEmcal::GetParticleArray(Int_t i) const {
1080 // Get i^th TClonesArray with AliVParticle
1082 AliParticleContainer *cont = GetParticleContainer(i);
1084 AliError(Form("%s: Particle container %d not found",GetName(),i));
1087 TString contName = cont->GetArrayName();
1088 return cont->GetArray();
1091 //________________________________________________________________________
1092 TClonesArray* AliAnalysisTaskEmcal::GetClusterArray(Int_t i) const {
1093 // Get i^th TClonesArray with AliVCluster
1095 AliClusterContainer *cont = GetClusterContainer(i);
1097 AliError(Form("%s:Cluster container %d not found",GetName(),i));
1100 return cont->GetArray();
1103 //________________________________________________________________________
1104 AliVParticle* AliAnalysisTaskEmcal::GetAcceptParticleFromArray(Int_t p, Int_t c) const {
1105 // Get particle p if accepted from container c
1106 // If particle not accepted return 0
1108 AliParticleContainer *cont = GetParticleContainer(c);
1110 AliError(Form("%s: Particle container %d not found",GetName(),c));
1113 AliVParticle *vp = cont->GetAcceptParticle(p);
1118 //________________________________________________________________________
1119 AliVCluster* AliAnalysisTaskEmcal::GetAcceptClusterFromArray(Int_t cl, Int_t c) const {
1120 // Get particle p if accepted from container c
1121 // If particle not accepted return 0
1123 AliClusterContainer *cont = GetClusterContainer(c);
1125 AliError(Form("%s: Cluster container %d not found",GetName(),c));
1128 AliVCluster *vc = cont->GetAcceptCluster(cl);
1133 //________________________________________________________________________
1134 Int_t AliAnalysisTaskEmcal::GetNParticles(Int_t i) const {
1135 // Get number of entries in particle array i
1137 AliParticleContainer *cont = GetParticleContainer(i);
1139 AliError(Form("%s: Particle container %d not found",GetName(),i));
1142 return cont->GetNEntries();
1145 //________________________________________________________________________
1146 Int_t AliAnalysisTaskEmcal::GetNClusters(Int_t i) const {
1147 // Get number of entries in cluster array i
1149 AliClusterContainer *cont = GetClusterContainer(i);
1151 AliError(Form("%s: Cluster container %d not found",GetName(),i));
1154 return cont->GetNEntries();
1157 //________________________________________________________________________
1158 AliEmcalTriggerPatchInfo* AliAnalysisTaskEmcal::GetMainTriggerPatch() {
1159 //get main trigger match; if not known yet, look for it and cache
1161 if (fMainTriggerPatch)
1162 return fMainTriggerPatch;
1164 if (!fTriggerPatchInfo) {
1165 AliError(Form("%s: fTriggerPatchInfo not available",GetName()));
1169 //number of patches in event
1170 Int_t nPatch = fTriggerPatchInfo->GetEntries();
1172 //extract main trigger patch
1173 AliEmcalTriggerPatchInfo *patch;
1174 for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
1176 patch = (AliEmcalTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
1177 if (patch->IsMainTrigger()) {
1178 fMainTriggerPatch = patch;
1183 return fMainTriggerPatch;