147{
148 Double_t
tp,tS,zp,xp,yp,zS,xS,yS,
pz,
px,
py,e,
w;
149 Double_t tm,zm,xm,ym,pmz,pmx,pmy,em;
150
151 Int_t im;
152
153
154
155
156 int iDP = 0;
157 std::vector<int> dec_chain;
158 std::vector<int> dpvec;
159 bool hadDecay = false;
160 do {
161
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180 }
181
184 double dpmom = 0;
185 double thetain = 0;
188 double dpe = sqrt(dpmom*dpmom+dpm*dpm);
189 double phiin = 2. * M_PI * gRandom->Rndm();
190
191 if ( debug > 1){std::cout << " Adding DP gun with p "
192 << dpmom
193 << " m " << dpm
194 << " e " << dpe
195 << " theta,phi " << thetain << "," << phiin << std::endl << std::flush;}
196 fPythia->event.append(
fDP, 1, 0, 0, dpmom * sin(thetain) * cos(phiin), dpmom * sin(thetain) * sin(phiin), dpmom * cos(thetain), dpe, dpm);
197 }
198
199 if (!
fPythia->next()) LOG(FATAL) <<
"fPythia->next() failed";
200
201
202 for(
int i=0;
i<
fPythia->event.size();
i++){
203
205 dpvec.push_back( i );
206 }
207 }
208 iDP = dpvec.size();
210 if ( iDP == 0 ){
211
212
214 }else{
215
216
218
220
225
230
231
232 std::cout << " Debug: decay product of A: "
235 << std::endl;
236
237
238
239
240
241
242
244 Double_t
p = TMath::Sqrt(px*px+py*py+pz*pz);
249 Double_t gam = e/TMath::Sqrt(e*e-p*p);
252
254 im = (Int_t)
fPythia->event[i].mother1();
255 zm =
fPythia->event[im].zProd();
256 xm =
fPythia->event[im].xProd();
257 ym =
fPythia->event[im].yProd();
262 tm =
fPythia->event[im].tProd();
263
268 Double_t Rsq =
test+1.;
269 while(Rsq>test){
273 }
274 }
276
277
278
279
280 }else{
281 cpg->AddTrack((Int_t)
fPythia->event[im].id(),pmx,pmy,pmz,xm/
cm+
dx,ym/
cm+
dy,zm/
cm,-1,
false,em,tm/
cm/
c_light,
w);
282 cpg->AddTrack(
fDP, px, py, pz, xp/
cm+dx,yp/
cm+dy,zp/
cm, 0,
false,e,tp/
cm/
c_light,w);
283 }
284
285 dec_chain.push_back( im );
286 dec_chain.push_back( i );
287 if (debug>1) std::cout << std::endl <<
" insert mother id " << im <<
" pdg=" <<
fPythia->event[im].id() <<
" pmz = " << pmz <<
" [GeV], zm = " << zm <<
" [mm] tm = " << tm <<
" [mm/c]" << std::endl;
288 if (debug>1) std::cout <<
" ----> insert DP id " <<
i <<
" pdg=" <<
fDP <<
" pz = " <<
pz <<
" [GeV] zp = " << zp <<
" [mm] tp = " <<
tp <<
" [mm/c]" << std::endl;
290 }
291 } while ( iDP == 0 );
292
294 LOGF(info,
"ship event %i / pythia event-nr %i",
fShipEventNr,
fn);
295 }
297
298 if (debug>1) std::cout << "Filling daughter particles" << std::endl;
299
300 for(
int k=0;
k<
fPythia->event.size();
k++){
301
302 if (debug>1) std::cout <<
k<<
" pdg =" <<
fPythia->event[
k].id() <<
" mum " <<
fPythia->event[
k].mother1() << std::endl;
304 while (im>0){
305 if ( im == iDP ){break;}
306
307 else {im =
fPythia->event[im].mother1();}
308 }
309 if (im < 1) {
310 if (debug>1) std::cout << "reject" << std::endl;
311 continue;
312 }
313 if (debug>1) std::cout << "accept" << std::endl;
314 dec_chain.push_back( k );
315 }
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334 for(std::vector<int>::iterator it = dec_chain.begin() + 2; it != dec_chain.end(); ++it){
335
337
338 int impy =
fPythia->event[
k].mother1();
339 std::vector<int>::iterator itm = std::find( dec_chain.begin(), dec_chain.end(), impy);
340 im =-1;
341 if ( itm != dec_chain.end() )
342 im = itm - dec_chain.begin();
343
344 Bool_t wanttracking=false;
345 if(
fPythia->event[k].isFinal()){ wanttracking=
true;}
351 cpg->AddTrack((Int_t)
fPythia->event[k].id(),px,py,pz,xS/
cm,yS/
cm,zS/
cm,im,wanttracking,e,tS/
cm/
c_light,w);
352
353 }
354 return kTRUE;
355}