Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4TpcElectronDrift.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4TpcElectronDrift.h
1 // Tell emacs that this is a C++ source
2 // -*- C++ -*-.
3 #ifndef G4TPC_PHG4TPCELECTRONDRIFT_H
4 #define G4TPC_PHG4TPCELECTRONDRIFT_H
5 
6 #include "TpcClusterBuilder.h"
7 
8 #include <array>
9 #include <cmath>
10 #include <fstream>
11 #include <fun4all/SubsysReco.h>
13 #include <gsl/gsl_rng.h>
14 #include <memory>
15 #include <phparameter/PHParameterInterface.h>
16 #include <string>
17 #include <trackbase/ActsGeometry.h>
18 
19 class PHG4TpcPadPlane;
20 class PHG4TpcDistortion;
21 class PHCompositeNode;
22 class TH1;
23 class TH2;
24 class TNtuple;
25 class TFile;
27 class TrkrHitTruthAssoc;
30 class TrkrTruthTrack;
31 class DistortedTrackContainer;
32 class TpcClusterBuilder;
34 class ClusHitsVerbose;
35 
37 {
38  public:
39  PHG4TpcElectronDrift(const std::string &name = "PHG4TpcElectronDrift");
40  ~PHG4TpcElectronDrift() override { };
41  int Init(PHCompositeNode *) override;
42  int InitRun(PHCompositeNode *) override;
43  int process_event(PHCompositeNode *) override;
44  int End(PHCompositeNode *) override;
45 
46  void SetDefaultParameters() override;
47 
49  void Detector(const std::string &d)
50  {
51  detector = d;
52  }
53 
56  {
57  return detector;
58  }
59 
61  void set_seed(const unsigned int iseed);
62 
65 
66  //
67  void set_flag_threshold_distortion(bool setflag, float setthreshold)
68  {
69  printf("The logical status of threshold is now %d! and the value is set to %f\n\n\n", setflag, setthreshold);
70  do_getReachReadout = setflag;
71  thresholdforreachesreadout = setthreshold;
72  }
73 
74 
77 
78  // cluster the PHG4Tracks individually
81  void set_max_g4hitstep (float _) { max_g4hitstep =_; };
82  void set_ClusHitsVerbose(bool set=true) { record_ClusHitsVerbose = set; };
83  void set_zero_bfield_flag(bool flag) { zero_bfield = flag; };
86 
87  private:
88  float max_g4hitstep { 7. };
89  bool record_ClusHitsVerbose { false };
91  /* TpcClusterBuilder MapToPadPlane(const double x, const double y, const */
92  /* double z, const unsigned int side, PHG4HitContainer::ConstIterator hiter, */
93  /* TNtuple *ntpad, TNtuple *nthit); */
94 
95  std::ofstream f_out;
96 
101  TrkrClusterContainer *truthclustercontainer = nullptr; // the TrkrClusterContainer for truth clusters
102  std::unique_ptr<TrkrHitSetContainer> temp_hitsetcontainer;
103  std::unique_ptr<TrkrHitSetContainer> single_hitsetcontainer;
104  std::unique_ptr<PHG4TpcPadPlane> padplane;
105 
106  std::unique_ptr<PHG4TpcDistortion> m_distortionMap;
109 
110  int event_num = 0;
113  bool do_getReachReadout = false;
114 
116 
117  TH1 *dlong = nullptr;
118  TH1 *dtrans = nullptr;
119  TH2 *hitmapstart = nullptr;
120  TH2 *hitmapend = nullptr;
121  TH2 *z_startmap = nullptr;
122  TH2 *deltaphi = nullptr;
123  TH2 *deltar = nullptr;
124  TH2 *deltaphinodiff = nullptr;
125  TH2 *deltaRphinodiff = nullptr;
126  TH2 *deltaphivsRnodiff = nullptr;
127  TH2 *deltaphinodist = nullptr;
128  TH2 *deltarnodiff = nullptr;
129  TH2 *deltarnodist = nullptr;
130  TH2 *deltaz = nullptr;
132 
133  std::unique_ptr<TFile> m_outf;
134  std::unique_ptr<TFile> EDrift_outf;
135 
136  TNtuple *nt = nullptr;
137  TNtuple *nthit = nullptr;
138  TNtuple *ntfinalhit = nullptr;
139  TNtuple *ntpad = nullptr;
140 
144 
145  double diffusion_trans = NAN;
147  double diffusion_long = NAN;
149  double drift_velocity = NAN;
150  double tpc_length = NAN;
151  double electrons_per_gev = NAN;
152  double min_active_radius = NAN;
153  double max_active_radius = NAN;
154  double min_time = NAN;
155  double max_time = NAN;
156 
157  bool zero_bfield = false;
158  double zero_bfield_diffusion_factor = 3.5; // at drift voltage of 400 V
159 
161  class Deleter
162  {
163  public:
165  void operator()(gsl_rng *rng) const { gsl_rng_free(rng); }
166  };
167  std::unique_ptr<gsl_rng, Deleter> RandomGenerator;
168 };
169 
170 #endif // G4TPC_PHG4TPCELECTRONDRIFT_H