214 G4LorentzVector ptot(0,0,0,0);
215 double E_cms,p_Mag,e_Mass2,M_cms,theta;
216 for(HepMC::GenEvent::vertex_const_iterator vitr= hepmcevt->vertices_begin();
217 vitr != hepmcevt->vertices_end(); ++vitr ) {
219 for(HepMC::GenVertex::particle_iterator
220 vpitr = (*vitr)->particles_begin(HepMC::children);
221 vpitr != (*vitr)->particles_end(HepMC::children); ++vpitr) {
223 if((*vpitr)->status() !=1)
continue;
236 ISvcLocator* svcLocator = Gaudi::svcLocator();
239 StatusCode sc=svcLocator->service(
"G4Svc", tmpSvc);
240 m_G4Svc=
dynamic_cast<G4Svc *
>(tmpSvc);
243 G4ThreeVector
v(0,0,0);
249 e_Mass2=electron_mass_c2*electron_mass_c2;
250 p_Mag=sqrt((E_cms*E_cms-4*e_Mass2)/(2*(1-
cos(
pi-2*theta))));
251 G4ThreeVector p_Positron(p_Mag*
sin(theta),0,p_Mag*
cos(theta));
252 G4ThreeVector p_Electron(p_Mag*
sin(
pi-theta),0,p_Mag*
cos(
pi-theta));
253 G4ThreeVector vee=p_Positron+p_Electron;
255 if(m_G4Svc-> GetSetBeamShift()==
true && fabs(M_cms-3686)<50.0) {vee = beamshift;}
258 M_cms = sqrt(M_cms*M_cms + pee*pee);
262 for(HepMC::GenEvent::vertex_const_iterator vitr= hepmcevt->vertices_begin();
263 vitr != hepmcevt->vertices_end(); ++vitr ) {
266 G4LorentzVector xvtx;
267 xvtx.setX( (*vitr)-> position().
x());
268 xvtx.setY( (*vitr)-> position().
y());
269 xvtx.setZ( (*vitr)-> position().z());
270 xvtx.setT( (*vitr)-> position().
t());
272 (*vitr)->set_position(xvtx);
276 for (HepMC::GenVertex::particle_iterator
277 vpitr = (*vitr)->particles_begin(HepMC::children);
278 vpitr != (*vitr)->particles_end(HepMC::children); ++vpitr) {
285 (*vpitr)->set_momentum(p);
300 ISvcLocator* svcLocator = Gaudi::svcLocator();
303 StatusCode sc=svcLocator->service(
"G4Svc", tmpSvc);
304 m_G4Svc=
dynamic_cast<G4Svc *
>(tmpSvc);
319 for(HepMC::GenEvent::vertex_const_iterator vitr= hepmcevt->vertices_begin();
320 vitr != hepmcevt->vertices_end(); ++vitr )
323 G4int pOut = (*vitr)->particles_out_size();
324 HepMC::GenVertex::particle_iterator pitr = (*vitr)->particles_begin(HepMC::children);
325 G4int pdgcode= (*pitr)-> pdg_id();
326 if(pOut == 1 &&
abs(pdgcode) == 11)
328 G4int barcodeVtx = (*vitr)->barcode();
330 for (HepMC::GenVertex::particle_iterator pitr= (*vitr)->particles_begin(HepMC::children);
331 pitr != (*vitr)->particles_end(HepMC::children); ++pitr)
333 G4int pdgcode = (*pitr)->pdg_id();
336 if(pdgcode==-22) pdgcode=22;
342 G4PrimaryParticle* particle = 0;
347 if(pdgcode==m_geantinoPdgId){
348 G4ParticleDefinition* pd = G4ParticleTable::GetParticleTable()->FindParticle(
"geantino");
349 particle =
new G4PrimaryParticle(pd, p.x()*GeV, p.y()*GeV, p.z()*GeV);
350 (*pitr)->set_pdg_id(particle->GetPDGcode());
352 else if(pdgcode==m_chargedgeantinoPdgId){
353 G4ParticleDefinition* pd = G4ParticleTable::GetParticleTable()->FindParticle(
"chargedgeantino");
354 particle =
new G4PrimaryParticle(pd, p.x()*GeV, p.y()*GeV, p.z()*GeV);
355 (*pitr)->set_pdg_id(particle->GetPDGcode());
361 particle =
new G4PrimaryParticle(pdgcode, p.x()*GeV, p.y()*GeV, p.z()*GeV);
364 G4cout <<
"ERROR! Cannot create particle PDGCode=" << pdgcode << G4endl;
368 G4int ISTHEP = (*pitr)->status();
370 G4int barcodeEndVtx = 0;
371 if((*pitr)->end_vertex())
372 barcodeEndVtx = (*pitr)->end_vertex()->barcode();
375 HPlist.push_back(hepmcParticle);
377 for(
size_t ii=0; ii<
HPlist.size(); ii++ )
379 if(barcodeVtx ==
HPlist[ii]->GetBarcodeEndVtx())
381 HPlist[ii]->GetTheParticle()->SetDaughter(particle);
382 hepmcParticle->
Done();
392 for(HepMC::GenEvent::vertex_const_iterator vitr= hepmcevt->vertices_begin();
393 vitr != hepmcevt->vertices_end(); ++vitr )
395 for (HepMC::GenVertex::particle_iterator pitr= (*vitr)->particles_begin(HepMC::children);
396 pitr != (*vitr)->particles_end(HepMC::children); ++pitr)
398 G4int ISTHEP = (*pitr)->status();
405 G4int pdgcode = (*pitr)->pdg_id();
406 G4int barcodeEndVtx = 0;
407 if((*pitr)->end_vertex())
408 barcodeEndVtx = (*pitr)->end_vertex()->barcode();
409 G4PrimaryParticle* particle = 0;
414 if(pdgcode==m_geantinoPdgId){
415 G4ParticleDefinition* pd = G4ParticleTable::GetParticleTable()->FindParticle(
"geantino");
416 particle =
new G4PrimaryParticle(pd, p.x()*GeV, p.y()*GeV, p.z()*GeV);
417 (*pitr)->set_pdg_id(particle->GetPDGcode());
419 else if(pdgcode==m_chargedgeantinoPdgId){
420 G4ParticleDefinition* pd = G4ParticleTable::GetParticleTable()->FindParticle(
"chargedgeantino");
421 particle =
new G4PrimaryParticle(pd, p.x()*GeV, p.y()*GeV, p.z()*GeV);
422 (*pitr)->set_pdg_id(particle->GetPDGcode());
428 particle =
new G4PrimaryParticle(pdgcode, p.x()*GeV, p.y()*GeV, p.z()*GeV);
431 G4cout <<
"ERROR! Cannot create particle PDGCode=" << pdgcode << G4endl;
437 HPlist.push_back(hepmcParticle);
439 hepmcParticle->
Done();
449 G4double pmPosX,pmPosY,pmPosZ,pmTime;
450 G4double tmpPosX,tmpPosY,tmpPosZ,tmpT;
451 G4double beamPosX,beamPosY,beamPosZ,beamSizeX,beamSizeY,beamSizeZ;
453 if(m_RealizationSvc->
UseDBFlag() ==
false) {
481 G4double gaussX = G4RandGauss::shoot();
482 G4double gaussY = G4RandGauss::shoot();
483 G4double gaussZ = G4RandGauss::shoot();
484 G4double gaussT = G4RandGauss::shoot();
491 G4double ran=G4UniformRand();
492 G4double beamTime = bunchTimeSigma*G4RandGauss::shoot() + beamStartTime + beamDeltaTime*int(ran*nBunch);
494 tmpPosX = (beamPosX + beamSizeX*gaussX ) *mm;
495 tmpPosY = (beamPosY + beamSizeY*gaussY ) *mm;
496 tmpPosZ = (beamPosZ + beamSizeZ*gaussZ ) *mm;
497 tmpT = (beamSizeZ * gaussT ) * mm/c_light +beamTime;
499 G4LorentzVector tmpv(tmpPosX,tmpPosY,tmpPosZ,tmpT*c_light/mm);
501 HepMC::GenEvent::vertex_const_iterator vitr0= hepmcevt->vertices_begin();
502 G4LorentzVector xvtx0 ;
503 xvtx0.setX( (*vitr0)-> position().
x());
504 xvtx0.setY( (*vitr0)-> position().
y());
505 xvtx0.setZ( (*vitr0)-> position().z());
506 xvtx0.setT( (*vitr0)-> position().
t());
507 pmPosX = xvtx0.x()*mm + tmpPosX;
508 pmPosY = xvtx0.y()*mm + tmpPosY;
509 pmPosZ = xvtx0.z()*mm + tmpPosZ;
510 pmTime = xvtx0.t()*mm/c_light + tmpT;
515 G4cout<<xvtx0.x()<<
" "<<xvtx0.y()<<
" "<<xvtx0.z()<<
" "
516 <<beamSizeX*gaussX<<
" "
517 <<beamSizeY*gaussY<<
" "
518 <<beamSizeZ*gaussZ<<
" "<<G4endl;
519 G4cout<<xvtx0.t()* mm/c_light<<
" "
520 <<beamSizeZ * gaussT/sqrt(2)*mm/c_light<<
" "
523 for(HepMC::GenEvent::vertex_const_iterator vitr= hepmcevt->vertices_begin();
524 vitr != hepmcevt->vertices_end(); ++vitr )
526 G4LorentzVector xvtx;
527 xvtx.setX((*vitr)-> position().
x());
528 xvtx.setY((*vitr)-> position().
y());
529 xvtx.setZ((*vitr)-> position().z());
530 xvtx.setT((*vitr)-> position().
t());
531 (*vitr)->set_position(xvtx+tmpv);
535 G4PrimaryVertex* g4vtx=
new G4PrimaryVertex(pmPosX,pmPosY,pmPosZ,pmTime);
538 for(
size_t ii=0; ii<
HPlist.size(); ii++ )
540 if(
HPlist[ii]->GetISTHEP() > 0 )
543 G4PrimaryParticle* initialParticle =
HPlist[ii]->GetTheParticle();
544 g4vtx->SetPrimary( initialParticle );
549 for(
size_t iii=0;iii<
HPlist.size();iii++)
553 g4event->AddPrimaryVertex(g4vtx);