Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:21:48

0001 #ifndef G4EVAL_SVTXEVALUATOR_H
0002 #define G4EVAL_SVTXEVALUATOR_H
0003 
0004 //===============================================
0005 /// \file SvtxEvaluator.h
0006 /// \brief Compares reconstructed tracks to truth particles
0007 /// \author Michael P. McCumber (revised SVTX version)
0008 //===============================================
0009 
0010 #include <fun4all/SubsysReco.h>
0011 
0012 #include <TMatrixFfwd.h>
0013 #include <TMatrixT.h>
0014 #include <TMatrixTUtils.h>
0015 
0016 #include <limits>
0017 #include <string>
0018 
0019 class PHCompositeNode;
0020 class PHTimer;
0021 class TrkrCluster;
0022 class SvtxEvalStack;
0023 class TFile;
0024 class TNtuple;
0025 class SvtxTrack;
0026 class SvtxVertexMap;
0027 class GlobalVertexMap;
0028 
0029 // class TrkrClusterContainer;
0030 
0031 /// \class SvtxEvaluator
0032 ///
0033 /// \brief Compares reconstructed tracks to truth particles
0034 ///
0035 /// Plan: This module will trace the reconstructed tracks back to
0036 /// the greatest contributor Monte Carlo particle and then
0037 /// test one against the other.
0038 ///
0039 class SvtxEvaluator : public SubsysReco
0040 {
0041  public:
0042   SvtxEvaluator(const std::string &name = "SVTXEVALUATOR",
0043                 const std::string &filename = "g4eval.root",
0044                 const std::string &trackmapname = "SvtxTrackMap",
0045                 unsigned int nlayers_maps = 3,
0046                 unsigned int nlayers_intt = 4,
0047                 unsigned int nlayers_tpc = 48,
0048                 unsigned int nlayers_mms = 2);
0049   ~SvtxEvaluator() override;
0050 
0051   int Init(PHCompositeNode *topNode) override;
0052   int InitRun(PHCompositeNode *topNode) override;
0053   int process_event(PHCompositeNode *topNode) override;
0054   int End(PHCompositeNode *topNode) override;
0055   //  void do_primaries(bool b);
0056 
0057   void set_strict(bool b) { _strict = b; }
0058   void set_use_initial_vertex(bool use_init_vtx) { _use_initial_vertex = use_init_vtx; }
0059   void set_use_genfit_vertex(bool use_genfit_vtx) { _use_genfit_vertex = use_genfit_vtx; }
0060   void do_info_eval(bool b) { _do_info_eval = b; }
0061   void do_vertex_eval(bool b) { _do_vertex_eval = b; }
0062   void do_gpoint_eval(bool b) { _do_gpoint_eval = b; }
0063   void do_g4hit_eval(bool b) { _do_g4hit_eval = b; }
0064   void do_hit_eval(bool b) { _do_hit_eval = b; }
0065   void do_cluster_eval(bool b) { _do_cluster_eval = b; }
0066   void do_g4cluster_eval(bool b) { _do_g4cluster_eval = b; }
0067   void do_gtrack_eval(bool b) { _do_gtrack_eval = b; }
0068   void do_track_eval(bool b) { _do_track_eval = b; }
0069   void do_gseed_eval(bool b) { _do_gseed_eval = b; }
0070 
0071   void do_track_match(bool b) { _do_track_match = b; }
0072   void do_eval_light(bool b) { _do_eval_light = b; }
0073   void do_vtx_eval_light(bool b) { _do_vtx_eval_light = b; }
0074   void scan_for_embedded(bool b) { _scan_for_embedded = b; }
0075   void scan_for_primaries(bool b) { _scan_for_primaries = b; }
0076   
0077  private:
0078   unsigned int _ievent {0};
0079   unsigned int _iseed {0};
0080   float m_fSeed {std::numeric_limits<float>::quiet_NaN()};
0081   // eval stack
0082   SvtxEvalStack *_svtxevalstack {nullptr};
0083 
0084   TMatrixF calculateClusterError(TrkrCluster *c, float &clusphi);
0085   void get_dca(SvtxTrack *track, GlobalVertexMap *vertexmap,
0086                float &dca3dxy, float &dca3dz,
0087                float &dca3dxysigma, float &dca3dzsigma);
0088   // TrkrClusterContainer *cluster_map{nullptr};
0089 
0090   //----------------------------------
0091   // evaluator output ntuples
0092 
0093   bool _strict {false};
0094   bool _use_initial_vertex {true};
0095   bool _use_genfit_vertex {false};
0096   unsigned int _errors {0};
0097 
0098   bool _do_info_eval {true};
0099   bool _do_vertex_eval {true};
0100   bool _do_gpoint_eval {true};
0101   bool _do_g4hit_eval {true};
0102   bool _do_hit_eval {true};
0103   bool _do_cluster_eval {true};
0104   bool _do_g4cluster_eval {true};
0105   bool _do_gtrack_eval {true};
0106   bool _do_track_eval {true};
0107   bool _do_gseed_eval {false};
0108 
0109   bool _do_track_match {true};
0110   bool _do_eval_light {true};
0111   bool _do_vtx_eval_light {true};
0112   bool _scan_for_embedded {false};
0113   bool _scan_for_primaries {false};
0114 
0115   unsigned int _nlayers_maps {3};
0116   unsigned int _nlayers_intt {4};
0117   unsigned int _nlayers_tpc {48};
0118   unsigned int _nlayers_mms {2};
0119 
0120   TNtuple *_ntp_info {nullptr};
0121   TNtuple *_ntp_vertex {nullptr};
0122   TNtuple *_ntp_gpoint {nullptr};
0123   TNtuple *_ntp_g4hit {nullptr};
0124   TNtuple *_ntp_hit {nullptr};
0125   TNtuple *_ntp_cluster {nullptr};
0126   TNtuple *_ntp_g4cluster {nullptr};
0127   TNtuple *_ntp_gtrack {nullptr};
0128   TNtuple *_ntp_track {nullptr};
0129   TNtuple *_ntp_gseed {nullptr};
0130 
0131   TFile *_tfile {nullptr};
0132 
0133   PHTimer *_timer {nullptr};
0134 
0135   // evaluator output file
0136   std::string _filename;
0137   // Track map name
0138   std::string _trackmapname;
0139 
0140   // output subroutines
0141   void fillOutputNtuples(PHCompositeNode *topNode);  ///< dump the evaluator information into ntuple for external analysis
0142   void printInputInfo(PHCompositeNode *topNode);     ///< print out the input object information (debugging upstream components)
0143   void printOutputInfo(PHCompositeNode *topNode);    ///< print out the ancestry information for detailed diagnosis
0144  
0145 };
0146 
0147 #endif  // G4EVAL_SVTXEVALUATOR_H