21 #include "CLHEP/Random/RandFlat.h"
39 produces<HepMCProduct>(
"unsmeared");
40 produces<GenEventInfoProduct>();
55 cout <<
" RandomtXiGunProducer : Begin New Event Generation" << endl ;
64 fEvt =
new HepMC::GenEvent() ;
70 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.));
75 for (
unsigned int ip=0; ip<
fPartIDs.size(); ++ip)
92 std::cout <<
"WARNING: t limits redefined (unphysical values for given xi)." << endl;
95 t = CLHEP::RandFlat::shoot(engine,min_t,max_t);
101 Part->suggest_barcode( barcode ) ;
103 Vtx->add_particle_out(Part);
109 double max_t =
fMaxt;
111 std::cout <<
"WARNING: t limits redefined (unphysical values for given xi)." << endl;
114 t = CLHEP::RandFlat::shoot(engine,min_t,max_t);
120 Part2->suggest_barcode( barcode ) ;
122 Vtx->add_particle_out(Part2) ;
126 fEvt->add_vertex(Vtx) ;
128 fEvt->set_signal_process_id(20) ;
135 std::unique_ptr<HepMCProduct> BProduct(
new HepMCProduct()) ;
136 BProduct->addHepMCData(
fEvt );
146 cout <<
" RandomtXiGunProducer : Event Generation Done " << endl;
154 double sMom =
sqrt(sEnergy*sEnergy-mass*mass);
155 double min_t = -2.*(fpMom*sMom-
fpEnergy*sEnergy+mass*
mass);
156 if (t<min_t) t=min_t;
157 long double theta = acos((-t/2.- mass*mass +
fpEnergy*sEnergy)/(sMom*fpMom));
159 if (direction<1) theta = acos(-1.) -
theta;
161 double px = sMom*
cos(phi)*
sin(theta)*direction;
162 double py = sMom*
sin(phi)*
sin(theta);
163 double pz = sMom*
cos(theta) ;
165 edm::LogInfo(
"RandomXiGunProducer") <<
"-----------------------------------------------------------------------------------------------------\n"
166 <<
"Produced a proton with phi : " << phi <<
" theta: " << theta <<
" t: " << t <<
" Xi: " << Xi <<
"\n"
167 <<
" Px : " << px <<
" Py : " << py <<
" Pz : " << pz <<
"\n"
168 <<
" direction: " << direction <<
"\n"
169 <<
"-----------------------------------------------------------------------------------------------------"
172 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
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::Service< edm::RandomNumberGenerator > rng
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)
Abs< T >::type abs(const T &t)
ESHandle< HepPDT::ParticleDataTable > fPDGTable
virtual void produce(Event &e, const EventSetup &es) override
std::vector< int > fPartIDs
virtual ~RandomtXiGunProducer()
StreamID streamID() const
const HepPDT::ParticleData * PData
double Minimum_t(double xi)