Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:21:53

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