6 #include <TClonesArray.h>
8 #include "AliEmcalJet.h"
11 #include "AliEMCALGeometry.h"
12 #include "AliParticleContainer.h"
13 #include "AliClusterContainer.h"
14 #include "AliLocalRhoParameter.h"
16 #include "AliJetContainer.h"
18 ClassImp(AliJetContainer)
20 //________________________________________________________________________
21 AliJetContainer::AliJetContainer():
22 AliEmcalContainer("AliJetContainer"),
23 fJetAcceptanceType(kUser),
42 fLeadingHadronType(0),
46 fParticleContainer(0),
53 // Default constructor.
55 fClassName = "AliEmcalJet";
58 //________________________________________________________________________
59 AliJetContainer::AliJetContainer(const char *name):
60 AliEmcalContainer(name),
61 fJetAcceptanceType(kUser),
80 fLeadingHadronType(0),
84 fParticleContainer(0),
91 // Standard constructor.
93 fClassName = "AliEmcalJet";
96 //________________________________________________________________________
97 void AliJetContainer::SetArray(AliVEvent *event)
101 AliEmcalContainer::SetArray(event);
103 if(fJetAcceptanceType==kTPC) {
104 AliDebug(2,Form("%s: set TPC acceptance cuts",GetName()));
107 else if(fJetAcceptanceType==kEMCAL) {
108 AliDebug(2,Form("%s: set EMCAL acceptance cuts",GetName()));
114 //________________________________________________________________________
115 void AliJetContainer::SetEMCALGeometry() {
116 fGeom = AliEMCALGeometry::GetInstance();
118 AliError(Form("%s: Can not create geometry", GetName()));
123 //________________________________________________________________________
124 void AliJetContainer::LoadRho(AliVEvent *event)
128 if (!fRhoName.IsNull() && !fRho) {
129 fRho = dynamic_cast<AliRhoParameter*>(event->FindListObject(fRhoName));
131 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
137 //________________________________________________________________________
138 void AliJetContainer::LoadLocalRho(AliVEvent *event)
142 if (!fLocalRhoName.IsNull() && !fLocalRho) {
143 fLocalRho = dynamic_cast<AliLocalRhoParameter*>(event->FindListObject(fLocalRhoName));
145 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fLocalRhoName.Data()));
151 //________________________________________________________________________
152 AliEmcalJet* AliJetContainer::GetLeadingJet(const char* opt)
154 // Get the leading jet; if opt contains "rho" the sorting is according to pt-A*rho
159 Int_t tempID = fCurrentID;
161 AliEmcalJet *jetMax = GetNextAcceptJet(0);
162 AliEmcalJet *jet = 0;
164 if (option.Contains("rho")) {
165 while ((jet = GetNextAcceptJet())) {
166 if (jet->Pt()-jet->Area()*fRho->GetVal() > jetMax->Pt()-jetMax->Area()*fRho->GetVal()) jetMax = jet;
170 while ((jet = GetNextAcceptJet())) {
171 if (jet->Pt() > jetMax->Pt()) jetMax = jet;
180 //________________________________________________________________________
181 AliEmcalJet* AliJetContainer::GetJet(Int_t i) const {
183 //Get i^th jet in array
185 if(i<0 || i>fClArray->GetEntriesFast()) return 0;
186 AliEmcalJet *jet = static_cast<AliEmcalJet*>(fClArray->At(i));
191 //________________________________________________________________________
192 AliEmcalJet* AliJetContainer::GetAcceptJet(Int_t i) const {
194 //Only return jet if is accepted
196 AliEmcalJet *jet = GetJet(i);
197 if(!AcceptJet(jet)) return 0;
202 //________________________________________________________________________
203 AliEmcalJet* AliJetContainer::GetJetWithLabel(Int_t lab) const {
205 //Get particle with label lab in array
207 Int_t i = GetIndexFromLabel(lab);
211 //________________________________________________________________________
212 AliEmcalJet* AliJetContainer::GetAcceptJetWithLabel(Int_t lab) const {
214 //Get particle with label lab in array
216 Int_t i = GetIndexFromLabel(lab);
217 return GetAcceptJet(i);
220 //________________________________________________________________________
221 AliEmcalJet* AliJetContainer::GetNextAcceptJet(Int_t i) {
223 //Get next accepted jet; if i >= 0 (re)start counter from i; return 0 if no accepted jet could be found
225 if (i>=0) fCurrentID = i;
227 const Int_t njets = GetNEntries();
228 AliEmcalJet *jet = 0;
229 while (fCurrentID < njets && !jet) {
230 jet = GetAcceptJet(fCurrentID);
237 //________________________________________________________________________
238 AliEmcalJet* AliJetContainer::GetNextJet(Int_t i) {
240 //Get next jet; if i >= 0 (re)start counter from i; return 0 if no jet could be found
242 if (i>=0) fCurrentID = i;
244 const Int_t njets = GetNEntries();
245 AliEmcalJet *jet = 0;
246 while (fCurrentID < njets && !jet) {
247 jet = GetJet(fCurrentID);
254 //________________________________________________________________________
255 Double_t AliJetContainer::GetJetPtCorr(Int_t i) const {
256 AliEmcalJet *jet = GetJet(i);
258 return jet->Pt() - fRho->GetVal()*jet->Area();
261 //________________________________________________________________________
262 Double_t AliJetContainer::GetJetPtCorrLocal(Int_t i) const {
263 AliEmcalJet *jet = GetJet(i);
265 return jet->Pt() - fLocalRho->GetLocalVal(jet->Phi(), fJetRadius)*jet->Area();
268 //________________________________________________________________________
269 void AliJetContainer::GetMomentum(TLorentzVector &mom, Int_t i) const
271 //Get momentum of the i^th jet in array
273 AliEmcalJet *jet = GetJet(i);
274 if(jet) jet->GetMom(mom);
277 //________________________________________________________________________
278 Bool_t AliJetContainer::AcceptBiasJet(AliEmcalJet *jet) const
280 // Accept jet with a bias.
282 if (fLeadingHadronType == 0) {
283 if (jet->MaxTrackPt() < fPtBiasJetTrack) return kFALSE;
285 else if (fLeadingHadronType == 1) {
286 if (jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
289 if (jet->MaxTrackPt() < fPtBiasJetTrack && jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
297 //________________________________________________________________________
298 Bool_t AliJetContainer::AcceptJet(AliEmcalJet *jet) const
300 // Return true if jet is accepted.
304 if (jet->TestBits(fJetBitMap) != (Int_t)fJetBitMap)
307 if (jet->Pt() <= fJetPtCut)
310 if (jet->Area() <= fJetAreaCut)
313 if (jet->AreaEmc()<fAreaEmcCut)
316 if( GetZLeadingCharged(jet)>fZLeadingChCut || GetZLeadingEmc(jet)>fZLeadingEmcCut)
319 if(jet->NEF()<fNEFMinCut || jet->NEF()>fNEFMaxCut)
322 if (!AcceptBiasJet(jet))
325 if (jet->MaxTrackPt() > fMaxTrackPt || jet->MaxClusterPt() > fMaxClusterPt)
329 Double_t jetPhi = jet->Phi();
330 Double_t jetEta = jet->Eta();
332 if (fJetMinPhi < 0) // if limits are given in (-pi, pi) range
333 jetPhi -= TMath::Pi() * 2;
335 return (Bool_t)(jetEta > fJetMinEta && jetEta < fJetMaxEta && jetPhi > fJetMinPhi && jetPhi < fJetMaxPhi);
338 //________________________________________________________________________
339 Double_t AliJetContainer::GetLeadingHadronPt(AliEmcalJet *jet) const
341 if (fLeadingHadronType == 0) // charged leading hadron
342 return jet->MaxTrackPt();
343 else if (fLeadingHadronType == 1) // neutral leading hadron
344 return jet->MaxClusterPt();
345 else // charged or neutral
346 return jet->MaxPartPt();
349 //________________________________________________________________________
350 void AliJetContainer::GetLeadingHadronMomentum(TLorentzVector &mom, AliEmcalJet *jet) const
352 Double_t maxClusterPt = 0;
353 Double_t maxClusterEta = 0;
354 Double_t maxClusterPhi = 0;
356 Double_t maxTrackPt = 0;
357 Double_t maxTrackEta = 0;
358 Double_t maxTrackPhi = 0;
360 if (fClusterContainer && fClusterContainer->GetArray() && (fLeadingHadronType == 1 || fLeadingHadronType == 2)) {
361 AliVCluster *cluster = jet->GetLeadingCluster(fClusterContainer->GetArray());
363 TLorentzVector nPart;
364 cluster->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
366 maxClusterEta = nPart.Eta();
367 maxClusterPhi = nPart.Phi();
368 maxClusterPt = nPart.Pt();
372 if (fParticleContainer && fParticleContainer->GetArray() && (fLeadingHadronType == 0 || fLeadingHadronType == 2)) {
373 AliVParticle *track = jet->GetLeadingTrack(fParticleContainer->GetArray());
375 maxTrackEta = track->Eta();
376 maxTrackPhi = track->Phi();
377 maxTrackPt = track->Pt();
381 if (maxTrackPt > maxClusterPt)
382 mom.SetPtEtaPhiM(maxTrackPt,maxTrackEta,maxTrackPhi,0.139);
384 mom.SetPtEtaPhiM(maxClusterPt,maxClusterEta,maxClusterPhi,0.139);
387 //________________________________________________________________________
388 Double_t AliJetContainer::GetZLeadingEmc(AliEmcalJet *jet) const
391 if (fClusterContainer && fClusterContainer->GetArray() ) {
394 AliVCluster *cluster = jet->GetLeadingCluster(fClusterContainer->GetArray());
396 cluster->GetMomentum(mom, const_cast<Double_t*>(fVertex));
398 return GetZ(jet,mom);
407 //________________________________________________________________________
408 Double_t AliJetContainer::GetZLeadingCharged(AliEmcalJet *jet) const
411 if (fParticleContainer && fParticleContainer->GetArray() ) {
414 AliVParticle *track = jet->GetLeadingTrack(fParticleContainer->GetArray());
416 mom.SetPtEtaPhiM(track->Pt(),track->Eta(),track->Phi(),0.139);
418 return GetZ(jet,mom);
427 //________________________________________________________________________
428 Double_t AliJetContainer::GetZ(AliEmcalJet *jet, TLorentzVector mom) const
431 Double_t pJetSq = jet->Px()*jet->Px() + jet->Py()*jet->Py() + jet->Pz()*jet->Pz();
434 return (mom.Px()*jet->Px() + mom.Py()*jet->Py() + mom.Pz()*jet->Pz())/pJetSq;
436 AliWarning(Form("%s: strange, pjet*pjet seems to be zero pJetSq: %f",GetName(), pJetSq));
442 //________________________________________________________________________
443 void AliJetContainer::SetJetEtaPhiEMCAL()
445 //Set default cuts for full jets
447 if(!fGeom) SetEMCALGeometry();
449 SetJetEtaLimits(fGeom->GetArm1EtaMin() + fJetRadius, fGeom->GetArm1EtaMax() - fJetRadius);
451 if(fRunNumber>=177295 && fRunNumber<=197470) //small SM masked in 2012 and 2013
452 SetJetPhiLimits(1.4+fJetRadius,TMath::Pi()-fJetRadius);
454 SetJetPhiLimits(fGeom->GetArm1PhiMin() * TMath::DegToRad() + fJetRadius, fGeom->GetArm1PhiMax() * TMath::DegToRad() - fJetRadius);
458 AliWarning("Could not get instance of AliEMCALGeometry. Using manual settings for EMCAL year 2011!!");
459 SetJetEtaLimits(-0.7+fJetRadius,0.7-fJetRadius);
460 SetJetPhiLimits(1.4+fJetRadius,TMath::Pi()-fJetRadius);
464 //________________________________________________________________________
465 void AliJetContainer::SetJetEtaPhiTPC()
467 //Set default cuts for charged jets
469 SetJetEtaLimits(-0.9+fJetRadius, 0.9-fJetRadius);
470 SetJetPhiLimits(-10, 10);
473 //________________________________________________________________________
474 void AliJetContainer::ResetCuts()
476 // Reset cuts to default values
487 fMaxClusterPt = 1000;
489 fLeadingHadronType = 0;
490 fZLeadingEmcCut = 10.;
491 fZLeadingChCut = 10.;
494 //________________________________________________________________________
495 void AliJetContainer::SetClassName(const char *clname)
497 // Set the class name
500 if (cls.InheritsFrom("AliEmcalJet")) fClassName = clname;
501 else AliError(Form("Unable to set class name %s for a AliJetContainer, it must inherits from AliEmcalJet!",clname));