15 #include "CLHEP/Random/RandFlat.h" 16 #include "CLHEP/Random/RandomEngine.h" 31 edm::LogInfo(
"FlatThetaGun") <<
"Internal FileRandomKEThetaGun is initialzed" 32 <<
" with data read from " << file <<
" and " 33 <<
particleN <<
" particles created/event";
36 double energy,
elem, sum=0;
43 <<
" GeV Count rate " <<
elem;
47 for (
unsigned int i=0;
i<
fdistn.size();
i++) {
57 throw cms::Exception(
"FileNotFound",
"Not enough data point found in file ")
61 produces<HepMCProduct>(
"unsmeared");
62 produces<GenEventInfoProduct>();
70 LogDebug(
"FlatThetaGun") <<
"FileRandomKEThetaGunProducer : Begin New Event Generation";
88 HepMC::GenVertex* Vtx =
new HepMC::GenVertex( HepMC::FourVector(0.,0.,0.));
96 double r1 = engine->flat();
103 double ke = (keMin*(rMax-
r1) + keMax*(r1-rMin))/(rMax-rMin);
105 LogDebug(
"FlatThetaGun") <<
"FileRandomKEThetaGunProducer: KE " << ke
106 <<
" in range " << keMin <<
":" << keMax
107 <<
" with " << r1 <<
" in " << rMin <<
":" <<
rMax;
113 double mass = PData->mass().value() ;
114 double energy = ke +
mass;
115 double mom2 = ke*ke + 2.*ke*
mass ;
117 double px = mom*
sin(theta)*
cos(phi);
118 double py = mom*
sin(theta)*
sin(phi);
119 double pz = mom*
cos(theta);
121 HepMC::FourVector
p(px,py,pz,energy) ;
123 Part->suggest_barcode( barcode ) ;
125 Vtx->add_particle_out(Part);
128 fEvt->add_vertex(Vtx) ;
130 fEvt->set_signal_process_id(20) ;
137 std::unique_ptr<HepMCProduct> BProduct(
new HepMCProduct()) ;
138 BProduct->addHepMCData(
fEvt );
145 LogDebug(
"FlatThetaGun") <<
"FileRandomKEThetaGunProducer : Event Generation Done";
T getParameter(std::string const &) const
EventNumber_t event() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Sin< T >::type sin(const T &t)
ESHandle< HepPDT::ParticleDataTable > fPDGTable
Geom::Theta< T > theta() const
void produce(Event &e, const EventSetup &es) override
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
std::vector< double > fdistn
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
HepPDT::ParticleData ParticleData
def elem(elemtype, innerHTML='', html_class='', kwargs)
FileRandomKEThetaGunProducer(const ParameterSet &)
std::vector< double > kineticE
~FileRandomKEThetaGunProducer() override
StreamID streamID() const
std::vector< int > fPartIDs