CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
lhef::LHEEvent Class Reference

#include <LHEEvent.h>

Public Types

typedef LHEEventProduct::PDF PDF
 
typedef LHEEventProduct::WGT WGT
 

Public Member Functions

void addComment (const std::string &line)
 
void addWeight (const WGT &wgt)
 
std::unique_ptr< HepMC::GenEventasHepMCEvent () const
 
void attempted ()
 
void count (LHERunInfo::CountMode count, double weight=1.0, double matchWeight=1.0)
 
int evtnum () const
 
void fillEventInfo (HepMC::GenEvent *hepmc) const
 
void fillPdfInfo (HepMC::PdfInfo *info) const
 
const std::vector< std::string > & getComments () const
 
const HEPEUPgetHEPEUP () const
 
const HEPRUPgetHEPRUP () const
 
const PDFgetPDF () const
 
const int getReadAttempts ()
 
const std::shared_ptr< LHERunInfo > & getRunInfo () const
 
 LHEEvent (const std::shared_ptr< LHERunInfo > &runInfo, std::istream &in)
 
 LHEEvent (const std::shared_ptr< LHERunInfo > &runInfo, const HEPEUP &hepeup)
 
 LHEEvent (const std::shared_ptr< LHERunInfo > &runInfo, const HEPEUP &hepeup, const LHEEventProduct::PDF *pdf, const std::vector< std::string > &comments)
 
 LHEEvent (const std::shared_ptr< LHERunInfo > &runInfo, const LHEEventProduct &product)
 
int npLO () const
 
int npNLO () const
 
double originalXWGTUP () const
 
void removeResonances (const std::vector< int > &ids)
 
const std::vector< float > & scales () const
 
void setEvtNum (int n)
 
void setNpLO (int n)
 
void setNpNLO (int n)
 
void setPDF (std::unique_ptr< PDF > pdf)
 
void setScales (const std::vector< float > &scales)
 
const std::vector< WGT > & weights () const
 
 ~LHEEvent ()
 

Static Public Member Functions

static const HepMC::GenVertex * findSignalVertex (const HepMC::GenEvent *event, bool status3=true)
 
static void fixHepMCEventTimeOrdering (HepMC::GenEvent *event)
 
static void removeParticle (lhef::HEPEUP &hepeup, int index)
 

Private Member Functions

HepMC::GenParticle * makeHepMCParticle (unsigned int i) const
 

Static Private Member Functions

static bool checkHepMCTree (const HepMC::GenEvent *event)
 

Private Attributes

std::vector< std::string > comments
 
bool counted
 
int evtnum_
 
HEPEUP hepeup
 
int npLO_
 
int npNLO_
 
double originalXWGTUP_
 
std::unique_ptr< PDFpdf
 
int readAttemptCounter
 
const std::shared_ptr< LHERunInforunInfo
 
std::vector< float > scales_
 
std::vector< WGTweights_
 

Detailed Description

Definition at line 23 of file LHEEvent.h.

Member Typedef Documentation

◆ PDF

Definition at line 34 of file LHEEvent.h.

◆ WGT

Definition at line 35 of file LHEEvent.h.

Constructor & Destructor Documentation

◆ LHEEvent() [1/4]

lhef::LHEEvent::LHEEvent ( const std::shared_ptr< LHERunInfo > &  runInfo,
std::istream &  in 
)

Definition at line 37 of file LHEEvent.cc.

References funct::abs(), lhef::HEPEUP::AQCDUP, lhef::HEPEUP::AQEDUP, comments, hepeup, mps_fire::i, lhef::HEPEUP::ICOLUP, lhef::HEPEUP::IDPRUP, lhef::HEPEUP::IDUP, recoMuon::in, lhef::HEPEUP::ISTUP, mps_splice::line, lhef::HEPEUP::MOTHUP, lhef::HEPEUP::NUP, originalXWGTUP_, pdf, lhef::HEPEUP::PUP, lhef::HEPEUP::resize(), runInfo, lhef::HEPEUP::SCALUP, skipWhitespace(), lhef::HEPEUP::SPINUP, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, lhef::HEPEUP::VTIMUP, lhef::HEPEUP::XPDWUP, and lhef::HEPEUP::XWGTUP.

38  : runInfo(runInfo),
39  weights_(0),
40  counted(false),
42  npLO_(-99),
43  npNLO_(-99),
44  evtnum_(-1)
45 
46  {
47  hepeup.NUP = 0;
48  hepeup.XPDWUP.first = hepeup.XPDWUP.second = 0.0;
49 
51  if (!in.good())
52  throw cms::Exception("InvalidFormat") << "Les Houches file contained invalid"
53  " event header."
54  << std::endl;
55 
56  // store the original value of XWGTUP for the user
58 
59  int idwtup = runInfo->getHEPRUP()->IDWTUP;
60  if (idwtup >= 0 && hepeup.XWGTUP < 0) {
61  edm::LogWarning("Generator|LHEInterface") << "Non-allowed negative event weight encountered." << std::endl;
63  }
64 
65  if (std::abs(idwtup) == 3 && std::abs(hepeup.XWGTUP) != 1.) {
66  edm::LogInfo("Generator|LHEInterface") << "Event weight not set to one for abs(IDWTUP) == 3" << std::endl;
67  hepeup.XWGTUP = hepeup.XWGTUP > 0. ? 1.0 : -1.0;
68  }
69 
70  hepeup.resize();
71 
72  for (int i = 0; i < hepeup.NUP; i++) {
73  in >> hepeup.IDUP[i] >> hepeup.ISTUP[i] >> hepeup.MOTHUP[i].first >> hepeup.MOTHUP[i].second >>
74  hepeup.ICOLUP[i].first >> hepeup.ICOLUP[i].second >> hepeup.PUP[i][0] >> hepeup.PUP[i][1] >>
75  hepeup.PUP[i][2] >> hepeup.PUP[i][3] >> hepeup.PUP[i][4] >> hepeup.VTIMUP[i] >> hepeup.SPINUP[i];
76  if (!in.good())
77  throw cms::Exception("InvalidFormat") << "Les Houches file contained invalid event"
78  " in particle line "
79  << (i + 1) << "." << std::endl;
80  }
81 
82  while (skipWhitespace(in) == '#') {
84  std::getline(in, line);
85  std::istringstream ss(line);
87  ss >> tag;
88  if (tag == "#pdf") {
89  pdf = std::make_unique<PDF>();
90  ss >> pdf->id.first >> pdf->id.second >> pdf->x.first >> pdf->x.second >> pdf->scalePDF >> pdf->xPDF.first >>
91  pdf->xPDF.second;
92  if (ss.bad()) {
93  edm::LogWarning("Generator|LHEInterface") << "Les Houches event contained"
94  " unparseable PDF information."
95  << std::endl;
96  pdf.reset();
97  } else
98  continue;
99  }
100  comments.push_back(line + "\n");
101  }
102 
103  if (!in.eof())
104  edm::LogWarning("Generator|LHEInterface") << "Les Houches file contained spurious"
105  " content after event data."
106  << std::endl;
107  }
HEPEUP hepeup
Definition: LHEEvent.h:88
std::vector< std::string > comments
Definition: LHEEvent.h:91
std::vector< std::pair< int, int > > ICOLUP
Definition: LesHouches.h:240
const std::shared_ptr< LHERunInfo > runInfo
Definition: LHEEvent.h:86
std::vector< double > VTIMUP
Definition: LesHouches.h:252
std::pair< double, double > XPDWUP
Definition: LesHouches.h:202
int readAttemptCounter
Definition: LHEEvent.h:93
void resize(int nup)
Definition: LesHouches.h:161
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
std::vector< double > SPINUP
Definition: LesHouches.h:259
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< int > ISTUP
Definition: LesHouches.h:228
std::vector< std::pair< int, int > > MOTHUP
Definition: LesHouches.h:234
std::vector< int > IDUP
Definition: LesHouches.h:223
Log< level::Info, false > LogInfo
double AQCDUP
Definition: LesHouches.h:218
std::unique_ptr< PDF > pdf
Definition: LHEEvent.h:89
bool counted
Definition: LHEEvent.h:92
double AQEDUP
Definition: LesHouches.h:213
Log< level::Warning, false > LogWarning
static int skipWhitespace(std::istream &in)
Definition: LHEEvent.cc:25
double XWGTUP
Definition: LesHouches.h:194
std::vector< WGT > weights_
Definition: LHEEvent.h:90
double originalXWGTUP_
Definition: LHEEvent.h:94
double SCALUP
Definition: LesHouches.h:208

◆ LHEEvent() [2/4]

lhef::LHEEvent::LHEEvent ( const std::shared_ptr< LHERunInfo > &  runInfo,
const HEPEUP hepeup 
)

Definition at line 109 of file LHEEvent.cc.

110  : runInfo(runInfo), hepeup(hepeup), counted(false), readAttemptCounter(0), npLO_(-99), npNLO_(-99), evtnum_(-1) {}
HEPEUP hepeup
Definition: LHEEvent.h:88
const std::shared_ptr< LHERunInfo > runInfo
Definition: LHEEvent.h:86
int readAttemptCounter
Definition: LHEEvent.h:93
bool counted
Definition: LHEEvent.h:92

◆ LHEEvent() [3/4]

lhef::LHEEvent::LHEEvent ( const std::shared_ptr< LHERunInfo > &  runInfo,
const HEPEUP hepeup,
const LHEEventProduct::PDF pdf,
const std::vector< std::string > &  comments 
)

Definition at line 112 of file LHEEvent.cc.

116  : runInfo(runInfo),
117  hepeup(hepeup),
118  pdf(pdf ? new PDF(*pdf) : nullptr),
120  counted(false),
122  npLO_(-99),
123  npNLO_(-99),
124  evtnum_(-1) {}
HEPEUP hepeup
Definition: LHEEvent.h:88
std::vector< std::string > comments
Definition: LHEEvent.h:91
const std::shared_ptr< LHERunInfo > runInfo
Definition: LHEEvent.h:86
int readAttemptCounter
Definition: LHEEvent.h:93
LHEEventProduct::PDF PDF
Definition: LHEEvent.h:34
std::unique_ptr< PDF > pdf
Definition: LHEEvent.h:89
bool counted
Definition: LHEEvent.h:92

◆ LHEEvent() [4/4]

lhef::LHEEvent::LHEEvent ( const std::shared_ptr< LHERunInfo > &  runInfo,
const LHEEventProduct product 
)

Definition at line 126 of file LHEEvent.cc.

127  : runInfo(runInfo),
128  hepeup(product.hepeup()),
129  pdf(product.pdf() ? new PDF(*product.pdf()) : nullptr),
130  weights_(product.weights()),
131  comments(product.comments_begin(), product.comments_end()),
132  counted(false),
134  originalXWGTUP_(product.originalXWGTUP()),
135  scales_(product.scales()),
136  npLO_(product.npLO()),
137  npNLO_(product.npNLO()),
138  evtnum_(product.evtnum()) {}
HEPEUP hepeup
Definition: LHEEvent.h:88
double originalXWGTUP() const
std::vector< std::string > comments
Definition: LHEEvent.h:91
int npLO() const
const std::shared_ptr< LHERunInfo > runInfo
Definition: LHEEvent.h:86
const std::vector< float > & scales() const
int readAttemptCounter
Definition: LHEEvent.h:93
int evtnum() const
LHEEventProduct::PDF PDF
Definition: LHEEvent.h:34
const PDF * pdf() const
comments_const_iterator comments_begin() const
std::vector< float > scales_
Definition: LHEEvent.h:95
std::unique_ptr< PDF > pdf
Definition: LHEEvent.h:89
bool counted
Definition: LHEEvent.h:92
int npNLO() const
const std::vector< WGT > & weights() const
std::vector< WGT > weights_
Definition: LHEEvent.h:90
double originalXWGTUP_
Definition: LHEEvent.h:94
comments_const_iterator comments_end() const
const lhef::HEPEUP & hepeup() const

◆ ~LHEEvent()

lhef::LHEEvent::~LHEEvent ( )

Definition at line 140 of file LHEEvent.cc.

140 {}

Member Function Documentation

◆ addComment()

void lhef::LHEEvent::addComment ( const std::string &  line)
inline

Definition at line 61 of file LHEEvent.h.

References comments, and mps_splice::line.

61 { comments.push_back(line); }
std::vector< std::string > comments
Definition: LHEEvent.h:91

◆ addWeight()

void lhef::LHEEvent::addWeight ( const WGT wgt)
inline

Definition at line 44 of file LHEEvent.h.

References weights_.

44 { weights_.push_back(wgt); }
std::vector< WGT > weights_
Definition: LHEEvent.h:90

◆ asHepMCEvent()

std::unique_ptr< HepMC::GenEvent > lhef::LHEEvent::asHepMCEvent ( ) const

Definition at line 230 of file LHEEvent.cc.

References lhef::HEPEUP::AQCDUP, lhef::HEPEUP::AQEDUP, b1, b2, checkHepMCTree(), pdg::cTau(), findSignalVertex(), GenParticle::GenParticle, AJJGenJetFilter_cfi::genParticles, getHEPRUP(), hepeup, mps_fire::i, lhef::HEPEUP::IDPRUP, dqmiolumiharvest::j, makeHepMCParticle(), lhef::HEPEUP::MOTHUP, lhef::HEPEUP::NUP, lhef::HEPEUP::SCALUP, and lhef::HEPEUP::VTIMUP.

230  {
231  std::unique_ptr<HepMC::GenEvent> hepmc(new HepMC::GenEvent);
232 
233  hepmc->set_signal_process_id(hepeup.IDPRUP);
234  hepmc->set_event_scale(hepeup.SCALUP);
235  hepmc->set_alphaQED(hepeup.AQEDUP);
236  hepmc->set_alphaQCD(hepeup.AQCDUP);
237 
238  unsigned int nup = hepeup.NUP; // particles in event
239 
240  // any particles in HEPEUP block?
241  if (!nup) {
242  edm::LogWarning("Generator|LHEInterface") << "Les Houches Event does not contain any partons. "
243  << "Not much to convert.";
244  return hepmc;
245  }
246 
247  // stores (pointers to) converted particles
248  std::vector<HepMC::GenParticle *> genParticles;
249  std::vector<HepMC::GenVertex *> genVertices;
250 
251  // I. convert particles
252  for (unsigned int i = 0; i < nup; i++)
253  genParticles.push_back(makeHepMCParticle(i));
254 
255  // II. loop again to build vertices
256  for (unsigned int i = 0; i < nup; i++) {
257  unsigned int mother1 = hepeup.MOTHUP.at(i).first;
258  unsigned int mother2 = hepeup.MOTHUP.at(i).second;
259  double cTau = hepeup.VTIMUP.at(i); // decay time
260 
261  // current particle has a mother? --- Sorry, parent! We're PC.
262  if (mother1) {
263  mother1--; // FORTRAN notation!
264  if (mother2)
265  mother2--;
266  else
267  mother2 = mother1;
268 
269  HepMC::GenParticle *in_par = genParticles.at(mother1);
270  HepMC::GenVertex *current_vtx = in_par->end_vertex(); // vertex of first mother
271 
272  if (!current_vtx) {
273  current_vtx = new HepMC::GenVertex(HepMC::FourVector(0, 0, 0, cTau));
274 
275  // add vertex to event
276  genVertices.push_back(current_vtx);
277  }
278 
279  for (unsigned int j = mother1; j <= mother2; j++) // set mother-daughter relations
280  if (!genParticles.at(j)->end_vertex())
281  current_vtx->add_particle_in(genParticles.at(j));
282 
283  // connect THIS outgoing particle to current vertex
284  current_vtx->add_particle_out(genParticles.at(i));
285  }
286  }
287 
288  checkHepMCTree(hepmc.get());
289 
290  // III. restore color flow
291  // ok, nobody knows how to do it so far...
292 
293  // IV. fill run information
294  const HEPRUP *heprup = getHEPRUP();
295 
296  // set beam particles
298  HepMC::FourVector(0.0, 0.0, +heprup->EBMUP.first, heprup->EBMUP.first), heprup->IDBMUP.first);
300  HepMC::FourVector(0.0, 0.0, -heprup->EBMUP.second, heprup->EBMUP.second), heprup->IDBMUP.second);
301  b1->set_status(3);
302  b2->set_status(3);
303 
304  HepMC::GenVertex *v1 = new HepMC::GenVertex();
305  HepMC::GenVertex *v2 = new HepMC::GenVertex();
306  v1->add_particle_in(b1);
307  v2->add_particle_in(b2);
308 
309  hepmc->add_vertex(v1);
310  hepmc->add_vertex(v2);
311  hepmc->set_beam_particles(b1, b2);
312 
313  // first two particles have to be the hard partons going into the interaction
314  if (genParticles.size() >= 2) {
315  if (!genParticles.at(0)->production_vertex() && !genParticles.at(1)->production_vertex()) {
316  v1->add_particle_out(genParticles.at(0));
317  v2->add_particle_out(genParticles.at(1));
318  } else
319  edm::LogWarning("Generator|LHEInterface") << "Initial partons do already have a"
320  " production vertex. "
321  << std::endl
322  << "Beam particles not connected.";
323  } else
324  edm::LogWarning("Generator|LHEInterface") << "Can't find any initial partons to be"
325  " connected to the beam particles.";
326 
327  for (std::vector<HepMC::GenVertex *>::const_iterator iter = genVertices.begin(); iter != genVertices.end(); ++iter)
328  hepmc->add_vertex(*iter);
329 
330  // do some more consistency checks
331  for (unsigned int i = 0; i < nup; i++) {
332  if (!genParticles.at(i)->parent_event()) {
333  edm::LogWarning("Generator|LHEInterface") << "Not all LHE particles could be stored"
334  " stored in the HepMC event. "
335  << std::endl
336  << "Check the mother-daughter relations"
337  " in the given LHE input file.";
338  break;
339  }
340  }
341 
342  hepmc->set_signal_process_vertex(const_cast<HepMC::GenVertex *>(findSignalVertex(hepmc.get(), false)));
343 
344  return hepmc;
345  }
HEPEUP hepeup
Definition: LHEEvent.h:88
double cTau(int pdgID, const HepPDT::ParticleDataTable *pdt)
std::vector< double > VTIMUP
Definition: LesHouches.h:252
const HEPRUP * getHEPRUP() const
Definition: LHEEvent.h:39
std::vector< std::pair< int, int > > MOTHUP
Definition: LesHouches.h:234
bias2_t b2[25]
Definition: b2.h:9
double AQCDUP
Definition: LesHouches.h:218
HepMC::GenParticle * makeHepMCParticle(unsigned int i) const
Definition: LHEEvent.cc:347
static const HepMC::GenVertex * findSignalVertex(const HepMC::GenEvent *event, bool status3=true)
Definition: LHEEvent.cc:396
double AQEDUP
Definition: LesHouches.h:213
static bool checkHepMCTree(const HepMC::GenEvent *event)
Definition: LHEEvent.cc:360
Log< level::Warning, false > LogWarning
static constexpr float b1
double SCALUP
Definition: LesHouches.h:208

◆ attempted()

void lhef::LHEEvent::attempted ( )
inline

Definition at line 68 of file LHEEvent.h.

References readAttemptCounter.

68  {
70  return;
71  }
int readAttemptCounter
Definition: LHEEvent.h:93

◆ checkHepMCTree()

bool lhef::LHEEvent::checkHepMCTree ( const HepMC::GenEvent event)
staticprivate

Definition at line 360 of file LHEEvent.cc.

References multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, and mps_update::status.

Referenced by asHepMCEvent().

360  {
361  double px = 0, py = 0, pz = 0, E = 0;
362 
363  for (HepMC::GenEvent::particle_const_iterator iter = event->particles_begin(); iter != event->particles_end();
364  iter++) {
365  int status = (*iter)->status();
366  HepMC::FourVector fv = (*iter)->momentum();
367 
368  // incoming particles
369  if (status == 3 && *iter != event->beam_particles().first && *iter != event->beam_particles().second) {
370  px -= fv.px();
371  py -= fv.py();
372  pz -= fv.pz();
373  E -= fv.e();
374  }
375 
376  // outgoing particles
377  if (status == 1) {
378  px += fv.px();
379  py += fv.py();
380  pz += fv.pz();
381  E += fv.e();
382  }
383  }
384 
385  if (px * px + py * py + pz * pz + E * E > 0.1) {
386  edm::LogWarning("Generator|LHEInterface")
387  << "Energy-momentum badly conserved. " << std::setprecision(3) << "sum p_i = [" << std::setw(7) << E << ", "
388  << std::setw(7) << px << ", " << std::setw(7) << py << ", " << std::setw(7) << pz << "]";
389 
390  return false;
391  }
392 
393  return true;
394  }
Log< level::Warning, false > LogWarning
Definition: event.py:1

◆ count()

void lhef::LHEEvent::count ( LHERunInfo::CountMode  count,
double  weight = 1.0,
double  matchWeight = 1.0 
)

Definition at line 187 of file LHEEvent.cc.

References counted, hepeup, lhef::HEPEUP::IDPRUP, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, runInfo, and lhef::HEPEUP::XWGTUP.

Referenced by gen::Pythia6Hadronizer::hadronize(), Pythia8HepMC3Hadronizer::hadronize(), and Pythia8Hadronizer::hadronize().

187  {
188  if (counted)
189  edm::LogWarning("Generator|LHEInterface") << "LHEEvent::count called twice on same event!" << std::endl;
190 
191  runInfo->count(hepeup.IDPRUP, mode, hepeup.XWGTUP, weight, matchWeight);
192 
193  counted = true;
194  }
HEPEUP hepeup
Definition: LHEEvent.h:88
const std::shared_ptr< LHERunInfo > runInfo
Definition: LHEEvent.h:86
Definition: weight.py:1
bool counted
Definition: LHEEvent.h:92
Log< level::Warning, false > LogWarning
double XWGTUP
Definition: LesHouches.h:194

◆ evtnum()

int lhef::LHEEvent::evtnum ( ) const
inline

Definition at line 55 of file LHEEvent.h.

References evtnum_.

Referenced by Herwig7Hadronizer::hadronize().

55 { return evtnum_; }

◆ fillEventInfo()

void lhef::LHEEvent::fillEventInfo ( HepMC::GenEvent hepmc) const

Definition at line 223 of file LHEEvent.cc.

References lhef::HEPEUP::AQCDUP, lhef::HEPEUP::AQEDUP, hepeup, lhef::HEPEUP::IDPRUP, and lhef::HEPEUP::SCALUP.

Referenced by gen::Pythia6Hadronizer::finalizeEvent().

223  {
224  event->set_signal_process_id(hepeup.IDPRUP);
225  event->set_event_scale(hepeup.SCALUP);
226  event->set_alphaQED(hepeup.AQEDUP);
227  event->set_alphaQCD(hepeup.AQCDUP);
228  }
HEPEUP hepeup
Definition: LHEEvent.h:88
double AQCDUP
Definition: LesHouches.h:218
double AQEDUP
Definition: LesHouches.h:213
double SCALUP
Definition: LesHouches.h:208

◆ fillPdfInfo()

void lhef::LHEEvent::fillPdfInfo ( HepMC::PdfInfo *  info) const

Definition at line 196 of file LHEEvent.cc.

References funct::abs(), lhef::HEPRUP::EBMUP, getHEPRUP(), hepeup, lhef::HEPEUP::IDUP, info(), lhef::HEPEUP::NUP, pdf, lhef::HEPEUP::PUP, and lhef::HEPEUP::SCALUP.

Referenced by gen::Pythia6Hadronizer::finalizeEvent().

196  {
197  if (pdf.get()) {
198  info->set_id1(pdf->id.first);
199  info->set_id2(pdf->id.second);
200  info->set_x1(pdf->x.first);
201  info->set_x2(pdf->x.second);
202  info->set_pdf1(pdf->xPDF.first);
203  info->set_pdf2(pdf->xPDF.second);
204  info->set_scalePDF(pdf->scalePDF);
205  } else if (hepeup.NUP >= 2) {
206  const HEPRUP *heprup = getHEPRUP();
207  info->set_id1(hepeup.IDUP[0] == 21 ? 0 : hepeup.IDUP[0]);
208  info->set_id2(hepeup.IDUP[1] == 21 ? 0 : hepeup.IDUP[1]);
209  info->set_x1(std::abs(hepeup.PUP[0][2] / heprup->EBMUP.first));
210  info->set_x2(std::abs(hepeup.PUP[1][2] / heprup->EBMUP.second));
211  info->set_pdf1(-1.0);
212  info->set_pdf2(-1.0);
213  info->set_scalePDF(hepeup.SCALUP);
214  } else {
215  info->set_x1(-1.0);
216  info->set_x2(-1.0);
217  info->set_pdf1(-1.0);
218  info->set_pdf2(-1.0);
219  info->set_scalePDF(hepeup.SCALUP);
220  }
221  }
HEPEUP hepeup
Definition: LHEEvent.h:88
static const TGPicture * info(bool iBackgroundIsBlack)
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const HEPRUP * getHEPRUP() const
Definition: LHEEvent.h:39
std::vector< int > IDUP
Definition: LesHouches.h:223
std::unique_ptr< PDF > pdf
Definition: LHEEvent.h:89
double SCALUP
Definition: LesHouches.h:208

◆ findSignalVertex()

const HepMC::GenVertex * lhef::LHEEvent::findSignalVertex ( const HepMC::GenEvent event,
bool  status3 = true 
)
static

Definition at line 396 of file LHEEvent.cc.

References multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, and bphysicsOniaDQM_cfi::vertex.

Referenced by asHepMCEvent().

396  {
397  double largestMass2 = -9.0e-30;
398  const HepMC::GenVertex *vertex = nullptr;
399  for (HepMC::GenEvent::vertex_const_iterator iter = event->vertices_begin(); iter != event->vertices_end(); ++iter) {
400  if ((*iter)->particles_in_size() < 2)
401  continue;
402  if ((*iter)->particles_out_size() < 1 ||
403  ((*iter)->particles_out_size() == 1 &&
404  (!(*(*iter)->particles_out_const_begin())->end_vertex() ||
405  !(*(*iter)->particles_out_const_begin())->end_vertex()->particles_out_size())))
406  continue;
407 
408  double px = 0.0, py = 0.0, pz = 0.0, E = 0.0;
409  bool hadStatus3 = false;
410  for (HepMC::GenVertex::particles_out_const_iterator iter2 = (*iter)->particles_out_const_begin();
411  iter2 != (*iter)->particles_out_const_end();
412  ++iter2) {
413  hadStatus3 = hadStatus3 || (*iter2)->status() == 3;
414  px += (*iter2)->momentum().px();
415  py += (*iter2)->momentum().py();
416  pz += (*iter2)->momentum().pz();
417  E += (*iter2)->momentum().e();
418  }
419  if (status3 && !hadStatus3)
420  continue;
421 
422  double mass2 = E * E - (px * px + py * py + pz * pz);
423  if (mass2 > largestMass2) {
424  vertex = *iter;
425  largestMass2 = mass2;
426  }
427  }
428 
429  return vertex;
430  }
Definition: event.py:1

◆ fixHepMCEventTimeOrdering()

void lhef::LHEEvent::fixHepMCEventTimeOrdering ( HepMC::GenEvent event)
static

Definition at line 456 of file LHEEvent.cc.

References lhef::fixSubTree(), and class-composition::visited.

456  {
457  std::set<const HepMC::GenVertex *> visited;
458  HepMC::FourVector zeroTime;
459  for (HepMC::GenEvent::vertex_iterator iter = event->vertices_begin(); iter != event->vertices_end(); ++iter)
460  fixSubTree(*iter, zeroTime, visited);
461  }
static void fixSubTree(HepMC::GenVertex *vertex, HepMC::FourVector &_time, std::set< const HepMC::GenVertex *> &visited)
Definition: LHEEvent.cc:432
VertexRefVector::iterator vertex_iterator
iterator over a vector of references to Vertex objects in the same collection
Definition: VertexFwd.h:19
Definition: event.py:1

◆ getComments()

const std::vector<std::string>& lhef::LHEEvent::getComments ( ) const
inline

Definition at line 41 of file LHEEvent.h.

References comments.

41 { return comments; }
std::vector< std::string > comments
Definition: LHEEvent.h:91

◆ getHEPEUP()

const HEPEUP* lhef::LHEEvent::getHEPEUP ( ) const
inline

◆ getHEPRUP()

const HEPRUP* lhef::LHEEvent::getHEPRUP ( ) const
inline

Definition at line 39 of file LHEEvent.h.

References runInfo.

Referenced by asHepMCEvent(), and fillPdfInfo().

39 { return runInfo->getHEPRUP(); }
const std::shared_ptr< LHERunInfo > runInfo
Definition: LHEEvent.h:86

◆ getPDF()

const PDF* lhef::LHEEvent::getPDF ( ) const
inline

Definition at line 40 of file LHEEvent.h.

References pdf.

40 { return pdf.get(); }
std::unique_ptr< PDF > pdf
Definition: LHEEvent.h:89

◆ getReadAttempts()

const int lhef::LHEEvent::getReadAttempts ( )
inline

Definition at line 42 of file LHEEvent.h.

References readAttemptCounter.

42 { return readAttemptCounter; }
int readAttemptCounter
Definition: LHEEvent.h:93

◆ getRunInfo()

const std::shared_ptr<LHERunInfo>& lhef::LHEEvent::getRunInfo ( ) const
inline

Definition at line 37 of file LHEEvent.h.

References runInfo.

37 { return runInfo; }
const std::shared_ptr< LHERunInfo > runInfo
Definition: LHEEvent.h:86

◆ makeHepMCParticle()

HepMC::GenParticle * lhef::LHEEvent::makeHepMCParticle ( unsigned int  i) const
private

Definition at line 347 of file LHEEvent.cc.

References GenParticle::GenParticle, hepeup, mps_fire::i, lhef::HEPEUP::IDUP, lhef::HEPEUP::ISTUP, lhef::HEPEUP::PUP, and mps_update::status.

Referenced by asHepMCEvent().

347  {
348  HepMC::GenParticle *particle = new HepMC::GenParticle(
349  HepMC::FourVector(hepeup.PUP.at(i)[0], hepeup.PUP.at(i)[1], hepeup.PUP.at(i)[2], hepeup.PUP.at(i)[3]),
350  hepeup.IDUP.at(i));
351 
352  int status = hepeup.ISTUP.at(i);
353 
354  particle->set_generated_mass(hepeup.PUP.at(i)[4]);
355  particle->set_status(status > 0 ? (status == 2 ? 3 : status) : 3);
356 
357  return particle;
358  }
HEPEUP hepeup
Definition: LHEEvent.h:88
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
std::vector< int > ISTUP
Definition: LesHouches.h:228
std::vector< int > IDUP
Definition: LesHouches.h:223

◆ npLO()

int lhef::LHEEvent::npLO ( ) const
inline

Definition at line 53 of file LHEEvent.h.

References npLO_.

53 { return npLO_; }

◆ npNLO()

int lhef::LHEEvent::npNLO ( ) const
inline

Definition at line 54 of file LHEEvent.h.

References npNLO_.

54 { return npNLO_; }

◆ originalXWGTUP()

double lhef::LHEEvent::originalXWGTUP ( ) const
inline

Definition at line 47 of file LHEEvent.h.

References originalXWGTUP_.

47 { return originalXWGTUP_; }
double originalXWGTUP_
Definition: LHEEvent.h:94

◆ removeParticle()

void lhef::LHEEvent::removeParticle ( lhef::HEPEUP hepeup,
int  index 
)
static

Definition at line 142 of file LHEEvent.cc.

References hepeup, mps_fire::i, lhef::HEPEUP::ICOLUP, lhef::HEPEUP::IDUP, lhef::HEPEUP::ISTUP, lhef::HEPEUP::MOTHUP, lhef::HEPEUP::NUP, lhef::HEPEUP::PUP, lhef::HEPEUP::SPINUP, and lhef::HEPEUP::VTIMUP.

Referenced by removeResonances().

142  {
143  index--;
144  if (index < 0 || index >= hepeup.NUP) {
145  edm::LogError("Generator|LHEInterface")
146  << "removeParticle: Index " << (index + 1) << " out of bounds." << std::endl;
147  return;
148  }
149 
150  std::pair<int, int> mo = hepeup.MOTHUP[index];
151 
152  hepeup.IDUP.erase(hepeup.IDUP.begin() + index);
153  hepeup.ISTUP.erase(hepeup.ISTUP.begin() + index);
154  hepeup.MOTHUP.erase(hepeup.MOTHUP.begin() + index);
155  hepeup.ICOLUP.erase(hepeup.ICOLUP.begin() + index);
156  hepeup.PUP.erase(hepeup.PUP.begin() + index);
157  hepeup.VTIMUP.erase(hepeup.VTIMUP.begin() + index);
158  hepeup.SPINUP.erase(hepeup.SPINUP.begin() + index);
159 
160  hepeup.NUP--;
161 
162  index++;
163  for (int i = 0; i < hepeup.NUP; i++) {
164  if (hepeup.MOTHUP[i].first == index) {
165  if (hepeup.MOTHUP[i].second > 0)
166  edm::LogError("Generator|LHEInterface")
167  << "removeParticle: Particle " << (i + 2) << " has two mothers." << std::endl;
168  hepeup.MOTHUP[i] = mo;
169  }
170 
171  if (hepeup.MOTHUP[i].first > index)
172  hepeup.MOTHUP[i].first--;
173  if (hepeup.MOTHUP[i].second > index)
174  hepeup.MOTHUP[i].second--;
175  }
176  }
HEPEUP hepeup
Definition: LHEEvent.h:88
std::vector< std::pair< int, int > > ICOLUP
Definition: LesHouches.h:240
std::vector< double > VTIMUP
Definition: LesHouches.h:252
Log< level::Error, false > LogError
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
std::vector< double > SPINUP
Definition: LesHouches.h:259
std::vector< int > ISTUP
Definition: LesHouches.h:228
std::vector< std::pair< int, int > > MOTHUP
Definition: LesHouches.h:234
std::vector< int > IDUP
Definition: LesHouches.h:223

◆ removeResonances()

void lhef::LHEEvent::removeResonances ( const std::vector< int > &  ids)

Definition at line 178 of file LHEEvent.cc.

References funct::abs(), spr::find(), hepeup, mps_fire::i, l1ctLayer2EG_cff::id, lhef::HEPEUP::IDUP, lhef::HEPEUP::MOTHUP, lhef::HEPEUP::NUP, and removeParticle().

178  {
179  for (int i = 1; i <= hepeup.NUP; i++) {
180  int id = std::abs(hepeup.IDUP[i - 1]);
181  if (hepeup.MOTHUP[i - 1].first > 0 && hepeup.MOTHUP[i - 1].second > 0 &&
182  std::find(ids.begin(), ids.end(), id) != ids.end())
183  removeParticle(hepeup, i--);
184  }
185  }
HEPEUP hepeup
Definition: LHEEvent.h:88
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
static void removeParticle(lhef::HEPEUP &hepeup, int index)
Definition: LHEEvent.cc:142
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< std::pair< int, int > > MOTHUP
Definition: LesHouches.h:234
std::vector< int > IDUP
Definition: LesHouches.h:223

◆ scales()

const std::vector<float>& lhef::LHEEvent::scales ( ) const
inline

Definition at line 50 of file LHEEvent.h.

References scales_.

Referenced by setScales().

50 { return scales_; }
std::vector< float > scales_
Definition: LHEEvent.h:95

◆ setEvtNum()

void lhef::LHEEvent::setEvtNum ( int  n)
inline

Definition at line 59 of file LHEEvent.h.

References evtnum_, and dqmiodumpmetadata::n.

◆ setNpLO()

void lhef::LHEEvent::setNpLO ( int  n)
inline

Definition at line 57 of file LHEEvent.h.

References dqmiodumpmetadata::n, and npLO_.

◆ setNpNLO()

void lhef::LHEEvent::setNpNLO ( int  n)
inline

Definition at line 58 of file LHEEvent.h.

References dqmiodumpmetadata::n, and npNLO_.

◆ setPDF()

void lhef::LHEEvent::setPDF ( std::unique_ptr< PDF pdf)
inline

Definition at line 45 of file LHEEvent.h.

References eostools::move(), and pdf.

45 { this->pdf = std::move(pdf); }
std::unique_ptr< PDF > pdf
Definition: LHEEvent.h:89
def move(src, dest)
Definition: eostools.py:511

◆ setScales()

void lhef::LHEEvent::setScales ( const std::vector< float > &  scales)
inline

Definition at line 51 of file LHEEvent.h.

References scales(), and scales_.

51 { scales_ = scales; }
const std::vector< float > & scales() const
Definition: LHEEvent.h:50
std::vector< float > scales_
Definition: LHEEvent.h:95

◆ weights()

const std::vector<WGT>& lhef::LHEEvent::weights ( ) const
inline

Definition at line 48 of file LHEEvent.h.

References weights_.

48 { return weights_; }
std::vector< WGT > weights_
Definition: LHEEvent.h:90

Member Data Documentation

◆ comments

std::vector<std::string> lhef::LHEEvent::comments
private

Definition at line 91 of file LHEEvent.h.

Referenced by addComment(), getComments(), and LHEEvent().

◆ counted

bool lhef::LHEEvent::counted
private

Definition at line 92 of file LHEEvent.h.

Referenced by count().

◆ evtnum_

int lhef::LHEEvent::evtnum_
private

Definition at line 98 of file LHEEvent.h.

Referenced by evtnum(), and setEvtNum().

◆ hepeup

HEPEUP lhef::LHEEvent::hepeup
private

◆ npLO_

int lhef::LHEEvent::npLO_
private

Definition at line 96 of file LHEEvent.h.

Referenced by npLO(), and setNpLO().

◆ npNLO_

int lhef::LHEEvent::npNLO_
private

Definition at line 97 of file LHEEvent.h.

Referenced by npNLO(), and setNpNLO().

◆ originalXWGTUP_

double lhef::LHEEvent::originalXWGTUP_
private

Definition at line 94 of file LHEEvent.h.

Referenced by LHEEvent(), and originalXWGTUP().

◆ pdf

std::unique_ptr<PDF> lhef::LHEEvent::pdf
private

Definition at line 89 of file LHEEvent.h.

Referenced by fillPdfInfo(), getPDF(), LHEEvent(), and setPDF().

◆ readAttemptCounter

int lhef::LHEEvent::readAttemptCounter
private

Definition at line 93 of file LHEEvent.h.

Referenced by attempted(), and getReadAttempts().

◆ runInfo

const std::shared_ptr<LHERunInfo> lhef::LHEEvent::runInfo
private

Definition at line 86 of file LHEEvent.h.

Referenced by count(), getHEPRUP(), getRunInfo(), and LHEEvent().

◆ scales_

std::vector<float> lhef::LHEEvent::scales_
private

Definition at line 95 of file LHEEvent.h.

Referenced by scales(), and setScales().

◆ weights_

std::vector<WGT> lhef::LHEEvent::weights_
private

Definition at line 90 of file LHEEvent.h.

Referenced by addWeight(), and weights().