コード例 #1
0
ファイル: ParticleGunAlg.cpp プロジェクト: EmanuelPerez/FCCSW
//=============================================================================
// Main execution
//=============================================================================
StatusCode ParticleGunAlg::execute() {

  StatusCode sc = StatusCode::SUCCESS ;

  Gaudi::LorentzVector theFourMomentum ;
  Gaudi::LorentzVector origin ;
  int thePdgId ;

  // prepare a new HepMC event
  HepMC::GenEvent * theEvent = new HepMC::GenEvent() ;
    
  m_particleGunTool->generateParticle( theFourMomentum , origin , thePdgId );
    
  // create HepMC Vertex
  HepMC::GenVertex * v = new HepMC::GenVertex( HepMC::FourVector( origin.X() ,
								  origin.Y() ,
								  origin.Z() ,
								  origin.T() ) ) ;
  // create HepMC particle
  HepMC::GenParticle * p = new HepMC::GenParticle( HepMC::FourVector( theFourMomentum.Px() ,
								      theFourMomentum.Py() ,
								      theFourMomentum.Pz() ,
								      theFourMomentum.E()  ) ,
						   thePdgId ,
						   3 ) ;
    
  v -> add_particle_out( p ) ;
    
  theEvent -> add_vertex( v ) ;
  theEvent -> set_signal_process_id( 0 ) ;
  theEvent -> set_signal_process_vertex( v ) ;

  if(m_vertexSmearTool != nullptr)
	  m_vertexSmearTool->smearVertex(theEvent);

  HepMCEntry * entry = new HepMCEntry();
  entry->setEvent(theEvent);
  m_hepmchandle.put(entry);
  return sc ;
}
コード例 #2
0
ファイル: ConstPtParticleGun.cpp プロジェクト: HEP-FCC/FCCSW
StatusCode ConstPtParticleGun::getNextEvent(HepMC::GenEvent& theEvent) {
  Gaudi::LorentzVector theFourMomentum;
  Gaudi::LorentzVector origin;
  // note: pgdid is set in function generateParticle
  int thePdgId;
  generateParticle(theFourMomentum, origin, thePdgId);

  // create HepMC Vertex --
  // by calling add_vertex(), the hepmc event is given ownership of the vertex
  HepMC::GenVertex* v = new HepMC::GenVertex(HepMC::FourVector(origin.X(), origin.Y(), origin.Z(), origin.T()));
  // create HepMC particle --
  // by calling add_particle_out(), the hepmc vertex is given ownership of the particle
  HepMC::GenParticle* p = new HepMC::GenParticle(
      HepMC::FourVector(theFourMomentum.Px(), theFourMomentum.Py(), theFourMomentum.Pz(), theFourMomentum.E()),
      thePdgId,
      1);  // hepmc status code for final state particle

  v->add_particle_out(p);

  theEvent.add_vertex(v);
  theEvent.set_signal_process_vertex(v);

  return StatusCode::SUCCESS;
}