3 // Container with name, TClonesArray and cuts for jets
7 #include <TClonesArray.h>
9 #include "AliEmcalJet.h"
10 #include "AliVEvent.h"
12 #include "AliEMCALGeometry.h"
13 #include "AliParticleContainer.h"
14 #include "AliClusterContainer.h"
15 #include "AliLocalRhoParameter.h"
17 #include "AliJetContainer.h"
19 ClassImp(AliJetContainer)
21 //________________________________________________________________________
22 AliJetContainer::AliJetContainer():
23 AliEmcalContainer("AliJetContainer"),
24 fJetAcceptanceType(kUser),
44 fLeadingHadronType(0),
49 fParticleContainer(0),
56 // Default constructor.
58 fClassName = "AliEmcalJet";
61 //________________________________________________________________________
62 AliJetContainer::AliJetContainer(const char *name):
63 AliEmcalContainer(name),
64 fJetAcceptanceType(kUser),
84 fLeadingHadronType(0),
89 fParticleContainer(0),
96 // Standard constructor.
98 fClassName = "AliEmcalJet";
101 //________________________________________________________________________
102 void AliJetContainer::SetArray(AliVEvent *event)
106 AliEmcalContainer::SetArray(event);
108 if(fJetAcceptanceType==kTPC) {
109 AliDebug(2,Form("%s: set TPC acceptance cuts",GetName()));
112 else if(fJetAcceptanceType==kEMCAL) {
113 AliDebug(2,Form("%s: set EMCAL acceptance cuts",GetName()));
119 //________________________________________________________________________
120 void AliJetContainer::SetEMCALGeometry() {
121 fGeom = AliEMCALGeometry::GetInstance();
123 AliError(Form("%s: Can not create geometry", GetName()));
128 //________________________________________________________________________
129 void AliJetContainer::LoadRho(AliVEvent *event)
133 if (!fRhoName.IsNull() && !fRho) {
134 fRho = dynamic_cast<AliRhoParameter*>(event->FindListObject(fRhoName));
136 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
142 //________________________________________________________________________
143 void AliJetContainer::LoadLocalRho(AliVEvent *event)
147 if (!fLocalRhoName.IsNull() && !fLocalRho) {
148 fLocalRho = dynamic_cast<AliLocalRhoParameter*>(event->FindListObject(fLocalRhoName));
150 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fLocalRhoName.Data()));
156 //________________________________________________________________________
157 AliEmcalJet* AliJetContainer::GetLeadingJet(const char* opt)
159 // Get the leading jet; if opt contains "rho" the sorting is according to pt-A*rho
164 Int_t tempID = fCurrentID;
166 AliEmcalJet *jetMax = GetNextAcceptJet(0);
167 AliEmcalJet *jet = 0;
169 if (option.Contains("rho")) {
170 while ((jet = GetNextAcceptJet())) {
171 if ( (jet->Pt()-jet->Area()*GetRhoVal()) > (jetMax->Pt()-jetMax->Area()*GetRhoVal()) )
176 while ((jet = GetNextAcceptJet())) {
177 if (jet->Pt() > jetMax->Pt()) jetMax = jet;
186 //________________________________________________________________________
187 AliEmcalJet* AliJetContainer::GetJet(Int_t i) const {
189 //Get i^th jet in array
191 if(i<0 || i>fClArray->GetEntriesFast()) return 0;
192 AliEmcalJet *jet = static_cast<AliEmcalJet*>(fClArray->At(i));
197 //________________________________________________________________________
198 AliEmcalJet* AliJetContainer::GetAcceptJet(Int_t i) const {
200 //Only return jet if is accepted
202 AliEmcalJet *jet = GetJet(i);
203 if(!AcceptJet(jet)) return 0;
208 //________________________________________________________________________
209 AliEmcalJet* AliJetContainer::GetJetWithLabel(Int_t lab) const {
211 //Get particle with label lab in array
213 Int_t i = GetIndexFromLabel(lab);
217 //________________________________________________________________________
218 AliEmcalJet* AliJetContainer::GetAcceptJetWithLabel(Int_t lab) const {
220 //Get particle with label lab in array
222 Int_t i = GetIndexFromLabel(lab);
223 return GetAcceptJet(i);
226 //________________________________________________________________________
227 AliEmcalJet* AliJetContainer::GetNextAcceptJet(Int_t i) {
229 //Get next accepted jet; if i >= 0 (re)start counter from i; return 0 if no accepted jet could be found
231 if (i>=0) fCurrentID = i;
233 const Int_t njets = GetNEntries();
234 AliEmcalJet *jet = 0;
235 while (fCurrentID < njets && !jet) {
236 jet = GetAcceptJet(fCurrentID);
243 //________________________________________________________________________
244 AliEmcalJet* AliJetContainer::GetNextJet(Int_t i) {
246 //Get next jet; if i >= 0 (re)start counter from i; return 0 if no jet could be found
248 if (i>=0) fCurrentID = i;
250 const Int_t njets = GetNEntries();
251 AliEmcalJet *jet = 0;
252 while (fCurrentID < njets && !jet) {
253 jet = GetJet(fCurrentID);
260 //________________________________________________________________________
261 Double_t AliJetContainer::GetJetPtCorr(Int_t i) const {
262 AliEmcalJet *jet = GetJet(i);
264 return jet->Pt() - fRho->GetVal()*jet->Area();
267 //________________________________________________________________________
268 Double_t AliJetContainer::GetJetPtCorrLocal(Int_t i) const {
269 AliEmcalJet *jet = GetJet(i);
271 return jet->Pt() - fLocalRho->GetLocalVal(jet->Phi(), fJetRadius)*jet->Area();
274 //________________________________________________________________________
275 void AliJetContainer::GetMomentum(TLorentzVector &mom, Int_t i) const
277 //Get momentum of the i^th jet in array
279 AliEmcalJet *jet = GetJet(i);
280 if(jet) jet->GetMom(mom);
283 //________________________________________________________________________
284 Bool_t AliJetContainer::AcceptBiasJet(AliEmcalJet *jet) const
286 // Accept jet with a bias.
288 if (fLeadingHadronType == 0) {
289 if (jet->MaxTrackPt() < fPtBiasJetTrack) return kFALSE;
291 else if (fLeadingHadronType == 1) {
292 if (jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
295 if (jet->MaxTrackPt() < fPtBiasJetTrack && jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
303 //________________________________________________________________________
304 Bool_t AliJetContainer::AcceptJet(AliEmcalJet *jet) const
307 // Return true if jet is accepted.
312 if (jet->TestBits(fJetBitMap) != (Int_t)fJetBitMap)
315 if (jet->Pt() <= fJetPtCut)
318 if (jet->Area() <= fJetAreaCut)
321 if (jet->AreaEmc() < fAreaEmcCut)
324 if (fZLeadingChCut < 1 && GetZLeadingCharged(jet) > fZLeadingChCut)
327 if (fZLeadingEmcCut < 1 && GetZLeadingEmc(jet) > fZLeadingEmcCut)
330 if (jet->NEF() < fNEFMinCut || jet->NEF() > fNEFMaxCut)
333 if (!AcceptBiasJet(jet))
336 if (jet->MaxTrackPt() > fMaxTrackPt || jet->MaxClusterPt() > fMaxClusterPt)
339 if (fFlavourSelection != 0 && !jet->TestFlavourTag(fFlavourSelection))
342 if(fTagStatus>-1 && jet->GetTagStatus()!=fTagStatus)
345 Double_t jetPhi = jet->Phi();
346 Double_t jetEta = jet->Eta();
348 if (fJetMinPhi < 0) // if limits are given in (-pi, pi) range
349 jetPhi -= TMath::Pi() * 2;
351 return (Bool_t)(jetEta > fJetMinEta && jetEta < fJetMaxEta && jetPhi > fJetMinPhi && jetPhi < fJetMaxPhi);
354 //________________________________________________________________________
355 Double_t AliJetContainer::GetLeadingHadronPt(AliEmcalJet *jet) const
357 if (fLeadingHadronType == 0) // charged leading hadron
358 return jet->MaxTrackPt();
359 else if (fLeadingHadronType == 1) // neutral leading hadron
360 return jet->MaxClusterPt();
361 else // charged or neutral
362 return jet->MaxPartPt();
365 //________________________________________________________________________
366 void AliJetContainer::GetLeadingHadronMomentum(TLorentzVector &mom, AliEmcalJet *jet) const
368 Double_t maxClusterPt = 0;
369 Double_t maxClusterEta = 0;
370 Double_t maxClusterPhi = 0;
372 Double_t maxTrackPt = 0;
373 Double_t maxTrackEta = 0;
374 Double_t maxTrackPhi = 0;
376 if (fClusterContainer && fClusterContainer->GetArray() && (fLeadingHadronType == 1 || fLeadingHadronType == 2)) {
377 AliVCluster *cluster = jet->GetLeadingCluster(fClusterContainer->GetArray());
379 TLorentzVector nPart;
380 cluster->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
382 maxClusterEta = nPart.Eta();
383 maxClusterPhi = nPart.Phi();
384 maxClusterPt = nPart.Pt();
388 if (fParticleContainer && fParticleContainer->GetArray() && (fLeadingHadronType == 0 || fLeadingHadronType == 2)) {
389 AliVParticle *track = jet->GetLeadingTrack(fParticleContainer->GetArray());
391 maxTrackEta = track->Eta();
392 maxTrackPhi = track->Phi();
393 maxTrackPt = track->Pt();
397 if (maxTrackPt > maxClusterPt)
398 mom.SetPtEtaPhiM(maxTrackPt,maxTrackEta,maxTrackPhi,0.139);
400 mom.SetPtEtaPhiM(maxClusterPt,maxClusterEta,maxClusterPhi,0.139);
403 //________________________________________________________________________
404 Double_t AliJetContainer::GetZLeadingEmc(AliEmcalJet *jet) const
407 if (fClusterContainer && fClusterContainer->GetArray()) {
410 AliVCluster *cluster = jet->GetLeadingCluster(fClusterContainer->GetArray());
412 cluster->GetMomentum(mom, const_cast<Double_t*>(fVertex));
414 return GetZ(jet,mom);
423 //________________________________________________________________________
424 Double_t AliJetContainer::GetZLeadingCharged(AliEmcalJet *jet) const
427 if (fParticleContainer && fParticleContainer->GetArray() ) {
430 AliVParticle *track = jet->GetLeadingTrack(fParticleContainer->GetArray());
432 mom.SetPtEtaPhiM(track->Pt(),track->Eta(),track->Phi(),0.139);
434 return GetZ(jet,mom);
443 //________________________________________________________________________
444 Double_t AliJetContainer::GetZ(AliEmcalJet *jet, TLorentzVector mom) const
447 Double_t pJetSq = jet->Px()*jet->Px() + jet->Py()*jet->Py() + jet->Pz()*jet->Pz();
450 return (mom.Px()*jet->Px() + mom.Py()*jet->Py() + mom.Pz()*jet->Pz())/pJetSq;
452 AliWarning(Form("%s: strange, pjet*pjet seems to be zero pJetSq: %f",GetName(), pJetSq));
458 //________________________________________________________________________
459 void AliJetContainer::SetJetEtaPhiEMCAL()
461 //Set default cuts for full jets
463 if(!fGeom) SetEMCALGeometry();
465 SetJetEtaLimits(fGeom->GetArm1EtaMin() + fJetRadius, fGeom->GetArm1EtaMax() - fJetRadius);
467 if(fRunNumber>=177295 && fRunNumber<=197470) //small SM masked in 2012 and 2013
468 SetJetPhiLimits(1.4+fJetRadius,TMath::Pi()-fJetRadius);
470 SetJetPhiLimits(fGeom->GetArm1PhiMin() * TMath::DegToRad() + fJetRadius, fGeom->GetArm1PhiMax() * TMath::DegToRad() - fJetRadius);
474 AliWarning("Could not get instance of AliEMCALGeometry. Using manual settings for EMCAL year 2011!!");
475 SetJetEtaLimits(-0.7+fJetRadius,0.7-fJetRadius);
476 SetJetPhiLimits(1.405+fJetRadius,3.135-fJetRadius);
480 //________________________________________________________________________
481 void AliJetContainer::SetJetEtaPhiTPC()
483 //Set default cuts for charged jets
485 SetJetEtaLimits(-0.9+fJetRadius, 0.9-fJetRadius);
486 SetJetPhiLimits(-10, 10);
489 //________________________________________________________________________
490 void AliJetContainer::ResetCuts()
492 // Reset cuts to default values
503 fMaxClusterPt = 1000;
505 fLeadingHadronType = 0;
506 fZLeadingEmcCut = 10.;
507 fZLeadingChCut = 10.;
510 //________________________________________________________________________
511 void AliJetContainer::SetClassName(const char *clname)
513 // Set the class name
516 if (cls.InheritsFrom("AliEmcalJet")) fClassName = clname;
517 else AliError(Form("Unable to set class name %s for a AliJetContainer, it must inherits from AliEmcalJet!",clname));
520 //________________________________________________________________________
521 Double_t AliJetContainer::GetFractionSharedPt(AliEmcalJet *jet1) const
524 // Get fraction of shared pT between matched full and charged jet
525 // Uses charged jet pT as baseline: fraction = \Sum_{const,full jet} pT,const,i / pT,jet,ch
526 // Only works if tracks array of both jets is the same
529 AliEmcalJet *jet2 = jet1->ClosestJet();
532 Double_t fraction = 0.;
533 Double_t jetPt2 = jet2->Pt();
537 AliVParticle *vpf = 0x0;
539 for(Int_t icc=0; icc<jet2->GetNumberOfTracks(); icc++) {
540 Int_t idx = (Int_t)jet2->TrackAt(icc);
542 for(Int_t icf=0; icf<jet1->GetNumberOfTracks(); icf++) {
543 if(idx == jet1->TrackAt(icf) && iFound==0 ) {
545 vpf = static_cast<AliVParticle*>(jet1->TrackAt(icf, fParticleContainer->GetArray()));
546 if(vpf) sumPt += vpf->Pt();
551 fraction = sumPt/jetPt2;