Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:53

0001 #ifndef TPC_TPCLOADDISTORTIONCORRECTION_H
0002 #define TPC_TPCLOADDISTORTIONCORRECTION_H
0003 
0004 /*!
0005  * \file TpcLoadDistortionCorrection.h
0006  * \brief loads distortion correction histogram from file to DistortionCorrectionObject and stores on node tree
0007  * \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0008  */
0009 
0010 #include <fun4all/SubsysReco.h>
0011 #include <phool/PHObject.h>
0012 #include <phool/PHTimer.h>
0013 #include <trackbase/TrkrDefs.h>
0014 
0015 #include <array>
0016 
0017 class TH3;
0018 
0019 class TpcLoadDistortionCorrection : public SubsysReco
0020 {
0021  public:
0022   //! constructor
0023   TpcLoadDistortionCorrection(const std::string& = "TpcLoadDistortionCorrection");
0024 
0025   //! global initialization
0026   int InitRun(PHCompositeNode*) override;
0027 
0028   //! event processing
0029   int process_event(PHCompositeNode*) override;
0030 
0031   // convenient enumeration for distortion type
0032   enum DistortionType:int
0033   {
0034     DistortionType_Static = 0,
0035     DistortionType_Average = 1,
0036     DistortionType_Fluctuation = 2,
0037     DistortionType_ModuleEdge = 3
0038   };
0039 
0040   static constexpr int nDistortionTypes = 4;
0041 
0042   //! correction filename
0043   void set_correction_filename(DistortionType i, const std::string& value)
0044   {
0045     if (i < 0 || i >= nDistortionTypes) return;
0046     m_correction_filename[i] = value;
0047     m_correction_in_use[i] = true;
0048   }
0049 
0050   //! set the scale factor to be applied to the correction
0051   void set_scale_factor(DistortionType i, float value)
0052   {
0053     m_use_scalefactor[i] = true;
0054     m_scalefactor[i] = value;
0055   }
0056 
0057   //! set the phi histogram to be interpreted as radians.
0058   void set_read_phi_as_radians(bool flag)
0059   {
0060     m_phi_hist_in_radians[0] = flag;
0061   }
0062  void set_read_phi_as_radians(int i, bool flag)
0063   {
0064     m_phi_hist_in_radians[i] = flag;
0065   }
0066   //! set the histogram to interpolate between hist value and zero, depending on z position. (has no effect if m_dimensions is 3)
0067   // false:  correction is corr(x,y) (regardless of z)
0068   // true:  correction is corr(x,y)*(1-(z/zspan)) so that corr(x,y) at readout is zero.
0069   void set_interpolate_2D_to_zero(bool flag)
0070   {
0071     m_interpolate_z[0] = flag;
0072   }
0073   void set_interpolate_2D_to_zero(int i, bool flag)
0074   {
0075     m_interpolate_z[i] = flag;
0076   }
0077 
0078   //! node name
0079   void set_node_name(const std::string& value)
0080   {
0081     m_node_name[0] = value;
0082   }
0083   void set_node_name(int i, const std::string& value)
0084   {
0085     m_node_name[i] = value;
0086   }
0087 
0088  private:
0089 
0090   //! correction filename
0091   std::array<std::string,nDistortionTypes> m_correction_filename = {};
0092 
0093   //! flag to indicate correction in use
0094   std::array<bool,nDistortionTypes> m_correction_in_use = {};
0095 
0096   //! flag and scalefactor to apply to correction
0097   std::array<bool,nDistortionTypes> m_use_scalefactor = {};
0098 
0099   //! scale factors
0100   std::array<float,nDistortionTypes> m_scalefactor = {1.0,1.0,1.0,1.0};
0101 
0102   //! set the phi histogram to be interpreted as radians rather than mm
0103   std::array<bool,nDistortionTypes> m_phi_hist_in_radians = {true,true,true,true};
0104 
0105   //! z interpolation
0106   std::array<bool,nDistortionTypes> m_interpolate_z = {true,true,true,true};
0107 
0108   //! distortion object node name
0109   std::array<std::string,nDistortionTypes> m_node_name = {"TpcDistortionCorrectionContainerStatic", "TpcDistortionCorrectionContainerAverage", "TpcDistortionCorrectionContainerFluctuation","TpcDistortionCorrectionContainerModuleEdge"};
0110 };
0111 
0112 #endif