GEMC  2.3
Geant4 Monte-Carlo Framework
ECAL_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 "ECAL_hitprocess.h"
7 
8 // CLHEP units
9 #include "CLHEP/Units/PhysicalConstants.h"
10 using namespace CLHEP;
11 
12 map<string, double> ECAL_HitProcess :: integrateDgt(MHit* aHit, int hitn)
13 {
14  map<string, double> dgtz;
15  vector<identifier> identity = aHit->GetId();
16  trueInfos tInfos(aHit);
17 
18 
19  // R.De Vita (April 2009)
20 
21  // relevant parameter for digitization (in the future should be read from database)
22  double tdc_time_to_channel=20; // conversion factor from time(ns) to TDC channels)
23  double tdc_max=4095; // TDC range
24  double adc_charge_tochannel=20; // conversion factor from charge(pC) to ADC channels
25  double PbWO4_light_yield =120/MeV; // Lead Tungsten Light Yield (PAD have similar QE for
26  // fast component, lambda=420nm-ly=120ph/MeV, and slow component,
27  // lambda=560nm-ly=20ph/MeV, taking fast component only)
28  double APD_qe = 0.75; // APD Quantum Efficiency (Hamamatsu S8664-55)
29  double APD_size = 25*mm*mm; // APD size ( 5 mm x 5 mm)
30  double APD_gain = 250; // based on IC note
31  double APD_noise = 0.006; // relative noise based on a Voltage and Temperature stability of 30 mV (10%/V) and 0.1 C (-5%/C)
32  double AMP_input_noise = 4500; // preamplifier input noise in number of electrons
33  double AMP_gain = 2500; // preamplifier gain = 5V/pC x 25 ns (tipical signal duration)
34  double light_speed =15;
35 
36  // Get the crystal length: in the IC crystal are trapezoid (TRD) and the half-length is the 5th element
37  double length = 2 * aHit->GetDetector().dimensions[4];
38  // Get the crystal width (rear face): in the IC crystal are trapezoid (TRD) and the half-length is the 2th element
39  double width = 2 * aHit->GetDetector().dimensions[1];
40 
41  // use Crystal ID to define IDX and IDY
42  int idx = identity[0].id;
43  int idy = identity[1].id;
44 
45  // initialize ADC and TDC
46  int adc = 0;
47  int tdc = 8192;
48 
49 
50  double Tmin = 99999.;
51  vector<G4double> times = aHit->GetTime();
52  vector<G4ThreeVector> Lpos = aHit->GetLPos();
53  vector<G4double> Edep = aHit->GetEdep();
54  if(tInfos.eTot>0)
55  {
56  for(unsigned int s=0; s<tInfos.nsteps; s++)
57  {
58  double dRight = length/2 - Lpos[s].z(); // distance along z between the hit position and the end of the crystal
59  double timeR = times[s] + dRight/cm/light_speed; // arrival time of the signal at the end of the crystal (speed of light in the crystal=15 cm/ns)
60  if(Edep[s]>1*MeV) Tmin=min(Tmin,timeR); // signal time is set to first hit time with energy above 1 MeV
61  }
62  tdc=int(Tmin*tdc_time_to_channel);
63  if(tdc>tdc_max) tdc=(int)tdc_max;
64  // calculate number of photoelectrons detected by the APD considering the light yield, the q.e., and the size of the sensor
65  double npe=G4Poisson(tInfos.eTot*PbWO4_light_yield/2*APD_qe*APD_size/width/width);
66  // calculating APD output charge (in number of electrons) and adding noise
67  double nel=npe*APD_gain;
68  nel=nel*G4RandGauss::shoot(1.,APD_noise);
69  if(nel<0) nel=0;
70  // adding preamplifier input noise
71  nel=nel+AMP_input_noise*G4RandGauss::shoot(0.,1.);
72  if(nel<0) nel=0;
73  // converting to charge (in picoCoulomb)
74  double crg=nel*AMP_gain*1.6e-7;
75  // converting to ADC channels
76  adc= (int) (crg*adc_charge_tochannel);
77 
78  }
79 
80  dgtz["hitn"] = hitn;
81  dgtz["idx"] = idx;
82  dgtz["idy"] = idy;
83  dgtz["adc"] = adc;
84  dgtz["tdc"] = tdc;
85 
86  return dgtz;
87 }
88 
89 vector<identifier> ECAL_HitProcess :: processID(vector<identifier> id, G4Step* aStep, detector Detector)
90 {
91  id[id.size()-1].id_sharing = 1;
92  return id;
93 }
94 
95 
96 map< string, vector <int> > ECAL_HitProcess :: multiDgt(MHit* aHit, int hitn)
97 {
98  map< string, vector <int> > MH;
99 
100  return MH;
101 }
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
vector< identifier > processID(vector< identifier >, G4Step *, detector)
map< string, double > integrateDgt(MHit *, int)
vector< identifier > GetId()
Definition: Hit.h:103
map< string, vector< int > > multiDgt(MHit *, int)
vector< G4ThreeVector > GetLPos()
Definition: Hit.h:76
double eTot
Definition: HitProcess.h:40
Definition: Hit.h:22
vector< double > GetTime()
Definition: Hit.h:89
unsigned int nsteps
Definition: HitProcess.h:39
vector< double > dimensions
vector of dimensions. Size, units depends on solid type
Definition: detector.h:77
vector< double > GetEdep()
Definition: Hit.h:83
detector GetDetector()
Definition: Hit.h:108