11 #include "AliEMCALRecoUtils.h"
12 #include "AliESDCaloCluster.h"
13 #include "AliAODCaloCluster.h"
14 #include "AliVParticle.h"
16 #include "AliEMCALGeometry.h"
17 #include "AliMCEvent.h"
32 fDoPropagation(kFALSE),
34 fAttemptPropMatch(kFALSE),
39 fUpdateClusters(kTRUE),
40 fClusterContainerIndexMap(),
41 fParticleContainerIndexMap(),
48 fMCGenerToAcceptForTrack(1),
51 for(
Int_t icent=0; icent<8; ++icent) {
52 for(
Int_t ipt=0; ipt<9; ++ipt) {
53 for(
Int_t ieta=0; ieta<2; ++ieta) {
86 Bool_t enableFracEMCRecalc = kFALSE;
87 GetProperty(
"enableFracEMCRecalc", enableFracEMCRecalc);
88 Int_t removeNMCGenerators = 0;
89 GetProperty(
"removeNMCGenerators", removeNMCGenerators);
91 std::string removeMcGen1 =
"";
93 TString removeMCGen1 = removeMcGen1.c_str();
94 std::string removeMcGen2 =
"";
96 TString removeMCGen2 = removeMcGen2.c_str();
98 if(enableFracEMCRecalc){
99 if(removeNMCGenerators > 0)
101 printf(
"\t gen1 <%s>, gen2 <%s>, remove tracks %d\n",removeMCGen1.Data(),removeMCGen2.Data(),
fMCGenerToAcceptForTrack);
119 std::string particleContainerNames =
"";
120 bool firstLoop =
true;
123 while ((partCont = static_cast<AliParticleContainer*>(nextPartCont()))) {
124 if (firstLoop !=
true) {
125 particleContainerNames +=
"_";
130 particleContainerNames += partCont->GetArrayName();
133 std::string clusterContainerNames =
"";
137 while ((clusCont = static_cast<AliClusterContainer*>(nextClusCont()))) {
138 if (firstLoop !=
true) {
139 clusterContainerNames +=
"_";
144 clusterContainerNames += clusCont->GetArrayName();
148 fEmcalTracks->SetName(Form(
"EmcalTracks_%s", particleContainerNames.c_str()));
150 fEmcalClusters->SetName(Form(
"EmcalClusters_%s", clusterContainerNames.c_str()));
154 fHistMatchEtaAll =
new TH1F(
"fHistMatchEtaAll",
"fHistMatchEtaAll", 400, -0.2, 0.2);
155 fHistMatchPhiAll =
new TH1F(
"fHistMatchPhiAll",
"fHistMatchPhiAll", 400, -0.2, 0.2);
160 for(
Int_t icent=0; icent<nCentChBins; ++icent) {
161 for(
Int_t ipt=0; ipt<9; ++ipt) {
162 for(
Int_t ieta=0; ieta<2; ++ieta) {
163 TString nameEta(Form(
"fHistMatchEta_%i_%i_%i",icent,ipt,ieta));
164 fHistMatchEta[icent][ipt][ieta] =
new TH1F(nameEta, nameEta, 400, -0.2, 0.2);
166 TString namePhi(Form(
"fHistMatchPhi_%i_%i_%i",icent,ipt,ieta));
167 fHistMatchPhi[icent][ipt][ieta] =
new TH1F(namePhi, namePhi, 400, -0.2, 0.2);
213 else if (p>=0.5 && p<1.0)
215 else if (p>=1.0 && p<1.5)
217 else if (p>=1.5 && p<2.)
219 else if (p>=2. && p<3.)
221 else if (p>=3. && p<4.)
223 else if (p>=4. && p<5.)
225 else if (p>=5. && p<8.)
245 AliVCluster* cluster = 0;
246 AliVTrack* track = 0;
250 while ((clusCont = static_cast<AliClusterContainer*>(nextClusCont()))) {
253 cluster =
static_cast<AliVCluster *
>(clusIterator->second);
256 cluster->SetEmcCpvDistance(-1);
257 cluster->SetTrackDistance(1024, 1024);
258 AliAODCaloCluster *ac =
dynamic_cast<AliAODCaloCluster*
>(cluster);
259 AliESDCaloCluster *ec = 0;
261 const Int_t N = ac->GetNTracksMatched();
262 AliDebug(2, TString::Format(
"Number of matched tracks: %d", N));
263 for (
Int_t i = N - 1; i >= 0; i--) {
264 TObject *ptr = ac->GetTrackMatched(i);
265 ac->RemoveTrackMatched(ptr);
266 AliDebug(2, TString::Format(
"N tracks matched: %i of %i", ac->GetNTracksMatched(), N));
270 ec =
dynamic_cast<AliESDCaloCluster*
>(cluster);
271 TArrayI *arr = ec->GetTracksMatched();
272 if (arr) arr->Set(0);
296 while ((partCont = static_cast<AliParticleContainer*>(nextPartCont()))) {
299 track =
static_cast<AliVTrack *
>(partIterator->second);
302 track->ResetStatus(AliVTrack::kEMCALmatch);
303 track->SetEMCALcluster(-1);
306 Bool_t propthistrack = kFALSE;
308 propthistrack = kTRUE;
310 else if (!track->IsExtrapolatedToEMCAL()) {
312 propthistrack = kTRUE;
315 propthistrack = kTRUE;
321 Int_t mcLabel = TMath::Abs(track->GetLabel());
325 fMCEvent->GetCocktailGenerator(mcLabel,genName);
333 if ( !generOK )
continue;
337 AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(track,
fPropDist, mass, 20, 0.35, kFALSE,
fUseDCA);
347 track->SetUniqueID(0);
348 track->ResetBit(TObject::kHasUUID);
349 track->ResetBit(TObject::kIsReferenced);
355 AliDebug(2, Form(
"Now adding track %i (pT = %.3f, eta = %.3f, phi = %.3f)"
356 "Phi, Eta on EMCal = %.3f, %.3f",
358 track->GetTrackEtaOnEMCal(), track->GetTrackPhiOnEMCal()));
374 AliVTrack* track = emcalTrack->
GetTrack();
378 AliVCluster* cluster = emcalCluster->
GetCluster();
383 Double_t d2 = deta * deta + dphi * dphi;
385 if (d2 > maxd2)
continue;
390 AliDebug(2, Form(
"Now matching cluster E = %.3f, pT = %.3f, eta = %.3f, phi = %.3f "
391 "with track pT = %.3f, eta = %.3f, phi = %.3f"
392 "Track eta, phi on EMCal = %.3f, %.3f, d = %.3f",
393 cluster->GetNonLinCorrEnergy(), emcalCluster->
Pt(), emcalCluster->
Eta(), emcalCluster->
Phi(),
394 emcalTrack->
Pt(), emcalTrack->
Eta(), emcalTrack->
Phi(),
395 track->GetTrackEtaOnEMCal(), track->GetTrackPhiOnEMCal(), d));
400 if (track->Charge() < 0) centbinch +=
fNcentBins;
402 if(track->Eta() > 0) etabin = 1;
421 AliVCluster* cluster = emcalCluster->
GetCluster();
422 AliDebug(3, Form(
"Cluster E = %.2f, eta = %.2f, phi = %.2f, Nmatch = %d", cluster->GetNonLinCorrEnergy(), emcalCluster->
Eta(), emcalCluster->
Phi(), N));
424 if (N <= 0)
continue;
429 AliVTrack* trackFirstMatch = emcalTrackFirstMatch->
GetTrack();
433 cluster->SetTrackDistance(dphi, deta);
436 AliAODCaloCluster *ac =
dynamic_cast<AliAODCaloCluster*
>(cluster);
437 AliESDCaloCluster *ec = 0;
438 if (!ac) ec =
dynamic_cast<AliESDCaloCluster*
>(cluster);
442 for (
Int_t i=0; i < N; ++i) {
446 AliDebug(3, Form(
"Pt = %.2f, eta = %.2f, phi = %.2f", emcalTrack->
Pt(), emcalTrack->
Eta(), emcalTrack->
Phi()));
449 ac->AddTrackMatched(obj);
454 for (
Int_t i = 0; i < N; ++i) {
459 ec->AddTracksMatched(arr);
476 AliVTrack* track = emcalTrack->
GetTrack();
478 track->SetStatus(AliVTrack::kEMCALmatch);
493 AliWarning(Form(
"%s - AliAnalysisTaskEmcal::IsTrackInEmcalAcceptance - Geometry is not available!", GetName()));
500 if (part->Phi() > minPhi && part->Phi() < maxPhi) {
Bool_t fUpdateClusters
update clusters with matching info
Int_t fNcentBins
How many centrality bins (this member copied from AliAnalysisTaskEmcal)
void SetNumberOfMCGeneratorsToAccept(Int_t nGen)
Bool_t fEsdMode
flag for ESD
virtual ~AliEmcalCorrectionClusterTrackMatcher()
Bool_t fUseDCA
Use DCA as starting point for track propagation, rather than primary vertex.
Double_t fPropDist
distance to surface (440cm default)
AliEMCALGeometry * fGeom
! Geometry object
Bool_t fAttemptProp
if true then attempt to propagate if not done yet
Bool_t fUpdateTracks
update tracks with matching info
Int_t GetMatchedObjId(UShort_t i=0) const
Int_t fNEmcalClusters
!number of emcal clusters
const AliClusterIterableMomentumContainer accepted_momentum() const
UShort_t GetNumberOfMatchedObj() const
bidirectional stl iterator over the EMCAL iterable container
Bool_t fAttemptPropMatch
if true then attempt to propagate if not done yet but IsEMCAL is true
void SetMatchedPtr(TObjArray *arr)
Bool_t fUsePIDmass
Use PID-based mass hypothesis for track propagation, rather than pion mass hypothesis.
virtual void UserCreateOutputObjects()
AliVTrack * GetTrack() const
Int_t fCentBin
! Event centrality bin
int GlobalIndexFromLocalIndex(const U *inputObject, const int localIndex) const
Container for particles within the EMCAL framework.
TH1 * fHistMatchPhi[10][9][2]
!dphi distribution
TObjArray fParticleCollArray
Particle/track collection array.
TObjArray fClusterCollArray
Cluster collection array.
AliEmcalContainerIndexMap< AliClusterContainer, AliVCluster > fClusterContainerIndexMap
! Mapping between index and cluster containers
Cluster-track matcher component in the EMCal correction framework.
TH1 * fHistMatchPhiAll
!dphi distribution
Base class for correction components in the EMCal correction framework.
static const AliEmcalContainerIndexMap< TClonesArray, AliVCluster > & GetEmcalContainerIndexMap()
Get the EMCal container utils associated with particle containers.
Int_t IdInCollection() const
AliMCEvent * fMCEvent
! MC
Bool_t fDoPropagation
if true then propagate all hybrid tracks to EMCal surface
Double_t fVertex[3]
! Event vertex
TString fMCGenerToAccept[5]
List with name of generators that should not be included.
void GenerateEmcalParticles()
Bool_t fMCGenerToAcceptForTrack
Activate the removal of tracks entering the track matching that come from a particular generator...
TList * fOutput
! List of output histograms
Bool_t fCreateHisto
Flag to make some basic histograms.
TH1 * fHistMatchEta[10][9][2]
!deta distribution
Int_t fNEmcalTracks
!number of emcal tracks
Int_t fNMCGenerToAccept
Number of MC generators that should not be included in analysis.
AliVCluster * GetCluster() const
virtual Bool_t Initialize()
const AliParticleIterableMomentumContainer accepted_momentum() const
void CopyMappingFrom(const AliEmcalContainerIndexMap< U2, V > &map, U *cont)
virtual Bool_t CheckIfRunChanged()
void UserCreateOutputObjects()
void AddMatchedObj(Int_t id, Double_t d)
Bool_t IsTrackInEmcalAcceptance(AliVParticle *part, Double_t edges=0.9) const
TH1 * fHistMatchEtaAll
!deta distribution
void GetEtaPhiDiff(const AliVTrack *t, const AliVCluster *v, Double_t &phidiff, Double_t &etadiff)
Int_t GetMomBin(Double_t p) const
void SetNameOfMCGeneratorsToAccept(Int_t ig, TString name)
AliEmcalCorrectionClusterTrackMatcher()
Container structure for EMCAL clusters.
TClonesArray * fEmcalTracks
!emcal tracks
Double_t fMaxDistance
maximum distance to match clusters and tracks
static RegisterCorrectionComponent< AliEmcalCorrectionClusterTrackMatcher > reg
AliEmcalContainerIndexMap< AliParticleContainer, AliVParticle > fParticleContainerIndexMap
! Mapping between index and particle containers
TClonesArray * fEmcalClusters
!emcal clusters
static const AliEmcalContainerIndexMap< TClonesArray, AliVParticle > & GetEmcalContainerIndexMap()
Get the EMCal container utils associated with particle containers.
bool GetProperty(std::string propertyName, T &property, bool requiredProperty=true, std::string correctionName="")
Retrieve property.