3 // Emcal jet analysis base task.
7 #include "AliAnalysisTaskEmcalJet.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"
20 #include "AliRhoParameter.h"
21 #include "AliVCluster.h"
22 #include "AliVEventHandler.h"
23 #include "AliVParticle.h"
25 ClassImp(AliAnalysisTaskEmcalJet)
27 //________________________________________________________________________
28 AliAnalysisTaskEmcalJet::AliAnalysisTaskEmcalJet() :
29 AliAnalysisTaskEmcal("AliAnalysisTaskEmcalJet"),
45 fLeadingHadronType(0),
52 // Default constructor.
55 //________________________________________________________________________
56 AliAnalysisTaskEmcalJet::AliAnalysisTaskEmcalJet(const char *name, Bool_t histo) :
57 AliAnalysisTaskEmcal(name, histo),
73 fLeadingHadronType(0),
80 // Standard constructor.
83 //________________________________________________________________________
84 AliAnalysisTaskEmcalJet::~AliAnalysisTaskEmcalJet()
89 //________________________________________________________________________
90 Bool_t AliAnalysisTaskEmcalJet::AcceptBiasJet(AliEmcalJet *jet) const
92 // Accept jet with a bias.
94 if (fLeadingHadronType == 0) {
95 if (jet->MaxTrackPt() < fPtBiasJetTrack) return kFALSE;
97 else if (fLeadingHadronType == 1) {
98 if (jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
101 if (jet->MaxTrackPt() < fPtBiasJetTrack && jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
107 //________________________________________________________________________
108 Float_t* AliAnalysisTaskEmcalJet::GenerateFixedBinArray(Int_t n, Float_t min, Float_t max) const
110 Float_t *bins = new Float_t[n+1];
112 Float_t binWidth = (max-min)/n;
114 for (Int_t i = 1; i <= n; i++) {
115 bins[i] = bins[i-1]+binWidth;
121 //________________________________________________________________________
122 Double_t AliAnalysisTaskEmcalJet::GetLeadingHadronPt(AliEmcalJet *jet) const
124 if (fLeadingHadronType == 0) // charged leading hadron
125 return jet->MaxTrackPt();
126 else if (fLeadingHadronType == 1) // neutral leading hadron
127 return jet->MaxClusterPt();
128 else // charged or neutral
129 return jet->MaxPartPt();
132 //________________________________________________________________________
133 Bool_t AliAnalysisTaskEmcalJet::AcceptJet(AliEmcalJet *jet) const
135 // Return true if jet is accepted.
139 if (jet->TestBits(fJetBitMap) != (Int_t)fJetBitMap)
142 if (jet->Pt() < fJetPtCut)
145 if (jet->Area() < fJetAreaCut)
148 if (jet->AreaEmc()<fAreaEmcCut)
151 if (!AcceptBiasJet(jet))
154 if (jet->MaxTrackPt() > fMaxTrackPt || jet->MaxClusterPt() > fMaxClusterPt)
157 Double_t jetPhi = jet->Phi();
158 Double_t jetEta = jet->Eta();
160 if (fJetMinPhi < 0) // if limits are given in (-pi, pi) range
161 jetPhi -= TMath::Pi() * 2;
163 return (Bool_t)(jetEta > fJetMinEta && jetEta < fJetMaxEta && jetPhi > fJetMinPhi && jetPhi < fJetMaxPhi);
166 //________________________________________________________________________
167 AliRhoParameter *AliAnalysisTaskEmcalJet::GetRhoFromEvent(const char *name)
169 // Get rho from event.
171 AliRhoParameter *rho = 0;
173 if (!sname.IsNull()) {
174 rho = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(sname));
176 AliWarning(Form("%s: Could not retrieve rho with name %s!", GetName(), name));
183 //________________________________________________________________________
184 void AliAnalysisTaskEmcalJet::ExecOnce()
186 // Init the analysis.
188 AliAnalysisTaskEmcal::ExecOnce();
190 if (fPercAreaCut >= 0) {
191 if (fJetAreaCut >= 0)
192 AliInfo(Form("%s: jet area cut will be calculated as a percentage of the average area, given value will be overwritten", GetName()));
193 fJetAreaCut = fPercAreaCut * fJetRadius * fJetRadius * TMath::Pi();
198 if (fAnaType == kTPC) {
199 SetJetEtaLimits(-0.5, 0.5);
200 SetJetPhiLimits(-10, 10);
202 else if (fAnaType == kEMCAL && fGeom) {
203 SetJetEtaLimits(fGeom->GetArm1EtaMin() + fJetRadius, fGeom->GetArm1EtaMax() - fJetRadius);
204 SetJetPhiLimits(fGeom->GetArm1PhiMin() * TMath::DegToRad() + fJetRadius, fGeom->GetArm1PhiMax() * TMath::DegToRad() - fJetRadius);
207 if (!fRhoName.IsNull() && !fRho) {
208 fRho = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(fRhoName));
210 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
211 fInitialized = kFALSE;
216 if (!fJetsName.IsNull() && !fJets) {
217 fJets = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fJetsName));
219 AliError(Form("%s: Could not retrieve jets %s!", GetName(), fJetsName.Data()));
220 fInitialized = kFALSE;
223 else if (!fJets->GetClass()->GetBaseClass("AliEmcalJet")) {
224 AliError(Form("%s: Collection %s does not contain AliEmcalJet objects!", GetName(), fJetsName.Data()));
226 fInitialized = kFALSE;
232 //________________________________________________________________________
233 Bool_t AliAnalysisTaskEmcalJet::GetSortedArray(Int_t indexes[], TClonesArray *array, Double_t rho) const
235 // Get the leading jets.
237 static Float_t pt[9999] = {0};
242 const Int_t n = array->GetEntriesFast();
247 if (array->GetClass()->GetBaseClass("AliEmcalJet")) {
249 for (Int_t i = 0; i < n; i++) {
253 AliEmcalJet* jet = static_cast<AliEmcalJet*>(array->At(i));
256 AliError(Form("Could not receive jet %d", i));
263 pt[i] = jet->Pt() - rho * jet->Area();
267 else if (array->GetClass()->GetBaseClass("AliVTrack")) {
269 for (Int_t i = 0; i < n; i++) {
273 AliVTrack* track = static_cast<AliVTrack*>(array->At(i));
276 AliError(Form("Could not receive track %d", i));
280 if (!AcceptTrack(track))
287 else if (array->GetClass()->GetBaseClass("AliVCluster")) {
289 for (Int_t i = 0; i < n; i++) {
293 AliVCluster* cluster = static_cast<AliVCluster*>(array->At(i));
296 AliError(Form("Could not receive cluster %d", i));
300 if (!AcceptCluster(cluster))
303 TLorentzVector nPart;
304 cluster->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
310 TMath::Sort(n, pt, indexes);
312 if (pt[indexes[0]] == -FLT_MAX)
318 //________________________________________________________________________
319 Bool_t AliAnalysisTaskEmcalJet::IsJetCluster(AliEmcalJet* jet, Int_t iclus, Bool_t sorted) const
321 // Return true if cluster is in jet.
323 for (Int_t i = 0; i < jet->GetNumberOfClusters(); ++i) {
324 Int_t ijetclus = jet->ClusterAt(i);
325 if (sorted && ijetclus > iclus)
327 if (ijetclus == iclus)
333 //________________________________________________________________________
334 Bool_t AliAnalysisTaskEmcalJet::IsJetTrack(AliEmcalJet* jet, Int_t itrack, Bool_t sorted) const
336 // Return true if track is in jet.
338 for (Int_t i = 0; i < jet->GetNumberOfTracks(); ++i) {
339 Int_t ijettrack = jet->TrackAt(i);
340 if (sorted && ijettrack > itrack)
342 if (ijettrack == itrack)
348 //________________________________________________________________________
349 Bool_t AliAnalysisTaskEmcalJet::RetrieveEventObjects()
351 // Retrieve objects from event.
353 if (!AliAnalysisTaskEmcal::RetrieveEventObjects())
357 fRhoVal = fRho->GetVal();