25 #include <TMathBase.h>
33 m_inputChain =
new TChain(
m_cfg.treeName.c_str());
35 if (
m_cfg.filePath.empty()) {
36 throw std::invalid_argument(
"Missing input filename");
39 m_outputTrackParameters.initialize(
m_cfg.outputTracks);
40 m_outputParticles.initialize(
m_cfg.outputParticles);
43 m_inputChain->SetBranchAddress(
"event_nr", &m_eventNr);
44 m_inputChain->SetBranchAddress(
"multiTraj_nr", &m_multiTrajNr);
45 m_inputChain->SetBranchAddress(
"subTraj_nr", &m_subTrajNr);
48 m_inputChain->SetBranchAddress(
"nStates", &m_nStates);
50 m_inputChain->SetBranchAddress(
"nOutliers", &
m_nOutliers);
51 m_inputChain->SetBranchAddress(
"nHoles", &
m_nHoles);
52 m_inputChain->SetBranchAddress(
"chi2Sum", &m_chi2Sum);
53 m_inputChain->SetBranchAddress(
"NDF", &m_NDF);
54 m_inputChain->SetBranchAddress(
"measurementChi2", &m_measurementChi2);
55 m_inputChain->SetBranchAddress(
"outlierChi2", &m_outlierChi2);
56 m_inputChain->SetBranchAddress(
"measurementVolume", &m_measurementVolume);
57 m_inputChain->SetBranchAddress(
"measurementLayer", &m_measurementLayer);
58 m_inputChain->SetBranchAddress(
"outlierVolume", &m_outlierVolume);
59 m_inputChain->SetBranchAddress(
"outlierLayer", &m_outlierLayer);
61 m_inputChain->SetBranchAddress(
"majorityParticleId", &m_majorityParticleId);
62 m_inputChain->SetBranchAddress(
"nMajorityHits", &m_nMajorityHits);
63 m_inputChain->SetBranchAddress(
"t_charge", &m_t_charge);
64 m_inputChain->SetBranchAddress(
"t_time", &m_t_time);
65 m_inputChain->SetBranchAddress(
"t_vx", &m_t_vx);
66 m_inputChain->SetBranchAddress(
"t_vy", &m_t_vy);
67 m_inputChain->SetBranchAddress(
"t_vz", &m_t_vz);
68 m_inputChain->SetBranchAddress(
"t_px", &m_t_px);
69 m_inputChain->SetBranchAddress(
"t_py", &m_t_py);
70 m_inputChain->SetBranchAddress(
"t_pz", &m_t_pz);
71 m_inputChain->SetBranchAddress(
"t_theta", &m_t_theta);
72 m_inputChain->SetBranchAddress(
"t_phi", &m_t_phi);
73 m_inputChain->SetBranchAddress(
"t_eta", &m_t_eta);
74 m_inputChain->SetBranchAddress(
"t_pT", &m_t_pT);
76 m_inputChain->SetBranchAddress(
"hasFittedParams", &m_hasFittedParams);
77 m_inputChain->SetBranchAddress(
"eLOC0_fit", &m_eLOC0_fit);
78 m_inputChain->SetBranchAddress(
"eLOC1_fit", &m_eLOC1_fit);
79 m_inputChain->SetBranchAddress(
"ePHI_fit", &m_ePHI_fit);
80 m_inputChain->SetBranchAddress(
"eTHETA_fit", &m_eTHETA_fit);
81 m_inputChain->SetBranchAddress(
"eQOP_fit", &m_eQOP_fit);
82 m_inputChain->SetBranchAddress(
"eT_fit", &m_eT_fit);
83 m_inputChain->SetBranchAddress(
"err_eLOC0_fit", &m_err_eLOC0_fit);
84 m_inputChain->SetBranchAddress(
"err_eLOC1_fit", &m_err_eLOC1_fit);
85 m_inputChain->SetBranchAddress(
"err_ePHI_fit", &m_err_ePHI_fit);
86 m_inputChain->SetBranchAddress(
"err_eTHETA_fit", &m_err_eTHETA_fit);
87 m_inputChain->SetBranchAddress(
"err_eQOP_fit", &m_err_eQOP_fit);
88 m_inputChain->SetBranchAddress(
"err_eT_fit", &m_err_eT_fit);
93 m_inputChain->Add(
path.c_str());
96 m_events = m_inputChain->GetEntries();
97 ACTS_DEBUG(
"The full chain has " << m_events <<
" entries.");
100 if (not
m_cfg.orderedEvents) {
101 m_entryNumbers.resize(m_events);
102 m_inputChain->Draw(
"event_nr",
"",
"goff");
104 TMath::Sort(m_inputChain->GetEntries(), m_inputChain->GetV1(),
105 m_entryNumbers.data(),
false);
109 std::pair<size_t, size_t>
111 return {0
u, m_events};
115 delete m_multiTrajNr;
123 delete m_measurementChi2;
124 delete m_outlierChi2;
125 delete m_measurementVolume;
126 delete m_measurementLayer;
127 delete m_outlierVolume;
128 delete m_outlierLayer;
129 delete m_majorityParticleId;
130 delete m_nMajorityHits;
143 delete m_hasFittedParams;
150 delete m_err_eLOC0_fit;
151 delete m_err_eLOC1_fit;
152 delete m_err_ePHI_fit;
153 delete m_err_eTHETA_fit;
154 delete m_err_eQOP_fit;
160 ACTS_DEBUG(
"Trying to read recorded tracks.");
163 if (m_inputChain !=
nullptr && context.
eventNumber < m_events) {
165 std::lock_guard<std::mutex> lock(m_read_mutex);
168 std::shared_ptr<Acts::PerigeeSurface> perigeeSurface =
169 Acts::Surface::makeShared<Acts::PerigeeSurface>(
173 std::vector<Acts::BoundTrackParameters> trackParameterCollection;
178 if (not
m_cfg.orderedEvents and
entry < m_entryNumbers.size()) {
181 m_inputChain->GetEntry(
entry);
183 <<
" stored as entry: " <<
entry);
185 unsigned int nTracks = m_eLOC0_fit->size();
186 for (
unsigned int i = 0;
i < nTracks;
i++) {
188 paramVec << (*m_eLOC0_fit)[
i], (*m_eLOC1_fit)[
i], (*m_ePHI_fit)[
i],
189 (*m_eTHETA_fit)[
i], (*m_eQOP_fit)[
i], (*m_eT_fit)[
i];
192 double resD0 = (*m_err_eLOC0_fit)[
i];
193 double resZ0 = (*m_err_eLOC1_fit)[
i];
194 double resPh = (*m_err_ePHI_fit)[
i];
195 double resTh = (*m_err_eTHETA_fit)[
i];
196 double resQp = (*m_err_eQOP_fit)[
i];
197 double resT = (*m_err_eT_fit)[
i];
202 covMat << resD0 * resD0, 0., 0., 0., 0., 0., 0., resZ0 * resZ0, 0., 0.,
203 0., 0., 0., 0., resPh * resPh, 0., 0., 0., 0., 0., 0., resTh * resTh,
204 0., 0., 0., 0., 0., 0., resQp * resQp, 0., 0., 0., 0., 0., 0.,
209 perigeeSurface, paramVec,
std::move(covMat),
213 unsigned int nTruthParticles = m_t_vx->size();
214 for (
unsigned int i = 0;
i < nTruthParticles;
i++) {
217 truthParticle.
setPosition4((*m_t_vx)[
i], (*m_t_vy)[i], (*m_t_vz)[i],
219 truthParticle.
setDirection((*m_t_px)[i], (*m_t_py)[i], (*m_t_pz)[i]);
222 truthParticleCollection.insert(truthParticleCollection.end(),
226 m_outputTrackParameters(context,
std::move(trackParameterCollection));
227 m_outputParticles(context,
std::move(truthParticleCollection));