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 xch = identity[1].id;
19 int ych = identity[2].id;
55 double integration_frac=1.;
56 double optical_coupling=0.8;
57 double light_yield_crs=50000*integration_frac/MeV;
58 double att_length_crs=600*cm;
59 double sensor_surface_crs=pow(0.3*cm,2);
61 double redout_surface_crs=pow(4.7*cm,2);
62 double light_coll_crs=sensor_surface_crs/redout_surface_crs;
63 double sensor_qe_crs=0.22;
72 double veff_crs=30/1.8*cm/ns;
75 double tdc_conv_crs=1./ns;
76 double T_offset_crs=0*ns;
79 double TDCL_crs = 4096;
80 double TDCR_crs = 4096;
90 double birks_constant=aHit->
GetDetector().
GetLogical()->GetMaterial()->GetIonisation()->GetBirksConstant();
94 birks_constant=3.2e-3;
97 double time_min_crs[4] = {0,0,0,0};
99 vector<G4ThreeVector> Lpos = aHit->
GetLPos();
100 vector<G4double> Edep = aHit->
GetEdep();
101 vector<G4double> Dx = aHit->
GetDx();
107 vector<G4double> times = aHit->
GetTime();
110 unsigned int nsteps = Edep.size();
114 for(
unsigned int s=0; s<nsteps; s++)
117 Etot_crs = Etot_crs + Edep[s];
124 for(
unsigned int s=0; s<nsteps; s++)
128 double dLeft_crs = length_crs + Lpos[s].z();
129 double dRight_crs = length_crs - Lpos[s].z();
150 double Edep_B_crs = BirksAttenuation(Edep[s],Dx[s],charge[s],birks_constant);
151 Etot_B_crs = Etot_B_crs + Edep_B_crs;
157 if (light_coll_crs > 1) light_coll_crs = 1.;
162 etotL_crs = etotL_crs + Edep_B_crs/2 * exp(-dLeft_crs/att_length_crs) * light_coll_crs;
163 etotR_crs = etotR_crs + Edep_B_crs/2 * exp(-dRight_crs/att_length_crs) * light_coll_crs;
178 timeL_crs= timeL_crs + (times[s] + dLeft_crs/veff_crs) / nsteps;
179 timeR_crs= timeR_crs + (times[s] + dRight_crs/veff_crs) / nsteps;
194 if(s==0 || (time_min_crs[0]>(times[s]+dLeft_crs/veff_crs))) time_min_crs[0]=times[s]+dLeft_crs/veff_crs;
198 if(s==0 || (time_min_crs[1]>(times[s]+dRight_crs/veff_crs))) time_min_crs[1]=times[s]+ dRight_crs/veff_crs;
256 peR_crs=G4Poisson(etotR_crs*light_yield_crs*sensor_qe_crs*optical_coupling);
257 test=WaveForm(peR_crs,&tim);
261 for(
int s=0; s<Nsamp_int; s++) peR_int_crs=peR_int_crs+test[s];
264 ADCR_crs=int(peR_int_crs);
269 double sigmaTR_crs=sqrt(pow(5.*nanosecond,2.)+pow(10.*nanosecond,2.)/(peR_crs/10.+1.));
271 TDCB=((time_min_crs[1]+T_offset_crs+G4RandGauss::shoot(0.,sigmaTR_crs)) * tdc_conv_crs);
276 double sensor_qe_crs_sipm2=0.35;
277 double optical_coupling_sipm2=optical_coupling;
278 peR_crs=G4Poisson(etotR_crs*light_yield_crs*sensor_qe_crs_sipm2*optical_coupling_sipm2);
279 test=WaveForm(peR_crs,&tim);
283 for(
int s=0; s<Nsamp_int; s++) peR_int_crs=peR_int_crs+test[s];
286 ADCL_crs=int(peR_int_crs);
316 cout << log_msg <<
" xch: " << xch <<
", ych: " << ych ;
317 cout << log_msg <<
" Etot=" << Etot_crs/MeV << endl;
318 cout << log_msg <<
" TDCL=" << TDCL_crs <<
" TDCR=" << TDCR_crs <<
" ADCL=" << ADCL_crs <<
" ADCR=" << ADCR_crs << endl;
323 dgtz[
"sector"] = sector;
326 dgtz[
"adcl"] = ADCL_crs;
327 dgtz[
"adcr"] = ADCR_crs;
328 dgtz[
"tdcl"] = TDCL_crs;
329 dgtz[
"tdcr"] = TDCR_crs;
332 dgtz[
"tdcb"] = TDCB*1000.;
341 id[
id.size()-1].id_sharing = 1;
354 double response = destep;
355 if (birks*destep*stepl*charge != 0.)
357 response = destep/(1. + birks*destep/stepl);
369 double C=9.59*1E-4*mm*mm/MeV/MeV;
370 double response = destep;
371 if (birks*destep*stepl*charge != 0.)
373 response = destep/(1. + birks*destep/stepl + C*pow(destep/stepl,2.));
381 map< string, vector <int> > MH;
400 static double WFsample[1000];
401 double smp_t=4./1000. ;
404 double p[6] = {0.,0.680,0.64,3.34,0.36,0.};
409 double area=(tau/c/2.);
414 double t_spread= 1.*0.000;
415 double A_spread= 1.*0.05*A;
418 for(
unsigned int s=0; s<1000; s++)
424 for(
unsigned int s=0; s<80; s++)
428 func=(t-t0)*(t-t0)*exp(-(t-t0)/tau)*A/(4*tau*tau*c)*0.5*(abs(t-t0)/(t-t0)+1);
430 AmpWF[s]=smp_t*1000.*func;
434 double frac=1-((p[2]*exp(-smp_t*Nch_digi/p[1])+p[4]*exp(-smp_t*Nch_digi/p[3])));
440 for(
int s=1; s<=Npe; s++){
444 rr=(rand() % 1000000+1)/1000000.;
445 t= Nch_digi*smp_t*rr;
447 WF= (p[2]/p[1]*exp(-t/p[1])+p[4]/p[3]*exp(-t/p[3]))/(p[2]/p[1]+p[4]/p[3]);
448 rr=(rand() % 10000000+1)/10000000.;
456 t=G4RandGauss::shoot(t,t_spread);
460 for(
int s=0; s<80; s++)
463 func=G4RandGauss::shoot(func,A_spread);
464 if((s+it)<Nch_digi) WFsample[s+it]=WFsample[s+it]+ func;
472 double time_max=-100;
475 while (time_max<WFsample[s]){
476 time_max=1/2.*(WFsample[s+1]+WFsample[s]);
478 *time=1000.*smp_t*s_time_max/3.;
map< string, vector< int > > multiDgt(MHit *, int)
vector< identifier > processID(vector< identifier >, G4Step *, detector)
G4LogicalVolume * GetLogical()
Returns Logical Volume pointer.
vector< identifier > GetId()
vector< G4ThreeVector > GetLPos()
vector< double > GetTime()
double BirksAttenuation(double, double, int, double)
double BirksAttenuation2(double, double, int, double)
vector< double > dimensions
vector of dimensions. Size, units depends on solid type
vector< double > GetEdep()
vector< int > GetCharges()
map< string, double > integrateDgt(MHit *, int)
double * WaveForm(double, double *)