Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // $Id: $
0002 
0003 /*!
0004  * \file PHG4TPCDistortion.h
0005  * \brief
0006  * \author Jin Huang <jhuang@bnl.gov>, Henry Klest <henry.klest@stonybrook.edu>, Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>, Ross Corliss <ross.corliss@stonybrook.edu>
0007  * \version $Revision:   $
0008  * \date $Date: $
0009  */
0010 
0011 #ifndef G4TPC_PHG4TPCDISTORTION_H
0012 #define G4TPC_PHG4TPCDISTORTION_H
0013 
0014 #include <memory>
0015 #include <string>
0016 
0017 class TFile;
0018 class TH3;
0019 class TTree;
0020 
0021 //! handle distortions (static and time-ordered)
0022 class PHG4TpcDistortion
0023 {
0024  public:
0025   //! constructor
0026   explicit PHG4TpcDistortion() = default;
0027 
0028   //!@name accessors
0029   //@{
0030 
0031   //! x distortion for a given truth location of the primary ionization
0032   double get_x_distortion_cartesian(double x, double y, double z) const;
0033 
0034   //! y distortion for a given truth location of the primary ionization
0035   double get_y_distortion_cartesian(double x, double y, double z) const;
0036 
0037   //! z distortion for a given truth location of the primary ionization
0038   double get_z_distortion_cartesian(double x, double y, double z) const;
0039 
0040   //! radial distortion for a given cylindrical truth location of the primary ionization
0041   double get_r_distortion(double r, double phi, double z) const;
0042 
0043   //! R*phi (hence the unitful phi-hat) distortion for a given cylindrical truth location of the primary ionization
0044   double get_rphi_distortion(double r, double phi, double z) const;
0045 
0046   //! z distortion for a given cylindrical truth location of the primary ionization
0047   double get_z_distortion(double r, double phi, double z) const;
0048 
0049   // The ReachesReadout serves as a fourth axis in the distortion histogram
0050   double get_reaches_readout(double r, double phi, double z) const;
0051 
0052   //! Gets the verbosity of this module.
0053   int Verbosity() const
0054   {
0055     return verbosity;
0056   }
0057 
0058   //@}
0059 
0060   //!@name modifiers
0061   //@{
0062 
0063   //! enable distortions from a single fixed source
0064   void set_do_static_distortions(bool value)
0065   {
0066     m_do_static_distortions = value;
0067   }
0068 
0069   //! set the filename for the single fixed distortion
0070   void set_static_distortion_filename(const std::string &value)
0071   {
0072     m_static_distortion_filename = value;
0073   }
0074 
0075   //! enable time ordered distortions
0076   void set_do_time_ordered_distortions(bool value)
0077   {
0078     m_do_time_ordered_distortions = value;
0079   }
0080 
0081   //! time ordered distortion filename
0082   void set_time_ordered_distortion_filename(const std::string &value)
0083   {
0084     m_time_ordered_distortion_filename = value;
0085   }
0086 
0087   //! enable reaches readout
0088   void set_do_ReachesReadout(bool value)
0089   {
0090     m_do_ReachesReadout = value;
0091   }
0092 
0093   void set_read_phi_as_radians(bool flag)
0094   {
0095     m_phi_hist_in_radians = flag;
0096   }
0097 
0098   //! initialize
0099   void Init();
0100 
0101   //! get relevant histogram from time ordered TTrees
0102   void load_event(int event_num);
0103 
0104   //! Sets the verbosity of this module (0 by default=quiet).
0105   void Verbosity(const int ival)
0106   {
0107     verbosity = ival;
0108   }
0109 
0110   //@}
0111 
0112  private:
0113   //! get distortion for a set of histogram and an input momentum distribution
0114   double get_distortion(char axis, double r, double phi, double z) const;
0115 
0116   //! The verbosity level. 0 means not verbose at all.
0117   int verbosity = 0;
0118 
0119   //! Flag controls whether to assume the phi hist units are radians or cm.
0120   bool m_phi_hist_in_radians = true;
0121 
0122   bool m_do_ReachesReadout = false;
0123 
0124   //!@name static histograms
0125   //@{
0126   bool m_do_static_distortions = false;
0127   std::string m_static_distortion_filename;
0128   std::unique_ptr<TFile> m_static_tfile;
0129   TH3 *hDRint[2] = {nullptr, nullptr};
0130   TH3 *hDPint[2] = {nullptr, nullptr};
0131   TH3 *hDZint[2] = {nullptr, nullptr};
0132   TH3 *hReach[2] = {nullptr, nullptr};
0133   //@}
0134 
0135   //!@name time ordered histograms
0136   //@{
0137   bool m_do_time_ordered_distortions = false;
0138   std::string m_time_ordered_distortion_filename;
0139   std::unique_ptr<TFile> m_time_ordered_tfile;
0140   TTree *TimeTree = nullptr;
0141   TH3 *TimehDR[2] = {nullptr, nullptr};
0142   TH3 *TimehDP[2] = {nullptr, nullptr};
0143   TH3 *TimehDZ[2] = {nullptr, nullptr};
0144   TH3 *TimehRR[2] = {nullptr, nullptr};
0145   //@}
0146 };
0147 
0148 #endif /* G4TPC_PHG4TPCDISTORTION_H */