32 #include "CLHEP/Random/RandFlat.h" 39 fOutFileName( pset.getUntrackedParameter<
string>(
"OutFileName",
"FlatEGunHepMC.dat") ),
72 if (
fOutStream->rdstate() == std::ios::failbit ) {
73 throw cms::Exception(
"FileNotOpen",
"FlatEGunASCIIWriter::beginJob()")
95 HepMC::GenVertex* Vtx =
new HepMC::GenVertex( HepMC::FourVector(0.,0.,0.) );
99 for (
unsigned int ip=0; ip<
fPartIDs.size(); ip++ )
101 double energy = CLHEP::RandFlat::shoot(
fMinE,
fMaxE ) ;
106 double mass = PData->mass().value() ;
107 double mom2 = energy*energy - mass*
mass ;
109 if ( mom2 > 0. ) mom =
sqrt(mom2) ;
111 double px = mom*
sin(theta)*
cos(phi) ;
112 double py = mom*
sin(theta)*
sin(phi) ;
113 double pz = mom*
cos(theta) ;
117 HepMC::FourVector
p(px,py,pz,energy);
120 Vtx->add_particle_out(Part);
122 fEvt->add_vertex( Vtx ) ;
124 fEvt->set_signal_process_id(20) ;
T getParameter(std::string const &) const
void beginRun(const edm::Run &, const EventSetup &) override
void analyze(const edm::Event &, const edm::EventSetup &) override
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
std::vector< int > fPartIDs
ESHandle< HepPDT::ParticleDataTable > fPDGTable
bool getData(T &iHolder) const
Cos< T >::type cos(const T &t)
~FlatEGunASCIIWriter() override
Abs< T >::type abs(const T &t)
HepPDT::ParticleData ParticleData
FlatEGunASCIIWriter(const edm::ParameterSet &)
HepMC::IO_GenEvent * fOutStream