Skip to content

Commit 2555fa6

Browse files
author
Cristian Moscatelli
committed
Mask-gen-ev-selection
1 parent 45987a4 commit 2555fa6

File tree

2 files changed

+72
-27
lines changed

2 files changed

+72
-27
lines changed

PWGLF/DataModel/LFSlimNucleiTables.h

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ DECLARE_SOA_COLUMN(MotherPDGcode, MotherpdgCode, int);
5555
DECLARE_SOA_COLUMN(MotherDecRad, motherDecRad, float);
5656
DECLARE_SOA_COLUMN(AbsoDecL, absoDecL, float);
5757
DECLARE_SOA_COLUMN(McProcess, mcProcess, uint64_t);
58-
58+
DECLARE_SOA_COLUMN(gEventMask, genEventMask, uint8_t);
5959
} // namespace NucleiTableNS
6060

6161
namespace NucleiPairTableNS
@@ -203,6 +203,40 @@ DECLARE_SOA_TABLE(NucleiTableRed, "AOD", "NUCLEITABLERED",
203203
NucleiTableNS::PDGcode,
204204
NucleiTableNS::MotherPDGcode);
205205

206+
// Table for keeping track of selection of generated events
207+
DECLARE_SOA_TABLE(GenEventMCSel, "AOD", "GENEVENTMCSEL",
208+
NucleiTableNS::gEventMask);
209+
210+
DECLARE_SOA_TABLE(NucleiTableMCExtension, "AOD", "NUCTABLEMCSEL",
211+
NucleiTableNS::Pt,
212+
NucleiTableNS::Eta,
213+
NucleiTableNS::Phi,
214+
NucleiTableNS::TPCInnerParam,
215+
NucleiTableNS::Beta,
216+
NucleiTableNS::Zvertex,
217+
NucleiTableNS::NContrib,
218+
NucleiTableNS::DCAxy,
219+
NucleiTableNS::DCAz,
220+
NucleiTableNS::TPCsignal,
221+
NucleiTableNS::ITSchi2,
222+
NucleiTableNS::TPCchi2,
223+
NucleiTableNS::TOFchi2,
224+
NucleiTableNS::Flags,
225+
NucleiTableNS::TPCfindableCls,
226+
NucleiTableNS::TPCcrossedRows,
227+
NucleiTableNS::ITSclsMap,
228+
NucleiTableNS::TPCnCls,
229+
NucleiTableNS::TPCnClsShared,
230+
NucleiTableNS::ITSclusterSizes,
231+
NucleiTableNS::SurvivedEventSelection,
232+
NucleiTableNS::gPt,
233+
NucleiTableNS::gEta,
234+
NucleiTableNS::gPhi,
235+
NucleiTableNS::PDGcode,
236+
NucleiTableNS::MotherPDGcode,
237+
NucleiTableNS::MotherDecRad,
238+
NucleiTableNS::AbsoDecL,
239+
NucleiTableNS::gEventMask);
206240
} // namespace o2::aod
207241

208242
#endif // PWGLF_DATAMODEL_LFSLIMNUCLEITABLES_H_

PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "PWGLF/DataModel/EPCalibrationTables.h"
2323
#include "PWGLF/DataModel/LFSlimNucleiTables.h"
24+
#include "PWGLF/Utils/inelGt.h"
2425

2526
#include "Common/Core/EventPlaneHelper.h"
2627
#include "Common/Core/PID/PIDTOF.h"
@@ -250,6 +251,13 @@ constexpr int EvSelDefault[9][1]{
250251
{0},
251252
{0},
252253
{0}};
254+
255+
enum EvGenSel : uint8_t {
256+
kGenTVX = 1 << 0,
257+
kGenZvtx = 1 << 1,
258+
kGenINELgt0 = 1 << 2,
259+
};
260+
253261
} // namespace nuclei
254262

255263
struct nucleiSpectra {
@@ -271,7 +279,9 @@ struct nucleiSpectra {
271279
Produces<o2::aod::NucleiTable> nucleiTable;
272280
Produces<o2::aod::NucleiPairTable> nucleiPairTable;
273281
Produces<o2::aod::NucleiTableMC> nucleiTableMC;
282+
Produces<o2::aod::NucleiTableMCExtension> nucleiTableMCExtension;
274283
Produces<o2::aod::NucleiTableFlow> nucleiTableFlow;
284+
Produces<o2::aod::GenEventMCSel> GenEventMCSel;
275285
Service<o2::ccdb::BasicCCDBManager> ccdb;
276286
Zorro zorro;
277287
OutputObj<ZorroSummary> zorroSummary{"zorroSummary"};
@@ -921,61 +931,62 @@ struct nucleiSpectra {
921931

922932
bool selectINELgt0 = cfgEventSelections->get(nuclei::evSel::kINELgt0);
923933
std::vector<bool> goodCollisions(mcCollisions.size(), false);
934+
std::vector<uint8_t> eventMask(mcCollisions.size(), 0);
924935

925936
auto* pdgDB = TDatabasePDG::Instance(); // Useful for evaluating the particle charge
926937

927938
for (const auto& c : mcCollisions) {
928939

929-
// Apply the |z| < 10 cm condition
930-
if (std::abs(c.posZ()) > 10.f)
931-
continue;
940+
uint8_t mask = 0;
932941

933942
const auto& slicedParticles = particlesMC.sliceBy(particlesPerMcCollision, c.globalIndex());
934943

935944
bool hasHitFT0A(false);
936945
bool hasHitFT0C(false);
937-
bool acceptEvent = !selectINELgt0;
938946

947+
// TVX trigger
939948
for (const auto& p : slicedParticles) {
940949
if (!p.isPhysicalPrimary())
941950
continue;
942951

952+
auto* pdg = pdgDB->GetParticle(p.pdgCode());
953+
if (!pdg || pdg->Charge() == 0)
954+
continue;
955+
943956
// Apply the TVX trigger condition
944957
if (p.eta() > 3.5f && p.eta() < 4.9f)
945958
hasHitFT0A = true;
946959
else if (p.eta() > -3.3f && p.eta() < -2.1f)
947960
hasHitFT0C = true;
948961

949-
// Apply the INEL>0 selection (only in case of active configurable)
950-
if (selectINELgt0 && !acceptEvent) {
951-
if (std::abs(p.eta()) < 1.0f) {
952-
auto* pdg = pdgDB->GetParticle(p.pdgCode());
953-
if (pdg && pdg->Charge() != 0)
954-
acceptEvent = true;
955-
}
956-
}
957-
958-
if (hasHitFT0A && hasHitFT0C && acceptEvent)
962+
if (hasHitFT0A && hasHitFT0C)
959963
break;
960964
}
961965

962-
if (hasHitFT0A && hasHitFT0C && acceptEvent) {
963-
goodCollisions[c.globalIndex()] = true;
964-
spectra.fill(HIST("hGenVtxZ"), c.posZ());
966+
if (hasHitFT0A && hasHitFT0C)
967+
mask |= nuclei::kGenTVX;
968+
969+
// |z| condition
970+
if (std::abs(c.posZ()) < cfgCutVertex)
971+
mask |= nuclei::kGenZvtx;
972+
973+
// INEL > 0 selection
974+
if (selectINELgt0) {
975+
if (o2::pwglf::isINELgt0mc(slicedParticles, pdgDB)) {
976+
mask |= nuclei::kGenINELgt0;
977+
}
965978
}
979+
980+
eventMask[c.globalIndex()] = mask;
981+
GenEventMCSel(mask);
982+
spectra.fill(HIST("hGenVtxZ"), c.posZ());
966983
}
967984

968985
for (const auto& collision : collisions) {
969986
if (!eventSelectionWithHisto(collision)) {
970987
continue;
971988
}
972-
973-
int mcId = collision.mcCollisionId();
974-
if (mcId < 0)
975-
continue;
976-
if (!goodCollisions[mcId])
977-
continue;
978-
989+
goodCollisions[collision.mcCollisionId()] = true;
979990
const auto& slicedTracks = tracks.sliceBy(tracksPerCollisions, collision.globalIndex());
980991
fillDataInfo(collision, slicedTracks);
981992
}
@@ -1041,7 +1052,7 @@ struct nucleiSpectra {
10411052

10421053
isReconstructed[particle.globalIndex()] = true;
10431054
float absoDecL = computeAbsoDecL(particle);
1044-
nucleiTableMC(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.nContrib, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS, goodCollisions[particle.mcCollisionId()], particle.pt(), particle.eta(), particle.phi(), particle.pdgCode(), motherPdgCode, motherDecRadius, absoDecL);
1055+
nucleiTableMCExtension(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.nContrib, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS, goodCollisions[particle.mcCollisionId()], particle.pt(), particle.eta(), particle.phi(), particle.pdgCode(), motherPdgCode, motherDecRadius, absoDecL, eventMask[particle.mcCollisionId()]);
10451056
}
10461057

10471058
int index{0};
@@ -1093,7 +1104,7 @@ struct nucleiSpectra {
10931104
continue; // skip secondaries from material if not requested
10941105
}
10951106
float absDecL = computeAbsoDecL(particle);
1096-
nucleiTableMC(999., 999., 999., 0., 0., 999., -1, 999., 999., -1, -1, -1, -1, flags, 0, 0, 0, 0, 0, 0, goodCollisions[particle.mcCollisionId()], particle.pt(), particle.eta(), particle.phi(), particle.pdgCode(), motherPdgCode, motherDecRadius, absDecL);
1107+
nucleiTableMCExtension(999., 999., 999., 0., 0., 999., -1, 999., 999., -1, -1, -1, -1, flags, 0, 0, 0, 0, 0, 0, goodCollisions[particle.mcCollisionId()], particle.pt(), particle.eta(), particle.phi(), particle.pdgCode(), motherPdgCode, motherDecRadius, absDecL, eventMask[particle.mcCollisionId()]);
10971108
}
10981109
break;
10991110
}

0 commit comments

Comments
 (0)