18 #include <TClonesArray.h> 24 #include <AliVCluster.h> 25 #include <AliVEvent.h> 26 #include <AliVParticle.h> 27 #include <AliEMCALGeometry.h> 29 #include <AliAnalysisManager.h> 30 #include <AliVEventHandler.h> 31 #include <AliMultiInputEventHandler.h> 75 fTrackEfficiencyOnlyForEmbedding(kFALSE),
77 fApplyArtificialTrackingEfficiency(kFALSE),
79 fFillConstituents(kTRUE),
87 fFastJetWrapper(
"AliEmcalJetTask",
"AliEmcalJetTask"),
88 fClusterContainerIndexMap(),
89 fParticleContainerIndexMap()
146 Error(
"AddUtility",
"Jet utility %s already connected.", utility->GetName());
163 while ((utility=static_cast<AliEmcalJetUtility*>(next()))) utility->
Init();
221 if (n == 0)
return kFALSE;
238 AliError(
"No tracks or clusters, returning.");
244 AliDebug(2,Form(
"Jet type = %d",
fJetType));
249 while ((tracks = static_cast<AliParticleContainer*>(nextPartColl()))) {
250 AliDebug(2,Form(
"Tracks from collection %d: '%s'. Embedded: %i, nTracks: %i", iColl-1, tracks->GetName(), tracks->GetIsEmbedding(), tracks->
GetNParticles()));
260 if (trackEfficiency < rnd) {
261 AliDebug(2,Form(
"Track %d rejected due to artificial tracking inefficiency", it.current_index()));
267 AliDebug(2,Form(
"Track %d accepted (label = %d, pt = %f, eta = %f, phi = %f, E = %f, m = %f, px = %f, py = %f, pz = %f)", it.current_index(), it->second->GetLabel(), it->first.Pt(), it->first.Eta(), it->first.Phi(), it->first.E(), it->first.M(), it->first.Px(), it->first.Py(), it->first.Pz()));
277 while ((clusters = static_cast<AliClusterContainer*>(nextClusColl()))) {
278 AliDebug(2,Form(
"Clusters from collection %d: '%s'. Embedded: %i, nClusters: %i", iColl-1, clusters->GetName(), clusters->GetIsEmbedding(), clusters->
GetNClusters()));
281 AliDebug(2,Form(
"Cluster %d accepted (label = %d, energy = %.3f)", it.current_index(), it->second->GetLabel(), it->first.E()));
308 static Int_t indexes[9999] = {-1};
311 AliDebug(1,Form(
"%d jets found", (
Int_t)jets_incl.size()));
312 for (
UInt_t ijet = 0, jetCount = 0; ijet < jets_incl.size(); ++ijet) {
313 Int_t ij = indexes[ijet];
316 if (jets_incl[ij].perp() <
fMinJetPt)
continue;
323 AliEmcalJet(jets_incl[ij].perp(), jets_incl[ij].eta(), jets_incl[ij].phi(), jets_incl[ij].m());
338 if ((jet->
Phi() >
fGeom->GetArm1PhiMin() * TMath::DegToRad()) &&
339 (jet->
Phi() <
fGeom->GetArm1PhiMax() * TMath::DegToRad()) &&
340 (jet->
Eta() >
fGeom->GetArm1EtaMin()) &&
341 (jet->
Eta() <
fGeom->GetArm1EtaMax()))
347 AliDebug(2,Form(
"Added jet n. %d, pt = %f, area = %f, constituents = %d", jetCount, jet->
Pt(), jet->
Area(), jet->
GetNumberOfConstituents()));
369 for (
Int_t i = 0; i < n; i++)
370 pt[i] = array[i].perp();
372 TMath::Sort(n, pt, indexes);
389 AliError(Form(
"%s: fTrackEfficiencyFunction was already loaded! Do not apply multiple artificial track efficiencies.", GetName()));
406 std::cout << GetName() <<
": Name of the jet container: " <<
fJetsName << std::endl;
407 std::cout <<
"Use this name in order to connect jet containers in your task to connect to the collection of jets found by this jet finder" << std::endl;
409 std::cout <<
"Found particle container with name " << partcont->GetName() << std::endl;
411 std::cout <<
"Not particle container found for task" << std::endl;
414 std::cout <<
"Found cluster container with name " << clustcont->GetName() << std::endl;
416 std::cout <<
"Not cluster container found for task" << std::endl;
420 if (!(InputEvent()->FindListObject(
fJetsName))) {
421 fJets =
new TClonesArray(
"AliEmcalJet");
423 ::Info(
"AliEmcalJetTask::ExecOnce",
"Jet collection with name '%s' has been added to the event.",
fJetsName.Data());
424 InputEvent()->AddObject(
fJets);
427 AliError(Form(
"%s: Object with name %s already in event! Returning", GetName(),
fJetsName.Data()));
465 std::vector<fastjet::PseudoJet>& constituents_unsub,
Int_t flag,
TString particlesSubName)
479 TClonesArray * particles_sub = 0;
486 for (
UInt_t ic = 0; ic < constituents.size(); ++ic) {
489 uid = constituents[ic].user_index();
492 if (constituents[ic].perp()<1.e-10) {
496 uid = constituents[ic].user_index();
499 AliError(
"correspondence between un/subtracted constituent not found");
504 AliDebug(3,Form(
"Processing constituent %d", uid));
508 Double_t gphi = constituents[ic].phi();
509 if (gphi < 0) gphi += TMath::TwoPi();
510 gphi *= TMath::RadToDeg();
511 Double_t geta = constituents[ic].eta();
512 if ((gphi >
fGeom->GetArm1PhiMin()) && (gphi < fGeom->GetArm1PhiMax()) &&
513 (geta >
fGeom->GetArm1EtaMin()) && (geta < fGeom->GetArm1EtaMax()))
518 constituents[ic].py(),
519 constituents[ic].pz(),
520 constituents[ic].e());
526 AliDebug(3,Form(
"Constituent %d is a track from collection %d and with ID %d", uid, iColl, tid));
529 AliError(Form(
"Could not find particle container %d",iColl));
534 AliError(Form(
"Could not find track %d",tid));
545 if (t->Charge() == 0) {
548 if (cPt > maxNe) maxNe = cPt;
551 if (cPt > maxCh) maxCh = cPt;
555 if (TMath::Abs(t->GetLabel()) >
fMinMCLabel) mcpt += cPt;
558 if (cPhi < 0) cPhi += TMath::TwoPi();
559 cPhi *= TMath::RadToDeg();
560 if ((cPhi >
fGeom->GetArm1PhiMin()) && (cPhi < fGeom->GetArm1PhiMax()) &&
561 (cEta >
fGeom->GetArm1EtaMin()) && (cEta < fGeom->GetArm1EtaMax())) {
567 if (flag == 0 || particlesSubName ==
"") {
573 particles_sub = partCont->GetArray();
575 Int_t part_sub_id = particles_sub->GetEntriesFast();
577 part_sub->
SetPtEtaPhiM(constituents[ic].perp(),constituents[ic].eta(),constituents[ic].phi(),constituents[ic].m());
587 AliDebug(3,Form(
"Constituent %d is a cluster from collection %d and with ID %d", uid, iColl, cid));
600 Double_t pvec[3] = {nP.Px(), nP.Py(), nP.Pz()};
604 if (cPt > maxNe) maxNe = cPt;
607 if (TMath::Abs(c->GetLabel()) >
fMinMCLabel) mcpt += c->GetMCEnergyFraction() > 1e-6 ? cPt * c->GetMCEnergyFraction() : cPt;
610 if (cPhi<0) cPhi += TMath::TwoPi();
611 cPhi *= TMath::RadToDeg();
612 if ((cPhi >
fGeom->GetArm1PhiMin()) && (cPhi < fGeom->GetArm1PhiMax()) &&
613 (cEta >
fGeom->GetArm1EtaMin()) && (cEta < fGeom->GetArm1EtaMax())) {
619 if (flag == 0 || particlesSubName ==
"") {
625 particles_sub = clusCont->GetArray();
627 Int_t part_sub_id = particles_sub->GetEntriesFast();
629 part_sub->
SetPtEtaPhiM(constituents[ic].perp(),constituents[ic].eta(),constituents[ic].phi(),constituents[ic].m());
637 AliError(Form(
"%s: No logical way to end up here (uid = %d).", GetName(), uid));
644 jet->
SetNEF(neutralE / jet->
E());
666 AliFatal(
"Jet finder task is locked! Changing properties is not allowed.");
684 fOfflineTriggerMask = offlineTriggerMask;
687 AliWarning(
"Manually setting the event selection for jet finders is not allowed! Using trigger=old_trigger | your_trigger");
688 fOfflineTriggerMask = fOfflineTriggerMask | offlineTriggerMask;
703 while ((tracks = static_cast<AliParticleContainer*>(nextPartColl()))) {
718 while ((clusters = static_cast<AliClusterContainer*>(nextClusColl()))) {
733 while ((clusters = static_cast<AliClusterContainer*>(nextClusColl()))) {
748 while ((tracks = static_cast<AliParticleContainer*>(nextPartColl()))) {
764 while ((tracks = static_cast<AliParticleContainer*>(nextPartColl()))) {
779 return fastjet::kt_algorithm;
781 return fastjet::antikt_algorithm;
783 return fastjet::cambridge_algorithm;
785 return fastjet::genkt_algorithm;
787 return fastjet::cambridge_for_passive_algorithm;
789 return fastjet::genkt_for_passive_algorithm;
791 return fastjet::plugin_algorithm;
793 return fastjet::undefined_jet_algorithm;
796 ::Error(
"AliEmcalJetTask::ConvertToFJAlgo",
"Jet algorithm %d not recognized!!!", algo);
797 return fastjet::undefined_jet_algorithm;
811 return fastjet::E_scheme;
814 return fastjet::pt_scheme;
817 return fastjet::pt2_scheme;
820 return fastjet::Et_scheme;
823 return fastjet::Et2_scheme;
826 return fastjet::BIpt_scheme;
829 return fastjet::BIpt2_scheme;
832 return fastjet::external_scheme;
835 ::Error(
"AliEmcalJetTask::ConvertToFJRecoScheme",
"Recombination scheme %d not recognized!!!", reco);
836 return fastjet::external_scheme;
851 if( eta < 0.9 && eta > -0.9 ) {
854 if (eta < 0.9 - r && eta > -0.9 + r)
890 return jetAcceptanceType;
898 if (!
fGeom)
return kFALSE;
900 if ( eta < fGeom->GetArm1EtaMax() - r && eta >
fGeom->GetArm1EtaMin() + r ) {
902 if ( phi < 3.135 - r && phi > 1.405 + r )
906 if ( phi < fGeom->GetEMCALPhiMax() * TMath::DegToRad() - r && phi >
fGeom->GetArm1PhiMin() * TMath::DegToRad() + r)
919 if (!
fGeom)
return kFALSE;
920 if (eta < fGeom->GetArm1EtaMax() - r && eta >
fGeom->GetArm1EtaMin() + r ) {
921 if ( phi < fGeom->GetDCALPhiMax() * TMath::DegToRad() - r && phi >
fGeom->GetDCALPhiMin() * TMath::DegToRad() + r)
935 if (!
fGeom)
return kFALSE;
937 if (eta < fGeom->GetArm1EtaMax() - r && eta >
fGeom->GetArm1EtaMin() + r) {
938 if ( phi < fGeom->GetDCALPhiMax() * TMath::DegToRad() - r && phi >
fGeom->GetDCALPhiMin() * TMath::DegToRad() + r) {
940 if (TMath::Abs(eta) >
fGeom->GetDCALInnerExtandedEta() + r) {
944 if (phi >
fGeom->GetEMCGeometry()->GetDCALStandardPhiMax() * TMath::DegToRad())
966 if (eta < etaMax - r && eta > etaMin + r ) {
967 if (phi < phiMax * TMath::DegToRad() - r && phi > phiMin * TMath::DegToRad() + r)
981 if (fname.BeginsWith(
"alien://")) {
982 TGrid::Connect(
"alien://");
985 TFile*
file = TFile::Open(path.data());
987 if (!file || file->IsZombie()) {
988 AliErrorStream() <<
"Could not open artificial track efficiency function file\n";
992 TF1* trackEff =
dynamic_cast<TF1*
>(file->Get(name.data()));
995 AliInfoStream() << Form(
"Artificial track efficiency function %s loaded from file %s.", name.data(), path.data()) <<
"\n";
998 AliErrorStream() << Form(
"Artificial track efficiency function %s not found in file %s.", name.data(), path.data()) <<
"\n";
1002 TF1* trackEffClone =
static_cast<TF1*
>(trackEff->Clone());
1039 ::Error(
"AddTaskEmcalJet",
"No analysis manager to connect to.");
1044 AliVEventHandler* handler = mgr->GetInputEventHandler();
1046 ::Error(
"AddTaskEmcalJet",
"This task requires an input event handler");
1052 if (handler->InheritsFrom(
"AliESDInputHandler")) {
1055 else if (handler->InheritsFrom(
"AliAODInputHandler")) {
1066 if (trackName ==
"usedefault") {
1067 if (dataType ==
kESD) {
1068 trackName =
"Tracks";
1070 else if (dataType ==
kAOD) {
1071 trackName =
"tracks";
1078 if (clusName ==
"usedefault") {
1079 if (dataType ==
kESD) {
1080 clusName =
"CaloClusters";
1082 else if (dataType ==
kAOD) {
1083 clusName =
"caloClusters";
1091 if (trackName ==
"mcparticles") {
1093 partCont = mcpartCont;
1095 else if (trackName ==
"tracks" || trackName ==
"Tracks") {
1097 partCont = trackCont;
1099 else if (!trackName.IsNull()) {
1105 if (!clusName.IsNull()) {
1126 Printf(
"Jet task name: %s", name.Data());
1129 if (mgrTask)
return mgrTask;
1147 mgr->AddTask(jetTask);
1150 AliAnalysisDataContainer* cinput = mgr->GetCommonInputContainer();
1151 mgr->ConnectInput(jetTask, 0, cinput);
Bool_t fTrackEfficiencyOnlyForEmbedding
Apply aritificial tracking inefficiency only for embedded tracks.
void SetMaxNeutralPt(Double32_t t)
void SetJetsName(const char *n)
void SetRecombScheme(ERecoScheme_t scheme)
fastjet::PseudoJet GetJetAreaVector(UInt_t idx) const
TObjArray fClusterCollArray
cluster collection array
void AddTrackAt(Int_t track, Int_t idx)
void SetParticlePtCut(Double_t cut)
TClonesArray * fJets
!jet collection
Bool_t fIsEmcPart
!=true if emcal particles are given as input (for clusters)
void SetEtaRange(Double_t emi, Double_t ema)
Bool_t fIsInit
!=true if already initialized
DCal acceptance – spans entire rectangular region in eta-phi (including most of PHOS) ...
void AdoptParticleContainer(AliParticleContainer *cont)
const AliClusterIterableMomentumContainer accepted_momentum() const
Base task in the EMCAL framework.
bidirectional stl iterator over the EMCAL iterable container
Double_t fJetEtaMin
minimum eta to keep jet in output
EJetType_t fJetType
jet type (full, charged, neutral)
Bool_t IsJetInEmcal(Double_t eta, Double_t phi, Double_t r)
Int_t GetNParticles() const
Container with name, TClonesArray and cuts for particles.
Bool_t fApplyArtificialTrackingEfficiency
Flag to apply artificial tracking efficiency.
void AddClusterAt(Int_t clus, Int_t idx)
AliEmcalJetUtility * AddUtility(AliEmcalJetUtility *utility)
Bool_t fFillGhost
=true ghost particles will be filled in AliEmcalJet obj
Declaration of class AliTLorentzVector.
virtual void ProcessJet(AliEmcalJet *jet, Int_t ij, AliFJWrapper &fjw)=0
void SetJetType(EJetType_t t)
void ExecuteUtilities(AliEmcalJet *jet, Int_t ij)
Full acceptance, i.e. no acceptance cut applied – left to user.
void SetMaxRap(Double_t maxrap)
virtual void Terminate(AliFJWrapper &fjw)=0
void SetMinJetPt(Double_t j)
void SetAreaE(Double_t a)
AliEmcalContainerIndexMap< AliParticleContainer, AliVParticle > fParticleContainerIndexMap
! Mapping between index and particle containers
ERecoScheme_t fRecombScheme
recombination scheme used by fastjet
void SetRecombScheme(const fastjet::RecombinationScheme &scheme)
Bool_t fFillConstituents
If true jet consituents will be filled to the AliEmcalJet.
Double_t fTrackEfficiency
artificial tracking inefficiency (0...1)
void SetJetAlgo(EJetAlgo_t a)
virtual ~AliEmcalJetTask()
static FJRecoScheme ConvertToFJRecoScheme(ERecoScheme_t reco)
int GlobalIndexFromLocalIndex(const U *inputObject, const int localIndex) const
General jet finder task implementing a wrapper for FastJet.
static TString GenerateJetName(EJetType_t jetType, EJetAlgo_t jetAlgo, ERecoScheme_t recoScheme, Double_t radius, AliParticleContainer *partCont, AliClusterContainer *clusCont, TString tag)
UShort_t GetNumberOfConstituents() const
Container for particles within the EMCAL framework.
Bool_t fIsPSelSet
!=true if physics selection was set
Int_t GetDefaultClusterEnergy() const
void LoadTrackEfficiencyFunction(const std::string &path, const std::string &name)
void AdoptClusterContainer(AliClusterContainer *cont)
TObjArray fParticleCollArray
particle/track collection array
void AddParticleConstituent(const AliVParticle *const part, Bool_t isFromEmbeddedEvent, UInt_t globalIndex)
Add new particle (track / mc particle) constituent to the given jet Note: this will append the consti...
AliParticleContainer * GetParticleContainer(Int_t i=0) const
Get particle container attached to this task.
TPC fiducial acceptance (each eta edge narrowed by jet R)
Bool_t fLocked
true if lock is set
const std::vector< fastjet::PseudoJet > & GetInclusiveJets() const
void SetJetAcceptanceType(UInt_t type)
Double_t fJetPhiMin
minimum phi to keep jet in output
UInt_t FindJetAcceptanceType(Double_t eta, Double_t phi, Double_t r)
Bool_t IsJetInDcal(Double_t eta, Double_t phi, Double_t r)
Double_t GetJetArea(UInt_t idx) const
AliEMCALGeometry * fGeom
!emcal geometry
PHOS fiducial acceptance (each eta, phi edge narrowed by jet R)
void AddClusterConstituent(const AliVCluster *const clust, AliVCluster::VCluUserDefEnergy_t endef, Double_t *pvec, Bool_t isFromEmbeddedEvent, UInt_t globalIndex)
Add new cluster constituent to the given jet Note: this will append the constituent. No sorting according to particle is done.
Double_t Phi_0_2pi() const
TString fJetsTag
tag of jet collection (usually = "Jets")
void SetLegacyMode(Bool_t mode)
virtual AliVParticle * GetParticle(Int_t i=-1) const
TObjArray * fUtilities
jet utilities (gen subtractor, constituent subtractor etc.)
void SetPtEtaPhiM(Double_t pt, Double_t eta, Double_t phi, Double_t m)
void SetAlgorithm(const fastjet::JetAlgorithm &algor)
static const AliEmcalContainerIndexMap< TClonesArray, AliVCluster > & GetEmcalContainerIndexMap()
Get the EMCal container utils associated with particle containers.
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
AliEmcalContainerIndexMap< AliClusterContainer, AliVCluster > fClusterContainerIndexMap
! Mapping between index and cluster containers
Int_t GetNClusters() const
Double_t Phi_0_2pi() const
Double_t fJetEtaMax
maximum eta to keep jet in output
Double_t fGhostArea
ghost area
void SetMaxChargedPt(Double32_t t)
virtual void Clear(const Option_t *="")
void SetNEF(Double_t nef)
Bool_t GetSortedArray(Int_t indexes[], std::vector< fastjet::PseudoJet > array) const
void AddGhost(const Double_t dPx, const Double_t dPy, const Double_t dPz, const Double_t dE)
AliVCluster * GetCluster(Int_t i) const
Bool_t IsJetInDcalOnly(Double_t eta, Double_t phi, Double_t r)
virtual void Prepare(AliFJWrapper &fjw)=0
Int_t fMinMCLabel
minimum MC label value for the tracks/clusters being considered MC particles
void SetJetTask(AliEmcalJetTask *jetTask)
void SetMinJetClusE(Double_t min)
void SelectCollisionCandidates(UInt_t offlineTriggerMask=AliVEvent::kMB)
void SetGhostArea(Double_t gharea)
void SetGhostArea(Double_t gharea)
EJetAlgo_t fJetAlgo
jet algorithm (kt, akt, etc)
void SetNumberOfCharged(Int_t n)
Double_t fJetPhiMax
maximum phi to keep jet in output
std::vector< fastjet::PseudoJet > GetJetConstituents(UInt_t idx) const
void SetAreaEta(Double_t a)
static FJJetAlgo ConvertToFJAlgo(EJetAlgo_t algo)
void SetParticleEtaLimits(Double_t min, Double_t max)
const std::vector< fastjet::PseudoJet > & GetInputVectors() const
void SetMinJetTrackPt(Double_t min)
Double_t fMinJetArea
min area to keep jet in output
TString fJetsName
!name of jet collection
void SetFillGhost(Bool_t b=kTRUE)
Double_t fMinJetPt
min jet pt to keep jet in output
const AliParticleIterableMomentumContainer accepted_momentum() const
TFile * file
TList with histograms for a given trigger.
void CopyMappingFrom(const AliEmcalContainerIndexMap< U2, V > &map, U *cont)
void FillJetConstituents(AliEmcalJet *jet, std::vector< fastjet::PseudoJet > &constituents, std::vector< fastjet::PseudoJet > &constituents_sub, Int_t flag=0, TString particlesSubName="")
Bool_t GetMomentum(TLorentzVector &mom, const AliVCluster *vc, Double_t mass) const
Represent a jet reconstructed using the EMCal jet framework.
void SetNumberOfTracks(Int_t n)
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
Double_t fRadius
jet radius
Bool_t fLegacyMode
!=true to enable FJ 2.x behavior
void SetClusPtCut(Double_t cut)
Int_t fRunNumber
!run number (triggering RunChanged()
virtual void AddInputVector(Double_t px, Double_t py, Double_t pz, Double_t E, Int_t index=-99999)
void SetMinJetClusPt(Double_t min)
DCal fiducial acceptance (each eta, phi edge narrowed by jet R)
void SetPhiRange(Double_t pmi, Double_t pma)
EDataType_t
Switch for the data type.
DCal acceptance – spans ONLY DCal (no PHOS or gap)
void SetClusECut(Double_t cut)
void SetDefaultClusterEnergy(Int_t d)
void SetAreaPhi(Double_t a)
virtual void InitEvent(AliFJWrapper &fjw)=0
void SetAreaType(const fastjet::AreaType &atype)
void SetParticlePhiLimits(Double_t min, Double_t max)
void SetPtEmc(Double_t pt)
Container structure for EMCAL clusters.
DCal fiducial acceptance (each eta, phi edge narrowed by jet R)
Container for MC-true particles within the EMCAL framework.
EMCal fiducial acceptance (each eta, phi edge narrowed by jet R)
static AliEmcalJetTask * AddTaskEmcalJet(const TString nTracks="usedefault", const TString nClusters="usedefault", const AliJetContainer::EJetAlgo_t jetAlgo=AliJetContainer::antikt_algorithm, const Double_t radius=0.4, const AliJetContainer::EJetType_t jetType=AliJetContainer::kFullJet, const Double_t minTrPt=0.15, const Double_t minClPt=0.30, const Double_t ghostArea=0.005, const AliJetContainer::ERecoScheme_t reco=AliJetContainer::pt_scheme, const TString tag="Jet", const Double_t minJetPt=0., const Bool_t lockTask=kTRUE, const Bool_t bFillGhosts=kFALSE)
void SetCharge(EChargeCut_t c)
Container for jet within the EMCAL jet framework.
void SetRadius(Double_t r)
AliFJWrapper fFastJetWrapper
!fastjet wrapper
void TerminateUtilities()
void SetNumberOfClusters(Int_t n)
Bool_t IsJetInPhos(Double_t eta, Double_t phi, Double_t r)
void SetAxisInEmcal(Bool_t b)
static const AliEmcalContainerIndexMap< TClonesArray, AliVParticle > & GetEmcalContainerIndexMap()
Get the EMCal container utils associated with particle containers.
static const Int_t fgkConstIndexShift
!contituent index shift
void SetAreaEmc(Double_t a)
void SetClusHadCorrEnergyCut(Double_t cut)
void SetNumberOfNeutrals(Int_t n)