Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:17:59

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