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),
48 fParticleContainer(0),
55 // Default constructor.
57 fClassName = "AliEmcalJet";
60 //________________________________________________________________________
61 AliJetContainer::AliJetContainer(const char *name):
62 AliEmcalContainer(name),
63 fJetAcceptanceType(kUser),
83 fLeadingHadronType(0),
87 fParticleContainer(0),
94 // Standard constructor.
96 fClassName = "AliEmcalJet";
99 //________________________________________________________________________
100 void AliJetContainer::SetArray(AliVEvent *event)
104 AliEmcalContainer::SetArray(event);
106 if(fJetAcceptanceType==kTPC) {
107 AliDebug(2,Form("%s: set TPC acceptance cuts",GetName()));
110 else if(fJetAcceptanceType==kEMCAL) {
111 AliDebug(2,Form("%s: set EMCAL acceptance cuts",GetName()));
117 //________________________________________________________________________
118 void AliJetContainer::SetEMCALGeometry() {
119 fGeom = AliEMCALGeometry::GetInstance();
121 AliError(Form("%s: Can not create geometry", GetName()));
126 //________________________________________________________________________
127 void AliJetContainer::LoadRho(AliVEvent *event)
131 if (!fRhoName.IsNull() && !fRho) {
132 fRho = dynamic_cast<AliRhoParameter*>(event->FindListObject(fRhoName));
134 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
140 //________________________________________________________________________
141 void AliJetContainer::LoadLocalRho(AliVEvent *event)
145 if (!fLocalRhoName.IsNull() && !fLocalRho) {
146 fLocalRho = dynamic_cast<AliLocalRhoParameter*>(event->FindListObject(fLocalRhoName));
148 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fLocalRhoName.Data()));
154 //________________________________________________________________________
155 AliEmcalJet* AliJetContainer::GetLeadingJet(const char* opt)
157 // Get the leading jet; if opt contains "rho" the sorting is according to pt-A*rho
162 Int_t tempID = fCurrentID;
164 AliEmcalJet *jetMax = GetNextAcceptJet(0);
165 AliEmcalJet *jet = 0;
167 if (option.Contains("rho")) {
168 while ((jet = GetNextAcceptJet())) {
169 if ( (jet->Pt()-jet->Area()*GetRhoVal()) > (jetMax->Pt()-jetMax->Area()*GetRhoVal()) )
174 while ((jet = GetNextAcceptJet())) {
175 if (jet->Pt() > jetMax->Pt()) jetMax = jet;
184 //________________________________________________________________________
185 AliEmcalJet* AliJetContainer::GetJet(Int_t i) const {
187 //Get i^th jet in array
189 if(i<0 || i>fClArray->GetEntriesFast()) return 0;
190 AliEmcalJet *jet = static_cast<AliEmcalJet*>(fClArray->At(i));
195 //________________________________________________________________________
196 AliEmcalJet* AliJetContainer::GetAcceptJet(Int_t i) const {
198 //Only return jet if is accepted
200 AliEmcalJet *jet = GetJet(i);
201 if(!AcceptJet(jet)) return 0;
206 //________________________________________________________________________
207 AliEmcalJet* AliJetContainer::GetJetWithLabel(Int_t lab) const {
209 //Get particle with label lab in array
211 Int_t i = GetIndexFromLabel(lab);
215 //________________________________________________________________________
216 AliEmcalJet* AliJetContainer::GetAcceptJetWithLabel(Int_t lab) const {
218 //Get particle with label lab in array
220 Int_t i = GetIndexFromLabel(lab);
221 return GetAcceptJet(i);
224 //________________________________________________________________________
225 AliEmcalJet* AliJetContainer::GetNextAcceptJet(Int_t i) {
227 //Get next accepted jet; if i >= 0 (re)start counter from i; return 0 if no accepted jet could be found
229 if (i>=0) fCurrentID = i;
231 const Int_t njets = GetNEntries();
232 AliEmcalJet *jet = 0;
233 while (fCurrentID < njets && !jet) {
234 jet = GetAcceptJet(fCurrentID);
241 //________________________________________________________________________
242 AliEmcalJet* AliJetContainer::GetNextJet(Int_t i) {
244 //Get next jet; if i >= 0 (re)start counter from i; return 0 if no jet could be found
246 if (i>=0) fCurrentID = i;
248 const Int_t njets = GetNEntries();
249 AliEmcalJet *jet = 0;
250 while (fCurrentID < njets && !jet) {
251 jet = GetJet(fCurrentID);
258 //________________________________________________________________________
259 Double_t AliJetContainer::GetJetPtCorr(Int_t i) const {
260 AliEmcalJet *jet = GetJet(i);
262 return jet->Pt() - fRho->GetVal()*jet->Area();
265 //________________________________________________________________________
266 Double_t AliJetContainer::GetJetPtCorrLocal(Int_t i) const {
267 AliEmcalJet *jet = GetJet(i);
269 return jet->Pt() - fLocalRho->GetLocalVal(jet->Phi(), fJetRadius)*jet->Area();
272 //________________________________________________________________________
273 void AliJetContainer::GetMomentum(TLorentzVector &mom, Int_t i) const
275 //Get momentum of the i^th jet in array
277 AliEmcalJet *jet = GetJet(i);
278 if(jet) jet->GetMom(mom);
281 //________________________________________________________________________
282 Bool_t AliJetContainer::AcceptBiasJet(AliEmcalJet *jet) const
284 // Accept jet with a bias.
286 if (fLeadingHadronType == 0) {
287 if (jet->MaxTrackPt() < fPtBiasJetTrack) return kFALSE;
289 else if (fLeadingHadronType == 1) {
290 if (jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
293 if (jet->MaxTrackPt() < fPtBiasJetTrack && jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
301 //________________________________________________________________________
302 Bool_t AliJetContainer::AcceptJet(AliEmcalJet *jet) const
305 // Return true if jet is accepted.
310 if (jet->TestBits(fJetBitMap) != (Int_t)fJetBitMap)
313 if (jet->Pt() <= fJetPtCut)
316 if (jet->Area() <= fJetAreaCut)
319 if (jet->AreaEmc() < fAreaEmcCut)
322 if (fZLeadingChCut < 1 && GetZLeadingCharged(jet) > fZLeadingChCut)
325 if (fZLeadingEmcCut < 1 && GetZLeadingEmc(jet) > fZLeadingEmcCut)
328 if (jet->NEF() < fNEFMinCut || jet->NEF() > fNEFMaxCut)
331 if (!AcceptBiasJet(jet))
334 if (jet->MaxTrackPt() > fMaxTrackPt || jet->MaxClusterPt() > fMaxClusterPt)
337 if (fFlavourSelection != 0 && !jet->TestFlavourTag(fFlavourSelection))
340 Double_t jetPhi = jet->Phi();
341 Double_t jetEta = jet->Eta();
343 if (fJetMinPhi < 0) // if limits are given in (-pi, pi) range
344 jetPhi -= TMath::Pi() * 2;
346 return (Bool_t)(jetEta > fJetMinEta && jetEta < fJetMaxEta && jetPhi > fJetMinPhi && jetPhi < fJetMaxPhi);
349 //________________________________________________________________________
350 Double_t AliJetContainer::GetLeadingHadronPt(AliEmcalJet *jet) const
352 if (fLeadingHadronType == 0) // charged leading hadron
353 return jet->MaxTrackPt();
354 else if (fLeadingHadronType == 1) // neutral leading hadron
355 return jet->MaxClusterPt();
356 else // charged or neutral
357 return jet->MaxPartPt();
360 //________________________________________________________________________
361 void AliJetContainer::GetLeadingHadronMomentum(TLorentzVector &mom, AliEmcalJet *jet) const
363 Double_t maxClusterPt = 0;
364 Double_t maxClusterEta = 0;
365 Double_t maxClusterPhi = 0;
367 Double_t maxTrackPt = 0;
368 Double_t maxTrackEta = 0;
369 Double_t maxTrackPhi = 0;
371 if (fClusterContainer && fClusterContainer->GetArray() && (fLeadingHadronType == 1 || fLeadingHadronType == 2)) {
372 AliVCluster *cluster = jet->GetLeadingCluster(fClusterContainer->GetArray());
374 TLorentzVector nPart;
375 cluster->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
377 maxClusterEta = nPart.Eta();
378 maxClusterPhi = nPart.Phi();
379 maxClusterPt = nPart.Pt();
383 if (fParticleContainer && fParticleContainer->GetArray() && (fLeadingHadronType == 0 || fLeadingHadronType == 2)) {
384 AliVParticle *track = jet->GetLeadingTrack(fParticleContainer->GetArray());
386 maxTrackEta = track->Eta();
387 maxTrackPhi = track->Phi();
388 maxTrackPt = track->Pt();
392 if (maxTrackPt > maxClusterPt)
393 mom.SetPtEtaPhiM(maxTrackPt,maxTrackEta,maxTrackPhi,0.139);
395 mom.SetPtEtaPhiM(maxClusterPt,maxClusterEta,maxClusterPhi,0.139);
398 //________________________________________________________________________
399 Double_t AliJetContainer::GetZLeadingEmc(AliEmcalJet *jet) const
402 if (fClusterContainer && fClusterContainer->GetArray()) {
405 AliVCluster *cluster = jet->GetLeadingCluster(fClusterContainer->GetArray());
407 cluster->GetMomentum(mom, const_cast<Double_t*>(fVertex));
409 return GetZ(jet,mom);
418 //________________________________________________________________________
419 Double_t AliJetContainer::GetZLeadingCharged(AliEmcalJet *jet) const
422 if (fParticleContainer && fParticleContainer->GetArray() ) {
425 AliVParticle *track = jet->GetLeadingTrack(fParticleContainer->GetArray());
427 mom.SetPtEtaPhiM(track->Pt(),track->Eta(),track->Phi(),0.139);
429 return GetZ(jet,mom);
438 //________________________________________________________________________
439 Double_t AliJetContainer::GetZ(AliEmcalJet *jet, TLorentzVector mom) const
442 Double_t pJetSq = jet->Px()*jet->Px() + jet->Py()*jet->Py() + jet->Pz()*jet->Pz();
445 return (mom.Px()*jet->Px() + mom.Py()*jet->Py() + mom.Pz()*jet->Pz())/pJetSq;
447 AliWarning(Form("%s: strange, pjet*pjet seems to be zero pJetSq: %f",GetName(), pJetSq));
453 //________________________________________________________________________
454 void AliJetContainer::SetJetEtaPhiEMCAL()
456 //Set default cuts for full jets
458 if(!fGeom) SetEMCALGeometry();
460 SetJetEtaLimits(fGeom->GetArm1EtaMin() + fJetRadius, fGeom->GetArm1EtaMax() - fJetRadius);
462 if(fRunNumber>=177295 && fRunNumber<=197470) //small SM masked in 2012 and 2013
463 SetJetPhiLimits(1.4+fJetRadius,TMath::Pi()-fJetRadius);
465 SetJetPhiLimits(fGeom->GetArm1PhiMin() * TMath::DegToRad() + fJetRadius, fGeom->GetArm1PhiMax() * TMath::DegToRad() - fJetRadius);
469 AliWarning("Could not get instance of AliEMCALGeometry. Using manual settings for EMCAL year 2011!!");
470 SetJetEtaLimits(-0.7+fJetRadius,0.7-fJetRadius);
471 SetJetPhiLimits(1.405+fJetRadius,3.135-fJetRadius);
475 //________________________________________________________________________
476 void AliJetContainer::SetJetEtaPhiTPC()
478 //Set default cuts for charged jets
480 SetJetEtaLimits(-0.9+fJetRadius, 0.9-fJetRadius);
481 SetJetPhiLimits(-10, 10);
484 //________________________________________________________________________
485 void AliJetContainer::ResetCuts()
487 // Reset cuts to default values
498 fMaxClusterPt = 1000;
500 fLeadingHadronType = 0;
501 fZLeadingEmcCut = 10.;
502 fZLeadingChCut = 10.;
505 //________________________________________________________________________
506 void AliJetContainer::SetClassName(const char *clname)
508 // Set the class name
511 if (cls.InheritsFrom("AliEmcalJet")) fClassName = clname;
512 else AliError(Form("Unable to set class name %s for a AliJetContainer, it must inherits from AliEmcalJet!",clname));
515 //________________________________________________________________________
516 Double_t AliJetContainer::GetFractionSharedPt(AliEmcalJet *jet1) const
519 // Get fraction of shared pT between matched full and charged jet
520 // Uses charged jet pT as baseline: fraction = \Sum_{const,full jet} pT,const,i / pT,jet,ch
521 // Only works if tracks array of both jets is the same
524 AliEmcalJet *jet2 = jet1->ClosestJet();
527 Double_t fraction = 0.;
528 Double_t jetPt2 = jet2->Pt();
532 AliVParticle *vpf = 0x0;
534 for(Int_t icc=0; icc<jet2->GetNumberOfTracks(); icc++) {
535 Int_t idx = (Int_t)jet2->TrackAt(icc);
537 for(Int_t icf=0; icf<jet1->GetNumberOfTracks(); icf++) {
538 if(idx == jet1->TrackAt(icf) && iFound==0 ) {
540 vpf = static_cast<AliVParticle*>(jet1->TrackAt(icf, fParticleContainer->GetArray()));
541 if(vpf) sumPt += vpf->Pt();
546 fraction = sumPt/jetPt2;