GEMC  2.3
Geant4 Monte-Carlo Framework
ecs_hitprocess.cc
Go to the documentation of this file.
1 // G4 headers
2 #include "G4Poisson.hh"
3 #include "Randomize.hh"
4 
5 // gemc headers
6 #include "ecs_hitprocess.h"
7 
8 static ecsConstants initializeECSConstants(int runno)
9 {
10  ecsConstants ecc;
11  ecc.runNo = 0;
12 
13  ecc.attlen = 3760.; // Attenuation Length (mm)
14  ecc.TDC_time_to_channel = 20.; // conversion from time (ns) to TDC channels.
15  ecc.ECfactor = 3.5; // number of p.e. divided by the energy deposited in MeV; value taken from gsim. see EC NIM paper table 1.
16  ecc.TDC_MAX = 4095; // max value for EC tdc.
17  ecc.ec_MeV_to_channel = 10.; // conversion from energy (MeV) to ADC channels
18 
19  return ecc;
20 }
21 
23 {
24  if(ecc.runNo != runno)
25  {
26  cout << " > Initializing " << HCname << " digitization for run number " << runno << endl;
27  ecc = initializeECSConstants(runno);
28  ecc.runNo = runno;
29  }
30 }
31 
32 // Process the ID and hit for the EC using individual EC scintillator strips.
33 map<string, double> ecs_HitProcess :: integrateDgt(MHit* aHit, int hitn)
34 {
35  map<string, double> dgtz;
36  vector<identifier> identity = aHit->GetId();
37 
38  // get sector, stack (inner or outer), view (U, V, W), and strip.
39  int sector = identity[0].id;
40  int stack = identity[1].id;
41  int view = identity[2].id;
42  int strip = identity[3].id;
43  trueInfos tInfos(aHit);
44 
45  // initialize ADC and TDC
46  int ADC = 0;
47  int TDC = ecc.TDC_MAX;
48 
49  // simulate the adc value.
50  if (tInfos.eTot > 0)
51  {
52  // number of photoelectrons.
53  double EC_npe = G4Poisson(tInfos.eTot*ecc.ECfactor);
54  // Fluctuations in PMT gain distributed using Gaussian with
55  // sigma SNR = sqrt(ngamma)/sqrt(del/del-1) del = dynode gain = 3 (From RCA PMT Handbook) p. 169)
56  // algorithm, values, and comment above taken from gsim.
57  double sigma = sqrt(EC_npe)*1.15;
58  double EC_charge = G4RandGauss::shoot(EC_npe,sigma)*ecc.ec_MeV_to_channel/ecc.ECfactor;
59  if (EC_charge <= 0) EC_charge=0.0; // guard against weird, rare events.
60  ADC = (int) EC_charge;
61  }
62 
63  // simulate the tdc.
64  TDC = (int) (tInfos.time*ecc.TDC_time_to_channel);
65  if (TDC > ecc.TDC_MAX) TDC = ecc.TDC_MAX;
66 
67  dgtz["hitn"] = hitn;
68  dgtz["sector"] = sector;
69  dgtz["stack"] = stack;
70  dgtz["view"] = view;
71  dgtz["strip"] = strip;
72  dgtz["ADC"] = ADC;
73  dgtz["TDC"] = TDC;
74 
75  return dgtz;
76 }
77 
78 vector<identifier> ecs_HitProcess :: processID(vector<identifier> id, G4Step* aStep, detector Detector)
79 {
80  id[id.size()-1].id_sharing = 1;
81  return id;
82 }
83 
84 
85 map< string, vector <int> > ecs_HitProcess :: multiDgt(MHit* aHit, int hitn)
86 {
87  map< string, vector <int> > MH;
88 
89  return MH;
90 }
91 
92 
93 
94 // this static function will be loaded first thing by the executable
95 ecsConstants ecs_HitProcess::ecc = initializeECSConstants(1);
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
double ec_MeV_to_channel
void initWithRunNumber(int runno)
vector< identifier > GetId()
Definition: Hit.h:103
double time
Definition: HitProcess.h:43
double TDC_time_to_channel
double eTot
Definition: HitProcess.h:40
Definition: Hit.h:22
static ecsConstants ecc
map< string, vector< int > > multiDgt(MHit *, int)
vector< identifier > processID(vector< identifier >, G4Step *, detector)
map< string, double > integrateDgt(MHit *, int)
string HCname
Definition: HitProcess.h:117