2 #include "G4Poisson.hh" 3 #include "Randomize.hh" 9 #include "CLHEP/Units/PhysicalConstants.h" 10 using namespace CLHEP;
14 map<string, double> dgtz;
15 vector<identifier> identity = aHit->
GetId();
17 int sector = identity[0].id;
18 int layer = identity[1].id;
19 int paddle = identity[2].id;
22 double light_yield=1600/MeV;
23 double att_length=108*cm;
24 double sensor_surface=pow(3.5*cm,2)*pi;
25 double paddle_surface=pow(10*cm,2);
26 double light_coll=sensor_surface/paddle_surface;
28 double sensor_qe=0.15;
29 double sensor_gain=0.472*1.6*1.275;
33 double tdc_conv=1/0.001/ns;
58 double length = 20*cm;
61 double birks_constant=aHit->
GetDetector().
GetLogical()->GetMaterial()->GetIonisation()->GetBirksConstant();
66 double time_min[4] = {0,0,0,0};
68 vector<G4ThreeVector> Lpos = aHit->
GetLPos();
69 vector<G4double> Edep = aHit->
GetEdep();
70 vector<G4double> Dx = aHit->
GetDx();
73 vector<G4double> times = aHit->
GetTime();
75 unsigned int nsteps = Edep.size();
77 for(
unsigned int s=0; s<nsteps; s++) Etot = Etot + Edep[s];
81 for(
unsigned int s=0; s<nsteps; s++)
84 double dLeft = length + Lpos[s].y();
85 double dRight = length - Lpos[s].y();
100 double Edep_B = BirksAttenuation(Edep[s],Dx[s],charge[s],birks_constant);
105 if (light_coll > 1) light_coll = 1.;
107 etotL = etotL + Edep_B/2 * exp(-dLeft/att_length) * light_coll;
108 etotR = etotR + Edep_B/2 * exp(-dRight/att_length) * light_coll;
110 etotB = etotB + Edep[s]/2 * exp(-dLeft/att_length) * light_coll;
111 etotF = etotF + Edep[s]/2 * exp(-dRight/att_length) * light_coll;
118 timeL= timeL + (times[s] + dLeft/veff) / nsteps;
119 timeR= timeR + (times[s] + dRight/veff) / nsteps;
121 timeB= timeB + (times[s] + dLeft/veff) / nsteps;
122 timeF= timeF + (times[s] + dRight/veff) / nsteps;
125 if(s==0 || (time_min[0]>(times[s]+dLeft/veff))) time_min[0]=times[s]+dLeft/veff;
129 if(s==0 || (time_min[1]>(times[s]+dRight/veff))) time_min[1]=times[s]+ dRight/veff;
133 if(s==0 || (time_min[2]>(times[s]+dLeft/veff))) time_min[2]=times[s]+ dLeft/veff;
136 if(s==0 || (time_min[3]>(times[s]+dRight/veff))) time_min[3]=times[s]+ dRight/veff;
141 double peL=G4Poisson(etotL*light_yield*sensor_qe);
142 double peR=G4Poisson(etotR*light_yield*sensor_qe);
143 double sigmaTL=sqrt(pow(0.2*nanosecond,2.)+pow(1.*nanosecond,2.)/(peL+1.));
144 double sigmaTR=sqrt(pow(0.2*nanosecond,2.)+pow(1.*nanosecond,2.)/(peR+1.));
147 TDCL=(int) ((time_min[0]+G4RandGauss::shoot(0.,sigmaTL)) * tdc_conv);
148 TDCR=(int) ((time_min[1]+G4RandGauss::shoot(0.,sigmaTR)) * tdc_conv);
151 ADCL=(int) (peL*sensor_gain*adc_conv + adc_ped);
152 ADCR=(int) (peR*sensor_gain*adc_conv + adc_ped);
156 double peB=G4Poisson(etotB*light_yield*sensor_qe);
157 double peF=G4Poisson(etotF*light_yield*sensor_qe);
158 double sigmaTB=sqrt(pow(0.2*nanosecond,2.)+pow(1.*nanosecond,2.)/(peB+1.));
159 double sigmaTF=sqrt(pow(0.2*nanosecond,2.)+pow(1.*nanosecond,2.)/(peF+1.));
162 TDCB=(int) ((time_min[2] + G4RandGauss::shoot(0.,sigmaTB)) * tdc_conv);
163 TDCF=(int) ((time_min[3] + G4RandGauss::shoot(0.,sigmaTF)) * tdc_conv);
166 ADCB=(int) (G4Poisson(etotB*light_yield*sensor_qe)*sensor_gain*adc_conv + adc_ped);
167 ADCF=(int) (G4Poisson(etotF*light_yield*sensor_qe)*sensor_gain*adc_conv + adc_ped);
180 cout << log_msg <<
" layer: " << layer <<
", paddle: " << paddle ;
181 cout << log_msg <<
" Etot=" << Etot/MeV << endl;
182 cout << log_msg <<
" TDCL=" << TDCL <<
" TDCR=" << TDCR <<
" ADCL=" << ADCL <<
" ADCR=" << ADCR << endl;
183 cout << log_msg <<
" TDCB=" << TDCB <<
" TDCF=" << TDCF <<
" ADCB=" << ADCB <<
" ADCF=" << ADCF << endl;
187 dgtz[
"sector"] = sector;
188 dgtz[
"layer"] = layer;
189 dgtz[
"paddle"] = paddle;
205 id[
id.size()-1].id_sharing = 1;
218 double response = destep;
219 if (birks*destep*stepl*charge != 0.)
221 response = destep/(1. + birks*destep/stepl);
233 double C=9.59*1E-4*mm*mm/MeV/MeV;
234 double response = destep;
235 if (birks*destep*stepl*charge != 0.)
237 response = destep/(1. + birks*destep/stepl + C*pow(destep/stepl,2.));
245 map< string, vector <int> > MH;
G4LogicalVolume * GetLogical()
Returns Logical Volume pointer.
vector< identifier > processID(vector< identifier >, G4Step *, detector)
map< string, double > integrateDgt(MHit *, int)
vector< identifier > GetId()
map< string, vector< int > > multiDgt(MHit *, int)
vector< G4ThreeVector > GetLPos()
vector< double > GetTime()
double BirksAttenuation2(double, double, int, double)
double BirksAttenuation(double, double, int, double)
vector< double > GetEdep()
vector< int > GetCharges()