77{
78
79 trackIndex=0;
80 partId=-999;
81 module_mrpc=-999;
82 time=-999.;
83
84
86 G4DigiManager* digiManager = G4DigiManager::GetDMpointer();
87 G4int THCID = digiManager->GetHitsCollectionID("BesTofHitsCollection");
89 if (m_THC)
90 {
91
92
93
95
96
97 vector<adc_info> avalanche_info;
98 avalanche_info.clear();
99
102
103
104
105
106 int deadarea=0;
107
108 for(G4int i=0;i<n_hit;i++)
109 {
110
111
113
114
117
118 if( readoutstripnumber==0 ) {deadarea++; continue;}
119
120
121 adc_info struct_adc_info;
122 struct_adc_info.gap =0; struct_adc_info.readoutstrip =0; struct_adc_info.ions =0; struct_adc_info.zdistance =0.; struct_adc_info.trackindex=0;struct_adc_info.time=0.;
123 struct_adc_info.pdg_code=0;
124
126 struct_adc_info.readoutstrip=readoutstripnumber;
127 struct_adc_info.ions=hit->
GetIons();
129 struct_adc_info.time = hit->
GetTime();
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;
138
139 if(struct_adc_info.ions>0 && struct_adc_info.readoutstrip!=0 && struct_adc_info.time!=0.) avalanche_info.push_back(struct_adc_info);
140
141 }
142
143
144
145 G4int avalanche_info_size = avalanche_info.size();
146
147
148
149 vector <int> fired_readoutstrips;
150
151 fired_readoutstrips.clear();
152 for(G4int i=0; i<avalanche_info_size; i++)
153 {
154
155 bool dlh=true;
156 for(G4int j=0;j<fired_readoutstrips.size();j++)
157 {
158 if(fired_readoutstrips[j]==avalanche_info[i].readoutstrip){dlh=false; break;}
159 }
160 if(dlh==true)
161 {
162 fired_readoutstrips.push_back(avalanche_info[i].readoutstrip);
163 }
164 }
165
166
167
168
169 vector <int> mybest_adcinfo_inreadoutstrips(fired_readoutstrips.size());
170 for(G4int i=0;i< fired_readoutstrips.size();i++)
171 {
172 double time_help=10000.;
173 for(G4int j=0; j<avalanche_info_size; j++)
174 {
175 if((time_help>avalanche_info[j].time) && avalanche_info[j].readoutstrip==fired_readoutstrips[i])
176 {
177 time_help = avalanche_info[j].time;
178 mybest_adcinfo_inreadoutstrips[i]=j;
179 }
180 }
181 }
182
183
184
185
186
187 double stripidentifier_1=0;
188 double stripidentifier_2=0;
189
190 for(G4int i=0; i<fired_readoutstrips.size();i++)
191 {
192
193
194
195
196 G4int sumions=0;
197 for(G4int j=0; j<avalanche_info_size; j++)
198 {
199 if(avalanche_info[j].readoutstrip==fired_readoutstrips[i])
200 {
201 sumions = sumions+ avalanche_info[j].ions;
202 }
203
204 }
205
206
207
208 G4int numberofgaps_with_avalanches=0;
209 for(G4int j=1;j<=12;j++)
210 {
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;} }
212 }
213
214
215
216
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);
219 signal_pc=signal_pc;
220 time_of_threshold_exceedance=time_of_threshold_exceedance*
s;
221
222
223 if(signal_pc<0.015) continue;
224
225
226 trackIndex = avalanche_info[(mybest_adcinfo_inreadoutstrips[i])].trackindex;
227
228
229
230
231
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);
234
235 if(resulting_phi<0)
236
237 {
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;
240 }
241 else
242
243 {
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;
246 }
247
248
249
250
251
252
253
254
255
256
257
258
259 double femtocolomb= 1000.;
260
261 double NINO_RES=0;
263 double smear_time = sqrt(NINO_RES*NINO_RES + 27.0*27.0 + 10.0*10.0 + 20.0*20.0);
264
267
268
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);
271
272
273
274
275
277 double smear_time_2 = sqrt(NINO_pulselength_resolution*NINO_pulselength_resolution + 27.0*27.0 );
278
281
282
283
284 double time2_digi2=
chargetotime(signal_pc*femtocolomb)+time_digi2;
286
287
288 if(m_storedata)
289 {
290 m_partID=partId;
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;
296 m_time_1=time;
297 m_time_2=time2;
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;
306 m_ecv4tree->Fill();
307 }
308
309
310
311
312
320
321
322
323
331
332
333
334 }
335
336
337
338
339 }
340
341}
G4THitsCollection< BesTofHit > BesTofHitsCollection
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 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)
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)
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)
double Get_NINO_pulselength_resolution(double induced_charge_fc)
static G4int Produce_unique_identifier(G4int module_mrpc_f, G4int readoutstripnumber_f)
G4double Distance_for_avalanche(G4int gap, G4double z_position, G4int partID)
double Get_NINO_leadingedge_resolution(double induced_charge_fc)
G4double Smear_gaussian(G4double, G4double, G4double)
double chargetotime(double)
BesTofDigitsCollection * m_besTofDigitsCollection
vector< G4int > * GetHitIndexes_mrpc()