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),
38 fLeadingHadronType(0),
42 fParticleContainer(0),
48 // Default constructor.
50 fClassName = "AliEmcalJet";
53 //________________________________________________________________________
54 AliJetContainer::AliJetContainer(const char *name):
55 AliEmcalContainer(name),
56 fJetAcceptanceType(kUser),
72 fLeadingHadronType(0),
76 fParticleContainer(0),
82 // Standard constructor.
84 fClassName = "AliEmcalJet";
87 //________________________________________________________________________
88 void AliJetContainer::SetArray(AliVEvent *event)
92 AliEmcalContainer::SetArray(event);
94 if(fJetAcceptanceType==kTPC) {
95 AliDebug(2,Form("%s: set TPC acceptance cuts",GetName()));
98 else if(fJetAcceptanceType==kEMCAL) {
99 AliDebug(2,Form("%s: set EMCAL acceptance cuts",GetName()));
105 //________________________________________________________________________
106 void AliJetContainer::SetEMCALGeometry() {
107 fGeom = AliEMCALGeometry::GetInstance();
109 AliError(Form("%s: Can not create geometry", GetName()));
114 //________________________________________________________________________
115 void AliJetContainer::LoadRho(AliVEvent *event)
119 if (!fRhoName.IsNull() && !fRho) {
120 fRho = dynamic_cast<AliRhoParameter*>(event->FindListObject(fRhoName));
122 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
128 //________________________________________________________________________
129 AliEmcalJet* AliJetContainer::GetLeadingJet(const char* opt)
131 // Get the leading jet; if opt contains "rho" the sorting is according to pt-A*rho
136 Int_t tempID = fCurrentID;
138 AliEmcalJet *jetMax = GetNextAcceptJet(0);
139 AliEmcalJet *jet = 0;
141 if (option.Contains("rho")) {
142 while ((jet = GetNextAcceptJet())) {
143 if (jet->Pt()-jet->Area()*fRho->GetVal() > jetMax->Pt()-jetMax->Area()*fRho->GetVal()) jetMax = jet;
147 while ((jet = GetNextAcceptJet())) {
148 if (jet->Pt() > jetMax->Pt()) jetMax = jet;
157 //________________________________________________________________________
158 AliEmcalJet* AliJetContainer::GetJet(Int_t i) const {
160 //Get i^th jet in array
162 if(i<0 || i>fClArray->GetEntriesFast()) return 0;
163 AliEmcalJet *jet = static_cast<AliEmcalJet*>(fClArray->At(i));
168 //________________________________________________________________________
169 AliEmcalJet* AliJetContainer::GetAcceptJet(Int_t i) const {
171 //Only return jet if is accepted
173 AliEmcalJet *jet = GetJet(i);
174 if(!AcceptJet(jet)) return 0;
179 //________________________________________________________________________
180 AliEmcalJet* AliJetContainer::GetJetWithLabel(Int_t lab) const {
182 //Get particle with label lab in array
184 Int_t i = GetIndexFromLabel(lab);
188 //________________________________________________________________________
189 AliEmcalJet* AliJetContainer::GetAcceptJetWithLabel(Int_t lab) const {
191 //Get particle with label lab in array
193 Int_t i = GetIndexFromLabel(lab);
194 return GetAcceptJet(i);
197 //________________________________________________________________________
198 AliEmcalJet* AliJetContainer::GetNextAcceptJet(Int_t i) {
200 //Get next accepted jet; if i >= 0 (re)start counter from i; return 0 if no accepted jet could be found
202 if (i>=0) fCurrentID = i;
204 const Int_t njets = GetNEntries();
205 AliEmcalJet *jet = 0;
206 while (fCurrentID < njets && !jet) {
207 jet = GetAcceptJet(fCurrentID);
214 //________________________________________________________________________
215 AliEmcalJet* AliJetContainer::GetNextJet(Int_t i) {
217 //Get next jet; if i >= 0 (re)start counter from i; return 0 if no jet could be found
219 if (i>=0) fCurrentID = i;
221 const Int_t njets = GetNEntries();
222 AliEmcalJet *jet = 0;
223 while (fCurrentID < njets && !jet) {
224 jet = GetJet(fCurrentID);
231 //________________________________________________________________________
232 Double_t AliJetContainer::GetJetPtCorr(Int_t i) const {
233 AliEmcalJet *jet = GetJet(i);
235 return jet->Pt() - fRho->GetVal()*jet->Area();
238 //________________________________________________________________________
239 void AliJetContainer::GetMomentum(TLorentzVector &mom, Int_t i) const
241 //Get momentum of the i^th jet in array
243 AliEmcalJet *jet = GetJet(i);
244 if(jet) jet->GetMom(mom);
247 //________________________________________________________________________
248 Bool_t AliJetContainer::AcceptBiasJet(AliEmcalJet *jet) const
250 // Accept jet with a bias.
252 if (fLeadingHadronType == 0) {
253 if (jet->MaxTrackPt() < fPtBiasJetTrack) return kFALSE;
255 else if (fLeadingHadronType == 1) {
256 if (jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
259 if (jet->MaxTrackPt() < fPtBiasJetTrack && jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE;
267 //________________________________________________________________________
268 Bool_t AliJetContainer::AcceptJet(AliEmcalJet *jet) const
270 // Return true if jet is accepted.
274 if (jet->TestBits(fJetBitMap) != (Int_t)fJetBitMap)
277 if (jet->Pt() <= fJetPtCut)
280 if (jet->Area() <= fJetAreaCut)
283 if (jet->AreaEmc()<fAreaEmcCut)
286 if( GetZLeadingCharged(jet)>fZLeadingChCut || GetZLeadingEmc(jet)>fZLeadingEmcCut)
289 if (!AcceptBiasJet(jet))
292 if (jet->MaxTrackPt() > fMaxTrackPt || jet->MaxClusterPt() > fMaxClusterPt)
296 Double_t jetPhi = jet->Phi();
297 Double_t jetEta = jet->Eta();
299 if (fJetMinPhi < 0) // if limits are given in (-pi, pi) range
300 jetPhi -= TMath::Pi() * 2;
302 return (Bool_t)(jetEta > fJetMinEta && jetEta < fJetMaxEta && jetPhi > fJetMinPhi && jetPhi < fJetMaxPhi);
305 //________________________________________________________________________
306 Double_t AliJetContainer::GetLeadingHadronPt(AliEmcalJet *jet) const
308 if (fLeadingHadronType == 0) // charged leading hadron
309 return jet->MaxTrackPt();
310 else if (fLeadingHadronType == 1) // neutral leading hadron
311 return jet->MaxClusterPt();
312 else // charged or neutral
313 return jet->MaxPartPt();
316 //________________________________________________________________________
317 void AliJetContainer::GetLeadingHadronMomentum(TLorentzVector &mom, AliEmcalJet *jet) const
319 Double_t maxClusterPt = 0;
320 Double_t maxClusterEta = 0;
321 Double_t maxClusterPhi = 0;
323 Double_t maxTrackPt = 0;
324 Double_t maxTrackEta = 0;
325 Double_t maxTrackPhi = 0;
327 if (fClusterContainer && fClusterContainer->GetArray() && (fLeadingHadronType == 1 || fLeadingHadronType == 2)) {
328 AliVCluster *cluster = jet->GetLeadingCluster(fClusterContainer->GetArray());
330 TLorentzVector nPart;
331 cluster->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
333 maxClusterEta = nPart.Eta();
334 maxClusterPhi = nPart.Phi();
335 maxClusterPt = nPart.Pt();
339 if (fParticleContainer && fParticleContainer->GetArray() && (fLeadingHadronType == 0 || fLeadingHadronType == 2)) {
340 AliVParticle *track = jet->GetLeadingTrack(fParticleContainer->GetArray());
342 maxTrackEta = track->Eta();
343 maxTrackPhi = track->Phi();
344 maxTrackPt = track->Pt();
348 if (maxTrackPt > maxClusterPt)
349 mom.SetPtEtaPhiM(maxTrackPt,maxTrackEta,maxTrackPhi,0.139);
351 mom.SetPtEtaPhiM(maxClusterPt,maxClusterEta,maxClusterPhi,0.139);
354 //________________________________________________________________________
355 Double_t AliJetContainer::GetZLeadingEmc(AliEmcalJet *jet) const
358 if (fClusterContainer && fClusterContainer->GetArray() ) {
361 AliVCluster *cluster = jet->GetLeadingCluster(fClusterContainer->GetArray());
363 cluster->GetMomentum(mom, const_cast<Double_t*>(fVertex));
365 return GetZ(jet,mom);
374 //________________________________________________________________________
375 Double_t AliJetContainer::GetZLeadingCharged(AliEmcalJet *jet) const
378 if (fParticleContainer && fParticleContainer->GetArray() ) {
381 AliVParticle *track = jet->GetLeadingTrack(fParticleContainer->GetArray());
383 mom.SetPtEtaPhiM(track->Pt(),track->Eta(),track->Phi(),0.139);
385 return GetZ(jet,mom);
394 //________________________________________________________________________
395 Double_t AliJetContainer::GetZ(AliEmcalJet *jet, TLorentzVector mom) const
398 Double_t pJetSq = jet->Px()*jet->Px() + jet->Py()*jet->Py() + jet->Pz()*jet->Pz();
401 return (mom.Px()*jet->Px() + mom.Py()*jet->Py() + mom.Pz()*jet->Pz())/pJetSq;
403 AliWarning(Form("%s: strange, pjet*pjet seems to be zero pJetSq: %f",GetName(), pJetSq));
409 //________________________________________________________________________
410 void AliJetContainer::SetJetEtaPhiEMCAL()
412 //Set default cuts for full jets
414 if(!fGeom) SetEMCALGeometry();
416 SetJetEtaLimits(fGeom->GetArm1EtaMin() + fJetRadius, fGeom->GetArm1EtaMax() - fJetRadius);
418 if(fRunNumber>=177295 && fRunNumber<=197470) //small SM masked in 2012 and 2013
419 SetJetPhiLimits(1.4+fJetRadius,TMath::Pi()-fJetRadius);
421 SetJetPhiLimits(fGeom->GetArm1PhiMin() * TMath::DegToRad() + fJetRadius, fGeom->GetArm1PhiMax() * TMath::DegToRad() - fJetRadius);
425 AliWarning("Could not get instance of AliEMCALGeometry. Using manual settings for EMCAL year 2011!!");
426 SetJetEtaLimits(-0.7+fJetRadius,0.7-fJetRadius);
427 SetJetPhiLimits(1.4+fJetRadius,TMath::Pi()-fJetRadius);
431 //________________________________________________________________________
432 void AliJetContainer::SetJetEtaPhiTPC()
434 //Set default cuts for charged jets
436 SetJetEtaLimits(-0.9+fJetRadius, 0.9-fJetRadius);
437 SetJetPhiLimits(-10, 10);
440 //________________________________________________________________________
441 void AliJetContainer::ResetCuts()
443 // Reset cuts to default values
454 fMaxClusterPt = 1000;
456 fLeadingHadronType = 0;
457 fZLeadingEmcCut = 10.;
458 fZLeadingChCut = 10.;
461 //________________________________________________________________________
462 void AliJetContainer::SetClassName(const char *clname)
464 // Set the class name
467 if (cls.InheritsFrom("AliEmcalJet")) fClassName = clname;
468 else AliError(Form("Unable to set class name %s for a AliJetContainer, it must inherits from AliEmcalJet!",clname));