Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fillSpaceChargeMaps.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file fillSpaceChargeMaps.h
1 // Tell emacs that this is a C++ source
2 // -*- C++ -*-.
3 #ifndef FILLSPACECHARGEMAPS_FILLSPACECHARGEMAPS_H
4 #define FILLSPACECHARGEMAPS_FILLSPACECHARGEMAPS_H
5 
6 #include <fun4all/SubsysReco.h>
7 
8 //#include <g4tpc/PHG4TpcPadPlane.h>
9 //#include <g4tpc/PHG4TpcPadPlaneReadout.h>
10 
11 #include <map>
12 #include <set>
13 #include <string>
14 #include <vector>
15 
16 #include <cmath> // for sin, asin, cos, floor, M_PI
17 
18 // Forward declerations
20 class PHCompositeNode;
21 class TFile;
22 class TH1;
23 class TH2;
24 class TH3;
25 class TTree;
26 
28 {
29  public:
30  fillSpaceChargeMaps(const std::string &name = "fillSpaceChargeMaps", const std::string &filename = "Hist.root");
31 
32  virtual ~fillSpaceChargeMaps();
33 
39  int Init(PHCompositeNode * /*topNode*/) override;
40 
46  int InitRun(PHCompositeNode * /*topNode*/) override;
47 
51  int process_event(PHCompositeNode *topNode) override;
52 
54  int End(PHCompositeNode * /*topNode*/) override;
55 
56  void SetFrequency(int freq);
57  void SetBeamXing(const std::vector<int> &beamXs);
58  void SetEvtStart(int newEvtStart);
59  void SetUseIBFMap(bool useIBFMap = true);
60  void SetGain(float ampGain = 2e3);
61  void SetIBF(float ampIBFfrac = 0.004);
62  void SetCollSyst(int coll_syst = 0);
63  void SetAvg(int fAvg = 0);
64  void UseSliming(int fSliming = 0);
65  void UseFieldMaps(int shiftElectrons = 0);
66 
67  private:
68  std::vector<double> getNewWeights(TH3 *_h_SC_ibf, TH2 *_h_modules_anode, TH2 *_h_modules_measuredibf, double _hit_r, double _hit_phi, double dr_bin, double dphi_bin, bool _fUseIBFMap);
69  bool IsOverFrame(double r, double phi);
70  std::vector<double> putOnPlane(double r, double phi);
71 
72  Fun4AllHistoManager *hm = nullptr;
74  std::set<std::string> _node_postfix;
75  std::map<int, int> _timestamps;
76  std::vector<int> _keys;
77  TFile *outfile = nullptr;
78  float _ampGain = 2e3;
79  float _ampIBFfrac = 0.02;
80  int _collSyst = 0;
81  int _shiftElectrons = 0;
82 
83  double _freqKhz = 22;
84  //int _beamxing = 0;
85  std::vector<int> _beamxing;
86  //std::vector<int> _beamxing_end;
87 
88  int _evtstart = 0;
89  int _fAvg = 0;
90  int _fSliming = 0;
91  TTree *_rawHits = nullptr;
92  int _isOnPlane = 0;
93  float _hit_z = 0;
94  float _hit_r = 0;
95  float _hit_phi = 0;
96  float _hit_eion = 0;
97  float _ibf_vol = 0;
98  float _amp_ele_vol = 0;
99  float _event_timestamp = 0;
100  float _event_bunchXing = 0;
101 
102  bool _fUseIBFMap = false;
103  TH2 *_h_modules_anode = nullptr;
104  TH2 *_h_modules_measuredibf = nullptr;
105  TH1 *_h_hits = nullptr;
106  TH1 *_h_R = nullptr;
107  TH2 *_h_DC_E = nullptr;
108  TH2 *_h_SC_XY = nullptr;
109  static const int nFrames = 30;
110  TH3 *_h_SC_prim[nFrames] = {nullptr};
111  TH3 *_h_SC_ibf[nFrames] = {nullptr};
112 
113  //PHG4TpcPadPlaneReadout *padplane = nullptr;
114  //PHG4TpcCylinderGeomContainer *seggeo = nullptr;
115 
116  float f = 0.5; //for now, just pick the middle of the hit. Do better later.
117  float ns = 1e-9, s = 1.0; // us=1e-6,ms=1e-3,
118  float mm = 1.0, cm = 10.0, m = 1000.0; //um=1e-3,//changed to make 'cm' 1.0, for convenience.
119  float kHz = 1e3, MHz = 1e6; //Hz=1,
120  float V = 1.0;
121  //used two ways: 1) to apply units to variables when defined
122  // 2) to divide by certain units so that those variables are expressed in those units.
123 
124  //float ionMobility=3.37*cm*cm/V/s;
125  float ionMobility = 1.65 * cm * cm / V / s;
126  float vIon = ionMobility * 400 * V / cm;
127  //float vIon=16.0*um/us;
128  float mbRate = _freqKhz * kHz;
129  float xingRate = 9.383 * MHz;
130  //float mean = mbRate/xingRate;
131  //float z_rdo=105.5*cm;
132  //float rmin=20*cm;
133  //float rmax=78*cm;
134 
135  double Ne_dEdx = 1.56 / cm; // keV/cm
136  double CF4_dEdx = 7.00 / cm; // keV/cm
137  double Ne_NTotal = 43 / cm; // Number/cm
138  double CF4_NTotal = 100 / cm; // Number/cm
139  //double Tpc_NTot = 0.90 * Ne_NTotal + 0.10 * CF4_NTotal;
140  //double Tpc_dEdx = 0.90 * Ne_dEdx + 0.10 * CF4_dEdx;
141  double Tpc_NTot = 0.50 * Ne_NTotal + 0.50 * CF4_NTotal;
142  double Tpc_dEdx = 0.50 * Ne_dEdx + 0.50 * CF4_dEdx;
143 
144  //double Tpc_ElectronsPerKeV = Tpc_NTot / Tpc_dEdx;
145  double Tpc_ElectronsPerGeV = Tpc_NTot / Tpc_dEdx * 1e6; //electrons per gev.
146  double phi_dead_bins[24] ={ 6.5314-2 * M_PI, 6.545-2 * M_PI,
147  0.7718, 0.7854,
148  1.2954, 1.309,
149  1.819, 1.8326,
150  2.3426, 2.3562,
151  2.8662, 2.8798,
152  3.3898, 3.4034,
153  3.9134, 3.927,
154  4.437, 4.4506,
155  4.9606, 4.9742,
156  5.4842, 5.4978,
157  6.0078, 6.0214};
158  //int nr=159;
159  //int nphi=360;
160  //int nz=62*2;
161 
162  //double hrstep=(rmax-rmin)/nr;
163  //double hphistep=2*pi/nphi;
164  //double hzstep=z_rdo/nz;
165 
166  //int nBeams = z_rdo/(vIon/xingRate); //numaber of beamcrossings to fill TPC
167 
168  float _mbRate = 0;
169  float _xingRate = 0;
170  float _mean = 0;
171 };
172 
173 #endif // FILLSPACECHARGEMAPS_FILLSPACECHARGEMAPS_H