Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:20:25

0001 #ifndef TRACKRECO_PHTPCRESIDUALS_H
0002 #define TRACKRECO_PHTPCRESIDUALS_H
0003 
0004 #include "TpcSpaceChargeMatrixContainer.h"  // for TpcSpaceChargeMa...
0005 
0006 #include <tpc/TpcGlobalPositionWrapper.h>
0007 
0008 #include <trackbase/TrkrDefs.h>
0009 
0010 #include <fun4all/SubsysReco.h>
0011 
0012 #include <Acts/Definitions/Algebra.hpp>  // for Vector3
0013 
0014 #include <cmath>
0015 #include <memory>
0016 #include <string>   // for basic_string
0017 #include <utility>  // for pair
0018 
0019 class ActsGeometry;
0020 class SvtxTrackState;
0021 class PHCompositeNode;
0022 class SvtxTrack;
0023 class SvtxTrackMap;
0024 class TrkrClusterContainer;
0025 
0026 /**
0027  * This class takes preliminary fits from PHActsTrkFitter to the
0028  * silicon + MM clusters and calculates the residuals in the TPC
0029  * from that track fit. The TPC state has to be explicitly determined
0030  * here since the Acts::DirectNavigator does not visit the TPC states
0031  */
0032 class PHTpcResiduals : public SubsysReco
0033 {
0034  public:
0035   PHTpcResiduals(const std::string &name = "PHTpcResiduals");
0036   ~PHTpcResiduals() override = default;
0037 
0038   int Init(PHCompositeNode *topNode) override;
0039   int InitRun(PHCompositeNode *topNode) override;
0040   int process_event(PHCompositeNode *topNode) override;
0041   int End(PHCompositeNode *topNode) override;
0042 
0043   ///@name Option for setting distortion correction calculation limits
0044   //@{
0045   void setMaxTrackAlpha(float maxTAlpha)
0046   {
0047     m_maxTAlpha = maxTAlpha;
0048   }
0049 
0050   void setMaxTrackBeta(float maxTBeta)
0051   {
0052     m_maxTBeta = maxTBeta;
0053   }
0054 
0055   void setMaxTrackResidualDrphi(float maxResidualDrphi)
0056   {
0057     m_maxResidualDrphi = maxResidualDrphi;
0058   }
0059 
0060   void setMaxTrackResidualDz(float maxResidualDz)
0061   {
0062     m_maxResidualDz = maxResidualDz;
0063   }
0064   //@}
0065 
0066   void setMinRPhiErr(float minRPhiErr)
0067   {
0068     m_minRPhiErr = minRPhiErr;
0069   }
0070 
0071   void setMinZErr(float minZErr)
0072   {
0073     m_minZErr = minZErr;
0074   }
0075 
0076   /// track min pT
0077   void setMinPt(double value)
0078   {
0079     m_minPt = value;
0080   }
0081 
0082   /// track crossing
0083   void requireCrossing(bool flag = true)
0084   {
0085     m_requireCrossing = flag;
0086   }
0087 
0088   /// Grid dimensions
0089   void setGridDimensions(const int phiBins, const int rBins, const int zBins);
0090 
0091   /// set to true to store evaluation histograms and ntuples
0092   void setSavehistograms(bool) {}
0093 
0094   /// output file name for evaluation histograms
0095   void setHistogramOutputfile(const std::string &) {}
0096 
0097   /// output file name for storing the space charge reconstruction matrices
0098   void setOutputfile(const std::string &outputfile)
0099   {
0100     m_outputfile = outputfile;
0101   }
0102 
0103   /// require micromegas to be present when extrapolating tracks to the TPC
0104   void setUseMicromegas(bool value)
0105   {
0106     m_useMicromegas = value;
0107   }
0108 
0109   void disableModuleEdgeCorr() { m_disable_module_edge_corr = true; }
0110   void disableStaticCorr() { m_disable_static_corr = true; }
0111   void disableAverageCorr() { m_disable_average_corr = true; }
0112   void disableFluctuationCorr() { m_disable_fluctuation_corr = true; }
0113 
0114   /// modify track map name
0115   void setTrackMapName( const std::string& value )
0116   { m_trackmapname = value; }
0117 
0118  private:
0119 
0120   int getNodes(PHCompositeNode *topNode);
0121   int createNodes(PHCompositeNode *topNode);
0122 
0123   int processTracks(PHCompositeNode *topNode);
0124 
0125   bool checkTrack(SvtxTrack *track) const;
0126   bool checkTPOTResidual(SvtxTrack *track) const;
0127   void processTrack(SvtxTrack *track);
0128 
0129   /// Gets distortion cell for identifying bins in TPC
0130   int getCell(const Acts::Vector3 &loc);
0131 
0132   /// Node information for Acts tracking geometry and silicon+MM
0133   /// track fit
0134   std::string m_trackmapname = "SvtxSiliconMMTrackMap";
0135   SvtxTrackMap *m_trackMap = nullptr;
0136   ActsGeometry *m_tGeometry = nullptr;
0137   TrkrClusterContainer *m_clusterContainer = nullptr;
0138 
0139   //! tpc global position wrapper
0140   TpcGlobalPositionWrapper m_globalPositionWrapper;
0141 
0142   float m_maxTAlpha = 0.6;
0143   float m_maxResidualDrphi = 0.5;  // cm
0144   float m_maxTBeta = 1.5;
0145   float m_maxResidualDz = 0.5;  // cm
0146 
0147   float m_minRPhiErr = 0.005;  // 0.005cm -- 50um
0148   float m_minZErr = 0.01;      // 0.01cm -- 100um
0149 
0150   static constexpr float m_phiMin = 0;
0151   static constexpr float m_phiMax = 2. * M_PI;
0152 
0153   static constexpr float m_rMin = 20;  // cm
0154   static constexpr float m_rMax = 78;  // cm
0155 
0156   static constexpr int m_minClusCount = 10;
0157 
0158   static constexpr float m_layerMin = 7;
0159   static constexpr float m_layerMax = 55;
0160 
0161   /// Tpc geometry
0162   static constexpr unsigned int m_nLayersTpc = 48;
0163   float m_zMin = 0;  // cm
0164   float m_zMax = 0;  // cm
0165 
0166   /// matrix container
0167   std::unique_ptr<TpcSpaceChargeMatrixContainer> m_matrix_container;
0168 
0169   // TODO: check if needed
0170   int m_event = 0;
0171 
0172   /// require micromegas to be present when extrapolating tracks to the TPC
0173   bool m_useMicromegas = true;
0174 
0175   /// minimum pT required for track to be considered in residuals calculation (GeV/c)
0176   double m_minPt = 0.5;
0177 
0178   /// require track crossing zero
0179   bool m_requireCrossing = false;
0180 
0181   /// disable distortion correction
0182   bool m_disable_module_edge_corr = false;
0183   bool m_disable_static_corr = false;
0184   bool m_disable_average_corr = false;
0185   bool m_disable_fluctuation_corr = false;
0186 
0187   /// output file
0188   std::string m_outputfile = "TpcSpaceChargeMatrices.root";
0189 
0190   ///@name counters
0191   //@{
0192   int m_total_tracks = 0;
0193   int m_accepted_tracks = 0;
0194 
0195   int m_total_clusters = 0;
0196   int m_accepted_clusters = 0;
0197   //@}
0198 };
0199 
0200 #endif