20 #include <CLHEP/Random/RandFlat.h> 35 produces<HepMCProduct>(
"unsmeared");
36 produces<GenEventInfoProduct>();
48 edm::LogInfo(
"RandomtXiGunProducer") <<
"Begin New Event Generation\n";
63 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(0., 0., 0.));
68 for (
unsigned int ip = 0; ip <
fPartIDs.size(); ++ip) {
85 edm::LogInfo(
"RandomtXiGunProducer") <<
"WARNING: t limits redefined (unphysical values for given xi).\n";
88 t = (
fLog_t) ?
pow(CLHEP::RandFlat::shoot(engine, log10(min_t), log10(max_t)), 10)
89 : CLHEP::RandFlat::shoot(engine, min_t, max_t);
94 Part->suggest_barcode(barcode);
96 Vtx->add_particle_out(Part);
102 double max_t =
fMaxt;
105 <<
"WARNING: t limits redefined (unphysical values for given xi)." << endl;
108 t = (
fLog_t) ?
pow(CLHEP::RandFlat::shoot(engine, log10(min_t), log10(max_t)), 10)
109 : CLHEP::RandFlat::shoot(engine, min_t, max_t);
114 Part2->suggest_barcode(barcode);
116 Vtx->add_particle_out(Part2);
120 fEvt->add_vertex(Vtx);
122 fEvt->set_signal_process_id(20);
128 std::unique_ptr<HepMCProduct> BProduct(
new HepMCProduct());
129 BProduct->addHepMCData(
fEvt);
138 edm::LogInfo(
"RandomtXiGunProducer") <<
" Event Generation Done \n";
144 double sEnergy = (1.0 - Xi) *
fpEnergy;
145 double sMom =
sqrt(sEnergy * sEnergy - mass * mass);
146 double min_t = -2. * (fpMom * sMom -
fpEnergy * sEnergy + mass *
mass);
149 long double theta = acos((-t / 2. - mass * mass +
fpEnergy * sEnergy) / (sMom * fpMom));
152 theta = acos(-1.) -
theta;
154 double px = sMom *
cos(phi) *
sin(theta);
155 double py = sMom *
sin(phi) *
sin(theta);
156 double pz = sMom *
cos(theta);
159 <<
"-----------------------------------------------------------------------------------------------------\n" 160 <<
"Produced a proton with phi : " << phi <<
" theta: " << theta <<
" t: " << t <<
" Xi: " << Xi <<
"\n" 161 <<
" Px : " << px <<
" Py : " << py <<
" Pz : " << pz <<
"\n" 162 <<
" direction: " << direction <<
"\n" 163 <<
"-----------------------------------------------------------------------------------------------------" 166 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)