Skip to content

Commit 04cbec3

Browse files
authored
[PWGLF] count generated charged particles in MC event + replace custom functions with O2 built-in ones (#12048)
1 parent cde0db9 commit 04cbec3

File tree

1 file changed

+9
-35
lines changed

1 file changed

+9
-35
lines changed

PWGLF/TableProducer/Nuspex/ebyeMaker.cxx

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -83,43 +83,13 @@ void momTotXYZ(std::array<float, 3>& momA, std::array<float, 3> const& momB, std
8383
momA[i] = momB[i] + momC[i];
8484
}
8585
}
86-
float invMass2Body(std::array<float, 3> const& momA, std::array<float, 3> const& momB, std::array<float, 3> const& momC, float const& massB, float const& massC)
87-
{
88-
float p2B = momB[0] * momB[0] + momB[1] * momB[1] + momB[2] * momB[2];
89-
float p2C = momC[0] * momC[0] + momC[1] * momC[1] + momC[2] * momC[2];
90-
float eB = std::sqrt(p2B + massB * massB);
91-
float eC = std::sqrt(p2C + massC * massC);
92-
float eA = eB + eC;
93-
float massA = std::sqrt(eA * eA - momA[0] * momA[0] - momA[1] * momA[1] - momA[2] * momA[2]);
94-
return massA;
95-
}
9686
float alphaAP(std::array<float, 3> const& momA, std::array<float, 3> const& momB, std::array<float, 3> const& momC)
9787
{
9888
float momTot = std::sqrt(std::pow(momA[0], 2.) + std::pow(momA[1], 2.) + std::pow(momA[2], 2.));
9989
float lQlPos = (momB[0] * momA[0] + momB[1] * momA[1] + momB[2] * momA[2]) / momTot;
10090
float lQlNeg = (momC[0] * momA[0] + momC[1] * momA[1] + momC[2] * momA[2]) / momTot;
10191
return (lQlPos - lQlNeg) / (lQlPos + lQlNeg);
10292
}
103-
float etaFromMom(std::array<float, 3> const& momA, std::array<float, 3> const& momB)
104-
{
105-
if (std::sqrt((1.f * momA[0] + 1.f * momB[0]) * (1.f * momA[0] + 1.f * momB[0]) +
106-
(1.f * momA[1] + 1.f * momB[1]) * (1.f * momA[1] + 1.f * momB[1]) +
107-
(1.f * momA[2] + 1.f * momB[2]) * (1.f * momA[2] + 1.f * momB[2])) -
108-
(1.f * momA[2] + 1.f * momB[2]) <
109-
static_cast<float>(1e-7)) {
110-
if ((1.f * momA[2] + 1.f * momB[2]) < 0.f)
111-
return -100.f;
112-
return 100.f;
113-
}
114-
return 0.5f * std::log((std::sqrt((1.f * momA[0] + 1.f * momB[0]) * (1.f * momA[0] + 1.f * momB[0]) +
115-
(1.f * momA[1] + 1.f * momB[1]) * (1.f * momA[1] + 1.f * momB[1]) +
116-
(1.f * momA[2] + 1.f * momB[2]) * (1.f * momA[2] + 1.f * momB[2])) +
117-
(1.f * momA[2] + 1.f * momB[2])) /
118-
(std::sqrt((1.f * momA[0] + 1.f * momB[0]) * (1.f * momA[0] + 1.f * momB[0]) +
119-
(1.f * momA[1] + 1.f * momB[1]) * (1.f * momA[1] + 1.f * momB[1]) +
120-
(1.f * momA[2] + 1.f * momB[2]) * (1.f * momA[2] + 1.f * momB[2])) -
121-
(1.f * momA[2] + 1.f * momB[2])));
122-
}
12393
float calculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ)
12494
{
12595
return std::sqrt((std::pow((pvY - Y) * Pz - (pvZ - Z) * Py, 2) + std::pow((pvX - X) * Pz - (pvZ - Z) * Px, 2) + std::pow((pvX - X) * Py - (pvY - Y) * Px, 2)) / (Px * Px + Py * Py + Pz * Pz));
@@ -208,6 +178,7 @@ struct EbyeMaker {
208178
float dBz;
209179
uint8_t nTrackletsColl;
210180
uint8_t nTracksColl;
181+
uint8_t nChPartGen;
211182

212183
Configurable<int> cfgMaterialCorrection{"cfgMaterialCorrection", static_cast<int>(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Type of material correction"};
213184
Configurable<LabeledArray<double>> cfgBetheBlochParams{"cfgBetheBlochParams", {kBetheBlochDefault[0], 2, 6, particleNamesPar, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for deuteron"};
@@ -705,7 +676,7 @@ struct EbyeMaker {
705676
continue;
706677
}
707678

708-
auto etaV0 = etaFromMom(momPos, momNeg);
679+
auto etaV0 = RecoDecay::eta(momV0);
709680
if (std::abs(etaV0) > etaMax) {
710681
continue;
711682
}
@@ -714,8 +685,8 @@ struct EbyeMaker {
714685
bool matter = alpha > 0;
715686
auto massPos = matter ? o2::constants::physics::MassProton : o2::constants::physics::MassPionCharged;
716687
auto massNeg = matter ? o2::constants::physics::MassPionCharged : o2::constants::physics::MassProton;
717-
auto mLambda = invMass2Body(momV0, momPos, momNeg, massPos, massNeg);
718-
auto mK0Short = invMass2Body(momV0, momPos, momNeg, o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged);
688+
auto mLambda = RecoDecay::m(std::array<std::array<float, 3>, 2>{momPos, momNeg}, std::array<double, 2>{massPos, massNeg});
689+
auto mK0Short = RecoDecay::m(std::array<std::array<float, 3>, 2>{momPos, momNeg}, std::array<double, 2>{o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged});
719690

720691
// pid selections
721692
float nSigmaTPCPos = getCustomTPCPID(posTrack, massPos);
@@ -871,6 +842,7 @@ struct EbyeMaker {
871842

872843
void fillMcGen(aod::McParticles const& mcParticles, aod::McTrackLabels const& /*mcLab*/, uint64_t const& collisionId)
873844
{
845+
nChPartGen = 0u;
874846
auto mcParticlesThisCollision = mcParticles.sliceBy(perCollisionMcParts, collisionId);
875847
for (const auto& mcPart : mcParticlesThisCollision) {
876848
auto genEta = mcPart.eta();
@@ -880,6 +852,8 @@ struct EbyeMaker {
880852
if ((((mcPart.flags() & 0x8) || (mcPart.flags() & 0x2)) && (doprocessMcRun2 || doprocessMiniMcRun2)) || ((mcPart.flags() & 0x1) && !doprocessMiniMcRun2))
881853
continue;
882854
auto pdgCode = mcPart.pdgCode();
855+
if (std::abs(pdgCode) == PDG_t::kPiPlus || std::abs(pdgCode) == PDG_t::kElectron || std::abs(pdgCode) == PDG_t::kMuonMinus || std::abs(pdgCode) == PDG_t::kKPlus || std::abs(pdgCode) == PDG_t::kProton)
856+
nChPartGen++;
883857
if (std::abs(pdgCode) == PDG_t::kLambda0) {
884858
if (!mcPart.isPhysicalPrimary() && !mcPart.has_mothers())
885859
continue;
@@ -1130,7 +1104,7 @@ struct EbyeMaker {
11301104
fillMcEvent(collision, tracks, v0TableThisCollision, centrality, mcParticles, mcLab);
11311105
fillMcGen(mcParticles, mcLab, collision.mcCollisionId());
11321106

1133-
miniCollTable(static_cast<int8_t>(collision.posZ() * 10), 0x0, 0x0, centrality, nTracksColl);
1107+
miniCollTable(static_cast<int8_t>(collision.posZ() * 10), nChPartGen, 0x0, centrality, nTracksColl);
11341108

11351109
for (auto& candidateTrack : candidateTracks[0]) { // o2-linter: disable=const-ref-in-for-loop (not a const ref)
11361110
int selMask = -1;
@@ -1245,7 +1219,7 @@ struct EbyeMaker {
12451219
fillMcEvent(collision, tracks, v0TableThisCollision, centrality, mcParticles, mcLab);
12461220
fillMcGen(mcParticles, mcLab, collision.mcCollisionId());
12471221

1248-
miniCollTable(static_cast<int8_t>(collision.posZ() * 10), 0x0, nTrackletsColl, centrality, nTracksColl);
1222+
miniCollTable(static_cast<int8_t>(collision.posZ() * 10), nChPartGen, nTrackletsColl, centrality, nTracksColl);
12491223

12501224
for (auto& candidateTrack : candidateTracks[0]) { // o2-linter: disable=const-ref-in-for-loop (not a const ref)
12511225
int selMask = -1;

0 commit comments

Comments
 (0)