Skip to content

Commit e63d668

Browse files
authored
[PWG-LF] Update spectra TOF selection for good MC ev (#5582)
1 parent c48f6e8 commit e63d668

File tree

1 file changed

+56
-22
lines changed

1 file changed

+56
-22
lines changed

PWGLF/Tasks/Nuspex/spectraTOF.cxx

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "Common/Core/TrackSelectionDefaults.h"
3434
#include "PWGLF/DataModel/LFParticleIdentification.h"
3535
#include "PWGLF/DataModel/spectraTOF.h"
36+
#include "Framework/O2DatabasePDGPlugin.h"
3637

3738
#include "TPDGCode.h"
3839

@@ -796,8 +797,8 @@ struct tofSpectra {
796797
}
797798
}
798799

799-
template <bool fillHistograms = false, bool fillMultiplicity = false, typename CollisionType, typename TrackType>
800-
bool isEventSelected(CollisionType const& collision, TrackType const& tracks)
800+
template <bool fillHistograms = false, bool fillMultiplicity = false, typename CollisionType>
801+
bool isEventSelected(CollisionType const& collision)
801802
{
802803
if constexpr (fillHistograms) {
803804
histos.fill(HIST("evsel"), 1.f);
@@ -1131,7 +1132,7 @@ struct tofSpectra {
11311132
void processStandard(CollisionCandidate::iterator const& collision,
11321133
TrackCandidates const& tracks)
11331134
{
1134-
if (!isEventSelected<true, true>(collision, tracks)) {
1135+
if (!isEventSelected<true, true>(collision)) {
11351136
return;
11361137
}
11371138
for (const auto& track : tracks) {
@@ -1148,7 +1149,7 @@ struct tofSpectra {
11481149
aod::SpTracks const& tracks)
11491150
{
11501151
for (const auto& collision : collisions) {
1151-
if (!isEventSelected<true, true>(collision, tracks)) {
1152+
if (!isEventSelected<true, true>(collision)) {
11521153
return;
11531154
}
11541155
const auto& tracksInCollision = tracks.sliceByCached(aod::spectra::collisionId, collision.globalIndex(), cacheTrk);
@@ -1170,7 +1171,7 @@ struct tofSpectra {
11701171
aod::pid##tofTable##inputPid, \
11711172
aod::pid##tpcTable##inputPid> const& tracks) \
11721173
{ \
1173-
if (!isEventSelected<false, false>(collision, tracks)) { \
1174+
if (!isEventSelected<false, false>(collision)) { \
11741175
return; \
11751176
} \
11761177
for (const auto& track : tracks) { \
@@ -1591,27 +1592,25 @@ struct tofSpectra {
15911592
const float multiplicity = getMultiplicity(collision);
15921593

15931594
if (mcParticle.isPhysicalPrimary()) {
1594-
if (collision.sel8()) {
1595-
if (abs(collision.posZ()) < cfgCutVertex) {
1596-
if (includeCentralityMC) {
1597-
histos.fill(HIST(hpt_den_prm_goodev[i]), mcParticle.pt(), multiplicity, mcParticle.eta());
1598-
} else {
1599-
histos.fill(HIST(hpt_den_prm_goodev[i]), mcParticle.pt());
1600-
}
1595+
if (isEventSelected<false, false>(collision)) {
1596+
if (includeCentralityMC) {
1597+
histos.fill(HIST(hpt_den_prm_goodev[i]), mcParticle.pt(), multiplicity, mcParticle.eta());
16011598
} else {
1602-
if (includeCentralityMC) {
1603-
histos.fill(HIST(hpt_den_prm_evsel[i]), mcParticle.pt(), multiplicity, mcParticle.eta());
1604-
} else {
1605-
histos.fill(HIST(hpt_den_prm_evsel[i]), mcParticle.pt());
1606-
}
1599+
histos.fill(HIST(hpt_den_prm_goodev[i]), mcParticle.pt());
16071600
}
1608-
} else {
1601+
} else if (collision.sel8()) {
16091602
if (includeCentralityMC) {
1610-
histos.fill(HIST(hpt_den_prm_recoev[i]), mcParticle.pt(), multiplicity, mcParticle.eta());
1603+
histos.fill(HIST(hpt_den_prm_evsel[i]), mcParticle.pt(), multiplicity, mcParticle.eta());
16111604
} else {
1612-
histos.fill(HIST(hpt_den_prm_recoev[i]), mcParticle.pt());
1605+
histos.fill(HIST(hpt_den_prm_evsel[i]), mcParticle.pt());
16131606
}
16141607
}
1608+
} else {
1609+
if (includeCentralityMC) {
1610+
histos.fill(HIST(hpt_den_prm_recoev[i]), mcParticle.pt(), multiplicity, mcParticle.eta());
1611+
} else {
1612+
histos.fill(HIST(hpt_den_prm_recoev[i]), mcParticle.pt());
1613+
}
16151614
}
16161615
}
16171616

@@ -1689,6 +1688,36 @@ struct tofSpectra {
16891688
}
16901689
}
16911690

1691+
Service<o2::framework::O2DatabasePDG> pdgDB;
1692+
1693+
// Event selection
1694+
template <typename TMcParticles>
1695+
bool isTrueINELgt0(TMcParticles particles)
1696+
{
1697+
int nPart = 0;
1698+
for (const auto& particle : particles) {
1699+
if (particle.isPhysicalPrimary() == 0)
1700+
continue; // consider only primaries
1701+
1702+
const auto& pdgInfo = pdgDB->GetParticle(particle.pdgCode());
1703+
if (!pdgInfo) {
1704+
continue;
1705+
}
1706+
if (TMath::Abs(pdgInfo->Charge()) < 0.001) {
1707+
continue; // consider only charged particles
1708+
}
1709+
1710+
if (particle.eta() < -1.0 || particle.eta() > 1.0)
1711+
continue; // consider only particles in |eta| < 1
1712+
1713+
nPart++;
1714+
}
1715+
if (nPart > 0)
1716+
return true;
1717+
else
1718+
return false;
1719+
}
1720+
16921721
Preslice<aod::McParticles> perMCCol = aod::mcparticle::mcCollisionId;
16931722
SliceCache cache;
16941723
void processMC(soa::Join<aod::Tracks, aod::TracksExtra,
@@ -1702,7 +1731,7 @@ struct tofSpectra {
17021731
// Fill number of generated and reconstructed collisions for normalization
17031732
histos.fill(HIST("MC/GenRecoCollisions"), 1.f, mcCollisions.size());
17041733
histos.fill(HIST("MC/GenRecoCollisions"), 2.f, collisions.size());
1705-
// LOGF(info, "Enter processMC!");
1734+
17061735
for (const auto& track : tracks) {
17071736
if (!track.has_collision()) {
17081737
if (track.sign() > 0) {
@@ -1712,7 +1741,7 @@ struct tofSpectra {
17121741
}
17131742
continue;
17141743
};
1715-
if (!isEventSelected<false, false>(track.collision_as<CollisionCandidateMC>(), tracks)) {
1744+
if (!isEventSelected<false, false>(track.collision_as<CollisionCandidateMC>())) {
17161745
continue;
17171746
}
17181747
if (!passesCutWoDCA(track)) {
@@ -1784,6 +1813,11 @@ struct tofSpectra {
17841813
const auto& particlesInCollision = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache);
17851814
bool hasParticleInFT0C = false;
17861815
bool hasParticleInFT0A = false;
1816+
if (cfgINELCut.value == 1) {
1817+
if (!isTrueINELgt0(particlesInCollision)) {
1818+
continue;
1819+
}
1820+
}
17871821

17881822
int nInelPart = 0;
17891823
for (const auto& mcParticle : particlesInCollision) {

0 commit comments

Comments
 (0)