21 #include <CLHEP/Random/RandFlat.h> 40 produces<HepMCProduct>(
"unsmeared");
41 produces<GenEventInfoProduct>();
56 edm::LogInfo(
"RandomtXiGunProducer")<<
"Begin New Event Generation\n";
71 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.));
76 for (
unsigned int ip=0; ip<
fPartIDs.size(); ++ip)
93 edm::LogInfo(
"RandomtXiGunProducer") <<
"WARNING: t limits redefined (unphysical values for given xi).\n";
96 t = (
fLog_t)?
pow(CLHEP::RandFlat::shoot(engine,log10(min_t),log10(max_t)),10):
97 CLHEP::RandFlat::shoot(engine,min_t,max_t);
103 Part->suggest_barcode( barcode ) ;
105 Vtx->add_particle_out(Part);
111 double max_t =
fMaxt;
113 edm::LogInfo(
"RandomtXiGunProducer") <<
"WARNING: t limits redefined (unphysical values for given xi)." << endl;
116 t = (
fLog_t)?
pow(CLHEP::RandFlat::shoot(engine,log10(min_t),log10(max_t)),10):
117 CLHEP::RandFlat::shoot(engine,min_t,max_t);
123 Part2->suggest_barcode( barcode ) ;
125 Vtx->add_particle_out(Part2) ;
129 fEvt->add_vertex(Vtx) ;
131 fEvt->set_signal_process_id(20) ;
138 std::unique_ptr<HepMCProduct> BProduct(
new HepMCProduct()) ;
139 BProduct->addHepMCData(
fEvt );
149 edm::LogInfo(
"RandomtXiGunProducer") <<
" Event Generation Done \n";
157 double sMom =
sqrt(sEnergy*sEnergy-mass*mass);
158 double min_t = -2.*(fpMom*sMom-
fpEnergy*sEnergy+mass*
mass);
159 if (t<min_t) t=min_t;
160 long double theta = acos((-t/2.- mass*mass +
fpEnergy*sEnergy)/(sMom*fpMom));
162 if (direction<1) theta = acos(-1.) -
theta;
164 double px = sMom*
cos(phi)*
sin(theta);
165 double py = sMom*
sin(phi)*
sin(theta);
166 double pz = sMom*
cos(theta) ;
168 edm::LogInfo(
"RandomXiGunProducer") <<
"-----------------------------------------------------------------------------------------------------\n" 169 <<
"Produced a proton with phi : " << phi <<
" theta: " << theta <<
" t: " << t <<
" Xi: " << Xi <<
"\n" 170 <<
" Px : " << px <<
" Py : " << py <<
" Pz : " << pz <<
"\n" 171 <<
" direction: " << direction <<
"\n" 172 <<
"-----------------------------------------------------------------------------------------------------" 175 return HepMC::FourVector(px,py,pz,sEnergy) ;
HepMC::FourVector make_particle(double t, double Xi, double phi, int PartID, int direction)
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
RandomtXiGunProducer(const ParameterSet &)
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
Cos< T >::type cos(const T &t)
~RandomtXiGunProducer() override
Abs< T >::type abs(const T &t)
ESHandle< HepPDT::ParticleDataTable > fPDGTable
void produce(Event &e, const EventSetup &es) override
std::vector< int > fPartIDs
StreamID streamID() const
const HepPDT::ParticleData * PData
double Minimum_t(double xi)
Power< A, B >::type pow(const A &a, const B &b)