150 {
151 double time_spent = 0.;
152 clock_t begin = clock();
153
155
156 std::vector < double > stripid_x;
157 std::vector < double > ind_charge_x;
158 std::vector < double > ind_time_x;
159
160 std::vector < double > stripid_v;
161 std::vector < double > ind_charge_v;
162 std::vector < double > ind_time_v;
163
164
165
166
167 for(int iele = 0; iele < nElectrons; iele++){
168
169 double x_start =
x.at(iele);
170 double y_start = y.at(iele);
171 double z_start = z.at(iele);
172 double t_start =
t.at(iele);
173
174
175 double x_end, y_end, z_end, t_end;
176 bool isanode =
drive_to_anode(layer, x_start, y_start, z_start, t_start, x_end, y_end, z_end, t_end);
177
178 int sheet = 0;
179 double phi = TMath::ATan2(y_start, x_start);
180 if(layer > 0 && phi > TMath::Pi()) sheet = 1;
181
183 int X_ID;
184 int V_ID;
185 G4ThreeVector pos(x_end, y_end, z_end);
186
188
189
190
191
192
193
194
195
196
197
198
199
200 double percX = 0.5;
201 double percV = 0.5;
202 double qele = 1.6e-4;
203
204
205 stripid_x.push_back(X_ID);
206 ind_charge_x.push_back(percX * qele);
207 ind_time_x.push_back(t_end);
208 sheetid_x.push_back(sheet);
209 stripid_v.push_back(V_ID);
210 ind_charge_v.push_back(percV * qele);
211 ind_time_v.push_back(t_end);
212 sheetid_v.push_back(sheet);
213
214 }
215
216
217
218
219 for (std::vector< double >::iterator it = stripid_x.begin() ; it != stripid_x.end(); it++) {
220 double stripid = *it;
221 int ipos = it - stripid_x.begin();
222 double sheetid = sheetid_x.at(ipos);
223
224 std::vector< double >::iterator it2 = std::find(m_XstripID.begin(), m_XstripID.end(), stripid);
225 std::vector< double >::iterator it3 = std::find(m_XstripSheet.begin(), m_XstripSheet.end(), sheetid);
226
227 if(it2 == m_XstripID.end() || it3 == m_XstripSheet.end()) {
228 m_XstripID.push_back(stripid);
229 m_XstripSheet.push_back(sheetid);
230 }
231 else {
232 double sheetid3 = *it3;
233 if(sheetid != sheetid3) {
234 m_XstripID.push_back(stripid);
235 m_XstripSheet.push_back(sheetid);
236 }
237 }
238 }
239 m_NXstrips = m_XstripID.size();
240
241
242
243 for(int istrip = 0; istrip < m_NXstrips; istrip++) {
244 double xID = m_XstripID.at(istrip);
245 int view = 0;
246 double strip_charge;
247 double strip_time;
248 double strip_dtime;
249 bool isASIC =
useAPV(xID, view, stripid_x, ind_charge_x, ind_time_x, strip_charge, strip_time, strip_dtime);
250 m_XstripQ.push_back(strip_charge);
251 m_XstripT.push_back(strip_time);
252 }
253
254
255
256 for (std::vector< double >::iterator it = stripid_v.begin() ; it != stripid_v.end(); it++) {
257 double stripid = *it;
258 int ipos = it - stripid_v.begin();
259 double sheetid = sheetid_v.at(ipos);
260
261 std::vector< double >::iterator it2 = std::find(m_VstripID.begin(), m_VstripID.end(), stripid);
262 std::vector< double >::iterator it3 = std::find(m_VstripSheet.begin(), m_VstripSheet.end(), sheetid);
263
264 if(it2 == m_VstripID.end() || it3 == m_VstripSheet.end()) {
265 m_VstripID.push_back(stripid);
266 m_VstripSheet.push_back(sheetid);
267 }
268 else {
269 double sheetid3 = *it3;
270 if(sheetid != sheetid3) {
271 m_VstripID.push_back(stripid);
272 m_VstripSheet.push_back(sheetid);
273 }
274 }
275 }
276 m_NVstrips = m_VstripID.size();
277
278
279
280
281 for(int istrip = 0; istrip < m_NVstrips; istrip++) {
282 double vID = m_VstripID.at(istrip);
283 int view = 1;
284
285 double strip_charge;
286 double strip_time;
287 double strip_dtime;
288 bool isASIC =
useAPV(vID, view, stripid_v, ind_charge_v, ind_time_v, strip_charge, strip_time, strip_dtime);
289 m_VstripQ.push_back(strip_charge);
290 m_VstripT.push_back(strip_time);
291 }
292
293 clock_t end = clock();
294 time_spent += (double)(end - begin) / CLOCKS_PER_SEC;
295 cout << "InductionGTS::induzione " << time_spent << " seconds" << endl;
296
297 evt++;
298
299}
void getStripID(G4ThreeVector pos, int &X_ID, int &V_ID) const
virtual CgemGeoReadoutPlane * getReadoutPlane(int iLayer, int iSheet) const =0
bool useAPV(int stripid, int view, std::vector< double > stripidvec, std::vector< double > indchargevec, std::vector< double > indtimevec, double &charge, double &time, double &dtime)
bool drive_to_anode(int, double, double, double, double, double &, double &, double &, double &)