forked from AliceO2Group/O2Physics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrackUtilities.h
More file actions
136 lines (121 loc) · 4.81 KB
/
TrackUtilities.h
File metadata and controls
136 lines (121 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \file TrackUtilities.h
/// \author Nicolò Jacazio, Universita del Piemonte Orientale (IT)
/// \brief Set of utilities for the ALICE3 track handling
/// \since May 21, 2025
///
#ifndef ALICE3_CORE_TRACKUTILITIES_H_
#define ALICE3_CORE_TRACKUTILITIES_H_
#include "ReconstructionDataFormats/Track.h"
#include "TLorentzVector.h"
#include <vector>
namespace o2::upgrade
{
/// Struct to store mc info for the otf decayer
struct OTFParticle {
int mPdgCode;
float mE;
float mVx, mVy, mVz;
float mPx, mPy, mPz;
// Setters
void setPDG(int pdg) { mPdgCode = pdg; }
void setVxVyVz(float vx, float vy, float vz)
{
mVx = vx;
mVy = vy;
mVz = vz;
}
void setPxPyPzE(float px, float py, float pz, float e)
{
mPx = px;
mPy = py;
mPz = pz;
mE = e;
}
// Getters
int pdgCode() const { return mPdgCode; }
float vx() const { return mVx; }
float vy() const { return mVy; }
float vz() const { return mVz; }
float px() const { return mPx; }
float py() const { return mPy; }
float pz() const { return mPz; }
float e() const { return mE; }
};
/// Function to convert a TLorentzVector into a perfect Track
/// \param charge particle charge (integer)
/// \param particle the particle to convert (TLorentzVector)
/// \param productionVertex where the particle was produced
/// \param o2track the address of the resulting TrackParCov
void convertTLorentzVectorToO2Track(const int charge,
const TLorentzVector particle,
const std::vector<double> productionVertex,
o2::track::TrackParCov& o2track);
/// Function to convert a TLorentzVector into a perfect Track
/// \param pdgCode particle pdg
/// \param particle the particle to convert (TLorentzVector)
/// \param productionVertex where the particle was produced
/// \param o2track the address of the resulting TrackParCov
/// \param pdg the pdg service
template <typename PdgService>
void convertTLorentzVectorToO2Track(int pdgCode,
TLorentzVector particle,
std::vector<double> productionVertex,
o2::track::TrackParCov& o2track,
const PdgService& pdg)
{
const auto pdgInfo = pdg->GetParticle(pdgCode);
int charge = 0;
if (pdgInfo != nullptr) {
charge = pdgInfo->Charge() / 3;
}
convertTLorentzVectorToO2Track(charge, particle, productionVertex, o2track);
}
/// Function to convert a OTFParticle into a perfect Track
/// \param particle the particle to convert (OTFParticle)
/// \param o2track the address of the resulting TrackParCov
/// \param pdg the pdg service
template <typename PdgService>
void convertOTFParticleToO2Track(const OTFParticle& particle, o2::track::TrackParCov& o2track, const PdgService& pdg)
{
static TLorentzVector tlv;
tlv.SetPxPyPzE(particle.px(), particle.py(), particle.pz(), particle.e());
convertTLorentzVectorToO2Track(particle.pdgCode(), tlv, {particle.vx(), particle.vy(), particle.vz()}, o2track, pdg);
}
/// Function to convert a McParticle into a perfect Track
/// \param particle the particle to convert (mcParticle)
/// \param o2track the address of the resulting TrackParCov
/// \param pdg the pdg service
template <typename McParticleType, typename PdgService>
void convertMCParticleToO2Track(McParticleType& particle,
o2::track::TrackParCov& o2track,
const PdgService& pdg)
{
static TLorentzVector tlv;
tlv.SetPxPyPzE(particle.px(), particle.py(), particle.pz(), particle.e());
convertTLorentzVectorToO2Track(particle.pdgCode(), tlv, {particle.vx(), particle.vy(), particle.vz()}, o2track, pdg);
}
/// Function to convert a McParticle into a perfect Track
/// \param particle the particle to convert (mcParticle)
/// \param o2track the address of the resulting TrackParCov
/// \param pdg the pdg service
template <typename McParticleType, typename PdgService>
o2::track::TrackParCov convertMCParticleToO2Track(McParticleType& particle,
const PdgService& pdg)
{
o2::track::TrackParCov o2track;
convertMCParticleToO2Track(particle, o2track, pdg);
return o2track;
}
} // namespace o2::upgrade
#endif // ALICE3_CORE_TRACKUTILITIES_H_