2 // Emcal jet finder task.
4 // Authors: C.Loizides, S.Aiola, M. Verweij
7 #include "AliEmcalJetTask.h"
10 #include <TClonesArray.h>
12 #include <TLorentzVector.h>
16 #include "AliAnalysisManager.h"
17 #include "AliCentrality.h"
18 #include "AliEMCALGeometry.h"
19 #include "AliESDEvent.h"
20 #include "AliEmcalJet.h"
21 #include "AliEmcalParticle.h"
22 #include "AliFJWrapper.h"
23 #include "AliMCEvent.h"
24 #include "AliVCluster.h"
25 #include "AliVEvent.h"
26 #include "AliVParticle.h"
27 #include "AliRhoParameter.h"
32 ClassImp(AliEmcalJetTask)
34 //________________________________________________________________________
35 AliEmcalJetTask::AliEmcalJetTask() :
36 AliAnalysisTaskSE("AliEmcalJetTask"),
37 fTracksName("Tracks"),
38 fCaloName("CaloClusters"),
49 fPhiMax(TMath::TwoPi()),
60 fRecombScheme(fastjet::pt_scheme),
71 fPionMassClusters(kFALSE),
72 fDoGenericSubtractionJetMass(kFALSE),
73 fDoGenericSubtractionGR(kFALSE),
74 fDoGenericSubtractionExtraJetShapes(kFALSE),
75 fDoConstituentSubtraction(kFALSE),
76 fUseExternalBkg(kFALSE),
92 // Default constructor.
95 //________________________________________________________________________
96 AliEmcalJetTask::AliEmcalJetTask(const char *name) :
97 AliAnalysisTaskSE(name),
98 fTracksName("Tracks"),
99 fCaloName("CaloClusters"),
102 fJetType(kAKT|kFullJet|kRX1Jet),
107 fMinJetTrackPt(0.15),
110 fPhiMax(TMath::TwoPi()),
121 fRecombScheme(fastjet::pt_scheme),
122 fTrackEfficiency(1.),
132 fPionMassClusters(kFALSE),
133 fDoGenericSubtractionJetMass(kFALSE),
134 fDoGenericSubtractionGR(kFALSE),
135 fDoGenericSubtractionExtraJetShapes(kFALSE),
136 fDoConstituentSubtraction(kFALSE),
137 fUseExternalBkg(kFALSE),
153 // Standard constructor.
155 fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.";
158 //________________________________________________________________________
159 AliEmcalJetTask::~AliEmcalJetTask()
164 //________________________________________________________________________
165 void AliEmcalJetTask::UserCreateOutputObjects()
167 // Create user objects.
169 fJets = new TClonesArray("AliEmcalJet");
170 fJets->SetName(fJetsName);
172 if(!fJetsSubName.IsNull()) {
173 fJetsSub = new TClonesArray("AliEmcalJet");
174 fJetsSub->SetName(fJetsSubName);
178 //________________________________________________________________________
179 void AliEmcalJetTask::UserExec(Option_t *)
181 // Main loop, called for each event.
188 // clear the jet array (normally a null operation)
190 if(fJetsSub) fJetsSub->Delete();
195 //________________________________________________________________________
196 void AliEmcalJetTask::Terminate(Option_t *)
198 // Called once at the end of the analysis.
201 //________________________________________________________________________
202 void AliEmcalJetTask::FindJets()
205 if (!fTracks && !fClus){
206 cout << "WARNING NO TRACKS OR CLUSTERS:" <<endl;
211 fRho = fRhoParam->GetVal();
213 fRhom = fRhomParam->GetVal();
216 fastjet::JetAlgorithm jalgo(fastjet::kt_algorithm);
217 if ((fJetType & kAKT) != 0) {
219 jalgo = fastjet::antikt_algorithm;
220 AliDebug(1,"Using AKT algorithm");
223 AliDebug(1,"Using KT algorithm");
226 if ((fJetType & kR020Jet) != 0)
228 else if ((fJetType & kR030Jet) != 0)
230 else if ((fJetType & kR040Jet) != 0)
234 AliFJWrapper fjw(name, name);
235 fjw.SetAreaType(fastjet::active_area_explicit_ghosts);
236 fjw.SetGhostArea(fGhostArea);
238 fjw.SetAlgorithm(jalgo);
239 fjw.SetRecombScheme(static_cast<fastjet::RecombinationScheme>(fRecombScheme));
240 fjw.SetMaxRap(fEtaMax);
243 // get primary vertex
244 Double_t vertex[3] = {0, 0, 0};
245 if(fEvent->GetPrimaryVertex()) fEvent->GetPrimaryVertex()->GetXYZ(vertex);
247 AliDebug(2,Form("Jet type = %d", fJetType));
249 if ((fIsMcPart || ((fJetType & kFullJet) != 0) || ((fJetType & kChargedJet) != 0)) && fTracks) {
250 const Int_t Ntracks = fTracks->GetEntries();
251 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
252 AliVParticle *t = static_cast<AliVParticle*>(fTracks->At(iTracks));
256 if (((fJetType & kChargedJet) != 0) && (t->Charge() == 0)) {
257 AliDebug(2,Form("Skipping track %d because it is neutral.", iTracks));
260 if (((fJetType & kNeutralJet) != 0) && (t->Charge() != 0)) {
261 AliDebug(2,Form("Skipping track %d because it is charged.", iTracks));
265 if (fIsMcPart || TMath::Abs(t->GetLabel()) > fMinMCLabel) {
266 if (t->TestBits(fMCConstSel) != (Int_t)fMCConstSel) {
267 AliDebug(2,Form("Skipping track %d because it does not match the bit mask (%d, %d)", iTracks, fMCConstSel, t->TestBits(TObject::kBitMask)));
271 AliDebug(2,Form("Track %d matches the bit mask (%d, %d)", iTracks, fMCConstSel, t->TestBits(TObject::kBitMask)));
275 if (t->TestBits(fConstSel) != (Int_t)fConstSel) {
276 AliDebug(2,Form("Skipping track %d because it does not match the bit mask (%d, %d)", iTracks, fConstSel, t->TestBits(TObject::kBitMask)));
280 AliDebug(2,Form("Track %d matches the bit mask (%d, %d)", iTracks, fConstSel, t->TestBits(TObject::kBitMask)));
283 if ((t->GetFlag() & fMCFlag) != fMCFlag) {
284 AliDebug(2,Form("Skipping track %d because it does not match the MC flags", iTracks));
287 if (fGeneratorIndex >= 0 && t->GetGeneratorIndex() != fGeneratorIndex) {
288 AliDebug(2,Form("Skipping track %d because it does not match the MC generator index", iTracks));
291 if (t->Pt() < fMinJetTrackPt)
293 Double_t eta = t->Eta();
294 Double_t phi = t->Phi();
295 if ((eta<fEtaMin) || (eta>fEtaMax) ||
296 (phi<fPhiMin) || (phi>fPhiMax))
299 // artificial inefficiency
300 if (fTrackEfficiency < 1.) {
301 Double_t rnd = gRandom->Rndm();
302 if (fTrackEfficiency < rnd) {
303 AliDebug(2,Form("Track %d rejected due to artificial tracking inefficiency", iTracks));
308 // offset of 100 for consistency with cluster ids
309 AliDebug(2,Form("Track %d accepted (label = %d, pt = %f)", iTracks, t->GetLabel(), t->Pt()));
310 fjw.AddInputVector(t->Px(), t->Py(), t->Pz(), t->E(), iTracks + 100);
314 if ((((fJetType & kFullJet) != 0) || ((fJetType & kNeutralJet) != 0)) && fClus) {
315 const Int_t Nclus = fClus->GetEntries();
316 for (Int_t iClus = 0; iClus < Nclus; ++iClus) {
318 Double_t cEta=0,cPhi=0,cPt=0;
319 Double_t cPx=0,cPy=0,cPz=0;
321 AliEmcalParticle *ep = static_cast<AliEmcalParticle*>(fClus->At(iClus));
325 c = ep->GetCluster();
329 if (c->GetLabel() > fMinMCLabel) {
330 if (ep->TestBits(fMCConstSel) != (Int_t)fMCConstSel) {
331 AliDebug(2,Form("Skipping cluster %d because it does not match the bit mask (%d, %d)", iClus, fMCConstSel, ep->TestBits(TObject::kBitMask)));
335 AliDebug(2,Form("Cluster %d matches the bit mask (%d, %d)", iClus, fMCConstSel, ep->TestBits(TObject::kBitMask)));
339 if (ep->TestBits(fConstSel) != (Int_t)fConstSel) {
340 AliDebug(2,Form("Skipping cluster %d because it does not match the bit mask (%d, %d)", iClus, fConstSel, ep->TestBits(TObject::kBitMask)));
344 AliDebug(2,Form("Cluster %d matches the bit mask (%d, %d)", iClus, fConstSel, ep->TestBits(TObject::kBitMask)));
355 c = static_cast<AliVCluster*>(fClus->At(iClus));
359 if (c->GetLabel() > fMinMCLabel) {
360 if (c->TestBits(fMCConstSel) != (Int_t)fMCConstSel) {
361 AliDebug(2,Form("Skipping cluster %d because it does not match the bit mask (%d, %d)", iClus, fMCConstSel, c->TestBits(TObject::kBitMask)));
365 AliDebug(2,Form("Cluster %d matches the bit mask (%d, %d)", iClus, fMCConstSel, c->TestBits(TObject::kBitMask)));
369 if (c->TestBits(fConstSel) != (Int_t)fConstSel) {
370 AliDebug(2,Form("Skipping cluster %d because it does not match the bit mask (%d, %d)", iClus, fConstSel, c->TestBits(TObject::kBitMask)));
374 AliDebug(2,Form("Cluster %d matches the bit mask (%d, %d)", iClus, fConstSel, c->TestBits(TObject::kBitMask)));
379 c->GetMomentum(nP, vertex);
389 if (cPt < fMinJetClusPt)
391 if ((cEta<fEtaMin) || (cEta>fEtaMax) ||
392 (cPhi<fPhiMin) || (cPhi>fPhiMax))
394 // offset of 100 to skip ghost particles uid = -1
395 AliDebug(2,Form("Cluster %d accepted (label = %d)", iClus, c->GetLabel()));
396 Double_t e = TMath::Sqrt(cPx*cPx+cPy*cPy+cPz*cPz);
397 if(fPionMassClusters) e = TMath::Sqrt(cPx*cPx+cPy*cPy+cPz*cPz + 0.13957*0.13957); //MV: dirty, need better solution
398 fjw.AddInputVector(cPx, cPy, cPz, e, -iClus - 100);
399 // fjw.AddInputVector(cPx, cPy, cPz, TMath::Sqrt(cPx*cPx+cPy*cPy+cPz*cPz), -iClus - 100);
403 // setting legacy mode
405 fjw.SetLegacyMode(kTRUE);
411 //run generic subtractor
412 if(fDoGenericSubtractionJetMass) {
413 fjw.SetUseExternalBkg(fUseExternalBkg,fRho,fRhom);
414 fjw.DoGenericSubtractionJetMass();
417 if(fDoGenericSubtractionExtraJetShapes) {
418 fjw.SetUseExternalBkg(fUseExternalBkg,fRho,fRhom);
419 fjw.DoGenericSubtractionJetAngularity();
420 fjw.DoGenericSubtractionJetpTD();
421 fjw.DoGenericSubtractionJetCircularity();
422 fjw.DoGenericSubtractionJetSigma2();
423 fjw.DoGenericSubtractionJetConstituent();
424 fjw.DoGenericSubtractionJetLeSub();
427 //run constituent subtractor
428 if(fDoConstituentSubtraction) {
429 fjw.SetUseExternalBkg(fUseExternalBkg,fRho,fRhom);
430 fjw.DoConstituentSubtraction();
434 AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
436 AliFatal(Form("%s: Can not create geometry", GetName()));
440 // loop over fastjet jets
441 std::vector<fastjet::PseudoJet> jets_incl = fjw.GetInclusiveJets();
442 // sort jets according to jet pt
443 static Int_t indexes[9999] = {-1};
444 GetSortedArray(indexes, jets_incl);
446 AliDebug(1,Form("%d jets found", (Int_t)jets_incl.size()));
447 for (UInt_t ijet=0, jetCount=0; ijet<jets_incl.size(); ++ijet) {
448 Int_t ij = indexes[ijet];
449 AliDebug(3,Form("Jet pt = %f, area = %f", jets_incl[ij].perp(), fjw.GetJetArea(ij)));
451 if (jets_incl[ij].perp()<fMinJetPt)
453 if (fjw.GetJetArea(ij)<fMinJetArea)
455 if ((jets_incl[ij].eta()<fJetEtaMin) || (jets_incl[ij].eta()>fJetEtaMax) ||
456 (jets_incl[ij].phi()<fJetPhiMin) || (jets_incl[ij].phi()>fJetPhiMax))
459 AliEmcalJet *jet = new ((*fJets)[jetCount])
460 AliEmcalJet(jets_incl[ij].perp(), jets_incl[ij].eta(), jets_incl[ij].phi(), jets_incl[ij].m());
463 //do generic subtraction if requested
464 #ifdef FASTJET_VERSION
465 if(fDoGenericSubtractionJetMass) {
466 std::vector<fastjet::contrib::GenericSubtractorInfo> jetMassInfo = fjw.GetGenSubtractorInfoJetMass();
467 Int_t n = (Int_t)jetMassInfo.size();
469 jet->SetFirstDerivative(jetMassInfo[ij].first_derivative());
470 jet->SetSecondDerivative(jetMassInfo[ij].second_derivative());
471 jet->SetFirstOrderSubtracted(jetMassInfo[ij].first_order_subtracted());
472 jet->SetSecondOrderSubtracted(jetMassInfo[ij].second_order_subtracted());
476 //here do generic subtraction for angular structure function
477 Double_t ptcorr = jets_incl[ij].perp()-fjw.GetJetArea(ij)*fRho;
479 if(fDoGenericSubtractionGR && ptcorr>fPtMinGR) {
480 fjw.SetUseExternalBkg(fUseExternalBkg,fRho,fRhom);
481 fjw.SetRMaxAndStep(fRMax,fDRStep);
482 fjw.DoGenericSubtractionGR(ij);
483 std::vector<double> num = fjw.GetGRNumerator();
484 std::vector<double> den = fjw.GetGRDenominator();
485 std::vector<double> nums = fjw.GetGRNumeratorSub();
486 std::vector<double> dens = fjw.GetGRDenominatorSub();
487 //pass this to AliEmcalJet
488 jet->SetGRNumSize(num.size());
489 jet->SetGRDenSize(den.size());
490 jet->SetGRNumSubSize(nums.size());
491 jet->SetGRDenSubSize(dens.size());
492 Int_t nsize = (Int_t)num.size();
493 for(Int_t g = 0; g<nsize; ++g) {
494 jet->AddGRNumAt(num[g],g);
495 jet->AddGRNumSubAt(nums[g],g);
497 Int_t dsize = (Int_t)den.size();
498 for(Int_t g = 0; g<dsize; ++g) {
499 jet->AddGRDenAt(den[g],g);
500 jet->AddGRDenSubAt(dens[g],g);
504 if(fDoGenericSubtractionExtraJetShapes){
505 std::vector<fastjet::contrib::GenericSubtractorInfo> jetAngularityInfo = fjw.GetGenSubtractorInfoJetAngularity();
506 Int_t na = (Int_t)jetAngularityInfo.size();
508 jet->SetFirstDerivativeAngularity(jetAngularityInfo[ij].first_derivative());
509 jet->SetSecondDerivativeAngularity(jetAngularityInfo[ij].second_derivative());
510 jet->SetFirstOrderSubtractedAngularity(jetAngularityInfo[ij].first_order_subtracted());
511 jet->SetSecondOrderSubtractedAngularity(jetAngularityInfo[ij].second_order_subtracted());
514 std::vector<fastjet::contrib::GenericSubtractorInfo> jetpTDInfo = fjw.GetGenSubtractorInfoJetpTD();
515 Int_t np = (Int_t)jetpTDInfo.size();
517 jet->SetFirstDerivativepTD(jetpTDInfo[ij].first_derivative());
518 jet->SetSecondDerivativepTD(jetpTDInfo[ij].second_derivative());
519 jet->SetFirstOrderSubtractedpTD(jetpTDInfo[ij].first_order_subtracted());
520 jet->SetSecondOrderSubtractedpTD(jetpTDInfo[ij].second_order_subtracted());
523 std::vector<fastjet::contrib::GenericSubtractorInfo> jetCircularityInfo = fjw.GetGenSubtractorInfoJetCircularity();
524 Int_t nc = (Int_t)jetCircularityInfo.size();
526 jet->SetFirstDerivativeCircularity(jetCircularityInfo[ij].first_derivative());
527 jet->SetSecondDerivativeCircularity(jetCircularityInfo[ij].second_derivative());
528 jet->SetFirstOrderSubtractedCircularity(jetCircularityInfo[ij].first_order_subtracted());
529 jet->SetSecondOrderSubtractedCircularity(jetCircularityInfo[ij].second_order_subtracted());
532 std::vector<fastjet::contrib::GenericSubtractorInfo> jetSigma2Info = fjw.GetGenSubtractorInfoJetSigma2();
533 Int_t ns = (Int_t)jetSigma2Info.size();
535 jet->SetFirstDerivativeSigma2(jetSigma2Info[ij].first_derivative());
536 jet->SetSecondDerivativeSigma2(jetSigma2Info[ij].second_derivative());
537 jet->SetFirstOrderSubtractedSigma2(jetSigma2Info[ij].first_order_subtracted());
538 jet->SetSecondOrderSubtractedSigma2(jetSigma2Info[ij].second_order_subtracted());
542 std::vector<fastjet::contrib::GenericSubtractorInfo> jetConstituentInfo = fjw.GetGenSubtractorInfoJetConstituent();
543 Int_t nco= (Int_t)jetConstituentInfo.size();
544 if(nco>ij && nco>0) {
545 jet->SetFirstDerivativeConstituent(jetConstituentInfo[ij].first_derivative());
546 jet->SetSecondDerivativeConstituent(jetConstituentInfo[ij].second_derivative());
547 jet->SetFirstOrderSubtractedConstituent(jetConstituentInfo[ij].first_order_subtracted());
548 jet->SetSecondOrderSubtractedConstituent(jetConstituentInfo[ij].second_order_subtracted());
551 std::vector<fastjet::contrib::GenericSubtractorInfo> jetLeSubInfo = fjw.GetGenSubtractorInfoJetLeSub();
552 Int_t nlsub= (Int_t)jetLeSubInfo.size();
553 if(nlsub>ij && nlsub>0) {
554 jet->SetFirstDerivativeLeSub(jetLeSubInfo[ij].first_derivative());
555 jet->SetSecondDerivativeLeSub(jetLeSubInfo[ij].second_derivative());
556 jet->SetFirstOrderSubtractedLeSub(jetLeSubInfo[ij].first_order_subtracted());
557 jet->SetSecondOrderSubtractedLeSub(jetLeSubInfo[ij].second_order_subtracted());
562 // Fill constituent info
563 std::vector<fastjet::PseudoJet> constituents(fjw.GetJetConstituents(ij));
564 jet->SetNumberOfTracks(constituents.size());
565 jet->SetNumberOfClusters(constituents.size());
569 Double_t neutralE = 0;
580 FillJetConstituents(constituents,jet,vertex,jetCount,nt,nc,maxCh,maxNe,ncharged,nneutral,neutralE,mcpt,cemc,emcpt,gall,gemc,constituents,0);
581 jet->SetNumberOfTracks(nt);
582 jet->SetNumberOfClusters(nc);
583 jet->SortConstituents();
584 jet->SetMaxNeutralPt(maxNe);
585 jet->SetMaxChargedPt(maxCh);
586 jet->SetNEF(neutralE / jet->E());
587 fastjet::PseudoJet area(fjw.GetJetAreaVector(ij));
588 jet->SetArea(area.perp());
589 jet->SetAreaEta(area.eta());
590 jet->SetAreaPhi(area.phi());
591 jet->SetNumberOfCharged(ncharged);
592 jet->SetNumberOfNeutrals(nneutral);
595 jet->SetPtEmc(emcpt);
598 jet->SetAreaEmc(fjw.GetJetArea(ij) * gemc / gall);
601 if ((jet->Phi() > geom->GetArm1PhiMin() * TMath::DegToRad()) &&
602 (jet->Phi() < geom->GetArm1PhiMax() * TMath::DegToRad()) &&
603 (jet->Eta() > geom->GetArm1EtaMin()) &&
604 (jet->Eta() < geom->GetArm1EtaMax()))
605 jet->SetAxisInEmcal(kTRUE);
607 AliDebug(2,Form("Added jet n. %d, pt = %f, area = %f, constituents = %d", jetCount, jet->Pt(), jet->Area(), (Int_t)constituents.size()));
612 //run constituent subtractor if requested
613 if(fDoConstituentSubtraction) {
614 #ifdef FASTJET_VERSION
615 if(!fJetsSub) AliWarning(Form("No jet branch to write to for subtracted jets. fJetsSubName: %s",fJetsSubName.Data()));
617 std::vector<fastjet::PseudoJet> jets_sub;
618 jets_sub = fjw.GetConstituentSubtrJets();
619 AliDebug(1,Form("%d constituent subtracted jets found", (Int_t)jets_sub.size()));
620 for (UInt_t ijet=0, jetCount=0; ijet<jets_sub.size(); ++ijet) {
621 //Only storing 4-vector and jet area of unsubtracted jet
622 AliEmcalJet *jet_sub = new ((*fJetsSub)[jetCount])
623 AliEmcalJet(jets_sub[ijet].perp(), jets_sub[ijet].eta(), jets_sub[ijet].phi(), jets_sub[ijet].m());
624 jet_sub->SetLabel(ijet);
625 // Fill constituent info
626 std::vector<fastjet::PseudoJet> constituents_unsub(fjw.GetJetConstituents(ijet));
627 std::vector<fastjet::PseudoJet> constituents_sub = jets_sub[ijet].constituents();
628 jet_sub->SetNumberOfTracks(constituents_sub.size());
629 jet_sub->SetNumberOfClusters(constituents_sub.size());
632 Double_t neutralE = 0;
643 FillJetConstituents(constituents_sub,jet_sub,vertex,jetCount,nt,nc,maxCh,maxNe,ncharged,nneutral,neutralE,mcpt,cemc,emcpt,gall,gemc,constituents_unsub,1);
644 jet_sub->SetNumberOfTracks(nt);
645 jet_sub->SetNumberOfClusters(nc);
646 jet_sub->SortConstituents();
648 fastjet::PseudoJet area(fjw.GetJetAreaVector(ijet));
649 jet_sub->SetArea(area.perp());
650 jet_sub->SetAreaEta(area.eta());
651 jet_sub->SetAreaPhi(area.phi());
652 jet_sub->SetAreaEmc(area.perp());
657 } //constituent subtraction
660 //________________________________________________________________________
661 Bool_t AliEmcalJetTask::GetSortedArray(Int_t indexes[], std::vector<fastjet::PseudoJet> array) const
663 // Get the leading jets.
665 static Float_t pt[9999] = {0};
667 const Int_t n = (Int_t)array.size();
672 for (Int_t i = 0; i < n; i++)
673 pt[i] = array[i].perp();
675 TMath::Sort(n, pt, indexes);
680 //________________________________________________________________________
681 Bool_t AliEmcalJetTask::DoInit()
683 // Init. Return true if successful.
685 if (fTrackEfficiency < 1.) {
686 if (gRandom) delete gRandom;
687 gRandom = new TRandom3(0);
690 // get input collections
691 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
694 fEvent = InputEvent();
696 AliError(Form("%s: Could not retrieve event! Returning", GetName()));
700 if (!(fEvent->FindListObject(fJetsSubName)) && fJetsSub)
701 fEvent->AddObject(fJetsSub);
703 if (fTracksName == "Tracks")
704 am->LoadBranch("Tracks");
705 if (!fTracks && !fTracksName.IsNull()) {
706 fTracks = dynamic_cast<TClonesArray*>(fEvent->FindListObject(fTracksName));
708 AliError(Form("%s: Pointer to tracks %s == 0", GetName(), fTracksName.Data()));
713 TClass cls(fTracks->GetClass()->GetName());
714 if (cls.InheritsFrom("AliMCParticle") || cls.InheritsFrom("AliAODMCParticle"))
718 if (fCaloName == "CaloClusters")
719 am->LoadBranch("CaloClusters");
720 if (!fClus && !fCaloName.IsNull()) {
721 fClus = dynamic_cast<TClonesArray*>(fEvent->FindListObject(fCaloName));
723 AliError(Form("%s: Pointer to clus %s == 0", GetName(), fCaloName.Data()));
728 TClass cls(fClus->GetClass()->GetName());
729 if (cls.InheritsFrom("AliEmcalParticle"))
733 if (!fRhoName.IsNull() && !fRhoParam) { // get rho from the event
734 fRhoParam = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(fRhoName));
736 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
740 if (!fRhomName.IsNull() && !fRhomParam) { // get rhom from the event
741 fRhomParam = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(fRhomName));
743 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhomName.Data()));
748 // add jets to event if not yet there
749 if (!(fEvent->FindListObject(fJetsName)))
750 fEvent->AddObject(fJets);
752 AliError(Form("%s: Object with name %s already in event! Returning", GetName(), fJetsName.Data()));
759 //___________________________________________________________________________________________________________________
760 void AliEmcalJetTask::FillJetConstituents(std::vector<fastjet::PseudoJet>& constituents,AliEmcalJet *jet,Double_t vertex[3],UInt_t jetCount,Int_t& nt,Int_t& nc,Double_t& maxCh,Double_t& maxNe,Int_t& ncharged,Int_t& nneutral,Double_t& neutralE,Double_t& mcpt,Int_t& cemc,Double_t& emcpt,Int_t& gall,Int_t& gemc,std::vector<fastjet::PseudoJet>& constituentsunsub,Int_t flagsub){
774 AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
775 for(UInt_t ic = 0; ic < constituents.size(); ++ic) {
776 if(flagsub==0) uid = constituents[ic].user_index();
777 if(flagsub!=0) uid=GetIndexSub(constituents[ic].perp(),constituentsunsub);
778 AliDebug(3,Form("Processing constituent %d", uid));
779 if ((uid == -1) /*&& (constituents[ic].kt2() < 1e-25)*/) { //ghost particle
781 Double_t gphi = constituents[ic].phi();
783 gphi += TMath::TwoPi();
784 gphi *= TMath::RadToDeg();
785 Double_t geta = constituents[ic].eta();
786 if ((gphi > geom->GetArm1PhiMin()) && (gphi < geom->GetArm1PhiMax()) &&
787 (geta > geom->GetArm1EtaMin()) && (geta < geom->GetArm1EtaMax()))
789 } else if ((uid > 0) && fTracks) { // track constituent
790 Int_t tid = uid - 100;
791 AliVParticle *t = static_cast<AliVParticle*>(fTracks->At(tid));
793 AliError(Form("Could not find track %d",tid));
796 if (jetCount < fMarkConst) {
797 AliDebug(2,Form("Marking track %d with bit map %d", tid, fJetType));
800 Double_t cEta = t->Eta();
801 Double_t cPhi = t->Phi();
802 Double_t cPt = t->Pt();
803 Double_t cP = t->P();
804 if (t->Charge() == 0) {
814 if (fIsMcPart || TMath::Abs(t->GetLabel()) > fMinMCLabel) // check if MC particle
818 cPhi += TMath::TwoPi();
819 cPhi *= TMath::RadToDeg();
820 if ((cPhi > geom->GetArm1PhiMin()) && (cPhi < geom->GetArm1PhiMax()) &&
821 (cEta > geom->GetArm1EtaMin()) && (cEta < geom->GetArm1EtaMax())) {
825 // cout<<"Adding the track"<<endl;
826 jet->AddTrackAt(tid, nt);
828 } else if (fClus) { // cluster constituent
829 Int_t cid = -uid - 100;
831 Double_t cEta=0,cPhi=0,cPt=0,cP=0;
833 AliEmcalParticle *ep = static_cast<AliEmcalParticle*>(fClus->At(cid));
836 c = ep->GetCluster();
839 if (jetCount < fMarkConst)
840 ep->SetBit(fJetType);
846 c = static_cast<AliVCluster*>(fClus->At(cid));
849 if (jetCount < fMarkConst)
852 c->GetMomentum(nP, vertex);
863 if (c->GetLabel() > fMinMCLabel) // MC particle
864 mcpt += c->GetMCEnergyFraction() > 1e-6 ? cPt * c->GetMCEnergyFraction() : cPt;
867 cPhi += TMath::TwoPi();
868 cPhi *= TMath::RadToDeg();
869 if ((cPhi > geom->GetArm1PhiMin()) && (cPhi < geom->GetArm1PhiMax()) &&
870 (cEta > geom->GetArm1EtaMin()) && (cEta < geom->GetArm1EtaMax())) {
875 jet->AddClusterAt(cid, nc);
879 AliError(Form("%s: No logical way to end up here.", GetName()));
884 //______________________________________________________________________________________
885 Int_t AliEmcalJetTask::GetIndexSub(Double_t ptsub,std::vector<fastjet::PseudoJet>& constituentsunsub){
887 for(UInt_t ii=0;ii<constituentsunsub.size();ii++){
888 Double_t ptunsub=constituentsunsub[ii].perp();
889 //cout<<ptunsub<<" "<<ptsub<<endl;
890 if(ptsub==ptunsub) return constituentsunsub[ii].user_index();
893 //______________________________________________________________________________________