1 #ifndef HI_MixEvtVtxGenerator_H
2 #define HI_MixEvtVtxGenerator_H
41 virtual HepMC::FourVector* getVertex(
edm::Event&);
42 virtual HepMC::FourVector* getRecVertex(
edm::Event&);
61 useRecVertex(pset.exists(
"useRecVertex") ? pset.getParameter<bool>(
"useRecVertex") :
false)
64 produces<edm::HepMCProduct>();
66 if (pset.
exists(
"vtxOffset"))
87 HepMC::GenVertex* genvtx =
nullptr;
95 throw cms::Exception(
"MatchVtx") <<
"Mixing has " <<
mix.size() <<
" sub-events, should have been at least 2"
100 throw cms::Exception(
"MatchVtx") <<
"Input background does not have smeared vertex!" << endl;
107 inev = input->GetEvent();
110 genvtx = inev->signal_process_vertex();
112 HepMC::GenEvent::particle_const_iterator
pt = inev->particles_begin();
113 HepMC::GenEvent::particle_const_iterator ptend = inev->particles_end();
114 while (!genvtx || (genvtx->particles_in_size() == 1 && pt != ptend)) {
116 cout <<
"End reached, No Gen Vertex!" << endl;
117 genvtx = (*pt)->production_vertex();
121 double aX, aY, aZ, aT;
123 aX = genvtx->position().x();
124 aY = genvtx->position().y();
125 aZ = genvtx->position().z();
126 aT = genvtx->position().t();
129 fVertex =
new HepMC::FourVector();
131 LogInfo(
"MatchVtx") <<
" setting vertex "
132 <<
" aX " << aX <<
" aY " << aY <<
" aZ " << aZ <<
" aT " << aT << endl;
144 aX = input->begin()->position().x() +
vtxOffset[0];
145 aY = input->begin()->position().y() +
vtxOffset[1];
146 aZ = input->begin()->position().z() +
vtxOffset[2];
149 fVertex =
new HepMC::FourVector();
150 fVertex->set(10.0 * aX, 10.0 * aY, 10.0 * aZ, 0.0);
162 if (HepUnsmearedMCEvt->isVtxGenApplied())
164 <<
"Signal HepMCProduct is not compatible for embedding - it's vertex is already smeared." << std::endl;
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
virtual HepMC::FourVector * getRecVertex(edm::Event &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< double > vtxOffset
#define DEFINE_FWK_MODULE(type)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
MixEvtVtxGenerator(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
virtual HepMC::FourVector * getVertex(edm::Event &)
static std::string const input
edm::EDGetTokenT< CrossingFrame< HepMCProduct > > cfLabel
Log< level::Info, false > LogInfo
edm::EDGetTokenT< reco::VertexCollection > hiLabel
edm::EDGetTokenT< HepMCProduct > signalLabel
const HepMC::GenEvent * GetEvent() const
T const * product() const
HepMC::FourVector * fVertex
bool isVtxGenApplied() const
T getParameter(std::string const &) const
~MixEvtVtxGenerator() override