15#include "G4DigiManager.hh"
17#include "Randomize.hh"
20#include "GaudiKernel/ISvcLocator.h"
21#include "GaudiKernel/Bootstrap.h"
22#include "GaudiKernel/IDataProviderSvc.h"
38 FileName =
"output_mrpc_digitizerecv4.root";
39 m_TreeFile=
new TFile(TString(FileName),
"RECREATE",
"TreeFile");
40 m_ecv4tree =
new TTree(
"ecv4tree",
"");
41 m_ecv4tree->Branch(
"m_partId",&m_partID,
"m_partId/D");
42 m_ecv4tree->Branch(
"m_stripidentifier",&m_stripidentifier,
"m_stripidentifier/D");
43 m_ecv4tree->Branch(
"m_trackIndex",&m_trackIndex,
"m_trackIndex/D");
44 m_ecv4tree->Branch(
"m_signal_pc",&m_signal_pc,
"m_signal_pc/D");
45 m_ecv4tree->Branch(
"m_time_threshold",&m_time_threshold,
"m_time_threshold/D");
46 m_ecv4tree->Branch(
"m_time_1sthit",&m_time_1sthit,
"m_time_1sthit/D");
47 m_ecv4tree->Branch(
"m_time_1",&m_time_1,
"m_time_1/D");
48 m_ecv4tree->Branch(
"m_time_2",&m_time_2,
"m_time_2/D");
49 m_ecv4tree->Branch(
"m_trans_time_1",&m_trans_time_1,
"m_trans_time_1/D");
50 m_ecv4tree->Branch(
"m_trans_time_2",&m_trans_time_2,
"m_trans_time_2/D");
51 m_ecv4tree->Branch(
"m_firedstrip",&m_firedstrip,
"m_firedstrip/D");
52 m_ecv4tree->Branch(
"m_numberions",&m_numberions,
"m_numberions/D");
53 m_ecv4tree->Branch(
"m_numberofgaps_with_avalanches",&m_numberofgaps_with_avalanches,
"m_numberofgaps_with_avalanches/D");
54 m_ecv4tree->Branch(
"m_numberofstripsfired",&m_numberofstripsfired,
"m_numberofstripsfired/D");
55 m_ecv4tree->Branch(
"m_multihit",&m_multihit,
"m_multihit/D");
56 m_ecv4tree->Branch(
"m_inefficiency",&m_inefficiency,
"m_inefficiency/D");
57 m_ecv4tree->Branch(
"m_particle_true",&m_particle_true,
"m_particle_true/D");
58 m_ecv4tree->Branch(
"m_particle_has_signal",&m_particle_has_signal,
"m_particle_has_signal/D");
86 G4DigiManager* digiManager = G4DigiManager::GetDMpointer();
87 G4int THCID = digiManager->GetHitsCollectionID(
"BesTofHitsCollection");
97 vector<adc_info> avalanche_info;
98 avalanche_info.clear();
108 for(G4int i=0;i<n_hit;i++)
118 if( readoutstripnumber==0 ) {deadarea++;
continue;}
134 struct_adc_info.
x=
help.x()/mm;
135 struct_adc_info.
y=
help.y()/mm;
136 struct_adc_info.
partId=partId;
137 struct_adc_info.
module=module_mrpc;
139 if(struct_adc_info.
ions>0 && struct_adc_info.
readoutstrip!=0 && struct_adc_info.
time!=0.) avalanche_info.push_back(struct_adc_info);
145 G4int avalanche_info_size = avalanche_info.size();
149 vector <int> fired_readoutstrips;
151 fired_readoutstrips.clear();
152 for(G4int i=0; i<avalanche_info_size; i++)
156 for(G4int j=0;j<fired_readoutstrips.size();j++)
158 if(fired_readoutstrips[j]==avalanche_info[i].readoutstrip){dlh=
false;
break;}
162 fired_readoutstrips.push_back(avalanche_info[i].readoutstrip);
169 vector <int> mybest_adcinfo_inreadoutstrips(fired_readoutstrips.size());
170 for(G4int i=0;i< fired_readoutstrips.size();i++)
172 double time_help=10000.;
173 for(G4int j=0; j<avalanche_info_size; j++)
175 if((time_help>avalanche_info[j].time) && avalanche_info[j].readoutstrip==fired_readoutstrips[i])
177 time_help = avalanche_info[j].time;
178 mybest_adcinfo_inreadoutstrips[i]=j;
187 double stripidentifier_1=0;
188 double stripidentifier_2=0;
190 for(G4int i=0; i<fired_readoutstrips.size();i++)
197 for(G4int j=0; j<avalanche_info_size; j++)
199 if(avalanche_info[j].readoutstrip==fired_readoutstrips[i])
201 sumions = sumions+ avalanche_info[j].ions;
208 G4int numberofgaps_with_avalanches=0;
209 for(G4int j=1;j<=12;j++)
211 for(G4int k=0; k<avalanche_info_size; k++) {
if(avalanche_info[k].gap ==j && avalanche_info[k].ions >0){numberofgaps_with_avalanches++;
break;} }
217 G4double signal_pc=0; G4double time_of_threshold_exceedance=0;
218 simulate_avalanche(fired_readoutstrips[i], &avalanche_info,&time_of_threshold_exceedance,&signal_pc);
220 time_of_threshold_exceedance=time_of_threshold_exceedance*
s;
223 if(signal_pc<0.015)
continue;
226 trackIndex = avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].trackindex;
232 double resulting_phi =
Calculate_resulting_phi(avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].
x,avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].y
233 ,avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].partId,avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].module);
238 time = avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].time + time_of_threshold_exceedance + avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].transtime_1;
239 time_digi2=avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].time + time_of_threshold_exceedance + avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].transtime_2;
244 time = avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].time + time_of_threshold_exceedance + avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].transtime_2;
245 time_digi2=avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].time + time_of_threshold_exceedance + avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].transtime_1;
259 double femtocolomb= 1000.;
263 double smear_time = sqrt(NINO_RES*NINO_RES + 27.0*27.0 + 10.0*10.0 + 20.0*20.0);
269 stripidentifier_1=
Produce_unique_identifier(module_mrpc,(avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].readoutstrip)*2-1);
270 stripidentifier_2=
Produce_unique_identifier(module_mrpc,(avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].readoutstrip)*2);
277 double smear_time_2 = sqrt(NINO_pulselength_resolution*NINO_pulselength_resolution + 27.0*27.0 );
284 double time2_digi2=
chargetotime(signal_pc*femtocolomb)+time_digi2;
291 m_stripidentifier=stripidentifier_1;
292 m_trackIndex=trackIndex;
293 m_signal_pc=signal_pc;
294 m_time_threshold= time_of_threshold_exceedance;
295 m_time_1sthit=avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].time;
298 m_trans_time_1=avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].transtime_1;
299 m_trans_time_2=avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].transtime_2;
300 m_firedstrip=fired_readoutstrips[i];
301 m_numberions=sumions;
302 m_numberofgaps_with_avalanches=numberofgaps_with_avalanches;
303 m_numberofstripsfired = fired_readoutstrips.size();
304 m_x=avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].
x;
305 m_y=avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].y;
360 G4double gaussrand = G4RandGauss::shoot(gauss_mean,gauss_sigma);
361 return (variable+gaussrand);
374 G4double phi= atan2(y_mm,x_mm)*180./
pi;
377 if(-180<phi && phi<90){phi=phi+270;}
381 G4double result_phi=0;
382 if(partId_f!=3 && partId_f!=6) result_phi=0;
383 else result_phi=9.97312;
385 if(partId_f==3 || partId_f==4) result_phi = -((19-module_mrpc_f-1)*20 - phi + result_phi);
386 else result_phi = (module_mrpc_f-1)*20 - phi + result_phi;
389 if(partId_f==4 && module_mrpc_f==18 && result_phi>350) result_phi=result_phi-360;
390 if(partId_f==5 && module_mrpc_f==1 && result_phi<-350) result_phi=result_phi+360;
406 G4int readoutstripnumber=0;
408 G4double result_radius= sqrt(x_mm*x_mm+y_mm*y_mm);
409 G4double phi= atan2(y_mm,x_mm)*180./
pi;
412 if(-180<phi && phi<90){phi=phi+270;}
416 G4double result_phi=0;
417 if(partId_f!=3 && partId_f!=6) result_phi=0;
418 else result_phi=9.97312;
422 if(partId_f==3 || partId_f==4) result_phi = -((19-module_mrpc_f-1)*20 - phi + result_phi);
423 else result_phi = (module_mrpc_f-1)*20 - phi + result_phi;
426 if(partId_f==4 && module_mrpc_f==18 && result_phi>350) result_phi=result_phi-360;
427 if(partId_f==5 && module_mrpc_f==1 && result_phi<-350) result_phi=result_phi+360;
431 result_radius= result_radius*
cos(result_phi*
pi/180.0) - 634.56 + 159.5 - 3.82;
434 double result_x=fabs((result_radius/
cos(result_phi*
pi/180.0)+634.56-159.5+3.82)*
sin(result_phi*
pi/180));
438 if( -12.5 <result_radius && result_radius < 12.5 && result_x <= 44 ) readoutstripnumber=1;
439 if( (-12.5 +(25.0+4.0)*1 ) <result_radius && result_radius < (12.5+(25.0+4.0)*1) && result_x <=46) readoutstripnumber=2;
440 if( (-12.5 +(25.0+4.0)*2 ) <result_radius && result_radius < (12.5+(25.0+4.0)*2) && result_x <=49) readoutstripnumber=3;
441 if( (-12.5 +(25.0+4.0)*3 ) <result_radius && result_radius < (12.5+(25.0+4.0)*3) && result_x <=51) readoutstripnumber=4;
442 if( (-12.5 +(25.0+4.0)*4 ) <result_radius && result_radius < (12.5+(25.0+4.0)*4) && result_x <=54) readoutstripnumber=5;
443 if( (-12.5 +(25.0+4.0)*5 ) <result_radius && result_radius < (12.5+(25.0+4.0)*5) && result_x <=56) readoutstripnumber=6;
444 if( (-12.5 +(25.0+4.0)*6 ) <result_radius && result_radius < (12.5+(25.0+4.0)*6) && result_x <=59) readoutstripnumber=7;
445 if( (-12.5 +(25.0+4.0)*7 ) <result_radius && result_radius < (12.5+(25.0+4.0)*7) && result_x <=61) readoutstripnumber=8;
446 if( (-12.5 +(25.0+4.0)*8 ) <result_radius && result_radius < (12.5+(25.0+4.0)*8) && result_x <=64) readoutstripnumber=9;
447 if( (-12.5 +(25.0+4.0)*9 ) <result_radius && result_radius < (12.5+(25.0+4.0)*9) && result_x <=66) readoutstripnumber=10;
448 if( (-12.5 +(25.0+4.0)*10 ) <result_radius && result_radius < (12.5+(25.0+4.0)*10) && result_x <=69) readoutstripnumber=11;
449 if( (-12.5 +(25.0+4.0)*11 ) <result_radius && result_radius < (12.5+(25.0+4.0)*11) && result_x <=71) readoutstripnumber=12;
452 return readoutstripnumber;
466 G4int readoutstripnumber=0;
468 G4double result_radius= sqrt(x_mm*x_mm+y_mm*y_mm);
469 G4double phi= atan2(y_mm,x_mm)*180./
pi;
472 if(-180<phi && phi<90){phi=phi+270;}
476 G4double result_phi=0;
477 if(partId_f!=3 && partId_f!=6) result_phi=0;
478 else result_phi=9.97312;
479 if(partId_f==3 || partId_f==4) result_phi = -((19-module_mrpc_f-1)*20 - phi + result_phi);
480 else result_phi = (module_mrpc_f-1)*20 - phi + result_phi;
483 if(partId_f==4 && module_mrpc_f==18 && result_phi>350) result_phi=result_phi-360;
484 if(partId_f==5 && module_mrpc_f==1 && result_phi<-350) result_phi=result_phi+360;
488 result_radius= result_radius*
cos(result_phi*
pi/180.0) - 634.56 + 159.5-3.82;
491 if( (-12.5 -12.0) <=result_radius && result_radius < 12.5+2.0 ) readoutstripnumber=1;
492 if( (-12.5 +(25.0+4.0)*1-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*1)+2.0 ) readoutstripnumber=2;
493 if( (-12.5 +(25.0+4.0)*2-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*2) +2.0) readoutstripnumber=3;
494 if( (-12.5 +(25.0+4.0)*3-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*3) +2.0) readoutstripnumber=4;
495 if( (-12.5 +(25.0+4.0)*4-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*4) +2.0) readoutstripnumber=5;
496 if( (-12.5 +(25.0+4.0)*5-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*5) +2.0) readoutstripnumber=6;
497 if( (-12.5 +(25.0+4.0)*6-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*6) +2.0) readoutstripnumber=7;
498 if( (-12.5 +(25.0+4.0)*7-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*7) +2.0) readoutstripnumber=8;
499 if( (-12.5 +(25.0+4.0)*8-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*8) +2.0) readoutstripnumber=9;
500 if( (-12.5 +(25.0+4.0)*9-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*9) +2.0) readoutstripnumber=10;
501 if( (-12.5 +(25.0+4.0)*10-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*10) +2.0) readoutstripnumber=11;
502 if( (-12.5 +(25.0+4.0)*11-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*11) +12.0) readoutstripnumber=12;
505 return readoutstripnumber;
518 G4double signal_velocity_copper_mrpc_strip= 0.8*0.299792458;
521 G4double length_to_border_of_the_readoutstrip=0;
522 G4double result_radius= sqrt(x_mm*x_mm+y_mm*y_mm);
523 G4double phi= atan2(y_mm,x_mm)*180./
pi;
525 if(-180<phi && phi<90){phi=phi+270;}
528 G4double result_phi=0;
529 if(partId_f!=3 && partId_f!=6) result_phi=0;
530 else result_phi=9.97312;
533 if(partId_f==3 || partId_f==4) result_phi = -((19-module_mrpc_f-1)*20 - phi + result_phi);
534 else result_phi = (module_mrpc_f-1)*20 - phi + result_phi;
537 if(partId_f==4 && module_mrpc_f==18 && result_phi>350) result_phi=result_phi-360;
538 if(partId_f==5 && module_mrpc_f==1 && result_phi<-350) result_phi=result_phi+360;
545 result_radius= result_radius*
cos(result_phi*
pi/180.0) - 634.56 + 159.5 - 3.82;
554 double result_x=fabs((result_radius/
cos(result_phi*
pi/180.0)+634.56-159.5+3.82)*
sin(result_phi*
pi/180));
557 if( -12.5 <result_radius && result_radius < 12.5 && result_x <= 44 )
559 length_to_border_of_the_readoutstrip=sqrt( (44-result_x)*(44-result_x) + fabs((result_radius-0.)*(result_radius-0.)));
561 if( (-12.5 +(25.0+4.0)*1 ) <result_radius && result_radius < (12.5+(25.0+4.0)*1) && result_x <=46)
563 length_to_border_of_the_readoutstrip=sqrt( (46-result_x)*(46-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*1)));
565 if( (-12.5 +(25.0+4.0)*2 ) <result_radius && result_radius < (12.5+(25.0+4.0)*2) && result_x <=49)
567 length_to_border_of_the_readoutstrip=sqrt( (49-result_x)*(49-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*2)));
569 if( (-12.5 +(25.0+4.0)*3 ) <result_radius && result_radius < (12.5+(25.0+4.0)*3) && result_x <=51)
571 length_to_border_of_the_readoutstrip=sqrt( (51-result_x)*(51-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*3)));
573 if( (-12.5 +(25.0+4.0)*4 ) <result_radius && result_radius < (12.5+(25.0+4.0)*4) && result_x <=54)
575 length_to_border_of_the_readoutstrip=sqrt( (54-result_x)*(54-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*4)));
577 if( (-12.5 +(25.0+4.0)*5 ) <result_radius && result_radius < (12.5+(25.0+4.0)*5) && result_x <=56)
579 length_to_border_of_the_readoutstrip=sqrt( (56-result_x)*(56-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*5)));
581 if( (-12.5 +(25.0+4.0)*6 ) <result_radius && result_radius < (12.5+(25.0+4.0)*6) && result_x <=59)
583 length_to_border_of_the_readoutstrip=sqrt( (59-result_x)*(59-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*6)));
585 if( (-12.5 +(25.0+4.0)*7 ) <result_radius && result_radius < (12.5+(25.0+4.0)*7) && result_x <=61)
587 length_to_border_of_the_readoutstrip=sqrt( (61-result_x)*(61-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*7)));
589 if( (-12.5 +(25.0+4.0)*8 ) <result_radius && result_radius < (12.5+(25.0+4.0)*8) && result_x <=64)
591 length_to_border_of_the_readoutstrip=sqrt( (64-result_x)*(64-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*8)));
593 if( (-12.5 +(25.0+4.0)*9 ) <result_radius && result_radius < (12.5+(25.0+4.0)*9) && result_x <=66)
595 length_to_border_of_the_readoutstrip=sqrt( (66-result_x)*(66-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*9)));
597 if( (-12.5 +(25.0+4.0)*10 ) <result_radius && result_radius < (12.5+(25.0+4.0)*10) && result_x <=69)
599 length_to_border_of_the_readoutstrip=sqrt( (69-result_x)*(69-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*10)));
601 if( (-12.5 +(25.0+4.0)*11 ) <result_radius && result_radius < (12.5+(25.0+4.0)*11) && result_x <=71)
603 length_to_border_of_the_readoutstrip=sqrt( (71-result_x)*(71-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*11)));
605 double transition_time = length_to_border_of_the_readoutstrip/signal_velocity_copper_mrpc_strip/1000.;
606 return transition_time;
615 G4double signal_velocity_copper_mrpc_strip= 0.8*0.299792458;
618 G4double length_to_border_of_the_readoutstrip=0;
619 G4double result_radius= sqrt(x_mm*x_mm+y_mm*y_mm);
620 G4double phi= atan2(y_mm,x_mm)*180./
pi;
622 if(-180<phi && phi<90){phi=phi+270;}
625 G4double result_phi=0;
626 if(partId_f!=3 && partId_f!=6) result_phi=0;
627 else result_phi=9.97312;
630 if(partId_f==3 || partId_f==4) result_phi = -((19-module_mrpc_f-1)*20 - phi + result_phi);
631 else result_phi = (module_mrpc_f-1)*20 - phi + result_phi;
634 if(partId_f==4 && module_mrpc_f==18 && result_phi>350) result_phi=result_phi-360;
635 if(partId_f==5 && module_mrpc_f==1 && result_phi<-350) result_phi=result_phi+360;
642 result_radius= result_radius*
cos(result_phi*
pi/180.0) - 634.56 + 159.5 - 3.82;
651 double result_x=fabs((result_radius/
cos(result_phi*
pi/180.0)+634.56-159.5+3.82)*
sin(result_phi*
pi/180));
654 if( -12.5 <result_radius && result_radius < 12.5 && result_x <= 44 )
656 length_to_border_of_the_readoutstrip=sqrt( (48+result_x)*(48+result_x) + fabs((result_radius-0.)*(result_radius-0.)));
658 if( (-12.5 +(25.0+4.0)*1 ) <result_radius && result_radius < (12.5+(25.0+4.0)*1) && result_x <=46)
660 length_to_border_of_the_readoutstrip=sqrt( (50+result_x)*(50+result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*1)));
662 if( (-12.5 +(25.0+4.0)*2 ) <result_radius && result_radius < (12.5+(25.0+4.0)*2) && result_x <=49)
664 length_to_border_of_the_readoutstrip=sqrt( (53+result_x)*(53+result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*2)));
666 if( (-12.5 +(25.0+4.0)*3 ) <result_radius && result_radius < (12.5+(25.0+4.0)*3) && result_x <=51)
668 length_to_border_of_the_readoutstrip=sqrt( (55+result_x)*(55+result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*3)));
670 if( (-12.5 +(25.0+4.0)*4 ) <result_radius && result_radius < (12.5+(25.0+4.0)*4) && result_x <=54)
672 length_to_border_of_the_readoutstrip=sqrt( (58+result_x)*(58+result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*4)));
674 if( (-12.5 +(25.0+4.0)*5 ) <result_radius && result_radius < (12.5+(25.0+4.0)*5) && result_x <=56)
676 length_to_border_of_the_readoutstrip=sqrt( (60+result_x)*(60+result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*5)));
678 if( (-12.5 +(25.0+4.0)*6 ) <result_radius && result_radius < (12.5+(25.0+4.0)*6) && result_x <=59)
680 length_to_border_of_the_readoutstrip=sqrt( (63+result_x)*(63+result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*6)));
682 if( (-12.5 +(25.0+4.0)*7 ) <result_radius && result_radius < (12.5+(25.0+4.0)*7) && result_x <=61)
684 length_to_border_of_the_readoutstrip=sqrt( (65+result_x)*(65+result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*7)));
686 if( (-12.5 +(25.0+4.0)*8 ) <result_radius && result_radius < (12.5+(25.0+4.0)*8) && result_x <=64)
688 length_to_border_of_the_readoutstrip=sqrt( (68+result_x)*(68+result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*8)));
690 if( (-12.5 +(25.0+4.0)*9 ) <result_radius && result_radius < (12.5+(25.0+4.0)*9) && result_x <=66)
692 length_to_border_of_the_readoutstrip=sqrt( (70+result_x)*(70+result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*9)));
694 if( (-12.5 +(25.0+4.0)*10 ) <result_radius && result_radius < (12.5+(25.0+4.0)*10) && result_x <=69)
696 length_to_border_of_the_readoutstrip=sqrt( (73+result_x)*(73+result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*10)));
698 if( (-12.5 +(25.0+4.0)*11 ) <result_radius && result_radius < (12.5+(25.0+4.0)*11) && result_x <=71)
700 length_to_border_of_the_readoutstrip=sqrt( (75+result_x)*(75+result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*11)));
703 double transition_time = length_to_border_of_the_readoutstrip/signal_velocity_copper_mrpc_strip/1000.;
704 return transition_time;
721 double signal_velocity_copper_mrpc_strip= 0.8*0.299792458;
722 double strip_length=0;
724 if(my_strip==1 || my_strip==2 ) strip_length=88;
725 else if(my_strip==3 || my_strip==4 ) strip_length=92;
726 else if(my_strip==5 || my_strip==6 ) strip_length=98;
727 else if(my_strip==7 || my_strip==8 ) strip_length=102;
728 else if(my_strip==9 || my_strip==10 ) strip_length=108;
729 else if(my_strip==11 || my_strip==12 ) strip_length=112;
730 else if(my_strip==13 || my_strip==14 ) strip_length=118;
731 else if(my_strip==15 || my_strip==16 ) strip_length=122;
732 else if(my_strip==17 || my_strip==18 ) strip_length=128;
733 else if(my_strip==19|| my_strip==20 ) strip_length=132;
734 else if(my_strip==21|| my_strip==22 ) strip_length=138;
735 else if(my_strip==23 || my_strip==24 ) strip_length=142;
739 double trans_time =(strip_length/signal_velocity_copper_mrpc_strip/1000+delta_t)/2.;
755 G4double signal_velocity_copper_mrpc_strip= 0.8*0.299792458;
758 G4double length_to_border_of_the_readoutstrip=0;
759 G4double result_radius= sqrt(x_mm*x_mm+y_mm*y_mm);
760 G4double phi= atan2(y_mm,x_mm)*180./
pi;
762 if(-180<phi && phi<90){phi=phi+270;}
765 G4double result_phi=0;
766 if(partId_f!=3 && partId_f!=6) result_phi=0.;
767 else result_phi=9.97312;
769 if(partId_f==3 || partId_f==4) result_phi = -((19-module_mrpc_f-1)*20. - phi + result_phi);
770 else result_phi = (module_mrpc_f-1)*20. - phi + result_phi;
773 if(partId_f==4 && module_mrpc_f==18 && result_phi>350) result_phi=result_phi-360;
774 if(partId_f==5 && module_mrpc_f==1 && result_phi<-350) result_phi=result_phi+360;
777 result_radius= result_radius*
cos(result_phi*
pi/180.0) - 634.56 + 159.5 - 3.82;
779 double result_x=((result_radius/
cos(result_phi*
pi/180.0)+634.56-159.5+3.82)*
sin(result_phi*
pi/180));
783 if( (my_strip%2)==0 )
786 length_to_border_of_the_readoutstrip=sqrt( (44-result_x)*(44-result_x) + fabs((result_radius-0.)*(result_radius-0.)));
788 length_to_border_of_the_readoutstrip=sqrt( (46-result_x)*(46-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*1)));
790 length_to_border_of_the_readoutstrip=sqrt( (49-result_x)*(49-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*2)));
792 length_to_border_of_the_readoutstrip=sqrt( (51-result_x)*(51-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*3)));
793 else if(my_strip==10)
794 length_to_border_of_the_readoutstrip=sqrt( (54-result_x)*(54-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*4)));
795 else if(my_strip==12)
796 length_to_border_of_the_readoutstrip=sqrt( (56-result_x)*(56-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*5)));
797 else if(my_strip==14)
798 length_to_border_of_the_readoutstrip=sqrt( (59-result_x)*(59-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*6)));
799 else if(my_strip==16)
800 length_to_border_of_the_readoutstrip=sqrt( (61-result_x)*(61-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*7)));
801 else if(my_strip==18)
802 length_to_border_of_the_readoutstrip=sqrt( (64-result_x)*(64-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*8)));
803 else if(my_strip==20)
804 length_to_border_of_the_readoutstrip=sqrt( (66-result_x)*(66-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*9)));
805 else if(my_strip==22)
806 length_to_border_of_the_readoutstrip=sqrt( (69-result_x)*(69-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*10)));
807 else if(my_strip==24)
808 length_to_border_of_the_readoutstrip=sqrt( (71-result_x)*(71-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*11)));
810 else if((my_strip%2)!=0)
813 length_to_border_of_the_readoutstrip=sqrt( (-44-result_x)*(-44-result_x) + fabs((result_radius-0.)*(result_radius-0.)));
815 length_to_border_of_the_readoutstrip=sqrt( (-46-result_x)*(-46-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*1)));
817 length_to_border_of_the_readoutstrip=sqrt( (-49-result_x)*(-49-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*2)));
819 length_to_border_of_the_readoutstrip=sqrt( (-51-result_x)*(-51-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*3)));
821 length_to_border_of_the_readoutstrip=sqrt( (-54-result_x)*(-54-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*4)));
822 else if(my_strip==11)
823 length_to_border_of_the_readoutstrip=sqrt( (-56-result_x)*(-56-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*5)));
824 else if(my_strip==13)
825 length_to_border_of_the_readoutstrip=sqrt( (-59-result_x)*(-59-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*6)));
826 else if(my_strip==15)
827 length_to_border_of_the_readoutstrip=sqrt( (-61-result_x)*(-61-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*7)));
828 else if(my_strip==17)
829 length_to_border_of_the_readoutstrip=sqrt( (-64-result_x)*(-64-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*8)));
830 else if(my_strip==19)
831 length_to_border_of_the_readoutstrip=sqrt( (-66-result_x)*(-66-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*9)));
832 else if(my_strip==21)
833 length_to_border_of_the_readoutstrip=sqrt( (-69-result_x)*(-69-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*10)));
834 else if(my_strip==23)
835 length_to_border_of_the_readoutstrip=sqrt( (-71-result_x)*(-71-result_x) + fabs((result_radius-(25.0+4.0)*1.)*(result_radius-(25.0+4.0)*11)));
838 double transition_time = length_to_border_of_the_readoutstrip/signal_velocity_copper_mrpc_strip/1000.;
839 return transition_time;
851 G4double signal_velocity_copper_mrpc_strip= 0.8*0.299792458;
853 G4double length_to_border_of_the_readoutstrip=0.;
855 if(my_module==1 || my_module==2) length_to_border_of_the_readoutstrip=44;
856 if(my_module==3 || my_module==4) length_to_border_of_the_readoutstrip=46;
857 if(my_module==5 || my_module==6) length_to_border_of_the_readoutstrip=49;
858 if(my_module==7 || my_module==8) length_to_border_of_the_readoutstrip=51;
859 if(my_module==9 || my_module==10) length_to_border_of_the_readoutstrip=54;
860 if(my_module==11 || my_module==12) length_to_border_of_the_readoutstrip=56;
861 if(my_module==13 || my_module==14) length_to_border_of_the_readoutstrip=59;
862 if(my_module==15 || my_module==16) length_to_border_of_the_readoutstrip=61;
863 if(my_module==17 || my_module==18) length_to_border_of_the_readoutstrip=64;
864 if(my_module==19 || my_module==20) length_to_border_of_the_readoutstrip=66;
865 if(my_module==21 || my_module==22) length_to_border_of_the_readoutstrip=69;
866 if(my_module==23 || my_module==24) length_to_border_of_the_readoutstrip=71;
868 double transition_time = length_to_border_of_the_readoutstrip/signal_velocity_copper_mrpc_strip/1000.;
869 return transition_time;
881 returnvalue= module_mrpc_f*25 + readoutstripnumber_f;
894 returnvalue= unique_identifier_f/25;
906 returnvalue= unique_identifier_f%25;
919 G4double pos_west_1=-1343.5*mm;
920 G4double pos_west_2=-1368.5*mm;
921 G4double pos_east_1=+1343.5*mm;
922 G4double pos_east_2=+1368.5*mm;
929 {z_zero= z_position-pos_east_2;}
931 {z_zero= z_position-pos_east_1;}
933 {z_zero = pos_west_1 - z_position ;}
935 {z_zero = pos_west_2 - z_position ;}
937 {G4cout <<
"TofDigitzer: Error in part ID" <<G4endl;
return 0;}
944 if((-4.5999*mm) >= z_zero && z_zero>(-4.8201*mm) ) {
return 1;}
945 else if((-3.9799*mm) >= z_zero && z_zero>(-4.2001*mm) ){
return 2;}
946 else if((-3.3599*mm) >= z_zero && z_zero>(-3.5801*mm) ){
return 3;}
947 else if((-2.7399*mm) >= z_zero && z_zero>(-2.9601*mm) ){
return 4;}
948 else if((-2.1199*mm) >= z_zero && z_zero>(-2.3401*mm) ){
return 5;}
949 else if((-1.4999*mm) >= z_zero && z_zero>(-1.7201*mm)) {
return 6;}
950 else if((1.4999*mm) <= z_zero && z_zero<=(1.7201*mm) ) {
return 7;}
951 else if((2.1199*mm) <= z_zero && z_zero<=(2.3401*mm) ) {
return 8;}
952 else if((2.7399*mm) <= z_zero && z_zero<=(2.9601*mm) ) {
return 9;}
953 else if((3.3599*mm) <= z_zero && z_zero<=(3.5801*mm) ) {
return 10;}
954 else if((3.9799*mm) <= z_zero && z_zero<=(4.2001*mm) ) {
return 11;}
955 else if((4.5999*mm) <= z_zero && z_zero<=(4.8201*mm) ){
return 12;}
956 else {G4cout <<
"TofDigitzer: Error in Hit-Position! " <<G4endl;
return 0; }
966 G4double pos_west_1=-1343.5*mm;
967 G4double pos_west_2=-1368.5*mm;
968 G4double pos_east_1=+1343.5*mm;
969 G4double pos_east_2=+1368.5*mm;
976 {z_zero= z_position-pos_east_2;}
978 {z_zero= z_position-pos_east_1;}
980 {z_zero = pos_west_1 - z_position ;}
982 {z_zero = pos_west_2 - z_position ;}
984 {G4cout <<
"TofDigitzer: Error in part ID" <<G4endl;
return 0;}
1007 if(gap==1)
return (-z_zero-4.60*mm);
1008 if(gap==2)
return (-z_zero-3.98*mm);
1009 if(gap==3)
return (-z_zero-3.36*mm);
1010 if(gap==4)
return (-z_zero-2.74*mm);
1011 if(gap==5)
return (-z_zero-2.12*mm);
1012 if(gap==6)
return (-z_zero-1.5*mm);
1013 if(gap==7)
return (1.72-z_zero*mm);
1014 if(gap==8)
return (2.34-z_zero*mm);
1015 if(gap==9)
return (2.96-z_zero*mm);
1016 if(gap==10)
return (3.58-z_zero*mm);
1017 if(gap==11)
return (4.20-z_zero*mm);
1018 if(gap==12)
return (4.82-z_zero*mm);
1049 int number_of_gaps=12;
1050 double alpha=144800.;
1053 double thick_gap = 0.00022;
1054 const int steps =200;
1055 double user_stepwidth=thick_gap/(double)steps;
1056 double v_drift = 210.9e3;
1058 double E_weight = 1./(6.*0.22e-3+(5.*0.4e-3+2*0.55e-3)/(8.)+2.*0.07e-3/(3.1));
1059 double physics_e= 1.602176462e-19;
1060 double threshold=93622.7;
1076 vector<int> primary_clusters_in_gap(number_of_gaps);
1077 for(
int i=0;i<number_of_gaps;i++)primary_clusters_in_gap[i]=0;
1079 vector< vector< vector<double> > > step_avalanche(number_of_gaps);
1080 vector< vector< vector<long int> > > elec_avalche(number_of_gaps);
1083 for(
int i=0;i<number_of_gaps;i++)
1085 int counter_avalanches=0;
1086 for(
int j=0;j<avalanche_info->size();j++)
1088 if(actual_strip==(*avalanche_info)[j].readoutstrip && ((i+1)==(*avalanche_info)[j].gap) )
1089 {counter_avalanches++;}
1092 primary_clusters_in_gap[i]=counter_avalanches;
1093 step_avalanche[i].resize(primary_clusters_in_gap[i]);
1094 elec_avalche[i].resize(primary_clusters_in_gap[i]);
1098 for(
int j=0;j<number_of_gaps;j++)
1100 for(
int i=0;i<primary_clusters_in_gap[j];i++)
1102 step_avalanche[j][i].resize(steps+2);
1103 elec_avalche[j][i].resize(steps+2);
1107 for(
int h=0;h<number_of_gaps;h++) {
for(
int i=0;i<primary_clusters_in_gap[h];i++){
for(
int j=0;j<steps+2;j++){step_avalanche[h][i][j]=0.;elec_avalche[h][i][j]=0;}}}
1109 vector<int> avalanches_in_gap(number_of_gaps);
1115 for(
int h=0;h<number_of_gaps;h++)
1120 for(
int j=0;j<avalanche_info->size();j++)
1122 if(actual_strip==(*avalanche_info)[j].readoutstrip && ((h+1)==(*avalanche_info)[j].gap) )
1124 step_avalanche[h][i][0]=thick_gap-((*avalanche_info)[j].zdistance/m);
1125 elec_avalche[h][i][0]=(*avalanche_info)[j].ions;
1130 avalanches_in_gap[h]=primary_clusters_in_gap[h];
1145 for(
int h=0;h<number_of_gaps;h++)
1148 long int tot_elec_in_gap=0;
1149 if(avalanches_in_gap[h]!=0)
1155 vector<bool> is_saturated(avalanches_in_gap[h]);
1156 for(
int e=0;e<avalanches_in_gap[h];e++) is_saturated[e]=
false;
1165 for(
int j=0;j<primary_clusters_in_gap[h];j++)
1171 step_avalanche[h][j][i+1]= step_avalanche[h][j][i] + user_stepwidth;
1172 tot_elec_in_gap=tot_elec_in_gap + elec_avalche[h][j][i+1];
1175 if(elec_avalche[h][j][i+1]>1.5e7){is_saturated[j]=
true;}
else{is_saturated[j]=
false;}
1182 for(
int j=0;j<primary_clusters_in_gap[h];j++)
1185 if((step_avalanche[h][j][i])>=thick_gap)
1187 primary_clusters_in_gap[h]=(primary_clusters_in_gap[h]-1);
1193 while(step_avalanche[h][0][i]<thick_gap);
1204 bool over_threshold =
false;
1206 for(
int i=0;i<steps;i++)
1208 for(
int h=0;h<number_of_gaps;h++)
1210 for(
int j=0;j<avalanches_in_gap[h];j++)
1212 signal= signal + elec_avalche[h][j][i];
1216 if(over_threshold ==
false && signal>threshold) {over_threshold=
true; *avalanche_threshold_time=(thick_gap/steps/v_drift*(i+1));}
1227 *induced_charge=signal*E_weight*v_drift*physics_e*1e12 * thick_gap/steps/v_drift;
1247 if(n_elec<=150 && (saturated ==
false))
1250 long int n_elec_step =0;
1252 for(
int j=0;j<n_elec;j++)
1254 double s=G4UniformRand();
1262 if(n_elec>150 && saturated ==
false)
1265 double nbar =
exp((
alpha-eta)*stepwidth);
1266 double my_sigma = G4RandGauss::shoot(0,(sqrt(n_elec)*sigma));
1268 return (
long int)(n_elec*nbar+ my_sigma);
1291 double nbar =
exp((
alpha-eta)*stepwidth);
1292 double s_border= eta/
alpha*(nbar-1.)/(nbar-eta/
alpha);
1293 double k = eta/
alpha;
1303 return (
long int) (1. + (1/log(((nbar-1)/(nbar-k))) * log(((nbar-k)*(
s-1)/(k-1)/nbar))));
1314 double nbar =
exp((
alpha-eta)*stepwidth);
1316 return (sqrt( (1.+k)/(1.-k) * nbar * (nbar-1.) )) ;
1330 if(charge>=13.)
time=(-4.50565/log(charge*0.0812208)+16.6653)*
ns;
1345 double result = (64.3326*
exp(-induced_charge_fc/25.4638 + 0.944184)+19.4846 );
1358 if(induced_charge_fc > 50.)
1360 result = 67.6737*
exp(-induced_charge_fc/50.9995-0.27755)+9.06223;
1364 result = 176.322-2.98345*induced_charge_fc;
double sin(const BesAngle a)
double cos(const BesAngle a)
G4TDigiCollection< BesTofDigi > BesTofDigitsCollection
G4THitsCollection< BesTofHit > BesTofHitsCollection
EvtComplex exp(const EvtComplex &c)
void SetTime1_mrpc(G4double time_mrpc)
void SetPartId(G4int partId)
void SetTrackIndex(G4int index)
void SetTime2_mrpc(G4double time_mrpc2)
void SetModule_mrpc(G4int module_mrpc)
static double GetTransitionTime_dbsmatch(double delta_t, int my_strip)
static G4int Calculate_Readoutstrip_number_continuum(G4double x_mm, G4double y_mm, G4int partId_f, G4int module_mrpc_f)
static G4int Calculate_Readoutstrip_number(G4double x, G4double y, G4int partId_f, G4int module_mrpc_f)
static G4double Calculate_resulting_phi(G4double x_mm, G4double y_mm, G4int partId_f, G4int module_mrpc_f)
virtual void Digitize(ScintSingle *, BesTofDigitsCollection *)
static G4double Calculate_strip_transition_time_2(G4double x_mm, G4double y_mm, G4int partId_f, G4int module_mrpc_f)
G4int Get_gapnumber(G4int partID, G4double z_position)
~BesTofDigitizerEcV4_dbs()
static G4double Calculate_strip_transition_time_1(G4double x_mm, G4double y_mm, G4int partId_f, G4int module_mrpc_f)
void simulate_avalanche(G4int actual_strip, vector< adc_info > *avalanche_info, double *avalanche_threshold_time, double *induced_charge)
static G4int Get_module_mrpc_from_unique_identifier(G4int unique_identifier_f)
double Get_NINO_pulselength_resolution(double induced_charge_fc)
static double Average_transition_time_dbs(G4int my_module)
static G4int Produce_unique_identifier(G4int module_mrpc_f, G4int readoutstripnumber_f)
long int adcsignal_get_n_electron(double s, double stepwidth, double alpha, double eta)
BesTofDigitizerEcV4_dbs()
long int adcsignal_simulate_step(int n_elec, double stepwidth, double alpha, double eta, bool saturated)
G4double Distance_for_avalanche(G4int gap, G4double z_position, G4int partID)
double adcsignal_get_sigma(double alpha, double eta, double stepwidth)
double Get_NINO_leadingedge_resolution(double induced_charge_fc)
static double GetTransitionTime_extrap_track(G4double x_mm, G4double y_mm, int partId_f, int module_mrpc_f, int my_strip)
static G4int Get_stripnumber_from_unique_identifier(G4int unique_identifier_f)
G4double Smear_gaussian(G4double, G4double, G4double)
double chargetotime(double)
BesTofDigitsCollection * m_besTofDigitsCollection
vector< G4int > * GetHitIndexes_mrpc()