133 for ( HepMC::GenEvent::vertex_const_iterator vitr = hepmcevt->vertices_begin();
134 vitr != hepmcevt->vertices_end(); ++vitr )
136 G4cout << G4endl <<
"vertex:" << i <<
" barcode:" << ( *vitr )->barcode() <<
" ";
142 G4LorentzVector xvtx;
143 xvtx.setX( ( *vitr )->position().x() );
144 xvtx.setY( ( *vitr )->position().y() );
145 xvtx.setZ( ( *vitr )->position().z() );
146 xvtx.setT( ( *vitr )->position().t() );
147 G4cout <<
"x:" << xvtx.x() <<
" y:" << xvtx.y() <<
" z:" << xvtx.z()
148 <<
" t:" << xvtx.t() * mm / c_light << G4endl;
151 for ( HepMC::GenVertex::particle_iterator pitr =
152 ( *vitr )->particles_begin( HepMC::children );
153 pitr != ( *vitr )->particles_end( HepMC::children ); ++pitr )
155 G4int pdgcode = ( *pitr )->pdg_id();
157 p.setX( ( *pitr )->momentum().x() );
158 p.setY( ( *pitr )->momentum().y() );
159 p.setZ( ( *pitr )->momentum().z() );
160 p.setT( ( *pitr )->momentum().t() );
161 G4cout <<
"particle:" << j <<
" pdgcode:" << pdgcode <<
" ";
162 G4cout <<
"p:" << p.x() <<
" " << p.y() <<
" " << p.z() <<
" ";
163 if ( ( *pitr )->end_vertex() )
164 G4cout <<
"endVtx:" << ( *pitr )->end_vertex()->barcode() <<
" ";
165 G4cout <<
"status:" << ( *pitr )->status() << G4endl;
223 G4LorentzVector ptot( 0, 0, 0, 0 );
224 double E_cms, p_Mag, e_Mass2, M_cms, theta;
225 for ( HepMC::GenEvent::vertex_const_iterator vitr = hepmcevt->vertices_begin();
226 vitr != hepmcevt->vertices_end(); ++vitr )
229 for ( HepMC::GenVertex::particle_iterator vpitr =
230 ( *vitr )->particles_begin( HepMC::children );
231 vpitr != ( *vitr )->particles_end( HepMC::children ); ++vpitr )
234 if ( ( *vpitr )->status() != 1 )
continue;
237 p.setX( ( *vpitr )->momentum().x() );
238 p.setY( ( *vpitr )->momentum().y() );
239 p.setZ( ( *vpitr )->momentum().z() );
240 p.setT( ( *vpitr )->momentum().t() );
244 E_cms = ptot.e() * GeV;
247 ISvcLocator* svcLocator = Gaudi::svcLocator();
250 StatusCode sc = svcLocator->service(
"G4Svc", tmpSvc );
251 m_G4Svc =
dynamic_cast<G4Svc*
>( tmpSvc );
253 G4ThreeVector
v( 0, 0, 0 );
260 e_Mass2 = electron_mass_c2 * electron_mass_c2;
261 p_Mag = sqrt( ( E_cms * E_cms - 4 * e_Mass2 ) / ( 2 * ( 1 -
cos(
pi - 2 * theta ) ) ) );
262 G4ThreeVector p_Positron( p_Mag *
sin( theta ), 0, p_Mag *
cos( theta ) );
263 G4ThreeVector p_Electron( p_Mag *
sin(
pi - theta ), 0, p_Mag *
cos(
pi - theta ) );
264 G4ThreeVector vee = p_Positron + p_Electron;
267 if ( m_G4Svc->
GetSetBeamShift() ==
true && fabs( M_cms - 3686 ) < 50.0 ) { vee = beamshift; }
269 double pee = vee.r();
270 M_cms = sqrt( M_cms * M_cms + pee * pee );
273 for ( HepMC::GenEvent::vertex_const_iterator vitr = hepmcevt->vertices_begin();
274 vitr != hepmcevt->vertices_end(); ++vitr )
278 G4LorentzVector xvtx;
279 xvtx.setX( ( *vitr )->position().x() );
280 xvtx.setY( ( *vitr )->position().y() );
281 xvtx.setZ( ( *vitr )->position().z() );
282 xvtx.setT( ( *vitr )->position().t() );
284 ( *vitr )->set_position( xvtx );
288 for ( HepMC::GenVertex::particle_iterator vpitr =
289 ( *vitr )->particles_begin( HepMC::children );
290 vpitr != ( *vitr )->particles_end( HepMC::children ); ++vpitr )
293 p.setX( ( *vpitr )->momentum().x() );
294 p.setY( ( *vpitr )->momentum().y() );
295 p.setZ( ( *vpitr )->momentum().z() );
296 p.setT( ( *vpitr )->momentum().t() );
298 ( *vpitr )->set_momentum( p );
311 ISvcLocator* svcLocator = Gaudi::svcLocator();
314 StatusCode sc = svcLocator->service(
"G4Svc", tmpSvc );
315 m_G4Svc =
dynamic_cast<G4Svc*
>( tmpSvc );
328 for ( HepMC::GenEvent::vertex_const_iterator vitr = hepmcevt->vertices_begin();
329 vitr != hepmcevt->vertices_end(); ++vitr )
332 G4int pOut = ( *vitr )->particles_out_size();
333 HepMC::GenVertex::particle_iterator pitr = ( *vitr )->particles_begin( HepMC::children );
334 G4int pdgcode = ( *pitr )->pdg_id();
335 if ( pOut == 1 &&
abs( pdgcode ) == 11 ) vtxFlag = 1;
336 G4int barcodeVtx = ( *vitr )->barcode();
338 for ( HepMC::GenVertex::particle_iterator pitr =
339 ( *vitr )->particles_begin( HepMC::children );
340 pitr != ( *vitr )->particles_end( HepMC::children ); ++pitr )
342 G4int pdgcode = ( *pitr )->pdg_id();
345 if ( pdgcode == -22 ) pdgcode = 22;
347 p.setX( ( *pitr )->momentum().x() );
348 p.setY( ( *pitr )->momentum().y() );
349 p.setZ( ( *pitr )->momentum().z() );
350 p.setT( ( *pitr )->momentum().t() );
351 G4PrimaryParticle* particle = 0;
376 particle =
new G4PrimaryParticle( pdgcode, p.x() * GeV, p.y() * GeV, p.z() * GeV );
382 G4int ISTHEP = ( *pitr )->status();
384 G4int barcodeEndVtx = 0;
385 if ( ( *pitr )->end_vertex() ) barcodeEndVtx = ( *pitr )->end_vertex()->barcode();
389 HPlist.push_back( hepmcParticle );
391 for (
size_t ii = 0; ii <
HPlist.size(); ii++ )
393 if ( barcodeVtx ==
HPlist[ii]->GetBarcodeEndVtx() )
395 HPlist[ii]->GetTheParticle()->SetDaughter( particle );
396 hepmcParticle->
Done();
406 for ( HepMC::GenEvent::vertex_const_iterator vitr = hepmcevt->vertices_begin();
407 vitr != hepmcevt->vertices_end(); ++vitr )
409 for ( HepMC::GenVertex::particle_iterator pitr =
410 ( *vitr )->particles_begin( HepMC::children );
411 pitr != ( *vitr )->particles_end( HepMC::children ); ++pitr )
413 G4int ISTHEP = ( *pitr )->status();
415 p.setX( ( *pitr )->momentum().x() );
416 p.setY( ( *pitr )->momentum().y() );
417 p.setZ( ( *pitr )->momentum().z() );
418 p.setT( ( *pitr )->momentum().t() );
420 G4int pdgcode = ( *pitr )->pdg_id();
421 G4int barcodeEndVtx = 0;
422 if ( ( *pitr )->end_vertex() ) barcodeEndVtx = ( *pitr )->end_vertex()->barcode();
423 G4PrimaryParticle* particle = 0;
448 particle =
new G4PrimaryParticle( pdgcode, p.x() * GeV, p.y() * GeV, p.z() * GeV );
457 HPlist.push_back( hepmcParticle );
458 if ( ISTHEP > 1 ) hepmcParticle->
Done();
467 G4double pmPosX, pmPosY, pmPosZ, pmTime;
468 G4double tmpPosX, tmpPosY, tmpPosZ, tmpT;
469 G4double beamPosX = 0, beamPosY = 0, beamPosZ = 0, beamSizeX = 0, beamSizeY = 0,
472 if ( m_RealizationSvc->UseDBFlag() ==
false )
482 if ( m_RealizationSvc->UseDBFlag() ==
true && m_RealizationSvc->ifReadBunch() ==
true )
484 beamPosX = m_RealizationSvc->getBunchPosX();
485 beamPosY = m_RealizationSvc->getBunchPosY();
486 beamPosZ = m_RealizationSvc->getBunchPosZ();
488 beamSizeX = m_RealizationSvc->getBunchSizeX();
489 beamSizeY = m_RealizationSvc->getBunchSizeY();
490 beamSizeZ = m_RealizationSvc->getBunchSizeZ();
492 if ( m_RealizationSvc->UseDBFlag() ==
true && m_RealizationSvc->ifReadBunch() ==
false )
503 G4double gaussX = G4RandGauss::shoot();
504 G4double gaussY = G4RandGauss::shoot();
505 G4double gaussZ = G4RandGauss::shoot();
506 G4double gaussT = G4RandGauss::shoot();
513 G4double ran = G4UniformRand();
514 G4double beamTime = bunchTimeSigma * G4RandGauss::shoot() + beamStartTime +
515 beamDeltaTime * int( ran * nBunch );
517 tmpPosX = ( beamPosX + beamSizeX * gaussX ) * mm;
518 tmpPosY = ( beamPosY + beamSizeY * gaussY ) * mm;
519 tmpPosZ = ( beamPosZ + beamSizeZ * gaussZ ) * mm;
520 tmpT = ( beamSizeZ * gaussT ) * mm / c_light + beamTime;
522 G4LorentzVector tmpv( tmpPosX, tmpPosY, tmpPosZ, tmpT * c_light / mm );
524 HepMC::GenEvent::vertex_const_iterator vitr0 = hepmcevt->vertices_begin();
525 G4LorentzVector xvtx0;
526 xvtx0.setX( ( *vitr0 )->position().x() );
527 xvtx0.setY( ( *vitr0 )->position().y() );
528 xvtx0.setZ( ( *vitr0 )->position().z() );
529 xvtx0.setT( ( *vitr0 )->position().t() );
530 pmPosX = xvtx0.x() * mm + tmpPosX;
531 pmPosY = xvtx0.y() * mm + tmpPosY;
532 pmPosZ = xvtx0.z() * mm + tmpPosZ;
533 pmTime = xvtx0.t() * mm / c_light + tmpT;
538 G4cout << xvtx0.x() <<
" " << xvtx0.y() <<
" " << xvtx0.z() <<
" " << beamSizeX * gaussX
539 <<
" " << beamSizeY * gaussY <<
" " << beamSizeZ * gaussZ <<
" " << G4endl;
540 G4cout << xvtx0.t() * mm / c_light <<
" " << beamSizeZ * gaussT / sqrt( 2 ) * mm / c_light
541 <<
" " << beamTime << G4endl;
543 for ( HepMC::GenEvent::vertex_const_iterator vitr = hepmcevt->vertices_begin();
544 vitr != hepmcevt->vertices_end(); ++vitr )
546 G4LorentzVector xvtx;
547 xvtx.setX( ( *vitr )->position().x() );
548 xvtx.setY( ( *vitr )->position().y() );
549 xvtx.setZ( ( *vitr )->position().z() );
550 xvtx.setT( ( *vitr )->position().t() );
551 ( *vitr )->set_position( xvtx + tmpv );
555 G4PrimaryVertex* g4vtx =
new G4PrimaryVertex( pmPosX, pmPosY, pmPosZ, pmTime );
558 for (
size_t ii = 0; ii <
HPlist.size(); ii++ )
560 if (
HPlist[ii]->GetISTHEP() > 0 )
563 G4PrimaryParticle* initialParticle =
HPlist[ii]->GetTheParticle();
564 g4vtx->SetPrimary( initialParticle );
569 for (
size_t iii = 0; iii <
HPlist.size(); iii++ ) {
delete HPlist[iii]; }
572 g4event->AddPrimaryVertex( g4vtx );