Skip to content

Commit c4e2827

Browse files
committed
Update
1 parent 5fffa74 commit c4e2827

File tree

2 files changed

+61
-56
lines changed

2 files changed

+61
-56
lines changed

ALICE3/Core/TrackUtilities.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "ReconstructionDataFormats/Track.h"
2323
#include "Framework/O2DatabasePDGPlugin.h"
2424
#include "Framework/AnalysisHelpers.h"
25+
#include "TLorentzVector.h"
2526

2627
namespace o2::upgrade
2728
{
@@ -62,7 +63,38 @@ o2::track::TrackParCov convertMCParticleToO2Track(McParticleType& particle,
6263
const o2::framework::Service<o2::framework::O2DatabasePDG>& pdg)
6364
{
6465
o2::track::TrackParCov o2track;
65-
convertMCParticleToO2Track(particle, o2track, pdg);
66+
return convertMCParticleToO2Track(particle, o2track, pdg);
67+
}
68+
69+
/// Function to convert a TLorentzVector into a perfect Track
70+
/// \param pdgCode particle pdg
71+
/// \param particle the particle to convert (TLorentzVector)
72+
/// \param productionVertex where the particle was produced
73+
/// \param o2track the address of the resulting TrackParCov
74+
void convertTLorentzVectorToO2Track(int pdgCode,
75+
TLorentzVector particle,
76+
std::vector<double> productionVertex,
77+
o2::track::TrackParCov& o2track,
78+
const o2::framework::Service<o2::framework::O2DatabasePDG>& pdg)
79+
{
80+
const auto pdgInfo = pdg->GetParticle(pdgCode);
81+
int charge = 0;
82+
if (pdgInfo != nullptr) {
83+
charge = pdgInfo->Charge() / 3;
84+
}
85+
std::array<float, 5> params;
86+
std::array<float, 15> covm = {0.};
87+
float s, c, x;
88+
o2::math_utils::sincos(static_cast<float>(particle.Phi()), s, c);
89+
o2::math_utils::rotateZInv(static_cast<float>(productionVertex[0]), static_cast<float>(productionVertex[1]), x, params[0], s, c);
90+
params[1] = static_cast<float>(productionVertex[2]);
91+
params[2] = 0;
92+
const auto theta = 2. * std::atan(std::exp(-particle.PseudoRapidity()));
93+
params[3] = 1. / std::tan(theta);
94+
params[4] = charge / particle.Pt();
95+
96+
// Initialize TrackParCov in-place
97+
new (&o2track)(o2::track::TrackParCov)(x, particle.Phi(), params, covm);
6698
}
6799

68100
} // namespace o2::upgrade

ALICE3/TableProducer/OTF/onTheFlyTracker.cxx

Lines changed: 28 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ struct OnTheFlyTracker {
8181
Produces<aod::TracksDCA> tracksDCA;
8282
Produces<aod::TracksDCACov> tracksDCACov;
8383
Produces<aod::CollisionsAlice3> collisionsAlice3;
84-
Produces<aod::TracksAlice3> TracksAlice3;
85-
Produces<aod::TracksExtraA3> TracksExtraA3;
84+
Produces<aod::TracksAlice3> tracksAlice3;
85+
Produces<aod::TracksExtraA3> tracksExtraA3;
8686
Produces<aod::UpgradeCascades> upgradeCascades;
8787

8888
// optionally produced, empty (to be tuned later)
@@ -450,42 +450,42 @@ struct OnTheFlyTracker {
450450
void decayParticle(McParticleType particle, o2::track::TrackParCov track, std::vector<TLorentzVector>& decayDaughters, std::vector<double>& xiDecayVertex, std::vector<double>& laDecayVertex)
451451
{
452452
double u = rand.Uniform(0, 1);
453-
double xi_mass = o2::constants::physics::MassXiMinus;
454-
double la_mass = o2::constants::physics::MassLambda;
455-
double pi_mass = o2::constants::physics::MassPionCharged;
456-
double pr_mass = o2::constants::physics::MassProton;
457-
458-
double xi_gamma = 1 / sqrt(1 + (particle.p() * particle.p()) / (xi_mass * xi_mass));
459-
double xi_ctau = 4.91 * xi_gamma;
460-
double xi_rxyz = (-xi_ctau * log(1 - u));
453+
static constexpr double xiMass = o2::constants::physics::MassXiMinus;
454+
static constexpr double laMass = o2::constants::physics::MassLambda;
455+
static constexpr double piMass = o2::constants::physics::MassPionCharged;
456+
static constexpr double prMass = o2::constants::physics::MassProton;
457+
458+
double xiGamma = 1 / sqrt(1 + (particle.p() * particle.p()) / (xiMass * xiMass));
459+
double xiCtau = 4.91 * xiGamma;
460+
double xiRxyz = (-xiCtau * log(1 - u));
461461
float sna, csa;
462462
o2::math_utils::CircleXYf_t xi_circle;
463463
track.getCircleParams(magneticField, xi_circle, sna, csa);
464-
double xi_rxy = xi_rxyz / sqrt(1. + track.getTgl() * track.getTgl());
465-
double theta = xi_rxy / xi_circle.rC;
464+
double xiRxy = xiRxyz / sqrt(1. + track.getTgl() * track.getTgl());
465+
double theta = xiRxy / xi_circle.rC;
466466
double newX = ((particle.vx() - xi_circle.xC) * std::cos(theta) - (particle.vy() - xi_circle.yC) * std::sin(theta)) + xi_circle.xC;
467467
double newY = ((particle.vy() - xi_circle.yC) * std::cos(theta) + (particle.vx() - xi_circle.xC) * std::sin(theta)) + xi_circle.yC;
468468
double newPx = particle.px() * std::cos(theta) - particle.py() * std::sin(theta);
469469
double newPy = particle.py() * std::cos(theta) + particle.px() * std::sin(theta);
470470
xiDecayVertex.push_back(newX);
471471
xiDecayVertex.push_back(newY);
472-
xiDecayVertex.push_back(particle.vz() + xi_rxyz * (particle.pz() / particle.p()));
472+
xiDecayVertex.push_back(particle.vz() + xiRxyz * (particle.pz() / particle.p()));
473473

474-
std::vector<double> xiDaughters = {la_mass, pi_mass};
474+
std::vector<double> xiDaughters = {laMass, piMass};
475475
TLorentzVector xi(newPx, newPy, particle.pz(), particle.e());
476476
TGenPhaseSpace xiDecay;
477477
xiDecay.SetDecay(xi, 2, xiDaughters.data());
478478
xiDecay.Generate();
479479
decayDaughters.push_back(*xiDecay.GetDecay(1));
480480
TLorentzVector la = *xiDecay.GetDecay(0);
481481

482-
double la_gamma = 1 / sqrt(1 + (la.P() * la.P()) / (la_mass * la_mass));
483-
double la_ctau = 7.89 * la_gamma;
484-
std::vector<double> laDaughters = {pi_mass, pr_mass};
485-
double la_rxyz = (-la_ctau * log(1 - u));
486-
laDecayVertex.push_back(xiDecayVertex[0] + la_rxyz * (xiDecay.GetDecay(0)->Px() / xiDecay.GetDecay(0)->P()));
487-
laDecayVertex.push_back(xiDecayVertex[1] + la_rxyz * (xiDecay.GetDecay(0)->Py() / xiDecay.GetDecay(0)->P()));
488-
laDecayVertex.push_back(xiDecayVertex[2] + la_rxyz * (xiDecay.GetDecay(0)->Pz() / xiDecay.GetDecay(0)->P()));
482+
double laGamma = 1 / sqrt(1 + (la.P() * la.P()) / (laMass * laMass));
483+
double laCtau = 7.89 * laGamma;
484+
std::vector<double> laDaughters = {piMass, prMass};
485+
double laRxyz = (-laCtau * log(1 - u));
486+
laDecayVertex.push_back(xiDecayVertex[0] + laRxyz * (xiDecay.GetDecay(0)->Px() / xiDecay.GetDecay(0)->P()));
487+
laDecayVertex.push_back(xiDecayVertex[1] + laRxyz * (xiDecay.GetDecay(0)->Py() / xiDecay.GetDecay(0)->P()));
488+
laDecayVertex.push_back(xiDecayVertex[2] + laRxyz * (xiDecay.GetDecay(0)->Pz() / xiDecay.GetDecay(0)->P()));
489489

490490
TGenPhaseSpace laDecay;
491491
laDecay.SetDecay(la, 2, laDaughters.data());
@@ -494,33 +494,6 @@ struct OnTheFlyTracker {
494494
decayDaughters.push_back(*laDecay.GetDecay(1));
495495
}
496496

497-
/// Function to convert a TLorentzVector into a perfect Track
498-
/// \param pdgCode particle pdg
499-
/// \param particle the particle to convert (TLorentzVector)
500-
/// \param productionVertex where the particle was produced
501-
/// \param o2track the address of the resulting TrackParCov
502-
void convertTLorentzVectorToO2Track(int pdgCode, TLorentzVector particle, std::vector<double> productionVertex, o2::track::TrackParCov& o2track)
503-
{
504-
auto pdgInfo = pdgDB->GetParticle(pdgCode);
505-
int charge = 0;
506-
if (pdgInfo != nullptr) {
507-
charge = pdgInfo->Charge() / 3;
508-
}
509-
std::array<float, 5> params;
510-
std::array<float, 15> covm = {0.};
511-
float s, c, x;
512-
o2::math_utils::sincos(static_cast<float>(particle.Phi()), s, c);
513-
o2::math_utils::rotateZInv(static_cast<float>(productionVertex[0]), static_cast<float>(productionVertex[1]), x, params[0], s, c);
514-
params[1] = static_cast<float>(productionVertex[2]);
515-
params[2] = 0;
516-
auto theta = 2. * std::atan(std::exp(-particle.PseudoRapidity()));
517-
params[3] = 1. / std::tan(theta);
518-
params[4] = charge / particle.Pt();
519-
520-
// Initialize TrackParCov in-place
521-
new (&o2track)(o2::track::TrackParCov)(x, particle.Phi(), params, covm);
522-
}
523-
524497
float dNdEta = 0.f; // Charged particle multiplicity to use in the efficiency evaluation
525498
void process(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles)
526499
{
@@ -649,9 +622,9 @@ struct OnTheFlyTracker {
649622
continue;
650623
}
651624

652-
convertTLorentzVectorToO2Track(-211, decayProducts[0], xiDecayVertex, xiDaughterTrackParCovsPerfect[0]);
653-
convertTLorentzVectorToO2Track(-211, decayProducts[1], laDecayVertex, xiDaughterTrackParCovsPerfect[1]);
654-
convertTLorentzVectorToO2Track(2212, decayProducts[2], laDecayVertex, xiDaughterTrackParCovsPerfect[2]);
625+
o2::upgrade::convertTLorentzVectorToO2Track(-211, decayProducts[0], xiDecayVertex, xiDaughterTrackParCovsPerfect[0], pdgDB);
626+
o2::upgrade::convertTLorentzVectorToO2Track(-211, decayProducts[1], laDecayVertex, xiDaughterTrackParCovsPerfect[1], pdgDB);
627+
o2::upgrade::convertTLorentzVectorToO2Track(2212, decayProducts[2], laDecayVertex, xiDaughterTrackParCovsPerfect[2], pdgDB);
655628

656629
for (int i = 0; i < 3; i++) {
657630
isReco[i] = false;
@@ -1059,7 +1032,7 @@ struct OnTheFlyTracker {
10591032
trackParCov.getSigmaTgl2(), trackParCov.getSigma1PtY(), trackParCov.getSigma1PtZ(), trackParCov.getSigma1PtSnp(), trackParCov.getSigma1PtTgl(),
10601033
trackParCov.getSigma1Pt2());
10611034
tracksLabels(trackParCov.mcLabel, 0);
1062-
TracksExtraA3(trackParCov.nSiliconHits, trackParCov.nTPCHits);
1035+
tracksExtraA3(trackParCov.nSiliconHits, trackParCov.nTPCHits);
10631036

10641037
// populate extra tables if required to do so
10651038
if (populateTracksExtra) {
@@ -1072,7 +1045,7 @@ struct OnTheFlyTracker {
10721045
trackSelection(static_cast<uint8_t>(0), false, false, false, false, false, false);
10731046
trackSelectionExtension(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false);
10741047
}
1075-
TracksAlice3(true);
1048+
tracksAlice3(true);
10761049
}
10771050
// populate ghost tracks
10781051
for (const auto& trackParCov : ghostTracksAlice3) {
@@ -1108,7 +1081,7 @@ struct OnTheFlyTracker {
11081081
trackParCov.getSigmaTgl2(), trackParCov.getSigma1PtY(), trackParCov.getSigma1PtZ(), trackParCov.getSigma1PtSnp(), trackParCov.getSigma1PtTgl(),
11091082
trackParCov.getSigma1Pt2());
11101083
tracksLabels(trackParCov.mcLabel, 0);
1111-
TracksExtraA3(trackParCov.nSiliconHits, trackParCov.nTPCHits);
1084+
tracksExtraA3(trackParCov.nSiliconHits, trackParCov.nTPCHits);
11121085

11131086
// populate extra tables if required to do so
11141087
if (populateTracksExtra) {
@@ -1121,7 +1094,7 @@ struct OnTheFlyTracker {
11211094
trackSelection(static_cast<uint8_t>(0), false, false, false, false, false, false);
11221095
trackSelectionExtension(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false);
11231096
}
1124-
TracksAlice3(false);
1097+
tracksAlice3(false);
11251098
}
11261099

11271100
for (const auto& cascade : cascadesAlice3) {

0 commit comments

Comments
 (0)