85 G4DigiManager* digiManager = G4DigiManager::GetDMpointer();
86 G4int THCID = digiManager->GetHitsCollectionID(
"BesTofHitsCollection");
98 vector<adc_info> avalanche_info;
99 avalanche_info.clear();
115 for(G4int i=0;i<n_hit;i++)
128 if( readoutstripnumber==0 ) {deadarea++;
continue;}
144 struct_adc_info.
x=
help.x()/mm;
145 struct_adc_info.
y=
help.y()/mm;
146 if(struct_adc_info.
ions>0 && struct_adc_info.
readoutstrip!=0 && struct_adc_info.
time!=0.) avalanche_info.push_back(struct_adc_info);
169 G4int avalanche_info_size = avalanche_info.size();
175 vector <int> fired_readoutstrips;
177 fired_readoutstrips.clear();
178 for(G4int i=0; i<avalanche_info_size; i++)
183 for(G4int j=0;j<fired_readoutstrips.size();j++)
185 if(fired_readoutstrips[j]==avalanche_info[i].readoutstrip){dlh=
false;
break;}
190 fired_readoutstrips.push_back(avalanche_info[i].readoutstrip);
197 vector <int> mybest_adcinfo_inreadoutstrips(fired_readoutstrips.size());
198 for(G4int i=0;i< fired_readoutstrips.size();i++)
200 double time_help=10000.;
201 for(G4int j=0; j<avalanche_info_size; j++)
203 if((time_help>avalanche_info[j].time) && avalanche_info[j].readoutstrip==fired_readoutstrips[i])
205 time_help = avalanche_info[j].time;
206 mybest_adcinfo_inreadoutstrips[i]=j;
215 double stripidentifier=0;
216 for(G4int i=0; i<fired_readoutstrips.size();i++)
224 for(G4int j=0; j<avalanche_info_size; j++)
226 if(avalanche_info[j].readoutstrip==fired_readoutstrips[i])
228 sumions = sumions+ avalanche_info[j].ions;
236 G4int numberofgaps_with_avalanches=0;
237 for(G4int j=1;j<=12;j++)
239 for(G4int k=0; k<avalanche_info_size; k++) {
if(avalanche_info[k].gap ==j && avalanche_info[k].ions >0){numberofgaps_with_avalanches++;
break;} }
245 G4double signal_pc=0; G4double time_of_threshold_exceedance=0;
246 simulate_avalanche(fired_readoutstrips[i], &avalanche_info,&time_of_threshold_exceedance,&signal_pc);
248 time_of_threshold_exceedance=time_of_threshold_exceedance*
s;
251 if(signal_pc<0.015)
continue;
259 trackIndex = avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].trackindex;
264 time = avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].
time + time_of_threshold_exceedance + avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].transtime;
282 double femtocolomb= 1000.;
286 double smear_time = sqrt(NINO_RES*NINO_RES + 27.0*27.0 + 10.0*10.0 + 20.0*20.0);
291 stripidentifier=
Produce_unique_identifier(module_mrpc,avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].readoutstrip);
297 double smear_time_2 = sqrt(NINO_pulselength_resolution*NINO_pulselength_resolution + 27.0*27.0 );
305 m_stripidentifier=stripidentifier;
306 m_trackIndex=trackIndex;
307 m_signal_pc=signal_pc;
308 m_time_threshold= time_of_threshold_exceedance;
309 m_time_1sthit=avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].
time;
312 m_trans_time=avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].transtime;
313 m_firedstrip=fired_readoutstrips[i];
314 m_numberions=sumions;
315 m_numberofgaps_with_avalanches=numberofgaps_with_avalanches;
316 m_numberofstripsfired = fired_readoutstrips.size();
317 m_x=avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].
x;
318 m_y=avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].y;
377 G4int readoutstripnumber=0;
379 G4double result_radius= sqrt(x_mm*x_mm+y_mm*y_mm);
380 G4double phi= atan2(y_mm,x_mm)*180./
pi;
383 if(-180<phi && phi<90){phi=phi+270;}
387 G4double result_phi=0;
388 if(partId_f!=3 && partId_f!=6) result_phi=0;
389 else result_phi=9.97312;
393 if(partId_f==3 || partId_f==4) result_phi = -((19-module_mrpc_f-1)*20 - phi + result_phi);
394 else result_phi = (module_mrpc_f-1)*20 - phi + result_phi;
397 if(partId_f==4 && module_mrpc_f==18 && result_phi>350) result_phi=result_phi-360;
398 if(partId_f==5 && module_mrpc_f==1 & result_phi<-350) result_phi=result_phi+360;
402 result_radius= result_radius*
cos(result_phi*
pi/180.0) - 634.56 + 159.5 - 3.82;
405 double result_x=fabs((result_radius/
cos(result_phi*
pi/180.0)+634.56-159.5+3.82)*
sin(result_phi*
pi/180));
408 if(result_phi>=0 && result_x>2.)
410 if( -12.5 <result_radius && result_radius < 12.5 && result_x <= 44 ) readoutstripnumber=2;
411 if( (-12.5 +(25.0+4.0)*1 ) <result_radius && result_radius < (12.5+(25.0+4.0)*1) && result_x <=46) readoutstripnumber=4;
412 if( (-12.5 +(25.0+4.0)*2 ) <result_radius && result_radius < (12.5+(25.0+4.0)*2) && result_x <=49) readoutstripnumber=6;
413 if( (-12.5 +(25.0+4.0)*3 ) <result_radius && result_radius < (12.5+(25.0+4.0)*3) && result_x <=51) readoutstripnumber=8;
414 if( (-12.5 +(25.0+4.0)*4 ) <result_radius && result_radius < (12.5+(25.0+4.0)*4) && result_x <=54) readoutstripnumber=10;
415 if( (-12.5 +(25.0+4.0)*5 ) <result_radius && result_radius < (12.5+(25.0+4.0)*5) && result_x <=56) readoutstripnumber=12;
416 if( (-12.5 +(25.0+4.0)*6 ) <result_radius && result_radius < (12.5+(25.0+4.0)*6) && result_x <=59) readoutstripnumber=14;
417 if( (-12.5 +(25.0+4.0)*7 ) <result_radius && result_radius < (12.5+(25.0+4.0)*7) && result_x <=61) readoutstripnumber=16;
418 if( (-12.5 +(25.0+4.0)*8 ) <result_radius && result_radius < (12.5+(25.0+4.0)*8) && result_x <=64) readoutstripnumber=18;
419 if( (-12.5 +(25.0+4.0)*9 ) <result_radius && result_radius < (12.5+(25.0+4.0)*9) && result_x <=66) readoutstripnumber=20;
420 if( (-12.5 +(25.0+4.0)*10 ) <result_radius && result_radius < (12.5+(25.0+4.0)*10) && result_x <=69) readoutstripnumber=22;
421 if( (-12.5 +(25.0+4.0)*11 ) <result_radius && result_radius < (12.5+(25.0+4.0)*11) && result_x <=71) readoutstripnumber=24;
423 else if(result_phi<0 && result_x>2.)
425 if( -12.5 <result_radius && result_radius < 12.5 && result_x <= 44 ) readoutstripnumber=1;
426 if( (-12.5 +(25.0+4.0)*1 ) <result_radius && result_radius < (12.5+(25.0+4.0)*1) && result_x<=46 ) readoutstripnumber=3;
427 if( (-12.5 +(25.0+4.0)*2 ) <result_radius && result_radius < (12.5+(25.0+4.0)*2) && result_x<=49) readoutstripnumber=5;
428 if( (-12.5 +(25.0+4.0)*3 ) <result_radius && result_radius < (12.5+(25.0+4.0)*3) && result_x<=51) readoutstripnumber=7;
429 if( (-12.5 +(25.0+4.0)*4 ) <result_radius && result_radius < (12.5+(25.0+4.0)*4) && result_x<=54) readoutstripnumber=9;
430 if( (-12.5 +(25.0+4.0)*5 ) <result_radius && result_radius < (12.5+(25.0+4.0)*5) && result_x<=56) readoutstripnumber=11;
431 if( (-12.5 +(25.0+4.0)*6 ) <result_radius && result_radius < (12.5+(25.0+4.0)*6) && result_x<=59) readoutstripnumber=13;
432 if( (-12.5 +(25.0+4.0)*7 ) <result_radius && result_radius < (12.5+(25.0+4.0)*7) && result_x<=61) readoutstripnumber=15;
433 if( (-12.5 +(25.0+4.0)*8 ) <result_radius && result_radius < (12.5+(25.0+4.0)*8) && result_x<=64) readoutstripnumber=17;
434 if( (-12.5 +(25.0+4.0)*9 ) <result_radius && result_radius < (12.5+(25.0+4.0)*9) && result_x<=66) readoutstripnumber=19;
435 if( (-12.5 +(25.0+4.0)*10 ) <result_radius && result_radius < (12.5+(25.0+4.0)*10) && result_x<=69) readoutstripnumber=21;
436 if( (-12.5 +(25.0+4.0)*11 ) <result_radius && result_radius < (12.5+(25.0+4.0)*11) && result_x<=71) readoutstripnumber=23;
446 return readoutstripnumber;
461 G4int readoutstripnumber=0;
463 G4double result_radius= sqrt(x_mm*x_mm+y_mm*y_mm);
464 G4double phi= atan2(y_mm,x_mm)*180./
pi;
467 if(-180<phi && phi<90){phi=phi+270;}
471 G4double result_phi=0;
472 if(partId_f!=3 && partId_f!=6) result_phi=0;
473 else result_phi=9.97312;
474 if(partId_f==3 || partId_f==4) result_phi = -((19-module_mrpc_f-1)*20 - phi + result_phi);
475 else result_phi = (module_mrpc_f-1)*20 - phi + result_phi;
478 if(partId_f==4 && module_mrpc_f==18 && result_phi>350) result_phi=result_phi-360;
479 if(partId_f==5 && module_mrpc_f==1 & result_phi<-350) result_phi=result_phi+360;
483 result_radius= result_radius*
cos(result_phi*
pi/180.0) - 634.56 + 159.5-3.82;
488 if( (-12.5 -12.0) <=result_radius && result_radius < 12.5+2.0 ) readoutstripnumber=2;
489 if( (-12.5 +(25.0+4.0)*1-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*1)+2.0 ) readoutstripnumber=4;
490 if( (-12.5 +(25.0+4.0)*2-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*2) +2.0) readoutstripnumber=6;
491 if( (-12.5 +(25.0+4.0)*3-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*3) +2.0) readoutstripnumber=8;
492 if( (-12.5 +(25.0+4.0)*4-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*4) +2.0) readoutstripnumber=10;
493 if( (-12.5 +(25.0+4.0)*5-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*5) +2.0) readoutstripnumber=12;
494 if( (-12.5 +(25.0+4.0)*6-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*6) +2.0) readoutstripnumber=14;
495 if( (-12.5 +(25.0+4.0)*7-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*7) +2.0) readoutstripnumber=16;
496 if( (-12.5 +(25.0+4.0)*8-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*8) +2.0) readoutstripnumber=18;
497 if( (-12.5 +(25.0+4.0)*9-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*9) +2.0) readoutstripnumber=20;
498 if( (-12.5 +(25.0+4.0)*10-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*10) +2.0) readoutstripnumber=22;
499 if( (-12.5 +(25.0+4.0)*11-2.0 ) <=result_radius && result_radius < (12.5+(25.0+4.0)*11) +12.0) readoutstripnumber=24;
501 else if(result_phi<0)
503 if( (-12.5-12.0) <=result_radius && result_radius < (12.5+2.0) ) readoutstripnumber=1;
504 if( (-12.5 +(25.0+4.0)*1 -2.0) <=result_radius && result_radius < (12.0+(25.0+4.0)*1) +2.0) readoutstripnumber=3;
505 if( (-12.5 +(25.0+4.0)*2 -2.0) <=result_radius && result_radius < (12.0+(25.0+4.0)*2) +2.0) readoutstripnumber=5;
506 if( (-12.5 +(25.0+4.0)*3 -2.0) <=result_radius && result_radius < (12.0+(25.0+4.0)*3) +2.0) readoutstripnumber=7;
507 if( (-12.5 +(25.0+4.0)*4 -2.0) <=result_radius && result_radius < (12.0+(25.0+4.0)*4) +2.0) readoutstripnumber=9;
508 if( (-12.5 +(25.0+4.0)*5 -2.0) <=result_radius && result_radius < (12.0+(25.0+4.0)*5) +2.0) readoutstripnumber=11;
509 if( (-12.5 +(25.0+4.0)*6 -2.0) <=result_radius && result_radius < (12.0+(25.0+4.0)*6) +2.0) readoutstripnumber=13;
510 if( (-12.5 +(25.0+4.0)*7 -2.0) <=result_radius && result_radius < (12.0+(25.0+4.0)*7) +2.0) readoutstripnumber=15;
511 if( (-12.5 +(25.0+4.0)*8 -2.0) <=result_radius && result_radius < (12.0+(25.0+4.0)*8) +2.0) readoutstripnumber=17;
512 if( (-12.5 +(25.0+4.0)*9 -2.0) <=result_radius && result_radius < (12.0+(25.0+4.0)*9) +2.0) readoutstripnumber=19;
513 if( (-12.5 +(25.0+4.0)*10 -2.0) <=result_radius && result_radius < (12.0+(25.0+4.0)*10) +2.0) readoutstripnumber=21;
514 if( (-12.5 +(25.0+4.0)*11 -2.0) <=result_radius && result_radius < (12.0+(25.0+4.0)*11) +12.0) readoutstripnumber=23;
523 return readoutstripnumber;
536 G4double signal_velocity_copper_mrpc_strip= 0.8*0.299792458;
540 G4double length_to_border_of_the_readoutstrip=0;
542 G4double result_radius= sqrt(x_mm*x_mm+y_mm*y_mm);
543 G4double phi= atan2(y_mm,x_mm)*180./
pi;
555 if(-180<phi && phi<90){phi=phi+270;}
558 G4double result_phi=0;
559 if(partId_f!=3 && partId_f!=6) result_phi=0;
560 else result_phi=9.97312;
563 if(partId_f==3 || partId_f==4) result_phi = -((19-module_mrpc_f-1)*20 - phi + result_phi);
564 else result_phi = (module_mrpc_f-1)*20 - phi + result_phi;
567 if(partId_f==4 && module_mrpc_f==18 && result_phi>350) result_phi=result_phi-360;
568 if(partId_f==5 && module_mrpc_f==1 & result_phi<-350) result_phi=result_phi+360;
576 result_radius= result_radius*
cos(result_phi*
pi/180.0) - 634.56 + 159.5 - 3.82;
585 double result_x=fabs((result_radius/
cos(result_phi*
pi/180.0)+634.56-159.5+3.82)*
sin(result_phi*
pi/180));
588 if(result_phi>=0 && result_x>2.)
590 if( -12.5 <result_radius && result_radius < 12.5 && result_x <= 44 )
592 length_to_border_of_the_readoutstrip=sqrt( (44-result_x)*(44-result_x) + fabs((result_radius-0.)*(result_radius-0.)));
595 if( (-12.5 +(25.0+4.0)*1 ) <result_radius && result_radius < (12.5+(25.0+4.0)*1) && result_x <=46)
597 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)));
600 if( (-12.5 +(25.0+4.0)*2 ) <result_radius && result_radius < (12.5+(25.0+4.0)*2) && result_x <=49)
602 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)));
605 if( (-12.5 +(25.0+4.0)*3 ) <result_radius && result_radius < (12.5+(25.0+4.0)*3) && result_x <=51)
607 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)));
610 if( (-12.5 +(25.0+4.0)*4 ) <result_radius && result_radius < (12.5+(25.0+4.0)*4) && result_x <=54)
612 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)));
615 if( (-12.5 +(25.0+4.0)*5 ) <result_radius && result_radius < (12.5+(25.0+4.0)*5) && result_x <=56)
617 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)));
620 if( (-12.5 +(25.0+4.0)*6 ) <result_radius && result_radius < (12.5+(25.0+4.0)*6) && result_x <=59)
622 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)));
625 if( (-12.5 +(25.0+4.0)*7 ) <result_radius && result_radius < (12.5+(25.0+4.0)*7) && result_x <=61)
627 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)));
630 if( (-12.5 +(25.0+4.0)*8 ) <result_radius && result_radius < (12.5+(25.0+4.0)*8) && result_x <=64)
632 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)));
635 if( (-12.5 +(25.0+4.0)*9 ) <result_radius && result_radius < (12.5+(25.0+4.0)*9) && result_x <=66)
637 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)));
640 if( (-12.5 +(25.0+4.0)*10 ) <result_radius && result_radius < (12.5+(25.0+4.0)*10) && result_x <=69)
642 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)));
645 if( (-12.5 +(25.0+4.0)*11 ) <result_radius && result_radius < (12.5+(25.0+4.0)*11) && result_x <=71)
647 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)));
651 else if(result_phi<0 && result_x>2.)
653 if( -12.5 <result_radius && result_radius < 12.5 && result_x <= 44 )
654 length_to_border_of_the_readoutstrip=sqrt( (44-result_x)*(44-result_x) + fabs((result_radius-0.)*(result_radius-0.)));
655 if( (-12.5 +(25.0+4.0)*1 ) <result_radius && result_radius < (12.5+(25.0+4.0)*1) && result_x <=46)
656 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)));
657 if( (-12.5 +(25.0+4.0)*2 ) <result_radius && result_radius < (12.5+(25.0+4.0)*2) && result_x <=49)
658 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)));
659 if( (-12.5 +(25.0+4.0)*3 ) <result_radius && result_radius < (12.5+(25.0+4.0)*3) && result_x <=51)
660 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)));
661 if( (-12.5 +(25.0+4.0)*4 ) <result_radius && result_radius < (12.5+(25.0+4.0)*4) && result_x <=54)
662 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)));
663 if( (-12.5 +(25.0+4.0)*5 ) <result_radius && result_radius < (12.5+(25.0+4.0)*5) && result_x <=56)
664 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)));
665 if( (-12.5 +(25.0+4.0)*6 ) <result_radius && result_radius < (12.5+(25.0+4.0)*6) && result_x <=59)
666 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)));
667 if( (-12.5 +(25.0+4.0)*7 ) <result_radius && result_radius < (12.5+(25.0+4.0)*7) && result_x <=61)
668 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)));
669 if( (-12.5 +(25.0+4.0)*8 ) <result_radius && result_radius < (12.5+(25.0+4.0)*8) && result_x <=64)
670 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)));
671 if( (-12.5 +(25.0+4.0)*9 ) <result_radius && result_radius < (12.5+(25.0+4.0)*9) && result_x <=66)
672 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)));
673 if( (-12.5 +(25.0+4.0)*10 ) <result_radius && result_radius < (12.5+(25.0+4.0)*10) && result_x <=69)
674 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)));
675 if( (-12.5 +(25.0+4.0)*11 ) <result_radius && result_radius < (12.5+(25.0+4.0)*11) && result_x <=71)
676 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)));
680 double transition_time = length_to_border_of_the_readoutstrip/signal_velocity_copper_mrpc_strip/1000.;
681 return transition_time;
694 G4double signal_velocity_copper_mrpc_strip= 0.8*0.299792458;
698 G4double length_to_border_of_the_readoutstrip=0;
700 G4double result_radius= sqrt(x_mm*x_mm+y_mm*y_mm);
701 G4double phi= atan2(y_mm,x_mm)*180./
pi;
713 if(-180<phi && phi<90){phi=phi+270;}
716 G4double result_phi=0;
717 if(partId_f!=3 && partId_f!=6) result_phi=0;
718 else result_phi=9.97312;
721 if(partId_f==3 || partId_f==4) result_phi = -((19-module_mrpc_f-1)*20 - phi + result_phi);
722 else result_phi = (module_mrpc_f-1)*20 - phi + result_phi;
725 if(partId_f==4 && module_mrpc_f==18 && result_phi>350) result_phi=result_phi-360;
726 if(partId_f==5 && module_mrpc_f==1 & result_phi<-350) result_phi=result_phi+360;
734 result_radius= result_radius*
cos(result_phi*
pi/180.0) - 634.56 + 159.5 - 3.82;
744 double result_x=fabs((result_radius/
cos(result_phi*
pi/180.0)+634.56-159.5+3.82)*
sin(result_phi*
pi/180));
747 if(result_phi>=0 && result_x>0.)
749 if( (-12.5-2.0) <result_radius && result_radius < (12.5+2.0) && result_x <= (44+2.0) )
750 length_to_border_of_the_readoutstrip=sqrt( (44-result_x)*(44-result_x) + fabs((result_radius-0.)*(result_radius-0.)));
751 if( (-12.5 +(25.0+4.0)*1-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*1+2.0) && result_x <=(46+2.0))
752 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)));
753 if( (-12.5 +(25.0+4.0)*2-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*2+2.0) && result_x <=(49+2.0))
754 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)));
755 if( (-12.5 +(25.0+4.0)*3-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*3+2.0) && result_x <=(51+2.0))
756 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)));
757 if( (-12.5 +(25.0+4.0)*4-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*4+2.0) && result_x <=(54+2.0))
758 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)));
759 if( (-12.5 +(25.0+4.0)*5-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*5+2.0) && result_x <=(56+2.0))
760 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)));
761 if( (-12.5 +(25.0+4.0)*6-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*6+2.0) && result_x <=(59+2.0))
762 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)));
763 if( (-12.5 +(25.0+4.0)*7-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*7+2.0) && result_x <=(61+2.0))
764 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)));
765 if( (-12.5 +(25.0+4.0)*8-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*8+2.0) && result_x <=(64+2.0))
766 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)));
767 if( (-12.5 +(25.0+4.0)*9-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*9+2.0) && result_x <=(66+2.0))
768 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)));
769 if( (-12.5 +(25.0+4.0)*10-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*10+2.0) && result_x <=(69+2.0))
770 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)));
771 if( (-12.5 +(25.0+4.0)*11-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*11+2.0) && result_x <=(71+2.0))
772 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)));
774 else if(result_phi<0 && result_x>0.)
776 if( (-12.5-2.0) <result_radius && result_radius < (12.5+2.0) && result_x <= (44+2.0) )
777 length_to_border_of_the_readoutstrip=sqrt( (44-result_x)*(44-result_x) + fabs((result_radius-0.)*(result_radius-0.)));
778 if( (-12.5 +(25.0+4.0)*1-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*1+2.0) && result_x <=(46+2.0))
779 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)));
780 if( (-12.5 +(25.0+4.0)*2-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*2+2.0) && result_x <=(49+2.0))
781 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)));
782 if( (-12.5 +(25.0+4.0)*3-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*3+2.0) && result_x <=(51+2.0))
783 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)));
784 if( (-12.5 +(25.0+4.0)*4-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*4+2.0) && result_x <=(54+2.0))
785 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)));
786 if( (-12.5 +(25.0+4.0)*5-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*5+2.0) && result_x <=(56+2.0))
787 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)));
788 if( (-12.5 +(25.0+4.0)*6-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*6+2.0) && result_x <=(59+2.0))
789 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)));
790 if( (-12.5 +(25.0+4.0)*7-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*7+2.0) && result_x <=(61+2.0))
791 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)));
792 if( (-12.5 +(25.0+4.0)*8-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*8+2.0) && result_x <=(64+2.0))
793 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)));
794 if( (-12.5 +(25.0+4.0)*9-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*9+2.0) && result_x <=(66+2.0))
795 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)));
796 if( (-12.5 +(25.0+4.0)*10-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*10+2.0) && result_x <=(69+2.0))
797 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)));
798 if( (-12.5 +(25.0+4.0)*11-2.0 ) <result_radius && result_radius < (12.5+(25.0+4.0)*11+2.0) && result_x <=(71+2.0))
799 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)));
802 double transition_time = length_to_border_of_the_readoutstrip/signal_velocity_copper_mrpc_strip/1000.;
803 return transition_time;
812 G4double signal_velocity_copper_mrpc_strip= 0.8*0.299792458;
813 G4double length_to_border_of_the_readoutstrip=0.;
814 if(my_module==1 || my_module==2) length_to_border_of_the_readoutstrip=sqrt( (44.-22.)*(44.-22.));
815 if(my_module==3 || my_module==4) length_to_border_of_the_readoutstrip=sqrt( (46.-23.)*(46.-23.));
816 if(my_module==5 || my_module==6) length_to_border_of_the_readoutstrip=sqrt( (49.-24.5)*(49.-24.5));
817 if(my_module==7 || my_module==8) length_to_border_of_the_readoutstrip=sqrt( (51.-25.5)*(51.-25.5));
818 if(my_module==9 || my_module==10) length_to_border_of_the_readoutstrip=sqrt( (54.-27.)*(54.-27.));
819 if(my_module==11 || my_module==12) length_to_border_of_the_readoutstrip=sqrt( (56.-28.)*(56.-28.));
820 if(my_module==13 || my_module==14) length_to_border_of_the_readoutstrip=sqrt( (59.-29.5)*(59.-29.5));
821 if(my_module==15 || my_module==16) length_to_border_of_the_readoutstrip=sqrt( (61.-30.5)*(61.-30.5));
822 if(my_module==17 || my_module==18) length_to_border_of_the_readoutstrip=sqrt( (64.-32.)*(64.-32.));
823 if(my_module==19 || my_module==20) length_to_border_of_the_readoutstrip=sqrt( (66.-33.)*(66.-33.));
824 if(my_module==21 || my_module==22) length_to_border_of_the_readoutstrip=sqrt( (69.-34.5)*(69.-34.5));
825 if(my_module==23 || my_module==24) length_to_border_of_the_readoutstrip=sqrt( (71.-35.5)*(71.-35.5));
827 double transition_time = length_to_border_of_the_readoutstrip/signal_velocity_copper_mrpc_strip/1000.;
828 return transition_time;
884 G4double pos_west_1=-1343.5*mm;
885 G4double pos_west_2=-1368.5*mm;
886 G4double pos_east_1=+1343.5*mm;
887 G4double pos_east_2=+1368.5*mm;
894 {z_zero= z_position-pos_east_2;}
896 {z_zero= z_position-pos_east_1;}
898 {z_zero = pos_west_1 - z_position ;}
900 {z_zero = pos_west_2 - z_position ;}
902 {G4cout <<
"TofDigitzer: Error in part ID" <<G4endl;
return 0;}
909 if((-4.5999*mm) >= z_zero && z_zero>(-4.8201*mm) ) {
return 1;}
910 else if((-3.9799*mm) >= z_zero && z_zero>(-4.2001*mm) ){
return 2;}
911 else if((-3.3599*mm) >= z_zero && z_zero>(-3.5801*mm) ){
return 3;}
912 else if((-2.7399*mm) >= z_zero && z_zero>(-2.9601*mm) ){
return 4;}
913 else if((-2.1199*mm) >= z_zero && z_zero>(-2.3401*mm) ){
return 5;}
914 else if((-1.4999*mm) >= z_zero && z_zero>(-1.7201*mm)) {
return 6;}
915 else if((1.4999*mm) <= z_zero && z_zero<=(1.7201*mm) ) {
return 7;}
916 else if((2.1199*mm) <= z_zero && z_zero<=(2.3401*mm) ) {
return 8;}
917 else if((2.7399*mm) <= z_zero && z_zero<=(2.9601*mm) ) {
return 9;}
918 else if((3.3599*mm) <= z_zero && z_zero<=(3.5801*mm) ) {
return 10;}
919 else if((3.9799*mm) <= z_zero && z_zero<=(4.2001*mm) ) {
return 11;}
920 else if((4.5999*mm) <= z_zero && z_zero<=(4.8201*mm) ){
return 12;}
921 else {G4cout <<
"TofDigitzer: Error in Hit-Position! " <<G4endl;
return 0; }
1014 int number_of_gaps=12;
1015 double alpha=144800.;
1018 double thick_gap = 0.00022;
1019 const int steps =200;
1020 double user_stepwidth=thick_gap/(double)steps;
1021 double v_drift = 210.9e3;
1023 double E_weight = 1./(6.*0.22e-3+(5.*0.4e-3+2*0.55e-3)/(8.)+2.*0.07e-3/(3.1));
1024 double physics_e= 1.602176462e-19;
1025 double threshold=93622.7;
1041 vector<int> primary_clusters_in_gap(number_of_gaps);
1042 for(
int i=0;i<number_of_gaps;i++)primary_clusters_in_gap[i]=0;
1044 vector< vector< vector<double> > > step_avalanche(number_of_gaps);
1045 vector< vector< vector<long int> > > elec_avalche(number_of_gaps);
1048 for(
int i=0;i<number_of_gaps;i++)
1050 int counter_avalanches=0;
1051 for(
int j=0;j<avalanche_info->size();j++)
1053 if(actual_strip==(*avalanche_info)[j].readoutstrip && ((i+1)==(*avalanche_info)[j].gap) )
1054 {counter_avalanches++;}
1057 primary_clusters_in_gap[i]=counter_avalanches;
1058 step_avalanche[i].resize(primary_clusters_in_gap[i]);
1059 elec_avalche[i].resize(primary_clusters_in_gap[i]);
1063 for(
int j=0;j<number_of_gaps;j++)
1065 for(
int i=0;i<primary_clusters_in_gap[j];i++)
1067 step_avalanche[j][i].resize(steps+2);
1068 elec_avalche[j][i].resize(steps+2);
1072 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;}}}
1074 vector<int> avalanches_in_gap(number_of_gaps);
1080 for(
int h=0;h<number_of_gaps;h++)
1085 for(
int j=0;j<avalanche_info->size();j++)
1087 if(actual_strip==(*avalanche_info)[j].readoutstrip && ((h+1)==(*avalanche_info)[j].gap) )
1089 step_avalanche[h][i][0]=thick_gap-((*avalanche_info)[j].zdistance/m);
1090 elec_avalche[h][i][0]=(*avalanche_info)[j].ions;
1095 avalanches_in_gap[h]=primary_clusters_in_gap[h];
1110 for(
int h=0;h<number_of_gaps;h++)
1113 long int tot_elec_in_gap=0;
1114 if(avalanches_in_gap[h]!=0)
1120 vector<bool> is_saturated(avalanches_in_gap[h]);
1121 for(
int e=0;e<avalanches_in_gap[h];e++) is_saturated[e]=
false;
1130 for(
int j=0;j<primary_clusters_in_gap[h];j++)
1136 step_avalanche[h][j][i+1]= step_avalanche[h][j][i] + user_stepwidth;
1137 tot_elec_in_gap=tot_elec_in_gap + elec_avalche[h][j][i+1];
1140 if(elec_avalche[h][j][i+1]>1.5e7){is_saturated[j]=
true;}
else{is_saturated[j]=
false;}
1147 for(
int j=0;j<primary_clusters_in_gap[h];j++)
1150 if((step_avalanche[h][j][i])>=thick_gap)
1152 primary_clusters_in_gap[h]=(primary_clusters_in_gap[h]-1);
1158 while(step_avalanche[h][0][i]<thick_gap);
1169 bool over_threshold =
false;
1171 for(
int i=0;i<steps;i++)
1173 for(
int h=0;h<number_of_gaps;h++)
1175 for(
int j=0;j<avalanches_in_gap[h];j++)
1177 signal= signal + elec_avalche[h][j][i];
1181 if(over_threshold ==
false && signal>threshold) {over_threshold=
true; *avalanche_threshold_time=(thick_gap/steps/v_drift*(i+1));}
1192 *induced_charge=signal*E_weight*v_drift*physics_e*1e12 * thick_gap/steps/v_drift;