File indexing completed on 2021-06-11 04:40:39
0001 #ifndef SimDataFormats_GeneratorProducts_LHEEventProduct_h
0002 #define SimDataFormats_GeneratorProducts_LHEEventProduct_h
0003
0004 #include <memory>
0005 #include <vector>
0006 #include <string>
0007
0008 #include "SimDataFormats/GeneratorProducts/interface/LesHouches.h"
0009 #include "SimDataFormats/GeneratorProducts/interface/PdfInfo.h"
0010 #include "SimDataFormats/GeneratorProducts/interface/WeightsInfo.h"
0011
0012 class LHEEventProduct {
0013 public:
0014 typedef gen::PdfInfo PDF;
0015 typedef gen::WeightsInfo WGT;
0016
0017 typedef std::vector<std::string>::const_iterator comments_const_iterator;
0018 typedef std::vector<std::string>::size_type size_type;
0019
0020 LHEEventProduct() {}
0021 LHEEventProduct(const lhef::HEPEUP &hepeup) : hepeup_(hepeup), originalXWGTUP_(0) {}
0022 LHEEventProduct(const lhef::HEPEUP &hepeup, const double originalXWGTUP)
0023 : hepeup_(hepeup), originalXWGTUP_(originalXWGTUP) {}
0024 LHEEventProduct(LHEEventProduct &&other) = default;
0025
0026 LHEEventProduct &operator=(LHEEventProduct &&other) = default;
0027
0028 ~LHEEventProduct() = default;
0029
0030 void setPDF(const PDF &pdf) { pdf_ = std::make_unique<PDF>(pdf); }
0031 void addWeight(const WGT &wgt) { weights_.push_back(wgt); }
0032 void addComment(const std::string &line) { comments_.push_back(line); }
0033
0034 double originalXWGTUP() const { return originalXWGTUP_; }
0035 const std::vector<WGT> &weights() const { return weights_; }
0036
0037 const std::vector<float> &scales() const { return scales_; }
0038 void setScales(const std::vector<float> &scales) { scales_ = scales; }
0039
0040 int npLO() const { return npLO_; }
0041 int npNLO() const { return npNLO_; }
0042
0043 void setNpLO(int n) { npLO_ = n; }
0044 void setNpNLO(int n) { npNLO_ = n; }
0045
0046 const lhef::HEPEUP &hepeup() const { return hepeup_; }
0047 const PDF *pdf() const { return pdf_.get(); }
0048
0049 size_type comments_size() const { return comments_.size(); }
0050 comments_const_iterator comments_begin() const { return comments_.begin(); }
0051 comments_const_iterator comments_end() const { return comments_.end(); }
0052
0053 const char *getComment(unsigned i) const {
0054 if (comments_.empty() || i >= comments_.size())
0055 return "";
0056 else
0057 return (const char *)comments_[i].c_str();
0058 }
0059
0060 class const_iterator {
0061 public:
0062 typedef std::forward_iterator_tag iterator_category;
0063 typedef std::string value_type;
0064 typedef std::ptrdiff_t difference_type;
0065 typedef std::string *pointer;
0066 typedef std::string &reference;
0067
0068 const_iterator() : line(npos) {}
0069 ~const_iterator() {}
0070
0071 inline bool operator==(const const_iterator &other) const { return line == other.line; }
0072 inline bool operator!=(const const_iterator &other) const { return !operator==(other); }
0073
0074 inline const_iterator &operator++() {
0075 next();
0076 return *this;
0077 }
0078 inline const_iterator operator++(int dummy) {
0079 const_iterator orig = *this;
0080 next();
0081 return orig;
0082 }
0083
0084 const std::string &operator*() const { return tmp; }
0085 const std::string *operator->() const { return &tmp; }
0086
0087 private:
0088 friend class LHEEventProduct;
0089
0090 void next();
0091
0092 const LHEEventProduct *event;
0093 unsigned int line;
0094 std::string tmp;
0095
0096 static const unsigned int npos = 99999;
0097 };
0098
0099 const_iterator begin() const;
0100 inline const_iterator end() const { return const_iterator(); }
0101
0102 private:
0103 lhef::HEPEUP hepeup_;
0104 std::vector<std::string> comments_;
0105 std::unique_ptr<PDF> pdf_;
0106 std::vector<WGT> weights_;
0107 double originalXWGTUP_;
0108 std::vector<float> scales_;
0109 int npLO_;
0110 int npNLO_;
0111 };
0112
0113 #endif