Skip to content

Commit

Permalink
Separate out PDF weights
Browse files Browse the repository at this point in the history
  • Loading branch information
kdlong committed Aug 7, 2019
1 parent 338a979 commit 8397fca
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 6 deletions.
3 changes: 2 additions & 1 deletion GeneratorInterface/LHEInterface/interface/TestWeightInfo.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "SimDataFormats/GeneratorProducts/interface/WeightGroupInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/PdfWeightGroupInfo.h"
#include <regex>

std::string parseId(std::string label) {
Expand Down Expand Up @@ -993,7 +994,7 @@ edm::OwnVector<gen::WeightGroupInfo> getExamplePdfWeights() {
int counter = 8;
for (const auto& entry : entries) {
if (entry.find("<weightgroup") != std::string::npos) {
pdfWeights.push_back(new gen::WeightGroupInfo(entry));
pdfWeights.push_back(new gen::PdfWeightGroupInfo(entry));
}
else if (entry.find("</weightgroup") == std::string::npos) {
auto& currentSet = pdfWeights.back();
Expand Down
44 changes: 44 additions & 0 deletions SimDataFormats/GeneratorProducts/interface/PdfWeightGroupInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#ifndef SimDataFormats_GeneratorProducts_PdfWeightGroupInfo_h
#define SimDataFormats_GeneratorProducts_PdfWeightGroupInfo_h

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

namespace gen {
enum PdfUncertaintyType {
kHessianUnc,
kMonteCarloUnc,
kUnknownUnc,
};

class PdfWeightGroupInfo : public WeightGroupInfo {
private:
PdfUncertaintyType uncertaintyType_;
bool hasAlphasVars_;
int alphasUpIndex_;
int alphasDownIndex_;
public:
PdfWeightGroupInfo() : WeightGroupInfo() { weightType_ = kPdfWeights; }
PdfWeightGroupInfo(std::string header, std::string name) :
WeightGroupInfo(header, name) { weightType_ = kPdfWeights; }
PdfWeightGroupInfo(std::string header) :
WeightGroupInfo(header) { weightType_ = kPdfWeights; }
PdfWeightGroupInfo(const PdfWeightGroupInfo &other) {
copy(other);
}
virtual ~PdfWeightGroupInfo() override {};
void copy(const PdfWeightGroupInfo &other);
PdfWeightGroupInfo* clone() const;

void setUncertaintyType(PdfUncertaintyType uncertaintyType) { uncertaintyType_ = uncertaintyType; }
void setHasAlphasVariations(bool hasAlphasVars) { hasAlphasVars_ = hasAlphasVars; }
void setAlphasUpIndex(int alphasUpIndex) { alphasUpIndex_ = alphasUpIndex; }
void setAlphasDownIndex(int alphasDownIndex) { alphasDownIndex_ = alphasDownIndex; }
PdfUncertaintyType uncertaintyType() const { return uncertaintyType_; }
bool hasAlphasVariations() const { return hasAlphasVars_; }
int alphasUpIndex() const { return alphasUpIndex_; }
int alphasDownIndex() const { return alphasDownIndex_; }
};
}

#endif // SimDataFormats_GeneratorProducts_PdfWeightGroupInfo_h

4 changes: 2 additions & 2 deletions SimDataFormats/GeneratorProducts/interface/WeightGroupInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ namespace gen {
copy(other);
return *this;
}
virtual ~WeightGroupInfo() {};
void copy(const WeightGroupInfo &other);

WeightGroupInfo* clone() const;
WeightMetaInfo weightMetaInfo(int weightEntry);
WeightMetaInfo weightMetaInfo(std::string wgtId);
Expand All @@ -63,7 +63,7 @@ namespace gen {
int firstId() const { return firstId_; }
int lastId() const { return lastId_; }

private:
protected:
std::string headerEntry_;
std::string name_;
WeightType weightType_;
Expand Down
16 changes: 16 additions & 0 deletions SimDataFormats/GeneratorProducts/src/PdfWeightGroupInfo.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <string>
#include "SimDataFormats/GeneratorProducts/interface/PdfWeightGroupInfo.h"

namespace gen {
void PdfWeightGroupInfo::copy(const PdfWeightGroupInfo &other) {
uncertaintyType_ = other.uncertaintyType();
hasAlphasVars_ = other.hasAlphasVariations();
alphasUpIndex_ = other.alphasDownIndex();
alphasDownIndex_ = other.alphasDownIndex();
WeightGroupInfo::copy(other);
}

PdfWeightGroupInfo* PdfWeightGroupInfo::clone() const {
return new PdfWeightGroupInfo(*this);
}
}
5 changes: 2 additions & 3 deletions SimDataFormats/GeneratorProducts/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,8 @@
<class name="gen::WeightsInfo" ClassVersion="10">
<version ClassVersion="10" checksum="2663143460"/>
</class>
<class name="gen::WeightGroupInfo" ClassVersion="6">
<version ClassVersion="6" checksum="1055618343"/>
</class>
<class name="gen::WeightGroupInfo"/>
<class name="gen::PdfWeightGroupInfo"/>
<class name="gen::WeightMetaInfo"/>
<class name="std::vector<gen::WeightsInfo>"/>
<class name="std::vector<gen::WeightGroupInfo>"/>
Expand Down

0 comments on commit 8397fca

Please sign in to comment.