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 "AliLocalRhoParameter.h"
22 #include "AliVCluster.h"
23 #include "AliVEventHandler.h"
24 #include "AliVParticle.h"
26 ClassImp(AliAnalysisTaskEmcalJet)
28 //________________________________________________________________________
29 AliAnalysisTaskEmcalJet::AliAnalysisTaskEmcalJet() :
30 AliAnalysisTaskEmcal("AliAnalysisTaskEmcalJet"),
47 fLeadingHadronType(0),
56 // Default constructor.
59 //________________________________________________________________________
60 AliAnalysisTaskEmcalJet::AliAnalysisTaskEmcalJet(const char *name, Bool_t histo) :
61 AliAnalysisTaskEmcal(name, histo),
78 fLeadingHadronType(0),
87 // Standard constructor.
90 //________________________________________________________________________
91 AliAnalysisTaskEmcalJet::~AliAnalysisTaskEmcalJet()
96 //________________________________________________________________________
97 Bool_t AliAnalysisTaskEmcalJet::AcceptBiasJet(AliEmcalJet *jet) const
99 // Accept jet with a bias.
101 if (fLeadingHadronType == 0) {
102 if (jet->MaxTrackPt() < fPtBiasJetTrack) return kFALSE;
104 else if (fLeadingHadronType == 1) {
105 if (jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
108 if (jet->MaxTrackPt() < fPtBiasJetTrack && jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
114 //________________________________________________________________________
115 Float_t* AliAnalysisTaskEmcalJet::GenerateFixedBinArray(Int_t n, Float_t min, Float_t max) const
117 Float_t *bins = new Float_t[n+1];
119 Float_t binWidth = (max-min)/n;
121 for (Int_t i = 1; i <= n; i++) {
122 bins[i] = bins[i-1]+binWidth;
128 //________________________________________________________________________
129 Double_t AliAnalysisTaskEmcalJet::GetLeadingHadronPt(AliEmcalJet *jet) const
131 if (fLeadingHadronType == 0) // charged leading hadron
132 return jet->MaxTrackPt();
133 else if (fLeadingHadronType == 1) // neutral leading hadron
134 return jet->MaxClusterPt();
135 else // charged or neutral
136 return jet->MaxPartPt();
139 //________________________________________________________________________
140 Bool_t AliAnalysisTaskEmcalJet::AcceptJet(AliEmcalJet *jet) const
142 // Return true if jet is accepted.
146 if (jet->TestBits(fJetBitMap) != (Int_t)fJetBitMap)
149 if (jet->Pt() < fJetPtCut)
152 if (jet->Area() < fJetAreaCut)
155 if (jet->AreaEmc()<fAreaEmcCut)
158 if (!AcceptBiasJet(jet))
161 if (jet->MaxTrackPt() > fMaxTrackPt || jet->MaxClusterPt() > fMaxClusterPt)
164 Double_t jetPhi = jet->Phi();
165 Double_t jetEta = jet->Eta();
167 if (fJetMinPhi < 0) // if limits are given in (-pi, pi) range
168 jetPhi -= TMath::Pi() * 2;
170 if (fJetTrigger != 0 && !jet->IsTriggerJet(fJetTrigger))
173 return (Bool_t)(jetEta > fJetMinEta && jetEta < fJetMaxEta && jetPhi > fJetMinPhi && jetPhi < fJetMaxPhi);
176 //________________________________________________________________________
177 AliRhoParameter *AliAnalysisTaskEmcalJet::GetRhoFromEvent(const char *name)
179 // Get rho from event.
181 AliRhoParameter *rho = 0;
183 if (!sname.IsNull()) {
184 rho = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(sname));
186 AliWarning(Form("%s: Could not retrieve rho with name %s!", GetName(), name));
192 //________________________________________________________________________
193 AliLocalRhoParameter *AliAnalysisTaskEmcalJet::GetLocalRhoFromEvent(const char *name)
195 // Get local rho from event.
196 AliLocalRhoParameter *rho = 0;
198 if (!sname.IsNull()) {
199 rho = dynamic_cast<AliLocalRhoParameter*>(InputEvent()->FindListObject(sname));
201 AliWarning(Form("%s: Could not retrieve local rho with name %s!", GetName(), name));
207 //________________________________________________________________________
208 void AliAnalysisTaskEmcalJet::ExecOnce()
210 // Init the analysis.
212 AliAnalysisTaskEmcal::ExecOnce();
214 if (fPercAreaCut >= 0) {
215 if (fJetAreaCut >= 0)
216 AliInfo(Form("%s: jet area cut will be calculated as a percentage of the average area, given value will be overwritten", GetName()));
217 fJetAreaCut = fPercAreaCut * fJetRadius * fJetRadius * TMath::Pi();
222 if (fAnaType == kTPC) {
223 SetJetEtaLimits(-0.5, 0.5);
224 SetJetPhiLimits(-10, 10);
226 else if (fAnaType == kEMCAL && fGeom) {
228 SetJetEtaLimits(fGeom->GetArm1EtaMin() + fJetRadius, fGeom->GetArm1EtaMax() - fJetRadius);
230 Int_t runno = InputEvent()->GetRunNumber();
231 if(runno>=177295 && runno<=197470) //small SM masked in 2012 and 2013
232 SetJetPhiLimits(1.4 + fJetRadius, TMath::Pi() - fJetRadius);
234 SetJetPhiLimits(fGeom->GetArm1PhiMin() * TMath::DegToRad() + fJetRadius, fGeom->GetArm1PhiMax() * TMath::DegToRad() - fJetRadius);
238 if (!fRhoName.IsNull() && !fRho) {
239 fRho = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(fRhoName));
241 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
242 fInitialized = kFALSE;
247 if (!fLocalRhoName.IsNull() && !fLocalRho) {
248 fLocalRho = dynamic_cast<AliLocalRhoParameter*>(InputEvent()->FindListObject(fLocalRhoName));
250 AliError(Form("%s: Could not retrieve local rho %s!", GetName(), fLocalRhoName.Data()));
251 fInitialized = kFALSE;
256 if (!fJetsName.IsNull() && !fJets) {
257 fJets = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fJetsName));
259 AliError(Form("%s: Could not retrieve jets %s!", GetName(), fJetsName.Data()));
260 fInitialized = kFALSE;
263 else if (!fJets->GetClass()->GetBaseClass("AliEmcalJet")) {
264 AliError(Form("%s: Collection %s does not contain AliEmcalJet objects!", GetName(), fJetsName.Data()));
266 fInitialized = kFALSE;
272 //________________________________________________________________________
273 Int_t AliAnalysisTaskEmcalJet::GetSortedArray(Int_t indexes[], TClonesArray *array, Double_t rho) const
275 // Get the leading jets.
277 static Float_t pt[9999] = {0};
282 const Int_t n = array->GetEntriesFast();
289 if (array->GetClass()->GetBaseClass("AliEmcalJet")) {
291 for (Int_t i = 0; i < n; i++) {
295 AliEmcalJet* jet = static_cast<AliEmcalJet*>(array->At(i));
298 AliError(Form("Could not receive jet %d", i));
305 pt[nacc] = jet->Pt() - rho * jet->Area();
310 else if (array->GetClass()->GetBaseClass("AliVTrack")) {
312 for (Int_t i = 0; i < n; i++) {
316 AliVTrack* track = static_cast<AliVTrack*>(array->At(i));
319 AliError(Form("Could not receive track %d", i));
323 if (!AcceptTrack(track))
326 pt[nacc] = track->Pt();
331 else if (array->GetClass()->GetBaseClass("AliVCluster")) {
333 for (Int_t i = 0; i < n; i++) {
337 AliVCluster* cluster = static_cast<AliVCluster*>(array->At(i));
340 AliError(Form("Could not receive cluster %d", i));
344 if (!AcceptCluster(cluster))
347 TLorentzVector nPart;
348 cluster->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
350 pt[nacc] = nPart.Pt();
356 TMath::Sort(nacc, pt, indexes);
361 //________________________________________________________________________
362 Bool_t AliAnalysisTaskEmcalJet::IsJetCluster(AliEmcalJet* jet, Int_t iclus, Bool_t sorted) const
364 // Return true if cluster is in jet.
366 for (Int_t i = 0; i < jet->GetNumberOfClusters(); ++i) {
367 Int_t ijetclus = jet->ClusterAt(i);
368 if (sorted && ijetclus > iclus)
370 if (ijetclus == iclus)
376 //________________________________________________________________________
377 Bool_t AliAnalysisTaskEmcalJet::IsJetTrack(AliEmcalJet* jet, Int_t itrack, Bool_t sorted) const
379 // Return true if track is in jet.
381 for (Int_t i = 0; i < jet->GetNumberOfTracks(); ++i) {
382 Int_t ijettrack = jet->TrackAt(i);
383 if (sorted && ijettrack > itrack)
385 if (ijettrack == itrack)
391 //________________________________________________________________________
392 Bool_t AliAnalysisTaskEmcalJet::RetrieveEventObjects()
394 // Retrieve objects from event.
396 if (!AliAnalysisTaskEmcal::RetrieveEventObjects())
400 fRhoVal = fRho->GetVal();