15#include "CLHEP/Random/RandPoisson.h"
40 ATH_MSG_INFO(
"In MultiParticleGunPileup::genInitialize" );
49 m_htgPileupProfile =
new TH1D(
"pileupProfile",
"input pileupProfile", 100, 0., 100. );
50 m_htgPileupMu =
new TH1D(
"generatedMu",
"generated pileup mu", 100, 0., 100. );
51 m_htgPileupEvents =
new TH1D(
"generatedEvents",
"generated pileup events", 100, 0., 100. );
66 ATH_MSG_INFO(
"Generate varying minbias collisions per event according to given pileup profile");
72 for (std::vector<float>::const_iterator itr=
m_multbcid.begin();
74 ATH_MSG_INFO(
"Bunch crossing BCID " << ibc <<
" mu multiplier " << *itr);
81 return StatusCode::SUCCESS;
86 const EventContext& ctx = Gaudi::Hive::currentContext();
87 CLHEP::HepRandomEngine* rndmEngine = this->
getRandomEngine(
"ParticleGun", ctx);
97 for (std::vector<float>::const_iterator bcitr=
m_multbcid.begin();
101 const int nevtraw=CLHEP::RandPoisson::shoot(muval);
103 const int nevt=(float)nevtraw*(*bcitr);
105 for (
int ievt=0;ievt<nevt;++ievt) {
106 ATH_MSG_DEBUG(
"Request generation of event " << ievt <<
" of " << nevt
107 <<
" for BCID " << bcid);
110 HepMC::GenEvent* evt=
new HepMC::GenEvent();
111 evt->weights().push_back(1.0);
114 std::vector<SampledParticle> particles =
m_partSampler->shoot();
115 for (
const auto& p : particles){
117 std::cout << ievt <<
" DEBUG0," << p.m_pid <<
", " << p.m_mom.E()<<
", " << p.m_mom.Pt()<<
", " << p.m_mom.M() << std::endl;
118 std::cout << ievt <<
" DEBUG1 (px,py,pz,E) = (" << p.m_mom.Px()<<
", " << p.m_mom.Py()<<
", " << p.m_mom.Pz()<<
", " << p.m_mom.E() <<
")" << std::endl;
119 std::cout << ievt <<
" DEBUG2 (eta,phi,pt,m) = ()" << p.m_mom.Eta()<<
", " << p.m_mom.Phi()<<
", " << p.m_mom.Pt()<<
", " << p.m_mom.M() <<
")" << std::endl;
120 std::cout << ievt <<
" DEBUG3 (x,y,z,t) = ()" << p.m_pos.X()<<
", " << p.m_pos.Y()<<
", " << p.m_pos.Z()<<
", " << p.m_pos.T() <<
")" << std::endl;
123 HepMC::FourVector pos(p.m_pos.X(), p.m_pos.Y(), p.m_pos.Z(), p.m_pos.T());
127 HepMC::FourVector mom(p.m_mom.Px(), p.m_mom.Py(), p.m_mom.Pz(), p.m_mom.E());
130 gp->set_pdg_id(p.m_pid);
131 gp->set_momentum(mom);
133 gp->set_generated_mass(p.m_mass);
134 gv->add_particle_out(std::move(gp));
149 " pileup events in buffer");
150 return StatusCode::SUCCESS;
157 for (
int i=1;i<nbuf;++i) {
158 events()->push_back(
m_evts[i]);
167 return StatusCode::SUCCESS;
179 return StatusCode::SUCCESS;
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
GenModule(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, const EventContext &ctx) const
virtual StatusCode genFinalize()
For finalising the generator, if required.
virtual StatusCode genInitialize()
For initializing the generator, if required.
virtual StatusCode callGenerator()
For calling the generator on each iteration of the event loop.
std::vector< double > m_pileupProfileIntegral
std::vector< HepMC::GenEvent * > m_evts
std::vector< float > m_multbcid
int nPileupEvents(CLHEP::HepRandomEngine *rndmEngine)
ParticleSampler * m_partSampler
~MultiParticleGunPileup()
MultiParticleGunPileup(const std::string &name, ISvcLocator *pSvcLocator)
TH1D * m_htgPileupProfile
virtual StatusCode fillEvt(HepMC::GenEvent *event)
For filling the HepMC event object.
std::vector< int > m_pileupProfile
int signal_process_id(const GenEvent &e)
HepMC::GenVertex * GenVertexPtr
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), int pid=0, int status=0)
void set_signal_process_id(GenEvent *e, const int i)
void fillBarcodesAttribute(GenEvent *)
GenParticle * GenParticlePtr