Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef G4TPC_PHG4TPCDIRECTLASER_H
0002 #define G4TPC_PHG4TPCDIRECTLASER_H
0003 
0004 #include <fun4all/SubsysReco.h>
0005 
0006 #include <phparameter/PHParameterInterface.h>
0007 
0008 #include <TNtuple.h>
0009 #include <TVector3.h>
0010 
0011 #include <cmath>
0012 #include <limits>
0013 #include <string>  // for string, allocator
0014 #include <vector>  // for vector
0015 
0016 class PHG4HitContainer;
0017 class SvtxTrackMap;
0018 class PHG4TruthInfoContainer;
0019 class PHCompositeNode;
0020 
0021 class PHG4TpcDirectLaser : public SubsysReco, public PHParameterInterface
0022 {
0023  public:
0024   /// constructor
0025   PHG4TpcDirectLaser(const std::string &name = "PHG4TpcDirectLaser");
0026 
0027   /// destructor
0028   ~PHG4TpcDirectLaser() override = default;
0029 
0030   /// run initialization
0031   int InitRun(PHCompositeNode *) override;
0032 
0033   /// per event processing
0034   int process_event(PHCompositeNode *) override;
0035 
0036   /// default parameters
0037   void SetDefaultParameters() override;
0038 
0039   /// detector name
0040   void Detector(const std::string &d)
0041   {
0042     detector = d;
0043   }
0044 
0045   /// define steps along phi
0046   void SetPhiStepping(int n, double min, double max);
0047 
0048   /// define steps along theta
0049   void SetThetaStepping(int n, double min, double max);
0050 
0051   /// define steps for file
0052   void SetFileStepping(int n);
0053 
0054   /// get total number of steps
0055   int GetNpatternSteps() const
0056   {
0057     return nPhiSteps * nThetaSteps;
0058   };
0059 
0060   /// set current patter step
0061   void SetCurrentPatternStep(int value)
0062   {
0063     currentPatternStep = value;
0064   }
0065 
0066   /// advance automatically through patterns
0067   void SetDirectLaserAuto(bool value)
0068   {
0069     m_autoAdvanceDirectLaser = value;
0070   };
0071 
0072   /// advance automatically through pattern from file
0073   void SetDirectLaserPatternfromFile(bool value)
0074   {
0075     m_steppingpattern = value;
0076   };
0077 
0078   void SetArbitraryThetaPhi(double theta, double phi)
0079   {
0080     arbitrary_theta = theta;
0081     arbitrary_phi = phi;
0082   }
0083 
0084  private:
0085   /// define lasers
0086   /* by default there are 4 lasers on each side of the TPC */
0087   void SetupLasers();
0088 
0089   /// aim lasers to a given theta and phi angle
0090   void AimToThetaPhi(double theta, double phi);
0091 
0092   /// aim lasers to a give step
0093   void AimToPatternStep(int n);
0094 
0095   /// aim lasers to a give step from file
0096   void AimToPatternStep_File(int n);
0097 
0098   float theta_p{0};
0099   float phi_p{0};
0100   TNtuple *pattern{nullptr};
0101 
0102   /// aim to next step
0103   void AimToNextPatternStep();
0104 
0105   /// stores laser position and direction along z
0106   class Laser
0107   {
0108    public:
0109     /// laser position
0110     TVector3 m_position;
0111 
0112     /// laser phi position
0113     double m_phi{0};
0114 
0115     /// laser direction along z
0116     int m_direction{1};
0117   };
0118 
0119   /// append track in given angular direction and for a given laser
0120   void AppendLaserTrack(double theta, double phi, const Laser &);
0121 
0122   /// detector name
0123   std::string detector{"TPC"};
0124 
0125   /// g4hitnode name
0126   std::string hitnodename;
0127 
0128   /// lasers
0129   std::vector<Laser> m_lasers;
0130 
0131   /// number of electrons deposited per cm laser track
0132   int electrons_per_cm{300};
0133 
0134   // number of electrons per deposited GeV in TPC gas
0135   /**
0136    * it is used to convert a given number of electrons into an energy
0137    * as expected by G4Hit. The energy is then converted back to a number of electrons
0138    * inside PHG4TpcElectronDrift
0139    */
0140   double electrons_per_gev{std::numeric_limits<double>::signaling_NaN()};
0141 
0142   double arbitrary_theta{-30.0};  // degrees
0143   double arbitrary_phi{-30.0};    // degrees
0144 
0145   ///@name default phi and theta steps
0146   //@{
0147   int nPhiSteps{1};
0148   int nThetaSteps{1};
0149   int nTotalSteps{1};
0150   double minPhi{0};
0151   double maxPhi{0};
0152   double minTheta{0};
0153   double maxTheta{0};
0154   //@}
0155 
0156   // current patter step
0157   int currentPatternStep{0};
0158 
0159   /// set to true to change direct laser tracks from one event to the other
0160   bool m_autoAdvanceDirectLaser{false};
0161 
0162   /// set to true to get stepping patern from file
0163   bool m_steppingpattern{false};
0164 
0165   /// g4hit container
0166   PHG4HitContainer *m_g4hitcontainer{nullptr};
0167 
0168   //! truth information
0169   PHG4TruthInfoContainer *m_g4truthinfo{nullptr};
0170 
0171   /// track map, used to store track parameters
0172   std::string m_track_map_name{"SvtxTrackMap"};
0173   SvtxTrackMap *m_track_map{nullptr};
0174 };
0175 
0176 #endif