247{
248
251
252
253 ISvcLocator* svcLocator = Gaudi::svcLocator();
256 StatusCode sc=svcLocator->service("G4Svc", tmpSvc);
257 m_G4Svc=
dynamic_cast<G4Svc *
>(tmpSvc);
258
259
260
263
264
265 if(m_logLevel <=2 && m_G4Svc->GetBoostLab()== true)
267
268
271 {
272 for(HepMC::GenEvent::vertex_const_iterator vitr= hepmcevt->vertices_begin();
273 vitr != hepmcevt->vertices_end(); ++vitr )
274 {
275 G4int vtxFlag=0;
276 G4int pOut = (*vitr)->particles_out_size();
277 HepMC::GenVertex::particle_iterator pitr = (*vitr)->particles_begin(HepMC::children);
278 G4int pdgcode= (*pitr)-> pdg_id();
279 if(pOut == 1 &&
abs(pdgcode) == 11)
280 vtxFlag=1;
281 G4int barcodeVtx = (*vitr)->barcode();
282
283 for (HepMC::GenVertex::particle_iterator pitr= (*vitr)->particles_begin(HepMC::children);
284 pitr != (*vitr)->particles_end(HepMC::children); ++pitr)
285 {
286 G4int pdgcode = (*pitr)->pdg_id();
287 if(vtxFlag==0)
288 {
289 if(pdgcode==-22) pdgcode=22;
290 G4LorentzVector p;
295 G4PrimaryParticle* particle = new G4PrimaryParticle(pdgcode, p.x()*GeV, p.y()*GeV, p.z()*GeV);
296
297
298 G4int ISTHEP = (*pitr)->status();
299
300 G4int barcodeEndVtx = 0;
301 if((*pitr)->end_vertex())
302 barcodeEndVtx = (*pitr)->end_vertex()->barcode();
303
305 HPlist.push_back(hepmcParticle);
306
307 for(
size_t ii=0; ii<
HPlist.size(); ii++ )
308 {
309 if(barcodeVtx ==
HPlist[ii]->GetBarcodeEndVtx())
310 {
311 HPlist[ii]->GetTheParticle()->SetDaughter(particle);
312 hepmcParticle->
Done();
313 break;
314 }
315 }
316 }
317 }
318 }
319 }
320 else
321 {
322 for(HepMC::GenEvent::vertex_const_iterator vitr= hepmcevt->vertices_begin();
323 vitr != hepmcevt->vertices_end(); ++vitr )
324 {
325 for (HepMC::GenVertex::particle_iterator pitr= (*vitr)->particles_begin(HepMC::children);
326 pitr != (*vitr)->particles_end(HepMC::children); ++pitr)
327 {
328 G4int ISTHEP = (*pitr)->status();
329 G4LorentzVector p;
334
335 G4int pdgcode = (*pitr)->pdg_id();
336 G4int barcodeEndVtx = 0;
337 if((*pitr)->end_vertex())
338 barcodeEndVtx = (*pitr)->end_vertex()->barcode();
339 G4PrimaryParticle* particle = new G4PrimaryParticle(pdgcode, p.x()*GeV, p.y()*GeV, p.z()*GeV);
340
341
342
344 HPlist.push_back(hepmcParticle);
345 if(ISTHEP>1)
346 hepmcParticle->
Done();
347 }
348 }
349 }
350
351
354
355
356 G4double pmPosX,pmPosY,pmPosZ,pmTime;
357 G4double tmpPosX,tmpPosY,tmpPosZ,tmpT;
358 G4double beamPosX,beamPosY,beamPosZ,beamSizeX,beamSizeY,beamSizeZ;
359
360 if(m_RealizationSvc->
UseDBFlag() ==
false) {
364
368 }
373
377 }
382
386 }
387
388 G4double gaussX = G4RandGauss::shoot();
389 G4double gaussY = G4RandGauss::shoot();
390 G4double gaussZ = G4RandGauss::shoot();
391 G4double gaussT = G4RandGauss::shoot();
392
397
398 G4double ran=G4UniformRand();
399 G4double beamTime = bunchTimeSigma*G4RandGauss::shoot() + beamStartTime + beamDeltaTime*int(ran*nBunch);
400
401 tmpPosX = (beamPosX + beamSizeX*gaussX ) *mm;
402 tmpPosY = (beamPosY + beamSizeY*gaussY ) *mm;
403 tmpPosZ = (beamPosZ + beamSizeZ*gaussZ ) *mm;
404 tmpT = (beamSizeZ * gaussT ) * mm/c_light +beamTime;
405
406 G4LorentzVector tmpv(tmpPosX,tmpPosY,tmpPosZ,tmpT*c_light/mm);
407
408 HepMC::GenEvent::vertex_const_iterator vitr0= hepmcevt->vertices_begin();
409 G4LorentzVector xvtx0 ;
410 xvtx0.setX( (*vitr0)-> position().
x());
411 xvtx0.setY( (*vitr0)-> position().
y());
412 xvtx0.setZ( (*vitr0)-> position().z());
413 xvtx0.setT( (*vitr0)-> position().
t());
414 pmPosX = xvtx0.x()*mm + tmpPosX;
415 pmPosY = xvtx0.y()*mm + tmpPosY;
416 pmPosZ = xvtx0.z()*mm + tmpPosZ;
417 pmTime = xvtx0.t()*mm/c_light + tmpT;
418
420 {
421 G4cout<<G4endl;
422 G4cout<<xvtx0.x()<<" "<<xvtx0.y()<<" "<<xvtx0.z()<<" "
423 <<beamSizeX*gaussX<<" "
424 <<beamSizeY*gaussY<<" "
425 <<beamSizeZ*gaussZ<<" "<<G4endl;
426 G4cout<<xvtx0.t()* mm/c_light<<" "
427 <<beamSizeZ * gaussT/sqrt(2)*mm/c_light<<" "
428 <<beamTime<<G4endl;
429 }
430 for(HepMC::GenEvent::vertex_const_iterator vitr= hepmcevt->vertices_begin();
431 vitr != hepmcevt->vertices_end(); ++vitr )
432 {
433 G4LorentzVector xvtx;
434 xvtx.setX((*vitr)-> position().
x());
435 xvtx.setY((*vitr)-> position().
y());
436 xvtx.setZ((*vitr)-> position().z());
437 xvtx.setT((*vitr)-> position().
t());
438 (*vitr)->set_position(xvtx+tmpv);
439 }
441
442 G4PrimaryVertex* g4vtx= new G4PrimaryVertex(pmPosX,pmPosY,pmPosZ,pmTime);
443
444
445 for(
size_t ii=0; ii<
HPlist.size(); ii++ )
446 {
447 if(
HPlist[ii]->GetISTHEP() > 0 )
448
449 {
450 G4PrimaryParticle* initialParticle =
HPlist[ii]->GetTheParticle();
451 g4vtx->SetPrimary( initialParticle );
452 }
453 }
454
455
456 for(
size_t iii=0;iii<
HPlist.size();iii++)
459
460 g4event->AddPrimaryVertex(g4vtx);
461}
std::vector< G4HepMCParticle * > HPlist
void Print(const HepMC::GenEvent *hepmcevt)
void Boost(HepMC::GenEvent *hepmcevt)
G4int CheckType(const HepMC::GenEvent *hepmcevt)
double GetBeamDeltaTime()
double GetBunchTimeSigma()
double GetBeamStartTime()
void SetBeamTime(double value)