Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:01

0001 // Tell emacs that this is a C++ source
0002 // -*- C++ -*-.
0003 
0004 #ifndef G4EVAL_TRACKEVALUATIONCONTAINERV1_H
0005 #define G4EVAL_TRACKEVALUATIONCONTAINERV1_H
0006 
0007 /*!
0008  * \file TrackEvaluationContainerv1.h
0009  * \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0010  */
0011 
0012 #include "TrackEvaluationContainer.h"
0013 
0014 #include <vector>
0015 
0016 //! track evaluation container
0017 /*!
0018   Contains:
0019   - some global quantities, such as number of clusters in tracking detectors
0020   - relevant information on clusters,
0021   - relevant information on tracks, including redundant information about participating clusters
0022   Each of those can be turned on/off using flags in the filling module at runtime
0023 
0024   IMPORTANT NOTE: do not modify and commit neither this class or subclasses.
0025   This will render past DSTs containing the container unreadible
0026   If you plan permanent modification to the class you need to create a TrackEvaluationContainerv2,
0027   copy the relevant code from this one there and modify the TrackEvaluation module in order to use the new container
0028 */
0029 class TrackEvaluationContainerv1 : public TrackEvaluationContainer
0030 {
0031  public:
0032   //! constructor
0033   explicit TrackEvaluationContainerv1()
0034   {
0035     // only one event structure per event (!)
0036     m_events.reserve(1);
0037   }
0038 
0039   //! reset
0040   void Reset() override;
0041 
0042   //! event information
0043   /*! do not modify and commit: this will break reading past DSTs */
0044   class EventStruct
0045   {
0046    public:
0047     using List = std::vector<EventStruct>;
0048     static constexpr size_t max_layer = 57;
0049 
0050     // constructor
0051     EventStruct()
0052     {
0053       for (size_t i = 0; i < max_layer; ++i)
0054       {
0055         nclusters[i] = 0;
0056       }
0057     }
0058 
0059     //! number of clusters per layer / event
0060     int nclusters[max_layer];
0061 
0062     //! number of clusters in the TPC
0063     int nclusters_mvtx = 0;
0064 
0065     //! number of clusters in the intt
0066     int nclusters_intt = 0;
0067 
0068     //! number of clusters in the TPC
0069     int nclusters_tpc = 0;
0070 
0071     //! number of clusters in the Micromegas
0072     int nclusters_micromegas = 0;
0073   };
0074 
0075   //! cluster information
0076   /*! do not modify and commit: this will break reading past DSTs */
0077   class ClusterStruct
0078   {
0079    public:
0080     using List = std::vector<ClusterStruct>;
0081 
0082     //! cluster layer
0083     unsigned int layer = 0;
0084 
0085     //! number of hits belonging to the cluster
0086     unsigned int size = 0;
0087 
0088     //! number of g4hits associated to this cluster
0089     unsigned int truth_size = 0;
0090 
0091     //! number of hits along phi and along z
0092     int phi_size = 0;
0093     int z_size = 0;
0094 
0095     //! cluster charge
0096     unsigned int adc = 0;
0097     unsigned int max_adc = 0;
0098     //! cluster quality info
0099     int ovlp = 0;
0100     int edge = 0;
0101 
0102     //!@name cluster position
0103     //@{
0104     float x = 0;
0105     float y = 0;
0106     float z = 0;
0107     float r = 0;
0108     float phi = 0;
0109     float phi_error = 0;
0110     float z_error = 0;
0111     float para_phi_error = 0;
0112     float para_z_error = 0;
0113     //@}
0114 
0115     //!@name track position at cluster
0116     //@{
0117     float trk_x = 0;
0118     float trk_y = 0;
0119     float trk_z = 0;
0120     float trk_r = 0;
0121     float trk_phi = 0;
0122 
0123     //! track errors
0124     float trk_phi_error = 0;
0125     float trk_z_error = 0;
0126 
0127     //! track inclination at cluster in r,phi plane
0128     float trk_alpha = 0;
0129 
0130     //! track inclination at cluster in r,z plane
0131     float trk_beta = 0;
0132 
0133     //! track radius
0134     float trk_radius = 0;
0135 
0136     //@}
0137 
0138     //!@name truth position
0139     //@{
0140     float truth_x = 0;
0141     float truth_y = 0;
0142     float truth_z = 0;
0143     float truth_r = 0;
0144     float truth_phi = 0;
0145 
0146     //! track inclination at cluster in r,phi plane
0147     float truth_alpha = 0;
0148 
0149     //! track inclination at cluster in r,z plane
0150     float truth_beta = 0;
0151     //@}
0152 
0153     //!@name charges
0154     //@{
0155 
0156     //* maximum charge on strip
0157     float energy_max = 0;
0158 
0159     //* sum of strip charges
0160     float energy_sum = 0;
0161 
0162     //@}
0163 
0164     //!@name track local momentum information
0165     //! TODO: in principle trk_alpha and trk_beta can be calculated from those. There should be no need to store them
0166     //@{
0167     float trk_px = 0;
0168     float trk_py = 0;
0169     float trk_pz = 0;
0170     //@}
0171 
0172     //!@name truth local momentum information
0173     //! TODO: in principle truth_alpha and truth_beta can be calculated from those. There should be no need to store them
0174     //@{
0175     float truth_px = 0;
0176     float truth_py = 0;
0177     float truth_pz = 0;
0178     //@}
0179   };
0180 
0181   //! track information
0182   /*! do not modify and commit: this will break reading past DSTs */
0183   class TrackStruct
0184   {
0185    public:
0186     // constructor
0187     explicit TrackStruct()
0188     {
0189       // allocate enough size for the clusters
0190       static constexpr int max_layers = 60;
0191       clusters.reserve(max_layers);
0192     }
0193 
0194     using List = std::vector<TrackStruct>;
0195 
0196     int charge = 0;
0197     int nclusters = 0;
0198     int64_t mask = 0;
0199 
0200     int nclusters_mvtx = 0;
0201     int nclusters_intt = 0;
0202     int nclusters_tpc = 0;
0203     int nclusters_micromegas = 0;
0204 
0205     float chisquare = 0;
0206     int ndf = 0;
0207 
0208     //!@name position
0209     //@{
0210     float x = 0;
0211     float y = 0;
0212     float z = 0;
0213     float r = 0;
0214     float phi = 0;
0215     //@}
0216 
0217     //!@name momentum
0218     //@{
0219     float px = 0;
0220     float py = 0;
0221     float pz = 0;
0222     float pt = 0;
0223     float p = 0;
0224     float eta = 0;
0225     //@}
0226 
0227     //!@name truth momentum
0228     //@{
0229     int pid = 0;
0230     int embed = 0;
0231     bool is_primary = false;
0232     int gtrackID = 0;
0233     float truth_t = 0;
0234 
0235     // number of g4hits from this MC track that match
0236     int contributors = 0;
0237 
0238     float truth_px = 0;
0239     float truth_py = 0;
0240     float truth_pz = 0;
0241     float truth_pt = 0;
0242     float truth_p = 0;
0243     float truth_eta = 0;
0244     //@}
0245 
0246     // associate clusters
0247     ClusterStruct::List clusters;
0248   };
0249 
0250   //!@name accessors
0251   //@{
0252 
0253   const EventStruct::List& events() const
0254   {
0255     return m_events;
0256   }
0257 
0258   const ClusterStruct::List& clusters() const
0259   {
0260     return m_clusters;
0261   }
0262 
0263   const TrackStruct::List& tracks() const
0264   {
0265     return m_tracks;
0266   }
0267 
0268   //@}
0269 
0270   //!@name modifiers
0271   //@{
0272 
0273   void addEvent(const EventStruct& event)
0274   {
0275     m_events.push_back(event);
0276   }
0277 
0278   void addCluster(const ClusterStruct& cluster)
0279   {
0280     m_clusters.push_back(cluster);
0281   }
0282 
0283   void addTrack(const TrackStruct& track)
0284   {
0285     m_tracks.push_back(track);
0286   }
0287 
0288   void clearEvents()
0289   {
0290     m_events.clear();
0291   }
0292 
0293   void clearClusters()
0294   {
0295     m_clusters.clear();
0296   }
0297 
0298   void clearTracks()
0299   {
0300     m_tracks.clear();
0301   }
0302 
0303   //@}
0304 
0305  private:
0306   //! event struct
0307   /* there is only one element per event in this array */
0308   EventStruct::List m_events;
0309 
0310   //! clusters array
0311   ClusterStruct::List m_clusters;
0312 
0313   //! tracks array
0314   TrackStruct::List m_tracks;
0315 
0316   ClassDefOverride(TrackEvaluationContainerv1, 1)
0317 };
0318 
0319 #endif