Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:13:09

0001 /*!
0002  *  \file       PHG4HitKalmanFitter.h
0003  *  \brief      Kalman Filter based on smeared truth PHG4Hit
0004  *  \details    Kalman Filter based on smeared truth PHG4Hit
0005  *  \author     Haiwang Yu <yuhw@nmsu.edu>
0006  */
0007 
0008 #ifndef __PHG4HitKalmanFitter_H__
0009 #define __PHG4HitKalmanFitter_H__
0010 
0011 #include <iostream>
0012 #include <string>
0013 #include <vector>
0014 
0015 #include <fun4all/SubsysReco.h>
0016 
0017 #include <TVector3.h>
0018 
0019 #include <g4main/PHG4HitContainer.h>
0020 #include <phgenfit/Measurement.h>
0021 
0022 class PHG4Particle;
0023 namespace PHGenFit
0024 {
0025   class PlanarMeasurement;
0026 } /* namespace PHGenFit */
0027 
0028 namespace PHGenFit
0029 {
0030   class Track;
0031 } /* namespace PHGenFit */
0032 
0033 namespace genfit
0034 {
0035   class GFRaveVertexFactory;
0036 } /* namespace genfit */
0037 
0038 class SvtxTrack;
0039 namespace PHGenFit
0040 {
0041   class Fitter;
0042 } /* namespace PHGenFit */
0043 
0044 class SvtxTrackMap;
0045 class SvtxVertexMap;
0046 class SvtxVertex;
0047 class PHCompositeNode;
0048 class PHG4TruthInfoContainer;
0049 class SvtxClusterMap;
0050 class SvtxEvalStack;
0051 class TFile;
0052 class TTree;
0053 
0054 class PHG4TrackFastSim : public SubsysReco
0055 {
0056  public:
0057   //! Default constructor
0058   PHG4TrackFastSim(const std::string& name = "PHG4HitKalmanFitter");
0059 
0060   //! dtor
0061   ~PHG4TrackFastSim();
0062 
0063   //!Initialization, called for initialization
0064   int Init(PHCompositeNode*);
0065 
0066   //!Initialization Run, called for initialization of a run
0067   int InitRun(PHCompositeNode*);
0068 
0069   //!Process Event, called for each event
0070   int process_event(PHCompositeNode*);
0071 
0072   //!End, write and close files
0073   int End(PHCompositeNode*);
0074 
0075   /// set verbosity
0076   void Verbosity(int verb)
0077   {
0078     verbosity = verb;  // SubsysReco verbosity
0079   }
0080 
0081   bool is_do_evt_display() const
0082   {
0083     return _do_evt_display;
0084   }
0085 
0086   void set_do_evt_display(bool doEvtDisplay)
0087   {
0088     _do_evt_display = doEvtDisplay;
0089   }
0090 
0091   double get_FGEM_phi_resolution() const
0092   {
0093     return _phi_resolution;
0094   }
0095 
0096   void set_FGEM_phi_resolution(double fgemPhiResolution)
0097   {
0098     _phi_resolution = fgemPhiResolution;
0099   }
0100 
0101   double get_FGEM_r_resolution() const
0102   {
0103     return _r_resolution;
0104   }
0105 
0106   void set_FGEM_r_resolution(double fgemRResolution)
0107   {
0108     _r_resolution = fgemRResolution;
0109   }
0110 
0111   const std::string& get_fit_alg_name() const
0112   {
0113     return _fit_alg_name;
0114   }
0115 
0116   void set_fit_alg_name(const std::string& fitAlgName)
0117   {
0118     _fit_alg_name = fitAlgName;
0119   }
0120 
0121   double get_pat_rec_hit_finding_eff() const
0122   {
0123     return _pat_rec_hit_finding_eff;
0124   }
0125 
0126   void set_pat_rec_hit_finding_eff(double patRecHitFindingEff)
0127   {
0128     if (!(patRecHitFindingEff >= 0 && patRecHitFindingEff <= 1))
0129     {
0130       std::cout << "ERROR: _pat_rec_hit_finding_eff out of range! \n";
0131     }
0132     _pat_rec_hit_finding_eff = patRecHitFindingEff;
0133   }
0134 
0135   double get_pat_rec_nosise_prob() const
0136   {
0137     return _pat_rec_nosise_prob;
0138   }
0139 
0140   void set_pat_rec_nosise_prob(double patRecNosiseProb)
0141   {
0142     if (!(patRecNosiseProb <= 1. && patRecNosiseProb >= 0))
0143     {
0144       std::cout << "ERROR: _pat_rec_nosise_prob out of range! \n";
0145       return;
0146     }
0147     _pat_rec_nosise_prob = patRecNosiseProb;
0148   }
0149 
0150  private:
0151   /*!
0152      * Create needed nodes.
0153      */
0154   int CreateNodes(PHCompositeNode*);
0155 
0156   /*!
0157      * Get all the all the required nodes off the node tree.
0158      */
0159   int GetNodes(PHCompositeNode*);
0160 
0161   /*!
0162      *
0163      */
0164   int PseudoPatternRecognition(const PHG4Particle* particle,
0165                                std::vector<PHGenFit::Measurement*>& meas_out, TVector3& seed_pos,
0166                                TVector3& seed_mom, TMatrixDSym& seed_cov, const bool do_smearing = true);
0167 
0168   PHGenFit::PlanarMeasurement* PHG4HitToMeasurementVerticalPlane(const PHG4Hit* g4hit);
0169 
0170   PHGenFit::PlanarMeasurement* VertexMeasurement(const TVector3& vtx, const double dr,
0171                                                  const double dphi);
0172 
0173   /*!
0174      * Make SvtxTrack from PHGenFit::Track
0175      */
0176   SvtxTrack* MakeSvtxTrack(const PHGenFit::Track* phgf_track_in);
0177 
0178   //! Event counter
0179   int _event;
0180 
0181   //! Input Node pointers
0182   PHG4TruthInfoContainer* _truth_container;
0183 
0184   std::vector<PHG4HitContainer*> _phg4hits;
0185   std::vector<std::string> _phg4hits_names;
0186 
0187   //! Output Node pointers
0188   SvtxTrackMap* _trackmap_out;
0189 
0190   /*!
0191      *  GenFit fitter interface
0192      */
0193   PHGenFit::Fitter* _fitter;
0194 
0195   //!
0196   std::string _fit_alg_name;
0197 
0198   //!
0199   bool _do_evt_display;
0200 
0201   /*!
0202      * For PseudoPatternRecognition function.
0203      */
0204 
0205   double _phi_resolution;
0206 
0207   double _r_resolution;
0208 
0209   //!
0210   double _pat_rec_hit_finding_eff;
0211 
0212   //!
0213   double _pat_rec_nosise_prob;
0214 };
0215 
0216 #endif /*__PHG4HitKalmanFitter_H__*/