160 {
161 Double_t
tp, tS, zp, xp, yp, zS, xS, yS,
pz,
px,
py, e,
w;
162 Double_t tm, zm, xm, ym, pmz, pmx, pmy, em;
163
164 Int_t im;
165
166
167
168
169 int iDP =
170 0;
171 std::vector<int>
172 dec_chain;
173 std::vector<int> dpvec;
174 do {
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192 }
193
196 double dpmom = 0;
197 double thetain = 0;
200 double dpe = sqrt(dpmom * dpmom + dpm * dpm);
201 double phiin = 2. * M_PI * gRandom->Rndm();
202
204 std::cout << " Adding DP gun with p " << dpmom << " m " << dpm << " e "
205 << dpe << " theta,phi " << thetain << "," << phiin
206 << std::endl
207 << std::flush;
208 }
209 fPythia->event.append(
fDP, 1, 0, 0, dpmom * sin(thetain) * cos(phiin),
210 dpmom * sin(thetain) * sin(phiin),
211 dpmom * cos(thetain), dpe, dpm);
212 }
213
214 if (!
fPythia->next()) LOG(fatal) <<
"fPythia->next() failed";
215
216
217 for (
int i = 0;
i <
fPythia->event.size();
i++) {
218
220 dpvec.push_back(i);
221 }
222 }
223 iDP = dpvec.size();
225 if (iDP == 0) {
226
227
229 1;
230 } else {
231
232
233 int r = iDP - 1;
234
236
241
246
247
248 std::cout << " Debug: decay product of A: "
251 << std::endl;
252
253
254
255
256
257
258
259
261 Double_t
p = TMath::Sqrt(px * px + py * py + pz * pz);
262 Double_t lam = LS /
p;
266 Double_t gam = e / TMath::Sqrt(e * e - p * p);
267 Double_t
beta =
p / e;
269
270
271
272 w = TMath::Exp(-LS / (beta * gam *
fctau)) *
274 im = (Int_t)
fPythia->event[i].mother1();
275 zm =
fPythia->event[im].zProd();
276 xm =
fPythia->event[im].xProd();
277 ym =
fPythia->event[im].yProd();
282 tm =
fPythia->event[im].tProd();
283
284 Double_t dx = 0;
288 Double_t Rsq =
test + 1.;
289 while (Rsq > test) {
292 Rsq = dx * dx +
dy *
dy;
293 }
294 }
296
297
298
299
300
301
302
303 } else {
304 cpg->AddTrack(
305 (Int_t)
fPythia->event[im].id(), pmx, pmy, pmz, xm /
cm + dx,
308 cpg->AddTrack(
fDP, px, py, pz, xp / cm + dx, yp / cm + dy, zp / cm, 0,
309 false, e, tp / cm /
c_light, w);
310 }
311
312 dec_chain.push_back(im);
313 dec_chain.push_back(i);
315 std::cout << std::endl
316 << " insert mother id " << im
317 <<
" pdg=" <<
fPythia->event[im].id() <<
" pmz = " << pmz
318 << " [GeV], zm = " << zm << " [mm] tm = " << tm << " [mm/c]"
319 << std::endl;
321 std::cout <<
" ----> insert DP id " <<
i <<
" pdg=" <<
fDP
322 <<
" pz = " <<
pz <<
" [GeV] zp = " << zp
323 <<
" [mm] tp = " <<
tp <<
" [mm/c]" << std::endl;
325 }
326 } while (iDP ==
327 0);
328
330 LOGF(info,
"ship event %i / pythia event-nr %i",
fShipEventNr,
fn);
331 }
333
334 if (
debug > 1) std::cout <<
"Filling daughter particles" << std::endl;
335
336 for (
int k = 0;
k <
fPythia->event.size();
k++) {
337
339 std::cout <<
k <<
" pdg =" <<
fPythia->event[
k].id() <<
" mum "
340 <<
fPythia->event[
k].mother1() << std::endl;
342 while (im > 0) {
343 if (im == iDP) {
344 break;
345 }
346
347 else {
348 im =
fPythia->event[im].mother1();
349 }
350 }
351 if (im < 1) {
352 if (
debug > 1) std::cout <<
"reject" << std::endl;
353 continue;
354 }
355 if (
debug > 1) std::cout <<
"accept" << std::endl;
356 dec_chain.push_back(k);
357 }
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383 for (std::vector<int>::iterator it = dec_chain.begin() + 2;
384 it != dec_chain.end(); ++it) {
385
387
388 int impy =
fPythia->event[
k].mother1();
389 std::vector<int>::iterator itm =
390 std::find(dec_chain.begin(), dec_chain.end(), impy);
391 im = -1;
392 if (itm != dec_chain.end())
393 im = itm - dec_chain.begin();
394
395 Bool_t wanttracking = false;
396 if (
fPythia->event[k].isFinal()) {
397 wanttracking = true;
398 }
404 im += 1;
405 };
406 cpg->AddTrack((Int_t)
fPythia->event[k].id(), px, py, pz, xS / cm, yS / cm,
407 zS / cm, im, wanttracking, e, tS / cm /
c_light, w);
408
409
410
411 }
412 return kTRUE;
413}