29#include "Tracking/Sim/LdmxSpacePoint.h"
32#include "Tracking/Event/Track.h"
35#include "Acts/Definitions/Algebra.hpp"
36#include "Acts/Definitions/PdgParticle.hpp"
37#include "Acts/Definitions/TrackParametrization.hpp"
38#include "Acts/Definitions/Units.hpp"
39#include "Acts/EventData/TrackParameters.hpp"
40#include "Acts/Surfaces/PerigeeSurface.hpp"
41#include "Acts/Surfaces/PlaneSurface.hpp"
42#include "Tracking/Event/Measurement.h"
43#include "Tracking/Sim/IndexSourceLink.h"
77 unsigned int sensorId = 0;
78 unsigned int layerId = 0;
107 unsigned int index = vol * 1000 + layerId * 100 + sensorId;
110 std::cout <<
"LdmxSpacePointConverter::Check index::" << vol <<
"--"
111 << layerId <<
"--" << sensorId <<
"==>" << index << std::endl;
131 double sigma_v = 1.) {
132 unsigned int index = getSensorID(hit);
140 index, hit.
getEdep(), sigma_u * sigma_u,
141 sigma_v * sigma_v, hit.
getID());
147inline void flatCov(Acts::BoundSquareMatrix cov, std::vector<double>& v_cov) {
149 v_cov.reserve(cov.rows() * (cov.rows() + 1) / 2);
150 for (
int i = 0; i < cov.rows(); i++)
151 for (
int j = i; j < cov.cols(); j++) v_cov.push_back(cov(i, j));
154inline Acts::BoundSquareMatrix unpackCov(
const std::vector<double>& v_cov) {
155 Acts::BoundSquareMatrix cov;
157 for (
int i = 0; i < cov.rows(); i++)
158 for (
int j = i; j < cov.cols(); j++) {
159 cov(i, j) = v_cov.at(e);
160 cov(j, i) = cov(i, j);
174inline Acts::Vector3 Ldmx2Acts(Acts::Vector3 ldmx_v) {
176 Acts::SquareMatrix3 acts_rot;
177 acts_rot << 0., 0., 1., 1., 0., 0., 0., 1, 0.;
179 return acts_rot * ldmx_v;
184inline Acts::FreeVector toFreeParameters(Acts::Vector3 pos, Acts::Vector3 mom,
185 Acts::ActsScalar q) {
186 Acts::FreeVector free_params;
187 Acts::ActsScalar p = mom.norm() * Acts::UnitConstants::MeV;
189 free_params[Acts::eFreePos0] = pos(Acts::ePos0) * Acts::UnitConstants::mm;
190 free_params[Acts::eFreePos1] = pos(Acts::ePos1) * Acts::UnitConstants::mm;
191 free_params[Acts::eFreePos2] = pos(Acts::ePos2) * Acts::UnitConstants::mm;
192 free_params[Acts::eFreeTime] = 0.;
193 free_params[Acts::eFreeDir0] = mom(0) / mom.norm();
194 free_params[Acts::eFreeDir1] = mom(1) / mom.norm();
195 free_params[Acts::eFreeDir2] = mom(2) / mom.norm();
196 free_params[Acts::eFreeQOverP] =
197 (q != Acts::ActsScalar(0)) ? (q / p) : 0.;
205inline std::vector<double> convertActsToLdmxPars(Acts::BoundVector acts_par) {
206 std::vector<double> v_ldmx(
207 acts_par.data(), acts_par.data() + acts_par.rows() * acts_par.cols());
211inline Acts::BoundVector boundState(
const ldmx::Track& trk) {
212 Acts::BoundVector paramVec;
213 paramVec << trk.getD0(), trk.getZ0(), trk.getPhi(), trk.getTheta(),
214 trk.getQoP(), trk.getT();
219 Acts::BoundVector paramVec;
220 paramVec << ts.params[0], ts.params[1], ts.params[2], ts.params[3],
221 ts.params[4], ts.params[5];
225inline Acts::BoundTrackParameters boundTrackParameters(
226 const ldmx::Track& trk, std::shared_ptr<Acts::PerigeeSurface> perigee) {
227 Acts::BoundVector paramVec = boundState(trk);
228 Acts::BoundSquareMatrix covMat = unpackCov(trk.getPerigeeCov());
229 auto partHypo{Acts::SinglyChargedParticleHypothesis::electron()};
234 return Acts::BoundTrackParameters(perigee, paramVec, std::move(covMat),
239 std::shared_ptr<Acts::Surface> surf,
241 Acts::BoundVector paramVec = boundState(ts);
242 Acts::BoundSquareMatrix covMat = unpackCov(ts.cov);
243 auto partHypo{Acts::SinglyChargedParticleHypothesis::electron()};
246 return Acts::BoundTrackParameters(surf, paramVec, std::move(covMat),
251inline const std::shared_ptr<Acts::PlaneSurface> unboundSurface(
252 double xloc,
double yloc = 0.,
double zloc = 0.) {
259 Acts::RotationMatrix3 surf_rotation = Acts::RotationMatrix3::Zero();
261 surf_rotation(1, 0) = 1;
263 surf_rotation(2, 1) = 1;
265 surf_rotation(0, 2) = 1;
267 Acts::Vector3 pos(xloc, yloc, zloc);
268 Acts::Translation3 surf_translation(pos);
269 Acts::Transform3 surf_transform(surf_translation * surf_rotation);
272 const std::shared_ptr<Acts::PlaneSurface> target_surface =
273 Acts::Surface::makeShared<Acts::PlaneSurface>(surf_transform);
275 return Acts::Surface::makeShared<Acts::PlaneSurface>(surf_transform);
279inline std::size_t sourceLinkHash(
const Acts::SourceLink& a) {
280 return static_cast<std::size_t
>(
285inline bool sourceLinkEquality(
const Acts::SourceLink& a,
286 const Acts::SourceLink& b) {
Class which encapsulates information from a hit in a simulated tracking detector.
A source link that stores just an index.
constexpr Index index() const
Access the index.
Represents a simulated tracker hit in the simulation.
int getModuleID() const
Get the module ID associated with a hit.
float getEdep() const
Get the energy deposited on the hit [MeV].
std::vector< float > getPosition() const
Get the XYZ position of the hit [mm].
int getID() const
Get the detector ID of the hit.
float getTime() const
Get the global time of the hit [ns].
int getLayerID() const
Get the geometric layer ID of the hit.
Implementation of a track object.
The measurement calibrator can be a function or a class/struct able to retrieve the sim hits containe...