Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:49

0001 #ifndef GeneratorInterface_LHEInterface_LHEEvent_h
0002 #define GeneratorInterface_LHEInterface_LHEEvent_h
0003 
0004 #include <iostream>
0005 #include <utility>
0006 #include <memory>
0007 #include <vector>
0008 #include <string>
0009 
0010 #include "HepMC/GenEvent.h"
0011 #include "HepMC/GenVertex.h"
0012 #include "HepMC/PdfInfo.h"
0013 
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 
0016 #include "SimDataFormats/GeneratorProducts/interface/LesHouches.h"
0017 #include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h"
0018 
0019 #include "GeneratorInterface/LHEInterface/interface/LHERunInfo.h"
0020 
0021 namespace lhef {
0022 
0023   class LHEEvent {
0024   public:
0025     LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo, std::istream &in);
0026     LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo, const HEPEUP &hepeup);
0027     LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo,
0028              const HEPEUP &hepeup,
0029              const LHEEventProduct::PDF *pdf,
0030              const std::vector<std::string> &comments);
0031     LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo, const LHEEventProduct &product);
0032     ~LHEEvent();
0033 
0034     typedef LHEEventProduct::PDF PDF;
0035     typedef LHEEventProduct::WGT WGT;
0036 
0037     const std::shared_ptr<LHERunInfo> &getRunInfo() const { return runInfo; }
0038     const HEPEUP *getHEPEUP() const { return &hepeup; }
0039     const HEPRUP *getHEPRUP() const { return runInfo->getHEPRUP(); }
0040     const PDF *getPDF() const { return pdf.get(); }
0041     const std::vector<std::string> &getComments() const { return comments; }
0042     const int getReadAttempts() { return readAttemptCounter; }
0043 
0044     void addWeight(const WGT &wgt) { weights_.push_back(wgt); }
0045     void setPDF(std::unique_ptr<PDF> pdf) { this->pdf = std::move(pdf); }
0046 
0047     double originalXWGTUP() const { return originalXWGTUP_; }
0048     const std::vector<WGT> &weights() const { return weights_; }
0049 
0050     const std::vector<float> &scales() const { return scales_; }
0051     void setScales(const std::vector<float> &scales) { scales_ = scales; }
0052 
0053     int npLO() const { return npLO_; }
0054     int npNLO() const { return npNLO_; }
0055     int evtnum() const { return evtnum_; }
0056 
0057     void setNpLO(int n) { npLO_ = n; }
0058     void setNpNLO(int n) { npNLO_ = n; }
0059     void setEvtNum(int n) { evtnum_ = n; }
0060 
0061     void addComment(const std::string &line) { comments.push_back(line); }
0062 
0063     static void removeParticle(lhef::HEPEUP &hepeup, int index);
0064     void removeResonances(const std::vector<int> &ids);
0065 
0066     void count(LHERunInfo::CountMode count, double weight = 1.0, double matchWeight = 1.0);
0067 
0068     void attempted() {
0069       readAttemptCounter++;
0070       return;
0071     }
0072 
0073     void fillPdfInfo(HepMC::PdfInfo *info) const;
0074     void fillEventInfo(HepMC::GenEvent *hepmc) const;
0075 
0076     std::unique_ptr<HepMC::GenEvent> asHepMCEvent() const;
0077 
0078     static const HepMC::GenVertex *findSignalVertex(const HepMC::GenEvent *event, bool status3 = true);
0079 
0080     static void fixHepMCEventTimeOrdering(HepMC::GenEvent *event);
0081 
0082   private:
0083     static bool checkHepMCTree(const HepMC::GenEvent *event);
0084     HepMC::GenParticle *makeHepMCParticle(unsigned int i) const;
0085 
0086     const std::shared_ptr<LHERunInfo> runInfo;
0087 
0088     HEPEUP hepeup;
0089     std::unique_ptr<PDF> pdf;
0090     std::vector<WGT> weights_;
0091     std::vector<std::string> comments;
0092     bool counted;
0093     int readAttemptCounter;
0094     double originalXWGTUP_;
0095     std::vector<float> scales_;  //scale value used to exclude EWK-produced partons from matching
0096     int npLO_;                   //number of partons for LO process (used to steer matching/merging)
0097     int npNLO_;                  //number of partons for NLO process (used to steer matching/merging)
0098     int evtnum_;  //The number of the event (needed to ensure the correct LHE events are saved for MG +Herwig)
0099   };
0100 
0101 }  // namespace lhef
0102 
0103 #endif  // GeneratorEvent_LHEInterface_LHEEvent_h