1 // $Id: AliAnalysisTaskEmcal.cxx 56756 2012-05-30 05:03:02Z loizides $
3 // Emcal base analysis task.
7 #include "AliAnalysisTaskEmcal.h"
10 #include <TClonesArray.h>
14 #include "AliAnalysisManager.h"
15 #include "AliCentrality.h"
16 #include "AliEMCALGeometry.h"
17 #include "AliESDEvent.h"
18 #include "AliEmcalJet.h"
19 #include "AliEmcalParticle.h"
21 #include "AliMCParticle.h"
22 #include "AliVCluster.h"
23 #include "AliVEventHandler.h"
24 #include "AliVParticle.h"
26 ClassImp(AliAnalysisTaskEmcal)
28 //________________________________________________________________________
29 AliAnalysisTaskEmcal::AliAnalysisTaskEmcal() :
30 AliAnalysisTaskSE("AliAnalysisTaskEmcal"),
34 fTracksName("Tracks"),
35 fCaloName("CaloClusters"),
47 // Default constructor.
54 //________________________________________________________________________
55 AliAnalysisTaskEmcal::AliAnalysisTaskEmcal(const char *name, Bool_t histo) :
56 AliAnalysisTaskSE(name),
60 fTracksName("Tracks"),
61 fCaloName("CaloClusters"),
73 // Standard constructor.
80 DefineOutput(1, TList::Class());
84 //________________________________________________________________________
85 AliAnalysisTaskEmcal::~AliAnalysisTaskEmcal()
90 //________________________________________________________________________
91 void AliAnalysisTaskEmcal::UserCreateOutputObjects()
93 // User create outputs.
96 //_____________________________________________________
97 AliAnalysisTaskEmcal::BeamType AliAnalysisTaskEmcal::GetBeamType()
99 // Get beam type : pp-AA-pA
100 // ESDs have it directly, AODs get it from hardcoded run number ranges
102 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(InputEvent());
104 const AliESDRun *run = esd->GetESDRun();
105 TString beamType = run->GetBeamType();
106 if (beamType == "p-p")
108 else if (beamType == "A-A")
110 else if (beamType == "p-A")
115 Int_t runNumber = InputEvent()->GetRunNumber();
116 if ((runNumber >= 136851 && runNumber <= 139517) || // LHC10h
117 (runNumber >= 166529 && runNumber <= 170593)) // LHC11h
126 void AliAnalysisTaskEmcal::Init()
128 // Init the analysis.
130 if (!fCaloName.IsNull() && (fAnaType == kEMCAL) && !fCaloClusters) {
131 fCaloClusters = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fCaloName));
132 if (!fCaloClusters) {
133 AliWarning(Form("%s: Could not retrieve clusters %s!", GetName(), fCaloName.Data()));
137 if (!fTracksName.IsNull() && !fTracks) {
138 fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksName));
140 AliWarning(Form("%s: Could not retrieve tracks %s!", GetName(), fTracksName.Data()));
147 //________________________________________________________________________
148 Bool_t AliAnalysisTaskEmcal::RetrieveEventObjects()
150 // Retrieve objects from event.
153 AliError(Form("%s: Could not retrieve event! Returning!", GetName()));
160 InputEvent()->GetPrimaryVertex()->GetXYZ(fVertex);
162 fBeamType = GetBeamType();
164 if (fBeamType == kAA) {
165 AliCentrality *aliCent = InputEvent()->GetCentrality();
167 fCent = aliCent->GetCentralityPercentile("V0M");
168 if (fCent >= 0 && fCent < 10) fCentBin = 0;
169 else if (fCent >= 10 && fCent < 30) fCentBin = 1;
170 else if (fCent >= 30 && fCent < 50) fCentBin = 2;
171 else if (fCent >= 50 && fCent <= 100) fCentBin = 3;
173 AliWarning(Form("%s: Negative centrality: %f. Assuming 99", GetName(), fCent));
177 AliWarning(Form("%s: Could not retrieve centrality information! Assuming 99", GetName()));
188 //________________________________________________________________________
189 Bool_t AliAnalysisTaskEmcal::AcceptCluster(AliVCluster *clus, Bool_t acceptMC) const
191 // Return true if cluster is accepted.
196 if (!clus->IsEMCAL())
199 if (!acceptMC && clus->Chi2() == 100)
202 TLorentzVector nPart;
203 clus->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
205 if (nPart.Et() < fPtCut)
211 //________________________________________________________________________
212 Bool_t AliAnalysisTaskEmcal::AcceptEmcalPart(AliEmcalParticle *part, Bool_t acceptMC) const
214 // Return true if EMCal particle is accepted.
219 if (fAnaType == kEMCAL && !part->IsEMCAL())
222 if (part->Pt() < fPtCut)
225 if (!acceptMC && part->IsMC())
231 //________________________________________________________________________
232 Bool_t AliAnalysisTaskEmcal::AcceptTrack(AliVTrack *track, Bool_t acceptMC) const
234 // Return true if track is accepted.
239 if (!acceptMC && track->GetLabel() == 100)
242 if (track->Pt() < fPtCut)
248 //________________________________________________________________________
249 void AliAnalysisTaskEmcal::UserExec(Option_t *)
251 // Main loop, called for each event.
256 if (!RetrieveEventObjects())
262 if (!FillHistograms())
266 // information for this iteration of the UserExec in the container
267 PostData(1, fOutput);
271 //________________________________________________________________________
272 void AliAnalysisTaskEmcal::Terminate(Option_t *)
274 // Called once at the end of the analysis.