Skip to content

Commit 42e8404

Browse files
committed
Do v0 correctly
1 parent 8973025 commit 42e8404

File tree

2 files changed

+72
-18
lines changed

2 files changed

+72
-18
lines changed

ALICE3/Core/Decayer.h

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,32 @@ class Decayer {
6060
const double ctau = o2::constants::physics::LightSpeedCm2S * particleInfo->Lifetime(); // cm
6161
const double betaGamma = track.getP() / mass;
6262
const double rxyz = -betaGamma * ctau * std::log(1 - u);
63-
64-
float sna, csa;
65-
o2::math_utils::CircleXYf_t circle;
66-
track.getCircleParams(mBz, circle, sna, csa);
67-
const double rxy = rxyz / std::sqrt(1. + track.getTgl() * track.getTgl());
68-
const double theta = rxy / circle.rC;
69-
70-
const double vx = ((pos[0] - circle.xC) * std::cos(theta) - (pos[1] - circle.yC) * std::sin(theta)) + circle.xC;
71-
const double vy = ((pos[1] - circle.yC) * std::cos(theta) + (pos[0] - circle.xC) * std::sin(theta)) + circle.yC;
72-
const double vz = mom[2] + rxyz * (mom[2] / track.getP());
73-
74-
const double px = mom[0] * std::cos(theta) - mom[1] * std::sin(theta);
75-
const double py = mom[1] * std::cos(theta) + mom[0] * std::sin(theta);
76-
const double e = std::sqrt(mass * mass + px * px + py * py + mom[2] * mom[2]);
63+
double vx, vy, vz;
64+
double px, py, e;
65+
66+
if (!charge) {
67+
vx = pos[0] + rxyz * (mom[0] / track.getP());
68+
vy = pos[1] + rxyz * (mom[1] / track.getP());
69+
vy = pos[2] + rxyz * (mom[2] / track.getP());
70+
px = mom[0];
71+
py = mom[2];
72+
} else {
73+
float sna, csa;
74+
o2::math_utils::CircleXYf_t circle;
75+
track.getCircleParams(mBz, circle, sna, csa);
76+
const double rxy = rxyz / std::sqrt(1. + track.getTgl() * track.getTgl());
77+
const double theta = rxy / circle.rC;
78+
79+
vx = ((pos[0] - circle.xC) * std::cos(theta) - (pos[1] - circle.yC) * std::sin(theta)) + circle.xC;
80+
vy = ((pos[1] - circle.yC) * std::cos(theta) + (pos[0] - circle.xC) * std::sin(theta)) + circle.yC;
81+
vz = mom[2] + rxyz * (mom[2] / track.getP());
82+
83+
px = mom[0] * std::cos(theta) - mom[1] * std::sin(theta);
84+
py = mom[1] * std::cos(theta) + mom[0] * std::sin(theta);
85+
}
7786

7887
double brTotal = 0.;
88+
e = std::sqrt(mass * mass + px * px + py * py + mom[2] * mom[2]);
7989
for (int ch = 0; ch < particleInfo->NDecayChannels(); ++ch) {
8090
brTotal += particleInfo->DecayChannel(ch)->BranchingRatio();
8191
}

ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "ALICE3/Core/Decayer.h"
1919
#include "ALICE3/Core/TrackUtilities.h"
20+
#include "ALICE3/DataModel/OTFMCParticle.h"
2021

2122
#include <CCDB/BasicCCDBManager.h>
2223
#include <CommonConstants/MathConstants.h>
@@ -64,16 +65,23 @@ static const std::vector<int> pdgCodes{kK0Short,
6465
kOmegaPlusBar};
6566

6667
struct OnTheFlyDecayer {
68+
Produces<aod::OTFMCParticles> tableMcParticles;
6769
o2::upgrade::Decayer decayer;
6870
Service<o2::ccdb::BasicCCDBManager> ccdb;
6971
Service<o2::framework::O2DatabasePDG> pdgDB;
72+
HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};
7073

7174
Configurable<int> seed{"seed", 0, "Set seed for particle decayer"};
7275
Configurable<float> magneticField{"magneticField", 20., "Magnetic field (kG)"};
7376
Configurable<LabeledArray<int>> enabledDecays{"enabledDecays",
7477
{defaultParameters[0], kNumDecays, kNumParameters, particleNames, parameterNames},
7578
"Enable option for particle to be decayed: 0 - no, 1 - yes"};
76-
79+
80+
81+
ConfigurableAxis axisRadius{"axisRadius", {1000, 0, 100}, "Radius"};
82+
ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for QA histograms"};
83+
84+
7785
std::vector<int> mEnabledDecays;
7886
void init(o2::framework::InitContext&)
7987
{
@@ -86,6 +94,14 @@ struct OnTheFlyDecayer {
8694
mEnabledDecays.push_back(pdgCodes[i]);
8795
}
8896
}
97+
98+
histos.add("K0S/hGenK0S", "hGenK0S", kTH2D, {axisRadius, axisPt});
99+
histos.add("Lambda/hGenLambda", "hGenLambda", kTH2D, {axisRadius, axisPt});
100+
histos.add("AntiLambda/hGenAntiLambda", "hGenAntiLambda", kTH2D, {axisRadius, axisPt});
101+
histos.add("Xi/hGenXi", "hGenXi", kTH2D, {axisRadius, axisPt});
102+
histos.add("AntiXi/hGenAntiXi", "hGenAntiXi", kTH2D, {axisRadius, axisPt});
103+
histos.add("Omega/hGenOmega", "hGenOmega", kTH2D, {axisRadius, axisPt});
104+
histos.add("AntiOmega/hGenAntiOmega", "hGenAntiOmega", kTH2D, {axisRadius, axisPt});
89105
}
90106

91107
bool canDecay(const int pdgCode)
@@ -103,7 +119,6 @@ struct OnTheFlyDecayer {
103119
o2::track::TrackParCov o2track;
104120
o2::upgrade::convertMCParticleToO2Track(particle, o2track, pdgDB);
105121
std::vector<o2::upgrade::OTFParticle> decayDaughters = decayer.decayParticle(pdgDB, o2track, particle.pdgCode());
106-
std::cout << particle.pdgCode() << " decayed into: ";
107122
for (const auto& dau : decayDaughters) {
108123
o2::track::TrackParCov dauTrack;
109124
o2::upgrade::convertOTFParticleToO2Track(dau, dauTrack, pdgDB);
@@ -114,9 +129,38 @@ struct OnTheFlyDecayer {
114129
}
115130
}
116131
}
117-
std::vector<bool> isFinalState;
132+
133+
if (decayDaughters.empty()) {
134+
LOG(error) << "Attempted to decay " << particle.pdgCode() << " but resulting vector of daugthers were empty";
135+
continue;
136+
}
137+
138+
139+
const float decayRadius2D = std::hypot(decayDaughters[0].vx, decayDaughters[0].vy);
140+
std::cout << particle.pdgCode() << ": " << decayRadius2D << std::endl;
141+
if (particle.pdgCode() == kK0Short) {
142+
histos.fill(HIST("K0S/hGenK0S"), decayRadius2D, particle.pt());
143+
} else if (particle.pdgCode() == kLambda0) {
144+
histos.fill(HIST("Lambda/hGenLambda"), decayRadius2D, particle.pt());
145+
} else if (particle.pdgCode() == kLambda0Bar) {
146+
histos.fill(HIST("AntiLambda/hGenAntiLambda"), decayRadius2D, particle.pt());
147+
} else if (particle.pdgCode() == kXiMinus) {
148+
histos.fill(HIST("Xi/hGenXi"), decayRadius2D, particle.pt());
149+
} else if (particle.pdgCode() == kXiPlusBar) {
150+
histos.fill(HIST("AntiXi/hGenAntiXi"), decayRadius2D, particle.pt());
151+
} else if (particle.pdgCode() == kOmegaMinus) {
152+
histos.fill(HIST("Omega/hGenOmega"), decayRadius2D, particle.pt());
153+
} else if (particle.pdgCode() == kOmegaPlusBar) {
154+
histos.fill(HIST("AntiOmega/hGenAntiOmega"), decayRadius2D, particle.pt());
155+
}
156+
118157
for (size_t i = 0; i < decayDaughters.size(); ++i) {
119-
isFinalState.push_back(!canDecay(decayDaughters[i].pdgCode));
158+
const o2::upgrade::OTFParticle& dau = decayDaughters[i];
159+
const bool isAlive = !canDecay(dau.pdgCode);
160+
tableMcParticles(particle.globalIndex(),
161+
isAlive, dau.pdgCode,
162+
dau.vx, dau.vy, dau.vz,
163+
dau.px, dau.py, dau.pz);
120164
}
121165
}
122166
}

0 commit comments

Comments
 (0)