6 #include <TClonesArray.h>
8 #include "AliEmcalJet.h"
11 #include "AliEMCALGeometry.h"
12 #include "AliParticleContainer.h"
13 #include "AliClusterContainer.h"
15 #include "AliJetContainer.h"
17 ClassImp(AliJetContainer)
19 //________________________________________________________________________
20 AliJetContainer::AliJetContainer():
21 AliEmcalContainer("AliJetContainer"),
22 fJetAcceptanceType(kUser),
36 fLeadingHadronType(0),
40 fParticleContainer(0),
46 // Default constructor.
50 //________________________________________________________________________
51 AliJetContainer::AliJetContainer(const char *name):
52 AliEmcalContainer(name),
53 fJetAcceptanceType(kUser),
67 fLeadingHadronType(0),
71 fParticleContainer(0),
77 // Standard constructor.
81 //________________________________________________________________________
82 void AliJetContainer::SetJetArray(AliVEvent *event)
86 SetArray(event, "AliEmcalJet");
88 if(fJetAcceptanceType==kTPC) {
89 AliDebug(2,Form("%s: set TPC acceptance cuts",GetName()));
92 else if(fJetAcceptanceType==kEMCAL) {
93 AliDebug(2,Form("%s: set EMCAL acceptance cuts",GetName()));
99 //________________________________________________________________________
100 void AliJetContainer::SetEMCALGeometry() {
101 fGeom = AliEMCALGeometry::GetInstance();
103 AliError(Form("%s: Can not create geometry", GetName()));
108 //________________________________________________________________________
109 void AliJetContainer::LoadRho(AliVEvent *event)
113 if (!fRhoName.IsNull() && !fRho) {
114 fRho = dynamic_cast<AliRhoParameter*>(event->FindListObject(fRhoName));
116 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
122 //________________________________________________________________________
123 AliEmcalJet* AliJetContainer::GetLeadingJet(const char* opt) const
125 // Get the leading jet; if opt contains "rho" the sorting is according to pt-A*rho
130 AliEmcalJet *jetMax = GetNextAcceptJet(0);
131 AliEmcalJet *jet = 0;
133 if (option.Contains("rho")) {
134 while ((jet = GetNextAcceptJet())) {
135 if (jet->Pt()-jet->Area()*fRho->GetVal() > jetMax->Pt()-jetMax->Area()*fRho->GetVal()) jetMax = jet;
139 while ((jet = GetNextAcceptJet())) {
140 if (jet->Pt() > jetMax->Pt()) jetMax = jet;
147 //________________________________________________________________________
148 AliEmcalJet* AliJetContainer::GetJet(Int_t i) const {
150 //Get i^th jet in array
152 if(i<0 || i>fClArray->GetEntriesFast()) return 0;
153 AliEmcalJet *jet = static_cast<AliEmcalJet*>(fClArray->At(i));
159 //________________________________________________________________________
160 Double_t AliJetContainer::GetJetPtCorr(Int_t i) const {
161 AliEmcalJet *jet = GetJet(i);
163 return jet->Pt() - fRho->GetVal()*jet->Area();
166 //________________________________________________________________________
167 AliEmcalJet* AliJetContainer::GetAcceptJet(Int_t i) const {
169 //Only return jet if is accepted
171 AliEmcalJet *jet = GetJet(i);
172 if(!AcceptJet(jet)) return 0;
177 //________________________________________________________________________
178 AliEmcalJet* AliJetContainer::GetNextAcceptJet(Int_t i) const {
180 //Get next accepted jet; if i >= 0 (re)start counter from i; return 0 if no accepted jet could be found
182 static Int_t counter = -1;
183 if (i>=0) counter = i;
185 const Int_t njets = GetNEntries();
186 AliEmcalJet *jet = 0;
187 while (counter < njets && !jet) {
188 jet = GetAcceptJet(counter);
195 //________________________________________________________________________
196 void AliJetContainer::GetMomentum(TLorentzVector &mom, Int_t i) const
198 //Get momentum of the i^th jet in array
200 AliEmcalJet *jet = GetJet(i);
201 if(jet) jet->GetMom(mom);
204 //________________________________________________________________________
205 Bool_t AliJetContainer::AcceptBiasJet(AliEmcalJet *jet) const
207 // Accept jet with a bias.
209 if (fLeadingHadronType == 0) {
210 if (jet->MaxTrackPt() < fPtBiasJetTrack) return kFALSE;
212 else if (fLeadingHadronType == 1) {
213 if (jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
216 if (jet->MaxTrackPt() < fPtBiasJetTrack && jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
224 //________________________________________________________________________
225 Bool_t AliJetContainer::AcceptJet(AliEmcalJet *jet) const
227 // Return true if jet is accepted.
231 if (jet->TestBits(fJetBitMap) != (Int_t)fJetBitMap)
234 if (jet->Pt() <= fJetPtCut)
237 if (jet->Area() <= fJetAreaCut)
240 if (jet->AreaEmc()<fAreaEmcCut)
243 if (!AcceptBiasJet(jet))
246 if (jet->MaxTrackPt() > fMaxTrackPt || jet->MaxClusterPt() > fMaxClusterPt)
249 Double_t jetPhi = jet->Phi();
250 Double_t jetEta = jet->Eta();
252 if (fJetMinPhi < 0) // if limits are given in (-pi, pi) range
253 jetPhi -= TMath::Pi() * 2;
255 return (Bool_t)(jetEta > fJetMinEta && jetEta < fJetMaxEta && jetPhi > fJetMinPhi && jetPhi < fJetMaxPhi);
258 //________________________________________________________________________
259 Double_t AliJetContainer::GetLeadingHadronPt(AliEmcalJet *jet) const
261 if (fLeadingHadronType == 0) // charged leading hadron
262 return jet->MaxTrackPt();
263 else if (fLeadingHadronType == 1) // neutral leading hadron
264 return jet->MaxClusterPt();
265 else // charged or neutral
266 return jet->MaxPartPt();
269 //________________________________________________________________________
270 void AliJetContainer::GetLeadingHadronMomentum(TLorentzVector &mom, AliEmcalJet *jet) const
272 Double_t maxClusterPt = 0;
273 Double_t maxClusterEta = 0;
274 Double_t maxClusterPhi = 0;
276 Double_t maxTrackPt = 0;
277 Double_t maxTrackEta = 0;
278 Double_t maxTrackPhi = 0;
280 if (fClusterContainer && fClusterContainer->GetArray() && (fLeadingHadronType == 1 || fLeadingHadronType == 2)) {
281 AliVCluster *cluster = jet->GetLeadingCluster(fClusterContainer->GetArray());
283 TLorentzVector nPart;
284 cluster->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
286 maxClusterEta = nPart.Eta();
287 maxClusterPhi = nPart.Phi();
288 maxClusterPt = nPart.Pt();
292 if (fParticleContainer && fParticleContainer->GetArray() && (fLeadingHadronType == 0 || fLeadingHadronType == 2)) {
293 AliVParticle *track = jet->GetLeadingTrack(fParticleContainer->GetArray());
295 maxTrackEta = track->Eta();
296 maxTrackPhi = track->Phi();
297 maxTrackPt = track->Pt();
301 if (maxTrackPt > maxClusterPt)
302 mom.SetPtEtaPhiM(maxTrackPt,maxTrackEta,maxTrackPhi,0.139);
304 mom.SetPtEtaPhiM(maxClusterPt,maxClusterEta,maxClusterPhi,0.139);
307 //________________________________________________________________________
308 void AliJetContainer::SetJetEtaPhiEMCAL()
310 //Set default cuts for full jets
312 if(!fGeom) SetEMCALGeometry();
314 SetJetEtaLimits(fGeom->GetArm1EtaMin() + fJetRadius, fGeom->GetArm1EtaMax() - fJetRadius);
316 if(fRunNumber>=177295 && fRunNumber<=197470) //small SM masked in 2012 and 2013
317 SetJetPhiLimits(1.4+fJetRadius,TMath::Pi()-fJetRadius);
319 SetJetPhiLimits(fGeom->GetArm1PhiMin() * TMath::DegToRad() + fJetRadius, fGeom->GetArm1PhiMax() * TMath::DegToRad() - fJetRadius);
323 AliWarning("Could not get instance of AliEMCALGeometry. Using manual settings for EMCAL year 2011!!");
324 SetJetEtaLimits(-0.7+fJetRadius,0.7-fJetRadius);
325 SetJetPhiLimits(1.4+fJetRadius,TMath::Pi()-fJetRadius);
329 //________________________________________________________________________
330 void AliJetContainer::SetJetEtaPhiTPC()
332 //Set default cuts for charged jets
334 SetJetEtaLimits(-0.9+fJetRadius, 0.9-fJetRadius);
335 SetJetPhiLimits(-10, 10);
338 //________________________________________________________________________
339 void AliJetContainer::ResetCuts()
341 // Reset cuts to default values
352 fMaxClusterPt = 1000;
354 fLeadingHadronType = 0;