Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // Tell emacs that this is a C++ source
0002 // -*- C++ -*-.
0003 #ifndef G4TPC_PHG4TPCELECTRONDRIFT_H
0004 #define G4TPC_PHG4TPCELECTRONDRIFT_H
0005 
0006 #include "TpcClusterBuilder.h"
0007 
0008 #include <trackbase/ActsGeometry.h>
0009 
0010 #include <g4main/PHG4HitContainer.h>
0011 
0012 #include <phparameter/PHParameterInterface.h>
0013 
0014 #include <fun4all/SubsysReco.h>
0015 
0016 #include <gsl/gsl_rng.h>
0017 
0018 #include <array>
0019 #include <cmath>
0020 #include <fstream>
0021 #include <limits>
0022 #include <memory>
0023 #include <string>
0024 
0025 class PHG4TpcPadPlane;
0026 class PHG4TpcDistortion;
0027 class PHCompositeNode;
0028 class TH1;
0029 class TH2;
0030 class TNtuple;
0031 class TFile;
0032 class TrkrHitSetContainer;
0033 class TrkrHitTruthAssoc;
0034 class TrkrTruthTrackContainer;
0035 class TrkrClusterContainer;
0036 class TrkrTruthTrack;
0037 class DistortedTrackContainer;
0038 class TpcClusterBuilder;
0039 class PHG4TpcCylinderGeomContainer;
0040 class ClusHitsVerbose;
0041 
0042 class PHG4TpcElectronDrift : public SubsysReco, public PHParameterInterface
0043 {
0044  public:
0045   PHG4TpcElectronDrift(const std::string &name = "PHG4TpcElectronDrift");
0046   ~PHG4TpcElectronDrift() override = default;
0047   int Init(PHCompositeNode *) override;
0048   int InitRun(PHCompositeNode *) override;
0049   int process_event(PHCompositeNode *) override;
0050   int End(PHCompositeNode *) override;
0051 
0052   void SetDefaultParameters() override;
0053 
0054   //! detector name
0055   void Detector(const std::string &d)
0056   {
0057     detector = d;
0058   }
0059 
0060   //! detector name
0061   const std::string &Detector() const
0062   {
0063     return detector;
0064   }
0065 
0066   //! random seed
0067   void set_seed(const unsigned int iseed);
0068 
0069   //! setup TPC distortion
0070   void setTpcDistortion(PHG4TpcDistortion *);
0071 
0072   //
0073   void set_flag_threshold_distortion(bool setflag, float setthreshold);
0074 
0075   //! setup readout plane
0076   void registerPadPlane(PHG4TpcPadPlane *padplane);
0077 
0078   // cluster the PHG4Tracks individually
0079   TpcClusterBuilder truth_clusterer{};
0080   void set_pixel_thresholdrat(double val) { truth_clusterer.set_pixel_thresholdrat(val); };
0081   void set_max_g4hitstep(float f) { max_g4hitstep = f; };
0082   void set_ClusHitsVerbose(bool set = true) { record_ClusHitsVerbose = set; };
0083   void set_zero_bfield_flag(bool flag) { zero_bfield = flag; };
0084   void set_zero_bfield_diffusion_factor(double f) { zero_bfield_diffusion_factor = f; };
0085   void use_PDG_gas_params() { m_use_PDG_gas_params = true; }
0086   ClusHitsVerbosev1 *mClusHitsVerbose{nullptr};
0087 
0088  private:
0089   TrkrHitSetContainer *hitsetcontainer{nullptr};
0090   TrkrHitTruthAssoc *hittruthassoc{nullptr};
0091   TrkrTruthTrackContainer *truthtracks{nullptr};
0092   TrkrTruthTrack *truth_track{nullptr};
0093   TrkrClusterContainer *truthclustercontainer{nullptr};  // the TrkrClusterContainer for truth clusters
0094   ActsGeometry *m_tGeometry{nullptr};
0095   PHG4TpcCylinderGeomContainer *seggeo{nullptr};
0096 
0097   TNtuple *nt{nullptr};
0098   TNtuple *nthit{nullptr};
0099   TNtuple *ntfinalhit{nullptr};
0100   TNtuple *ntpad{nullptr};
0101 
0102   ///@name evaluation histograms
0103   //@{
0104   TH1 *dlong{nullptr};
0105   TH1 *dtrans{nullptr};
0106   TH1 *ratioElectronsRR{nullptr};
0107   TH2 *hitmapstart{nullptr};
0108   TH2 *hitmapend{nullptr};
0109   TH2 *hitmapstart_z{nullptr};
0110   TH2 *hitmapend_z{nullptr};
0111   TH2 *z_startmap{nullptr};
0112   TH2 *deltaphi{nullptr};
0113   TH2 *deltar{nullptr};
0114   TH2 *deltaphinodiff{nullptr};
0115   TH2 *deltaRphinodiff{nullptr};
0116   TH2 *deltaphivsRnodiff{nullptr};
0117   TH2 *deltaphinodist{nullptr};
0118   TH2 *deltarnodiff{nullptr};
0119   TH2 *deltarnodist{nullptr};
0120   TH2 *deltaz{nullptr};
0121   //@}
0122 
0123   int event_num{0};
0124 
0125   float max_g4hitstep{7.};
0126   float thresholdforreachesreadout{0.5};
0127 
0128   double diffusion_trans = std::numeric_limits<double>::signaling_NaN();
0129   double added_smear_sigma_trans = std::numeric_limits<double>::signaling_NaN();
0130   double diffusion_long = std::numeric_limits<double>::signaling_NaN();
0131   double added_smear_sigma_long = std::numeric_limits<double>::signaling_NaN();
0132   double drift_velocity = std::numeric_limits<double>::signaling_NaN();
0133   double tpc_length = std::numeric_limits<double>::signaling_NaN();
0134   double electrons_per_gev = std::numeric_limits<double>::signaling_NaN();
0135   double min_active_radius = std::numeric_limits<double>::signaling_NaN();
0136   double max_active_radius = std::numeric_limits<double>::signaling_NaN();
0137   double min_time = std::numeric_limits<double>::signaling_NaN();
0138   double max_time = std::numeric_limits<double>::signaling_NaN();
0139   double zero_bfield_diffusion_factor{3.5};  // at drift voltage of 400 V
0140 
0141   bool record_ClusHitsVerbose{false};
0142   bool do_ElectronDriftQAHistos{false};
0143   bool do_getReachReadout{false};
0144   bool zero_bfield{false};
0145   bool m_use_PDG_gas_params{false};
0146 
0147   std::unique_ptr<TrkrHitSetContainer> temp_hitsetcontainer;
0148   std::unique_ptr<TrkrHitSetContainer> single_hitsetcontainer;
0149   std::unique_ptr<PHG4TpcPadPlane> padplane;
0150   std::unique_ptr<PHG4TpcDistortion> m_distortionMap;
0151   std::unique_ptr<TFile> m_outf;
0152   std::unique_ptr<TFile> EDrift_outf;
0153 
0154   std::string detector;
0155   std::string hitnodename;
0156   std::string seggeonodename;
0157 
0158   //! rng de-allocator
0159   class Deleter
0160   {
0161    public:
0162     //! deletion operator
0163     void operator()(gsl_rng *rng) const { gsl_rng_free(rng); }
0164   };
0165   std::unique_ptr<gsl_rng, Deleter> RandomGenerator;
0166 };
0167 
0168 #endif  // G4TPC_PHG4TPCELECTRONDRIFT_H