CMS 3D CMS Logo

LHEEvent.h
Go to the documentation of this file.
1 #ifndef GeneratorInterface_LHEInterface_LHEEvent_h
2 #define GeneratorInterface_LHEInterface_LHEEvent_h
3 
4 #include <iostream>
5 #include <utility>
6 #include <memory>
7 #include <vector>
8 #include <string>
9 
10 #include "HepMC/GenEvent.h"
11 #include "HepMC/GenVertex.h"
12 #include "HepMC/PdfInfo.h"
13 
15 
18 
20 
21 namespace lhef {
22 
23  class LHEEvent {
24  public:
25  LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo, std::istream &in);
26  LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo, const HEPEUP &hepeup);
27  LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo,
28  const HEPEUP &hepeup,
30  const std::vector<std::string> &comments);
31  LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo, const LHEEventProduct &product);
32  ~LHEEvent();
33 
36 
37  const std::shared_ptr<LHERunInfo> &getRunInfo() const { return runInfo; }
38  const HEPEUP *getHEPEUP() const { return &hepeup; }
39  const HEPRUP *getHEPRUP() const { return runInfo->getHEPRUP(); }
40  const PDF *getPDF() const { return pdf.get(); }
41  const std::vector<std::string> &getComments() const { return comments; }
42  const int getReadAttempts() { return readAttemptCounter; }
43 
44  void addWeight(const WGT &wgt) { weights_.push_back(wgt); }
45  void setPDF(std::unique_ptr<PDF> pdf) { this->pdf = std::move(pdf); }
46 
47  double originalXWGTUP() const { return originalXWGTUP_; }
48  const std::vector<WGT> &weights() const { return weights_; }
49 
50  const std::vector<float> &scales() const { return scales_; }
51  void setScales(const std::vector<float> &scales) { scales_ = scales; }
52 
53  int npLO() const { return npLO_; }
54  int npNLO() const { return npNLO_; }
55  int evtnum() const { return evtnum_; }
56 
57  void setNpLO(int n) { npLO_ = n; }
58  void setNpNLO(int n) { npNLO_ = n; }
59  void setEvtNum(int n) { evtnum_ = n; }
60 
61  void addComment(const std::string &line) { comments.push_back(line); }
62 
63  static void removeParticle(lhef::HEPEUP &hepeup, int index);
64  void removeResonances(const std::vector<int> &ids);
65 
66  void count(LHERunInfo::CountMode count, double weight = 1.0, double matchWeight = 1.0);
67 
68  void attempted() {
70  return;
71  }
72 
73  void fillPdfInfo(HepMC::PdfInfo *info) const;
74  void fillEventInfo(HepMC::GenEvent *hepmc) const;
75 
76  std::unique_ptr<HepMC::GenEvent> asHepMCEvent() const;
77 
78  static const HepMC::GenVertex *findSignalVertex(const HepMC::GenEvent *event, bool status3 = true);
79 
81 
82  private:
83  static bool checkHepMCTree(const HepMC::GenEvent *event);
84  HepMC::GenParticle *makeHepMCParticle(unsigned int i) const;
85 
86  const std::shared_ptr<LHERunInfo> runInfo;
87 
89  std::unique_ptr<PDF> pdf;
90  std::vector<WGT> weights_;
91  std::vector<std::string> comments;
92  bool counted;
95  std::vector<float> scales_; //scale value used to exclude EWK-produced partons from matching
96  int npLO_; //number of partons for LO process (used to steer matching/merging)
97  int npNLO_; //number of partons for NLO process (used to steer matching/merging)
98  int evtnum_; //The number of the event (needed to ensure the correct LHE events are saved for MG +Herwig)
99  };
100 
101 } // namespace lhef
102 
103 #endif // GeneratorEvent_LHEInterface_LHEEvent_h
const std::vector< std::string > & getComments() const
Definition: LHEEvent.h:41
HEPEUP hepeup
Definition: LHEEvent.h:88
static const TGPicture * info(bool iBackgroundIsBlack)
const PDF * getPDF() const
Definition: LHEEvent.h:40
LHEEvent(const std::shared_ptr< LHERunInfo > &runInfo, std::istream &in)
Definition: LHEEvent.cc:37
void addWeight(const WGT &wgt)
Definition: LHEEvent.h:44
LHEEventProduct::WGT WGT
Definition: LHEEvent.h:35
std::vector< std::string > comments
Definition: LHEEvent.h:91
const std::vector< float > & scales() const
Definition: LHEEvent.h:50
const std::shared_ptr< LHERunInfo > runInfo
Definition: LHEEvent.h:86
static void fixHepMCEventTimeOrdering(HepMC::GenEvent *event)
Definition: LHEEvent.cc:456
void removeResonances(const std::vector< int > &ids)
Definition: LHEEvent.cc:178
Definition: weight.py:1
void count(LHERunInfo::CountMode count, double weight=1.0, double matchWeight=1.0)
Definition: LHEEvent.cc:187
const int getReadAttempts()
Definition: LHEEvent.h:42
int npNLO() const
Definition: LHEEvent.h:54
std::unique_ptr< HepMC::GenEvent > asHepMCEvent() const
Definition: LHEEvent.cc:230
void attempted()
Definition: LHEEvent.h:68
int readAttemptCounter
Definition: LHEEvent.h:93
void addComment(const std::string &line)
Definition: LHEEvent.h:61
void fillEventInfo(HepMC::GenEvent *hepmc) const
Definition: LHEEvent.cc:223
void setScales(const std::vector< float > &scales)
Definition: LHEEvent.h:51
static void removeParticle(lhef::HEPEUP &hepeup, int index)
Definition: LHEEvent.cc:142
const std::vector< WGT > & weights() const
Definition: LHEEvent.h:48
const std::shared_ptr< LHERunInfo > & getRunInfo() const
Definition: LHEEvent.h:37
const HEPRUP * getHEPRUP() const
Definition: LHEEvent.h:39
void setNpNLO(int n)
Definition: LHEEvent.h:58
int evtnum() const
Definition: LHEEvent.h:55
LHEEventProduct::PDF PDF
Definition: LHEEvent.h:34
void setEvtNum(int n)
Definition: LHEEvent.h:59
void fillPdfInfo(HepMC::PdfInfo *info) const
Definition: LHEEvent.cc:196
const HEPEUP * getHEPEUP() const
Definition: LHEEvent.h:38
HepMC::GenParticle * makeHepMCParticle(unsigned int i) const
Definition: LHEEvent.cc:347
double originalXWGTUP() const
Definition: LHEEvent.h:47
static const HepMC::GenVertex * findSignalVertex(const HepMC::GenEvent *event, bool status3=true)
Definition: LHEEvent.cc:396
std::vector< float > scales_
Definition: LHEEvent.h:95
std::unique_ptr< PDF > pdf
Definition: LHEEvent.h:89
void setPDF(std::unique_ptr< PDF > pdf)
Definition: LHEEvent.h:45
bool counted
Definition: LHEEvent.h:92
void setNpLO(int n)
Definition: LHEEvent.h:57
static bool checkHepMCTree(const HepMC::GenEvent *event)
Definition: LHEEvent.cc:360
int npLO() const
Definition: LHEEvent.h:53
def move(src, dest)
Definition: eostools.py:511
std::vector< WGT > weights_
Definition: LHEEvent.h:90
Definition: event.py:1
double originalXWGTUP_
Definition: LHEEvent.h:94