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,
26  std::istream &in);
27  LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo,
28  const HEPEUP &hepeup);
29  LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo,
30  const HEPEUP &hepeup,
32  const std::vector<std::string> &comments);
33  LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo,
34  const LHEEventProduct &product);
35  ~LHEEvent();
36 
39 
40  const std::shared_ptr<LHERunInfo> &getRunInfo() const { return runInfo; }
41  const HEPEUP *getHEPEUP() const { return &hepeup; }
42  const HEPRUP *getHEPRUP() const { return runInfo->getHEPRUP(); }
43  const PDF *getPDF() const { return pdf.get(); }
44  const std::vector<std::string> &getComments() const { return comments; }
45  const int getReadAttempts() { return readAttemptCounter; }
46 
47  void addWeight(const WGT& wgt) { weights_.push_back(wgt); }
48  void setPDF(std::unique_ptr<PDF> pdf) { this->pdf = std::move(pdf); }
49 
50  double originalXWGTUP() const { return originalXWGTUP_; }
51  const std::vector<WGT>& weights() const { return weights_; }
52 
53  const std::vector<float> &scales() const { return scales_; }
54  void setScales(const std::vector<float> &scales) { scales_ = scales; }
55 
56  int npLO() const { return npLO_; }
57  int npNLO() const { return npNLO_; }
58  int evtnum() const { return evtnum_; }
59 
60  void setNpLO(int n) { npLO_ = n; }
61  void setNpNLO(int n) { npNLO_ = n; }
62  void setEvtNum(int n) { evtnum_ = n; }
63 
64  void addComment(const std::string &line) { comments.push_back(line); }
65 
66  static void removeParticle(lhef::HEPEUP &hepeup, int index);
67  void removeResonances(const std::vector<int> &ids);
68 
70  double weight = 1.0, double matchWeight = 1.0);
71 
72  void attempted() { readAttemptCounter++; return; }
73 
74  void fillPdfInfo(HepMC::PdfInfo *info) const;
75  void fillEventInfo(HepMC::GenEvent *hepmc) const;
76 
77  std::unique_ptr<HepMC::GenEvent> asHepMCEvent() const;
78 
79  static const HepMC::GenVertex *findSignalVertex(
80  const HepMC::GenEvent *event, bool status3 = true);
81 
82  static void fixHepMCEventTimeOrdering(HepMC::GenEvent *event);
83 
84  private:
85  static bool checkHepMCTree(const HepMC::GenEvent *event);
86  HepMC::GenParticle *makeHepMCParticle(unsigned int i) const;
87 
88  const std::shared_ptr<LHERunInfo> runInfo;
89 
91  std::unique_ptr<PDF> pdf;
92  std::vector<WGT> weights_;
93  std::vector<std::string> comments;
94  bool counted;
97  std::vector<float> scales_; //scale value used to exclude EWK-produced partons from matching
98  int npLO_; //number of partons for LO process (used to steer matching/merging)
99  int npNLO_; //number of partons for NLO process (used to steer matching/merging)
100  int evtnum_; //The number of the event (needed to ensure the correct LHE events are saved for MG +Herwig)
101 };
102 
103 } // namespace lhef
104 
105 #endif // GeneratorEvent_LHEInterface_LHEEvent_h
const PDF * getPDF() const
Definition: LHEEvent.h:43
HEPEUP hepeup
Definition: LHEEvent.h:90
static const TGPicture * info(bool iBackgroundIsBlack)
LHEEvent(const std::shared_ptr< LHERunInfo > &runInfo, std::istream &in)
Definition: LHEEvent.cc:36
int npLO() const
Definition: LHEEvent.h:56
void addWeight(const WGT &wgt)
Definition: LHEEvent.h:47
LHEEventProduct::WGT WGT
Definition: LHEEvent.h:38
std::vector< std::string > comments
Definition: LHEEvent.h:93
const HEPRUP * getHEPRUP() const
Definition: LHEEvent.h:42
void fillEventInfo(HepMC::GenEvent *hepmc) const
Definition: LHEEvent.cc:242
const std::shared_ptr< LHERunInfo > runInfo
Definition: LHEEvent.h:88
static void fixHepMCEventTimeOrdering(HepMC::GenEvent *event)
Definition: LHEEvent.cc:506
void removeResonances(const std::vector< int > &ids)
Definition: LHEEvent.cc:189
Definition: weight.py:1
void count(LHERunInfo::CountMode count, double weight=1.0, double matchWeight=1.0)
Definition: LHEEvent.cc:200
const int getReadAttempts()
Definition: LHEEvent.h:45
const HEPEUP * getHEPEUP() const
Definition: LHEEvent.h:41
int npNLO() const
Definition: LHEEvent.h:57
void attempted()
Definition: LHEEvent.h:72
int readAttemptCounter
Definition: LHEEvent.h:95
void addComment(const std::string &line)
Definition: LHEEvent.h:64
const std::vector< std::string > & getComments() const
Definition: LHEEvent.h:44
void setScales(const std::vector< float > &scales)
Definition: LHEEvent.h:54
HepMC::GenParticle * makeHepMCParticle(unsigned int i) const
Definition: LHEEvent.cc:380
static void removeParticle(lhef::HEPEUP &hepeup, int index)
Definition: LHEEvent.cc:149
void fillPdfInfo(HepMC::PdfInfo *info) const
Definition: LHEEvent.cc:214
std::unique_ptr< HepMC::GenEvent > asHepMCEvent() const
Definition: LHEEvent.cc:250
void setNpNLO(int n)
Definition: LHEEvent.h:61
LHEEventProduct::PDF PDF
Definition: LHEEvent.h:37
void setEvtNum(int n)
Definition: LHEEvent.h:62
const std::vector< float > & scales() const
Definition: LHEEvent.h:53
static const HepMC::GenVertex * findSignalVertex(const HepMC::GenEvent *event, bool status3=true)
Definition: LHEEvent.cc:441
double originalXWGTUP() const
Definition: LHEEvent.h:50
int evtnum() const
Definition: LHEEvent.h:58
std::vector< float > scales_
Definition: LHEEvent.h:97
std::unique_ptr< PDF > pdf
Definition: LHEEvent.h:91
void setPDF(std::unique_ptr< PDF > pdf)
Definition: LHEEvent.h:48
bool counted
Definition: LHEEvent.h:94
void setNpLO(int n)
Definition: LHEEvent.h:60
static bool checkHepMCTree(const HepMC::GenEvent *event)
Definition: LHEEvent.cc:397
const std::shared_ptr< LHERunInfo > & getRunInfo() const
Definition: LHEEvent.h:40
def move(src, dest)
Definition: eostools.py:511
const std::vector< WGT > & weights() const
Definition: LHEEvent.h:51
std::vector< WGT > weights_
Definition: LHEEvent.h:92
Definition: event.py:1
double originalXWGTUP_
Definition: LHEEvent.h:96