Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:19:13

0001 #ifndef G4EVAL_TRACKEVALUATION_H
0002 #define G4EVAL_TRACKEVALUATION_H
0003 
0004 /*!
0005  * \file TrackEvaluation.h
0006  * \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0007  */
0008 
0009 #include "TrackEvaluationContainerv1.h"
0010 
0011 #include <fun4all/SubsysReco.h>
0012 
0013 #include <trackbase/ClusterErrorPara.h>
0014 #include <trackbase/TrkrDefs.h>
0015 
0016 #include <trackbase_historic/SvtxTrackState.h>
0017 
0018 #include <map>
0019 #include <set>
0020 #include <string>
0021 #include <vector>
0022 
0023 class ActsGeometry;
0024 class PHG4TpcCylinderGeomContainer;
0025 class PHG4CylinderGeomContainer;
0026 class PHG4Hit;
0027 class PHG4HitContainer;
0028 class PHG4Particle;
0029 class PHG4TruthInfoContainer;
0030 class SvtxTrack;
0031 class SvtxTrackMap;
0032 class TrkrCluster;
0033 class TrkrClusterContainer;
0034 class TrkrClusterHitAssoc;
0035 class TrkrHitSetContainer;
0036 class TrkrHitTruthAssoc;
0037 
0038 class TrackEvaluation : public SubsysReco
0039 {
0040  public:
0041   //! constructor
0042   TrackEvaluation(const std::string& = "TrackEvaluation");
0043 
0044   //! global initialization
0045   int Init(PHCompositeNode*) override;
0046 
0047   //! run initialization
0048   int InitRun(PHCompositeNode*) override;
0049 
0050   //! event processing
0051   int process_event(PHCompositeNode*) override;
0052 
0053   //! end of processing
0054   int End(PHCompositeNode*) override;
0055 
0056   enum Flags
0057   {
0058     EvalEvent = 1 << 0,
0059     EvalClusters = 1 << 1,
0060     EvalTracks = 1 << 2
0061   };
0062 
0063   //! set flags. Should be a bitwise or of Flags enum
0064   void set_flags(int flags)
0065   {
0066     m_flags = flags;
0067   }
0068 
0069  private:
0070   //! load nodes
0071   int load_nodes(PHCompositeNode*);
0072 
0073   //! evaluate event
0074   void evaluate_event();
0075 
0076   //! evaluate clusters
0077   void evaluate_clusters();
0078 
0079   //! evaluate tracks
0080   void evaluate_tracks();
0081 
0082   // get geant hits associated to a cluster
0083   using G4HitSet = std::set<PHG4Hit*>;
0084   G4HitSet find_g4hits(TrkrDefs::cluskey) const;
0085   G4HitSet find_g4hits(TrkrDefs::cluskey, int id) const;
0086 
0087   //! get G4Particle id of max contributor to a given track
0088   std::pair<int, int> get_max_contributor(SvtxTrack*) const;
0089 
0090   //! get embedded id for given g4track
0091   int get_embed(PHG4Particle*) const;
0092 
0093   //! create cluster structure from cluster
0094   TrackEvaluationContainerv1::ClusterStruct create_cluster(TrkrDefs::cluskey, TrkrCluster*, SvtxTrack*) const;
0095 
0096   //! add track information to a cluster
0097   void add_trk_information(TrackEvaluationContainerv1::ClusterStruct&, SvtxTrackState*) const;
0098 
0099   //! add track information to a cluster for the micromegas case
0100   /*!
0101    * the difference between this and the generic method is that the track state to
0102    * the tiles detector plane, and not to the same radius as the cluster
0103    */
0104   void add_trk_information_micromegas(TrackEvaluationContainerv1::ClusterStruct&, int /* tileid */, SvtxTrackState*) const;
0105 
0106   // add truth information
0107   void add_truth_information(TrackEvaluationContainerv1::ClusterStruct&, const std::set<PHG4Hit*>&) const;
0108 
0109   // add truth information
0110   /*!
0111    * the difference between this and the generic method is that the track state to
0112    * the tiles detector plane, and not to the same radius as the cluster
0113    */
0114   void add_truth_information_micromegas(TrackEvaluationContainerv1::ClusterStruct&, int /* tileid */, const std::set<PHG4Hit*>&) const;
0115 
0116   //! evaluation node
0117   TrackEvaluationContainerv1* m_container = nullptr;
0118 
0119   //! flags
0120   int m_flags = EvalEvent | EvalClusters | EvalTracks;
0121 
0122   /// Acts tracking geometry for surface lookup
0123   ActsGeometry* m_tGeometry = nullptr;
0124 
0125   //! hits
0126   TrkrHitSetContainer* m_hitsetcontainer = nullptr;
0127 
0128   //! clusters
0129   TrkrClusterContainer* m_cluster_map = nullptr;
0130 
0131   //! cluster to hit association
0132   TrkrClusterHitAssoc* m_cluster_hit_map = nullptr;
0133 
0134   //! hit to truth association
0135   TrkrHitTruthAssoc* m_hit_truth_map = nullptr;
0136 
0137   //! tracks
0138   SvtxTrackMap* m_track_map = nullptr;
0139 
0140   //!@name geant4 hits
0141   //@{
0142   PHG4HitContainer* m_g4hits_tpc = nullptr;
0143   PHG4HitContainer* m_g4hits_intt = nullptr;
0144   PHG4HitContainer* m_g4hits_mvtx = nullptr;
0145   PHG4HitContainer* m_g4hits_micromegas = nullptr;
0146   //@}
0147 
0148   //! truth information
0149   PHG4TruthInfoContainer* m_g4truthinfo = nullptr;
0150 
0151   //! tpc geometry
0152   PHG4TpcCylinderGeomContainer* m_tpc_geom_container = nullptr;
0153 
0154   //! micromegas geometry
0155   PHG4CylinderGeomContainer* m_micromegas_geom_container = nullptr;
0156 
0157   // map cluster keys to g4hits
0158   using G4HitMap = std::map<TrkrDefs::cluskey, G4HitSet>;
0159   mutable G4HitMap m_g4hit_map;
0160   ClusterErrorPara _ClusErrPara;
0161 };
0162 
0163 #endif  // G4EVAL_TrackEvaluation_H