Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-08-31 08:21:17

0001 #ifndef G4EVAL_SiliconDriftEvaluator_H
0002 #define G4EVAL_SiliconDriftEvaluator_H
0003 
0004 /*
0005  * Bade Sayki June 16th, 2026 -- LANL
0006  * This module is created to calibrate the drift velocity in the TPC by projecting the silicon seeds and the TPC seeds to the beam axis and calculating the z residuals.
0007  * This is heavily inspired by and distilled from Dr. Hugo Pereira Da Costa's TrackingEvaluator_hp module. It is meant to be a more lightweight and specialized version.
0008  * Claude tool was used to format and comment this module.
0009  */
0010 
0011 #include <fun4all/SubsysReco.h>
0012 #include <phool/PHObject.h>
0013 
0014 #include <string>
0015 #include <vector>
0016 
0017 class SvtxTrackMap;
0018 class TH2F;
0019 class TH3F;
0020 
0021 class SiliconDriftEvaluator : public SubsysReco
0022 {
0023  public:
0024   //! constructor
0025   SiliconDriftEvaluator(const std::string& = "SiliconDriftEvaluator");
0026 
0027   //! global initialization
0028   virtual int Init(PHCompositeNode*);
0029 
0030   //! run initialization
0031   virtual int InitRun(PHCompositeNode*);
0032 
0033   //! event processing
0034   virtual int process_event(PHCompositeNode*);
0035 
0036   //! end of processing
0037   virtual int End(PHCompositeNode*);
0038 
0039   // track information stored in the Container
0040   class TrackStruct
0041   {
0042    public:
0043     using List = std::vector<TrackStruct>;
0044 
0045     // cluster counts
0046     unsigned int _nclusters_mvtx = 0;
0047     unsigned int _nclusters_intt = 0;
0048     unsigned int _nclusters_tpc = 0;
0049 
0050     // tpc seed kinematics
0051     float _pt = 0;
0052     float _eta = 0;
0053     float _phi = 0;
0054 
0055     // seed z positions
0056 
0057     // z position of the TPC seed at the beamline
0058     float _z_tpc = 0;
0059 
0060     //! z position of the silicon seed at the beamline
0061     float _z_si = 0;
0062 
0063     //! beam-bunch crossing number
0064     short int _crossing = 0;
0065 
0066     //! crossing-corrected dz = z_tpc_corr - z_si (cm)
0067     float _dz = 0;
0068   };
0069 
0070   //! track container stored on the node tree
0071   class Container : public PHObject
0072   {
0073    public:
0074     //! constructor
0075     explicit Container() = default;
0076 
0077     //! copy constructor
0078     explicit Container(const Container&) = delete;
0079 
0080     //! assignment operator
0081     Container& operator=(const Container&) = delete;
0082 
0083     //! reset
0084     void Reset() override
0085     {
0086       _tracks.clear();
0087     }
0088 
0089     //!@name accessors
0090     //@{
0091 
0092     const TrackStruct::List& tracks() const
0093     {
0094       return _tracks;
0095     }
0096 
0097     // modifiers
0098 
0099     void addTrack(const TrackStruct& track)
0100     {
0101       _tracks.push_back(track);
0102     }
0103 
0104     void clearTracks()
0105     {
0106       _tracks.clear();
0107     }
0108 
0109    private:
0110     //! tracks array
0111     TrackStruct::List _tracks;
0112 
0113     ClassDefOverride(Container, 1)
0114   };
0115 
0116   //! track map name
0117   void set_trackmapname(const std::string& value) { m_trackmapname = value; }
0118 
0119   // initial drift velocity (cm/ns); used as starting point for the fit and for the crossing correction
0120   void set_drift_velocity(double value) { m_drift_velocity = value; }
0121 
0122   // bunch-crossing interval in ns (default: 106.65237 ns)
0123   void set_crossing_interval(double value) { m_crossing_interval = value; }
0124 
0125   // minimum pT cut on tracks (GeV)
0126   void set_min_pt(double value) { m_min_pt = value; }
0127 
0128   // minimum number of TPC clusters required
0129   void set_min_nclusters_tpc(unsigned int value) { m_min_nclusters_tpc = value; }
0130 
0131   // minimum number of MVTX clusters required
0132   void set_min_nclusters_mvtx(unsigned int value) { m_min_nclusters_mvtx = value; }
0133 
0134   // minimum number of INTT clusters required
0135   void set_min_nclusters_intt(unsigned int value) { m_min_nclusters_intt = value; }
0136 
0137   // maximum abs(eta) of TPC seed accepted
0138   void set_max_eta(double value) { m_max_eta = value; }
0139 
0140   // half-range of the z_si histogram axis (cm)
0141   void set_max_z(double value) { m_max_z = value; }
0142 
0143   // half-range of the dz histogram axis (cm)
0144   void set_max_dz(double value) { m_max_dz = value; }
0145 
0146   //! minimum entries per z slice required by FitSlicesY
0147   void set_min_slice_entries(int value) { m_min_slice_entries = value; }
0148 
0149   // output drift plot filename. Do this in your macro.
0150   void set_plot_filename(const std::string& value) { m_plot_filename = value; }
0151 
0152   // output ROOT filename for histograms and fit results. Do this in your macro.
0153   void set_root_filename(const std::string& value) { m_root_filename = value; }
0154 
0155  private:
0156   //! load nodes
0157   int load_nodes(PHCompositeNode*);
0158 
0159   //! evaluate tracks
0160   void evaluate_tracks();
0161 
0162   //! evaluation node
0163   Container* m_container = nullptr;
0164 
0165   //! track map
0166   SvtxTrackMap* m_track_map = nullptr;
0167 
0168   //! 3D accumulator histogram: x = eta bin [2], y = z_si, z = dz
0169   TH3F* m_hist3D = nullptr;
0170 
0171   //! track map name
0172   std::string m_trackmapname = "SvtxTrackMap";
0173 
0174   //! initial drift velocity (cm/ns)
0175   double m_drift_velocity = 0.00747;
0176 
0177   //! bunch-crossing interval (ns)
0178   double m_crossing_interval = 106.65237;
0179 
0180   // track selection cuts
0181 
0182   double m_min_pt = 0.5;
0183   unsigned int m_min_nclusters_tpc = 20;
0184   unsigned int m_min_nclusters_mvtx = 3;
0185   unsigned int m_min_nclusters_intt = 2;
0186   double m_max_eta = 0.9;
0187 
0188   //! histogram range
0189   double m_max_z = 20.0;
0190   double m_max_dz = 10.0;
0191 
0192   //! minimum entries per z slice for FitSlicesY
0193   int m_min_slice_entries = 10;
0194 
0195   //! output QA plot filename
0196   std::string m_plot_filename = "silicon_drift_calib.png";
0197 
0198   //! output ROOT filename for histograms and fit results
0199   std::string m_root_filename = "silicon_drift_calib.root";
0200 };
0201 
0202 #endif  // G4EVAL_SiliconDriftEvaluator_H