Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-08-31 08:22:18

0001 #ifndef QA_TRACKING_MICROMEGASDRIFTQA_H
0002 #define QA_TRACKING_MICROMEGASDRIFTQA_H
0003 
0004 /*
0005  * Bade Sayki June 10th, 2026 -- LANL
0006  * This QA module is created to monitor the calibration of the drift velocity in the TPC by fitting a helix to the clusters within a certain layer range, and projecting it to the TPOT z view module plane. The default layers in the TPC are set to be 39-55, which correspond to R3.
0007  * This is heavily inspired by and distilled from Dr. Hugo Pereira Da Costa's MicromegasTrackEvaluator_hp module. It is meant to be a more lightweight and specialized version.
0008  * If you have any questions, please feel free to message me on mattermost.
0009  * Claude Code tool was used to format and debug this module
0010  */
0011 
0012 #include <fun4all/SubsysReco.h>
0013 #include <tpc/TpcGlobalPositionWrapper.h>
0014 
0015 #include <string>
0016 
0017 class ActsGeometry;
0018 class PHCompositeNode;
0019 class PHG4CylinderGeomContainer;
0020 class SvtxTrackMap;
0021 class TrkrClusterContainer;
0022 class TH1;
0023 class TH2;
0024 
0025 class MicromegasDriftQA : public SubsysReco
0026 {
0027  public:
0028   explicit MicromegasDriftQA(const std::string& name = "MicromegasDriftQA");
0029 
0030   ~MicromegasDriftQA() override = default;
0031 
0032   //! run initialization: load nodes, create and register histograms
0033   int InitRun(PHCompositeNode* topNode) override;
0034 
0035   //! event processing: fill histograms
0036   int process_event(PHCompositeNode* topNode) override;
0037 
0038   //! end of processing: fit accumulated distributions, fill summary histogram
0039   int End(PHCompositeNode* topNode) override;
0040 
0041   //! track map name
0042   void set_trackmapname(const std::string& value) { m_trackmapname = value; }
0043 
0044   //! initial drift velocity (cm/ns); starting point for the fit. Use the drift velocity used at reconstruction.
0045   void set_drift_velocity(double value) { m_drift_velocity = value; }
0046 
0047   //! TPC layer range used for the helix fit (default: R3)
0048   void set_min_tpc_layer(unsigned int value) { m_min_tpc_layer = value; }
0049   void set_max_tpc_layer(unsigned int value) { m_max_tpc_layer = value; }
0050 
0051   //! reject track states near the tile edge (cm, local y)
0052   void set_y_local_cut(double value) { m_y_local_cut = value; }
0053 
0054   //! search window to match a Micromegas cluster to the prediction (cm)
0055   void set_z_search_window(double value) { m_z_search_win = value; }
0056 
0057   //! minimum entries per z slice required by FitSlicesY
0058   void set_min_slice_entries(int value) { m_min_slice_entries = value; }
0059 
0060  private:
0061   int load_nodes(PHCompositeNode* topNode);
0062 
0063   void createHistos();
0064   std::string getHistoPrefix() const;
0065 
0066   //!@name histograms (owned by the QA histogram manager)
0067   //@{
0068 
0069   //! z_track vs dz, one per z-view tile
0070   TH2* h_ztrk_dz[8]{nullptr};
0071 
0072   //! dz = z_track - z_cluster, all tiles
0073   TH1* h_dz{nullptr};
0074 
0075   //! matched track states per tile
0076   TH1* h_tile{nullptr};
0077 
0078   //! local y of the track state on the tile
0079   TH1* h_ylocal{nullptr};
0080 
0081   //! number of matched track states per event
0082   TH1* h_ntracks{nullptr};
0083 
0084   //! drift velocity fit summary, filled in End()
0085   TH1* h_driftSummary{nullptr};
0086 
0087   //@}
0088 
0089   //!@name nodes
0090   //@{
0091   ActsGeometry* m_tGeometry{nullptr};
0092   TpcGlobalPositionWrapper m_globalPositionWrapper;
0093   PHG4CylinderGeomContainer* m_micromegas_geomcontainer{nullptr};
0094   TrkrClusterContainer* m_cluster_map{nullptr};
0095   SvtxTrackMap* m_track_map{nullptr};
0096   //@}
0097 
0098   //! track map name
0099   std::string m_trackmapname{"SvtxTrackMap"};
0100 
0101   //! initial drift velocity (cm/ns)
0102   double m_drift_velocity{0.00745};
0103 
0104   //! TPC layer range used for the helix fit
0105   unsigned int m_min_tpc_layer{39};
0106   unsigned int m_max_tpc_layer{55};
0107 
0108   //! reject track states near the tile edge (cm)
0109   double m_y_local_cut{22.0};
0110 
0111   //! search window to match a Micromegas cluster to the prediction (cm)
0112   double m_z_search_win{3.0};
0113 
0114   //! minimum entries per z slice for FitSlicesY
0115   int m_min_slice_entries{10};
0116 };
0117 
0118 #endif  // QA_TRACKING_MICROMEGASDRIFTQA_H