Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:25:18

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include <ActsExamples/EventData/Index.hpp>
0013 #include <ActsExamples/Io/Csv/CsvInputOutput.hpp>
0014 
0015 #include <cstdint>
0016 
0017 namespace ActsExamples {
0018 
0019 struct ParticleData {
0020   /// Event-unique particle identifier a.k.a barcode.
0021   std::uint32_t particle_id_pv = 0;
0022   std::uint32_t particle_id_sv = 0;
0023   std::uint32_t particle_id_part = 0;
0024   std::uint32_t particle_id_gen = 0;
0025   std::uint32_t particle_id_subpart = 0;
0026   /// Particle type number a.k.a. PDG particle number.
0027   std::int32_t particle_type = 0;
0028   /// Production process type. Not available in the TrackML datasets.
0029   std::uint32_t process = 0u;
0030   /// Production position components in mm.
0031   float vx = 0, vy = 0, vz = 0;
0032   // Production time in ns. Not available in the TrackML datasets.
0033   float vt = 0.0f;
0034   /// Momentum components in GeV.
0035   float px = 0, py = 0, pz = 0;
0036   /// Mass in GeV. Not available in the TrackML datasets
0037   float m = 0.0f;
0038   /// Charge in e.
0039   float q = 0;
0040 
0041   DFE_NAMEDTUPLE(ParticleData, particle_id_pv, particle_id_sv, particle_id_part,
0042                  particle_id_gen, particle_id_subpart, particle_type, process,
0043                  vx, vy, vz, vt, px, py, pz, m, q);
0044 };
0045 
0046 struct VertexData {
0047   /// Position
0048   float x = 0, y = 0, z = 0, T = 0;
0049 
0050   DFE_NAMEDTUPLE(VertexData, x, y, z, T);
0051 };
0052 
0053 // Write out simhits before digitization (no hi_id associated)
0054 struct SimHitData {
0055   /// Hit surface identifier. Not available in the TrackML datasets.
0056   std::uint64_t geometry_id = 0u;
0057   /// Event-unique particle identifier of the generating particle.
0058   std::uint32_t particle_id_pv = 0;
0059   std::uint32_t particle_id_sv = 0;
0060   std::uint32_t particle_id_part = 0;
0061   std::uint32_t particle_id_gen = 0;
0062   std::uint32_t particle_id_subpart = 0;
0063   /// True global hit position components in mm.
0064   float tx = 0, ty = 0, tz = 0;
0065   // True global hit time in ns. Not available in the TrackML datasets.
0066   float tt = 0.0f;
0067   /// True particle momentum in GeV before interaction.
0068   float tpx = 0, tpy = 0, tpz = 0;
0069   /// True particle energy in GeV before interaction.
0070   /// Not available in the TrackML datasets.
0071   float te = 0.0f;
0072   /// True four-momentum change in GeV due to interaction.
0073   /// Not available in the TrackML datasets.
0074   float deltapx = 0.0f;
0075   float deltapy = 0.0f;
0076   float deltapz = 0.0f;
0077   float deltae = 0.0f;
0078   // Hit index along the trajectory. Not available in the TrackML datasets.
0079   std::int32_t index = -1;
0080 
0081   DFE_NAMEDTUPLE(SimHitData, particle_id_pv, particle_id_sv, particle_id_part,
0082                  particle_id_gen, particle_id_subpart, geometry_id, tx, ty, tz,
0083                  tt, tpx, tpy, tpz, te, deltapx, deltapy, deltapz, deltae,
0084                  index);
0085 };
0086 
0087 // Write out muon simhits before digitization
0088 struct MuonSegmentData {
0089   /// @brief Identifier hash encoding the spectrometer sector, layer & detector side
0090   int sectorId{0};
0091   /// @brief Position in the global coordinate system
0092   float globalPositionX{0.f};
0093   float globalPositionY{0.f};
0094   float globalPositionZ{0.f};
0095   /// @brief Segment direction in the global coordinate system
0096   float globalDirectionX{0.f};
0097   float globalDirectionY{0.f};
0098   float globalDirectionZ{0.f};
0099   /// @brief Position in the local coordinate system
0100   float localPositionX{0.f};
0101   float localPositionY{0.f};
0102   float localPositionZ{0.f};
0103   /// @brief Segment direction in the local coordinate system
0104   float localDirectionX{0.f};
0105   float localDirectionY{0.f};
0106   float localDirectionZ{0.f};
0107   /// @brief Segment time & associated error
0108   float time{0.f};
0109   float timeError{0.f};
0110   /// @brief segment chi2 & number of degrees of freedom
0111   float chiSquared{0.f};
0112   unsigned nDoF{0u};
0113 
0114   /// @brief how many precision hits are on the segment (Straw tubes or Mm)
0115   unsigned precisionHits{0u};
0116   /// @brief  Complementary hits in the non-bending direction (Rpc / Tgc / sTgc)
0117   unsigned phiLayers{0u};
0118   /// @brief  Complementary hits in the bending direction (Rpc / Tgc)
0119   unsigned trigEtaLayers{0u};
0120   DFE_NAMEDTUPLE(MuonSegmentData, sectorId, globalPositionX, globalPositionY,
0121                  globalPositionZ, globalDirectionX, globalDirectionY,
0122                  globalDirectionZ, localPositionX, localPositionY,
0123                  localPositionZ, localDirectionX, localDirectionY,
0124                  localDirectionZ, time, timeError, chiSquared, nDoF,
0125                  precisionHits, phiLayers, trigEtaLayers);
0126 };
0127 
0128 struct MuonSpacePointData {
0129   /// @brief Identifier hash encoding the spectrometer sector, layer & detector side
0130   int sectorId{0};
0131   /// @brief Number of the associated bucket inside the container. A change of bucket Id
0132   ///         pushes the space point into a new bucket container
0133   int bucketId{0};
0134   /// @brief Local position of the space point measurement
0135   float locPositionX{0.f};
0136   float locPositionY{0.f};
0137   float locPositionZ{0.f};
0138   /// @brief Direction of the sensor line
0139   float locSensorDirX{0.f};
0140   float locSensorDirY{0.f};
0141   float locSensorDirZ{0.f};
0142   /// @brief Direction vector normal pointing to the next sensor
0143   float locToNextSensorX{0.f};
0144   float locToNextSensorY{0.f};
0145   float locToNextSensorZ{0.f};
0146   /// @brief Measurement covariance entries in the local x-y plane
0147   float covX{0.f};
0148   float covY{0.f};
0149   float covT{0.f};
0150   /// @brief Drift radius
0151   float driftR{0.f};
0152   //// @brief Associated gasGap type
0153   unsigned short gasGap{0u};
0154   /// @brief Primary measurement channel
0155   unsigned short primaryCh{0u};
0156   /// @brief Flag toggling whether the measurement is a precision one
0157   bool measuresEta{false};
0158   /// @brief Flag toggling whether the measurement is a non-precision one
0159   bool measuresPhi{false};
0160   /// @brief Flag toggling whether the measurement provides a time coordinate
0161   bool measuresTime{false};
0162   DFE_NAMEDTUPLE(MuonSpacePointData, sectorId, bucketId, locPositionX,
0163                  locPositionY, locPositionZ, locSensorDirX, locSensorDirY,
0164                  locSensorDirZ, locToNextSensorX, locToNextSensorY,
0165                  locToNextSensorZ, covX, covY, covT, driftR, gasGap, primaryCh,
0166                  measuresEta, measuresPhi, measuresTime);
0167 };
0168 
0169 struct TruthHitData {
0170   /// Event-unique hit identifier. As defined for the simulated hit below and
0171   /// used to link back to it; same value can appear multiple times here due to
0172   /// shared hits in dense environments.
0173   std::uint64_t hit_id = 0;
0174   /// Hit surface identifier. Not available in the TrackML datasets.
0175   std::uint64_t geometry_id = 0u;
0176   /// Event-unique particle identifier of the generating particle.
0177   std::uint32_t particle_id_pv = 0;
0178   std::uint32_t particle_id_sv = 0;
0179   std::uint32_t particle_id_part = 0;
0180   std::uint32_t particle_id_gen = 0;
0181   std::uint32_t particle_id_subpart = 0;
0182   /// True global hit position components in mm.
0183   float tx = 0, ty = 0, tz = 0;
0184   // True global hit time in ns. Not available in the TrackML datasets.
0185   float tt = 0.0f;
0186   /// True particle momentum in GeV before interaction.
0187   float tpx = 0, tpy = 0, tpz = 0;
0188   /// True particle energy in GeV before interaction.
0189   /// Not available in the TrackML datasets.
0190   float te = 0.0f;
0191   /// True four-momentum change in GeV due to interaction.
0192   /// Not available in the TrackML datasets.
0193   float deltapx = 0.0f;
0194   float deltapy = 0.0f;
0195   float deltapz = 0.0f;
0196   float deltae = 0.0f;
0197   // Hit index along the trajectory. Not available in the TrackML datasets.
0198   std::int32_t index = -1;
0199 
0200   DFE_NAMEDTUPLE(TruthHitData, hit_id, particle_id_pv, particle_id_sv,
0201                  particle_id_part, particle_id_gen, particle_id_subpart,
0202                  geometry_id, tx, ty, tz, tt, tpx, tpy, tpz, te, deltapx,
0203                  deltapy, deltapz, deltae, index);
0204 };
0205 
0206 struct HitData {
0207   /// Event-unique hit identifier. Each value can appear at most once.
0208   std::uint64_t hit_id = 0;
0209   /// Hit surface identifier. Not available in the TrackML datasets.
0210   std::uint64_t geometry_id = 0u;
0211   /// Global hit position components in mm.
0212   float x = 0, y = 0, z = 0;
0213   /// Global hit time in ns. Not available in the TrackML datasets.
0214   float t = 0.0f;
0215 
0216   DFE_NAMEDTUPLE(HitData, hit_id, geometry_id, x, y, z, t);
0217 };
0218 
0219 struct MeasurementSimHitLink {
0220   /// Event-unique measurement identifier. Each value can appear at most once.
0221   std::uint64_t measurement_id = 0;
0222   /// Event-unique measurement sim hit identifier.
0223   std::uint64_t hit_id = 0;
0224 
0225   DFE_NAMEDTUPLE(MeasurementSimHitLink, measurement_id, hit_id);
0226 };
0227 
0228 struct MeasurementData {
0229   /// Event-unique measurement identifier. Each value can appear at most once.
0230   std::uint64_t measurement_id = 0;
0231   /// Hit surface identifier.
0232   std::uint64_t geometry_id = 0u;
0233   /// Local hit information - bit identification what's measured
0234   std::uint8_t local_key = 0;
0235   float local0 = 0, local1 = 0, phi = 0, theta = 0, time = 0;
0236   float var_local0 = 0, var_local1 = 0, var_phi = 0, var_theta = 0,
0237         var_time = 0;
0238   float global_x = 0, global_y = 0, global_z = 0;
0239 
0240   DFE_NAMEDTUPLE(MeasurementData, measurement_id, geometry_id, local_key,
0241                  local0, local1, phi, theta, time, var_local0, var_local1,
0242                  var_phi, var_theta, var_time, global_x, global_y, global_z);
0243 };
0244 
0245 struct CellData {
0246   /// Hit surface identifier.
0247   std::uint64_t geometry_id = 0u;
0248   /// Event-unique measurement identifier. As defined for the measurement above
0249   /// and used to link back to it; same value can appear multiple times for
0250   /// clusters with more than one active cell.
0251   std::uint64_t measurement_id = 0;
0252   /// Digital cell address/ channel
0253   std::int32_t channel0 = 0, channel1 = 0;
0254   /// Digital cell timestamp. Not available in the TrackML datasets.
0255   float timestamp = 0;
0256   /// (Digital) measured cell value, e.g. amplitude or time-over-threshold.
0257   float value = 0;
0258 
0259   DFE_NAMEDTUPLE(CellData, geometry_id, measurement_id, channel0, channel1,
0260                  timestamp, value);
0261 };
0262 
0263 // uses hit id
0264 struct CellDataLegacy {
0265   /// Hit surface identifier.
0266   std::uint64_t geometry_id = 0u;
0267   /// Event-unique measurement identifier. As defined for the measurement above
0268   /// and used to link back to it; same value can appear multiple times for
0269   /// clusters with more than one active cell.
0270   std::uint64_t hit_id = 0;
0271   /// Digital cell address/ channel
0272   std::int32_t channel0 = 0, channel1 = 0;
0273   /// Digital cell timestamp. Not available in the TrackML datasets.
0274   float timestamp = 0;
0275   /// (Digital) measured cell value, e.g. amplitude or time-over-threshold.
0276   float value = 0;
0277 
0278   DFE_NAMEDTUPLE(CellDataLegacy, geometry_id, hit_id, channel0, channel1,
0279                  timestamp, value);
0280 };
0281 
0282 struct SurfaceData {
0283   /// Surface identifier. Not available in the TrackML datasets.
0284   std::uint64_t geometry_id = 0;
0285   /// Partially decoded surface identifier components.
0286   std::uint32_t volume_id = 0, boundary_id = 0, layer_id = 0, module_id = 0,
0287                 extra_id = 0;
0288   /// Center position components in mm.
0289   float cx = 0, cy = 0, cz = 0;
0290   /// Rotation matrix components.
0291   float rot_xu = 0, rot_xv = 0, rot_xw = 0;
0292   float rot_yu = 0, rot_yv = 0, rot_yw = 0;
0293   float rot_zu = 0, rot_zv = 0, rot_zw = 0;
0294   /// The type of the surface bounds object, determines the parameters filled
0295   int bounds_type = 0;
0296   float bound_param0 = -1.f;
0297   float bound_param1 = -1.f;
0298   float bound_param2 = -1.f;
0299   float bound_param3 = -1.f;
0300   float bound_param4 = -1.f;
0301   float bound_param5 = -1.f;
0302   float bound_param6 = -1.f;
0303 
0304   float module_t = -1.f;
0305   float pitch_u = -1.f;
0306   float pitch_v = -1.f;
0307 
0308   DFE_NAMEDTUPLE(SurfaceData, geometry_id, volume_id, boundary_id, layer_id,
0309                  module_id, extra_id, cx, cy, cz, rot_xu, rot_xv, rot_xw,
0310                  rot_yu, rot_yv, rot_yw, rot_zu, rot_zv, rot_zw, bounds_type,
0311                  bound_param0, bound_param1, bound_param2, bound_param3,
0312                  bound_param4, bound_param5, bound_param6, module_t, pitch_u,
0313                  pitch_v);
0314 };
0315 
0316 struct LayerVolumeData {
0317   /// Surface identifier. Not available in the TrackML datasets.
0318   std::uint64_t geometry_id = 0;
0319   /// Partially decoded surface identifier components.
0320   std::uint32_t volume_id = 0, layer_id = 0;
0321   /// The type of the volume object, determines the parameters filled
0322   int volume_type = 0;
0323   float min_v0 = -1.f;
0324   float max_v0 = -1.f;
0325   float min_v1 = -1.f;
0326   float max_v1 = -1.f;
0327   float min_v2 = -1.f;
0328   float max_v2 = -1.f;
0329 
0330   DFE_NAMEDTUPLE(LayerVolumeData, geometry_id, volume_id, layer_id, min_v0,
0331                  max_v0, min_v1, max_v1, min_v2, max_v2);
0332 };
0333 
0334 struct SpacePointData {
0335   /// Event-unique measurement identifier. Each value can appear at most once.
0336   std::uint64_t measurement_id = 0;
0337   /// Space point information
0338   float sp_x = 0, sp_y = 0, sp_z = 0, sp_radius = 0;
0339   float sp_covr = 0, sp_covz = 0;
0340 
0341   // half of the length of the top strip
0342   float sp_topHalfStripLength = 0;
0343   // half of the length of the bottom strip
0344   float sp_bottomHalfStripLength = 0;
0345   // direction of the top strip
0346   Acts::Vector3 sp_topStripDirection{};
0347   // direction of the bottom strip
0348   Acts::Vector3 sp_bottomStripDirection{};
0349   // distance between the center of the two strips
0350   Acts::Vector3 sp_stripCenterDistance{};
0351   // position of the center of the bottom strip
0352   Acts::Vector3 sp_topStripCenterPosition{};
0353 
0354   DFE_NAMEDTUPLE(SpacePointData, measurement_id, sp_x, sp_y, sp_z, sp_radius,
0355                  sp_covr, sp_covz, sp_topHalfStripLength,
0356                  sp_bottomHalfStripLength, sp_topStripDirection[0],
0357                  sp_topStripDirection[1], sp_topStripDirection[2],
0358                  sp_bottomStripDirection[0], sp_bottomStripDirection[1],
0359                  sp_bottomStripDirection[2], sp_stripCenterDistance[0],
0360                  sp_stripCenterDistance[1], sp_stripCenterDistance[2],
0361                  sp_topStripCenterPosition[0], sp_topStripCenterPosition[1],
0362                  sp_topStripCenterPosition[2]);
0363 };
0364 
0365 struct SurfaceGridData {
0366   /// Surface identifier. Not available in the TrackML datasets.
0367   std::uint64_t geometry_id = 0;
0368   /// Partially decoded surface identifier components.
0369   std::uint32_t volume_id = 0, layer_id = 0, surface_id = 0;
0370   /// The number of bins in loc 0 / 1
0371   int type_loc0 = -1;
0372   int nbins_loc0 = -1;
0373   float min_loc0 = 0, max_loc0 = 0;
0374   int type_loc1 = -1;
0375   int nbins_loc1 = -1;
0376   float min_loc1 = 0, max_loc1 = 0;
0377 
0378   DFE_NAMEDTUPLE(SurfaceGridData, geometry_id, volume_id, layer_id, surface_id,
0379                  type_loc0, nbins_loc0, min_loc0, max_loc0, type_loc1,
0380                  nbins_loc1, min_loc1, max_loc1);
0381 };
0382 
0383 struct SpacepointData {
0384   std::uint64_t measurement_id_1, measurement_id_2;
0385   std::uint64_t geometry_id_1, geometry_id_2;
0386   float x, y, z, t;
0387   float var_r, var_z;
0388   DFE_NAMEDTUPLE(SpacepointData, measurement_id_1, measurement_id_2,
0389                  geometry_id_1, geometry_id_2, x, y, z, t, var_r, var_z);
0390 };
0391 
0392 struct TrackParameterData {
0393   std::size_t trackId;
0394   double d0;
0395   double z0;
0396   double phi;
0397   double theta;
0398   double qop;
0399 
0400   double var_d0, var_z0, var_phi, var_theta, var_qop;
0401 
0402   double cov_d0z0, cov_d0phi, cov_d0theta, cov_d0qop;
0403   double cov_z0d0, cov_z0phi, cov_z0theta, cov_z0qop;
0404   double cov_phid0, cov_phiz0, cov_phitheta, cov_phiqop;
0405   double cov_thetad0, cov_thetaz0, cov_thetaphi, cov_thetaqop;
0406   double cov_qopd0, cov_qopz0, cov_qopphi, cov_qoptheta;
0407 
0408   DFE_NAMEDTUPLE(TrackParameterData, trackId, d0, z0, phi, theta, qop, var_d0,
0409                  var_z0, var_phi, var_theta, var_qop, cov_d0z0, cov_d0phi,
0410                  cov_d0theta, cov_d0qop, cov_z0d0, cov_z0phi, cov_z0theta,
0411                  cov_z0qop, cov_phid0, cov_phiz0, cov_phitheta, cov_phiqop,
0412                  cov_thetad0, cov_thetaz0, cov_thetaphi, cov_thetaqop,
0413                  cov_qopd0, cov_qopz0, cov_qopphi, cov_qoptheta);
0414 };
0415 
0416 struct ProtoTrackData {
0417   std::size_t trackId;
0418   Index measurementId;
0419   double x, y, z;
0420 
0421   DFE_NAMEDTUPLE(ProtoTrackData, trackId, measurementId, x, y, z);
0422 };
0423 
0424 struct GraphData {
0425   std::int64_t edge0 = 0;
0426   std::int64_t edge1 = 0;
0427   float weight = 0.0;
0428   DFE_NAMEDTUPLE(GraphData, edge0, edge1, weight);
0429 };
0430 
0431 struct SpacePointBucketData {
0432   /// @brief Data structure for space point buckets
0433   /// @details A bucket is a collection of space points
0434   ///        Different buckets can contain the same space point
0435   ///        Measurement IDs are used to uniquely identify space points
0436 
0437   /// Bucket index
0438   std::uint64_t bucketIdx;
0439   /// Bucket size (number of space points)
0440   std::uint64_t bucketSize;
0441 
0442   /// Measurement IDs of the space points in the bucket
0443   /// To allow for variable size, the bucket data is split into several lines
0444   /// A line can contain up to 20 space points (arbitrary number)
0445   std::array<std::uint64_t, 20> measurement_id;
0446 
0447   DFE_NAMEDTUPLE(SpacePointBucketData, bucketIdx, bucketSize, measurement_id[0],
0448                  measurement_id[1], measurement_id[2], measurement_id[3],
0449                  measurement_id[4], measurement_id[5], measurement_id[6],
0450                  measurement_id[7], measurement_id[8], measurement_id[9],
0451                  measurement_id[10], measurement_id[11], measurement_id[12],
0452                  measurement_id[13], measurement_id[14], measurement_id[15],
0453                  measurement_id[16], measurement_id[17], measurement_id[18],
0454                  measurement_id[19]);
0455 };
0456 
0457 }  // namespace ActsExamples