Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 /*!
0002  *  \file PrelimDistortionCorrection.h
0003  *  \brief      Makes preliminary distortion corrections when crossing is unknown
0004  *  \author Tony Frawley
0005  */
0006 
0007 #ifndef TRACKRECO_PRELIMDISTORTIONCORRECTION_H
0008 #define TRACKRECO_PRELIMDISTORTIONCORRECTION_H
0009 
0010 #include "ALICEKF.h"
0011 #include "nanoflann.hpp"
0012 
0013 // PHENIX includes
0014 #include <fun4all/SubsysReco.h>
0015 #include <tpc/TpcDistortionCorrection.h>
0016 #include <trackbase/TrkrDefs.h>
0017 #include <Acts/MagneticField/MagneticFieldProvider.hpp>
0018 
0019 #include <Eigen/Core>
0020 
0021 // STL includes
0022 #include <memory>
0023 #include <string>
0024 #include <vector>
0025 
0026 class ActsGeometry;
0027 class PHCompositeNode;
0028 class PHField;
0029 class TpcDistortionCorrectionContainer;
0030 class TrkrClusterContainer;
0031 class TrkrClusterIterationMapv1;
0032 class SvtxTrackMap;
0033 class TrackSeedContainer;
0034 class TrackSeed_v2;
0035 
0036 using PositionMap = std::map<TrkrDefs::cluskey, Acts::Vector3>;
0037 
0038 class PrelimDistortionCorrection : public SubsysReco
0039 {
0040  public:
0041   PrelimDistortionCorrection(const std::string &name = "PrelimDistortionCorrection");
0042   ~PrelimDistortionCorrection() override;
0043 
0044   int InitRun(PHCompositeNode *topNode) override;
0045   int process_event(PHCompositeNode *topNode) override;
0046   int End(PHCompositeNode *topNode) override;
0047 
0048   void set_field_dir(const double rescale)
0049   {
0050     _fieldDir = 1;
0051     if(rescale > 0)
0052       { _fieldDir = -1; }
0053   }
0054   void set_max_window(double s){_max_dist = s;}
0055   void useConstBField(bool opt){_use_const_field = opt;}
0056   void setConstBField(float b) { _const_field = b; }
0057   void useFixedClusterError(bool opt){_use_fixed_clus_err = opt;}
0058   void setFixedClusterError(int i, double val){_fixed_clus_err.at(i) = val;}
0059   void use_truth_clusters(bool truth) { _use_truth_clusters = truth; }
0060   void set_pp_mode(bool mode) {_pp_mode = mode;}
0061 
0062   void setNeonFraction(double frac) { Ne_frac = frac; };
0063   void setArgonFraction(double frac) { Ar_frac = frac; };
0064   void setCF4Fraction(double frac) { CF4_frac = frac; };
0065   void setNitrogenFraction(double frac) { N2_frac = frac; };
0066   void setIsobutaneFraction(double frac) { isobutane_frac = frac; };
0067 
0068  private:
0069 
0070   //! put refitted seeds on map
0071   void publishSeeds(std::vector<TrackSeed_v2>& seeds, PositionMap &positions);
0072 
0073   /// tpc distortion correction utility class
0074   TpcDistortionCorrection m_distortionCorrection;
0075 
0076   bool _use_truth_clusters = false;
0077 
0078   /// fetch node pointers
0079   int get_nodes(PHCompositeNode *topNode);
0080   std::vector<double> radii;
0081   std::vector<double> _vertex_x;
0082   std::vector<double> _vertex_y;
0083   std::vector<double> _vertex_z;
0084   std::vector<double> _vertex_xerr;
0085   std::vector<double> _vertex_yerr;
0086   std::vector<double> _vertex_zerr;
0087   std::vector<double> _vertex_ids;
0088   //double _Bz = 1.4*_Bzconst;
0089   double _max_dist = .05;
0090   size_t _min_clusters_per_track = 3;
0091   double _fieldDir = -1;
0092   double _max_sin_phi = 1.;
0093   bool _pp_mode = false;
0094 
0095   TrkrClusterContainer *_cluster_map = nullptr;
0096 
0097   TrackSeedContainer *_track_map = nullptr;
0098 
0099   //! magnetic field map
0100   PHField* _field_map = nullptr;
0101   bool m_own_fieldmap = false;
0102 
0103   /// acts geometry
0104   ActsGeometry *_tgeometry = nullptr;
0105 
0106   //!@name distortion correction containers
0107   //@{
0108   /** used in input to correct CM clusters before calculating residuals */
0109   TpcDistortionCorrectionContainer *m_dcc_module_edge{nullptr};
0110   TpcDistortionCorrectionContainer *m_dcc_static{nullptr};
0111   TpcDistortionCorrectionContainer *m_dcc_average{nullptr};
0112   //@}
0113 
0114   std::unique_ptr<ALICEKF> fitter;
0115 
0116   bool _use_const_field = false;
0117   float _const_field = 1.4;
0118   bool _use_fixed_clus_err = false;
0119   std::array<double,3> _fixed_clus_err = {.1,.1,.1};
0120 
0121   double Ne_frac = 0.00;
0122   double Ar_frac = 0.75;
0123   double CF4_frac = 0.20;
0124   double N2_frac = 0.00;
0125   double isobutane_frac = 0.05;
0126 
0127 };
0128 
0129 #endif