Skip to content

Commit

Permalink
Adding first outlines of weight products
Browse files Browse the repository at this point in the history
  • Loading branch information
kdlong committed May 28, 2019
1 parent b45186e commit 208a4a3
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 0 deletions.
47 changes: 47 additions & 0 deletions SimDataFormats/GeneratorProducts/interface/LHEWeightInfoProduct.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef SimDataFormats_GeneratorProducts_LHEWeightInfoProduct_h
#define SimDataFormats_GeneratorProducts_LHEWeightInfoProduct_h

#include <iterator>
#include <memory>
#include <vector>
#include <string>

//#include <hepml.hpp>

#include "SimDataFormats/GeneratorProducts/interface/LesHouches.h"
#include "SimDataFormats/GeneratorProducts/interface/WeightGroupInfo.h"

class LHEWeightInfoProduct {
public:
LHEWeightInfoProduct() {
gen::WeightGroupInfo scaleInfo(
"<weightgroup name=\"Central scale variation\" combine=\"envelope\">"
);
//scaleInfo.isPDF = false;
//scaleInfo.pdfLabel = "";
//scaleInfo.pdfLHAID = "";

gen::WeightGroupInfo cenPdfInfo(
"<weightgroup name=\"NNPDF31_nnlo_hessian_pdfas\" combine=\"hessian\">"
);

//cenPdfInfo.isPDF = true;
//cenPdfInfo.pdfLabel = "NNPDF31_nnlo_hessian_pdfas";
//cenPdfInfo.pdfLHAID = "3061000";

weightGroupsInfo_.push_back(scaleInfo);
weightGroupsInfo_.push_back(cenPdfInfo);
};
std::vector<gen::WeightGroupInfo> getWeightGroupsInfo() { return weightGroupsInfo_; }
void addWeightGroupInfo(gen::WeightGroupInfo info) {
weightGroupsInfo_.push_back(info);
}

private:
std::vector<gen::WeightGroupInfo> weightGroupsInfo_;


};

#endif // GeneratorWeightInfo_LHEInterface_LHEWeightInfoProduct_h

36 changes: 36 additions & 0 deletions SimDataFormats/GeneratorProducts/interface/LHEWeightProduct.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef SimDataFormats_GeneratorProducts_LHEWeightProduct_h
#define SimDataFormats_GeneratorProducts_LHEWeightProduct_h

#include <memory>
#include <vector>
#include <string>

#include "SimDataFormats/GeneratorProducts/interface/LesHouches.h"
#include "SimDataFormats/GeneratorProducts/interface/WeightsInfo.h"

class LHEWeightProduct {
public:
typedef weightsContainer std::vector<std::vector<double>>;

LHEWeightProduct() {}
LHEWeightProduct& operator=(LHEWeightProduct&& other) {
weights_ = std::move(other.weights_);
originalXWGTUP_ = std::move(other.originalXWGTUP_);
return *this;
}
~LHEWeightProduct() {}

void addWeight(double weight, size_t setEntry, size_t weightNum) {
weights_.at(setEntry).insert(weight, weightNum);
}
double originalXWGTUP() const { return originalXWGTUP_; }
const std::vector<WGT>& weights() const { return weights_; }

private:
weightsContainer weights_;
std::map<std::string, double> weightsMap_;
double originalXWGTUP_;
};

#endif // GeneratorEvent_LHEInterface_LHEWeightProduct_h

58 changes: 58 additions & 0 deletions SimDataFormats/GeneratorProducts/interface/WeightGroupInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef SimDataFormats_GeneratorProducts_WeightGroupInfo_h
#define SimDataFormats_GeneratorProducts_WeightGroupInfo_h

/** \class PdfInfo
*
*/
#include <string>

namespace gen {
typedef std::pair<size_t, std::string> weightId;

enum WeightType {
pdfWeights,
scaleWeights,
matrixElementWeights,
unknownWeights,
};

class WeightGroupInfo {
public:
WeightGroupInfo(std::string header):
headerEntry_(header), name_(header), firstId_(0), lastId_(0) {}
int getWeightVectorEntry(const std::string& wgtId, size_t weightEntry) {
int orderedEntry = weightEntry - firstId_;
int entry = -1;
if (orderedEntry >= 0 && static_cast<size_t>(orderedEntry) < idsContained_.size())
if (idsContained_.at(orderedEntry).second == wgtId)
return orderedEntry;
//auto it = std::find(
return entry;
}
void addContainedID(std::string id, size_t weightEntry) {
if (!indexInRange(weightEntry))
throw std::domain_error("This entry is out of the expected range");
size_t orderedEntry = weightEntry - firstId_;
idsContained_.insert(idsContained_.begin()+weightEntry, std::make_pair(orderedEntry, id));
}
void setWeightType(WeightType type) { weightType_ = type; }

void setFirstEntry(size_t entryNum) { firstId_ = entryNum;}
void setLastEntry(size_t entryNum) { lastId_ = entryNum;}

bool indexInRange(size_t index) {
return (index <= lastId_ && index >= firstId_);
}

private:
std::string headerEntry_;
std::string name_;
WeightType weightType_;
std::vector<weightId> idsContained_;
size_t firstId_;
size_t lastId_;
};
}

#endif // SimDataFormats_GeneratorProducts_WeightGroupInfo_h

1 change: 1 addition & 0 deletions SimDataFormats/GeneratorProducts/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/LHERunInfoProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/LHEWeightInfoProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/LHEXMLStringProduct.h"

#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
Expand Down
3 changes: 3 additions & 0 deletions SimDataFormats/GeneratorProducts/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@
<class name="gen::WeightsInfo" ClassVersion="10">
<version ClassVersion="10" checksum="2663143460"/>
</class>
<class name="gen::WeightGroupInfo" ClassVersion="4">
<version ClassVersion="4" checksum="4219107434"/>
</class>
<class name="std::vector<gen::WeightsInfo>"/>
<class name="edm::Wrapper&lt;LHERunInfoProduct&gt;"/>
<class name="edm::Wrapper&lt;LHEEventProduct&gt;"/>
Expand Down

0 comments on commit 208a4a3

Please sign in to comment.