Skip to content

Commit

Permalink
Fix setting of ScaleWeight indices
Browse files Browse the repository at this point in the history
  • Loading branch information
kdlong committed Sep 20, 2019
1 parent 5668f0d commit 8c0c98e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@ ExternalLHEProducer::beginRunProduce(edm::Run& run, edm::EventSetup const& es)
reader.parseWeightGroupsFromHeader(runInfo->findHeader("initrwgt"));

for (auto& weightGroup : reader.getWeightGroups()) {
if (weightGroup.weightType() == 1) {
gen::ScaleWeightGroupInfo* group = static_cast<gen::ScaleWeightGroupInfo*>(weightGroup.clone());
std::cout << "MuR1MuF2Index is " << group->muR1muF2Index();
}

weightInfoProduct_->addWeightGroupInfo(weightGroup.clone());
}

Expand Down
9 changes: 4 additions & 5 deletions GeneratorInterface/LHEInterface/test/testWeights.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
for j, weights in enumerate(weightInfo.weights()):
print "-"*10, "Looking at entry", j, "length is", len(weights),"-"*10
matching = weightInfoProd.orderedWeightGroupInfo(j)
print matching
print "Group is", matching
if matching.weightType() == 1:
print " muR1muF05Index", matching.muR1muF05Index()
print " muR1muF1Index", matching.centralIndex()
print " muR2muF2Index", matching.muR2muF2Index()
print " muR05muF05Index", matching.muR05muF05Index()
for var in [(x, y) for x in ["05", "1", "2"] for y in ["05", "1", "2"]]:
name = "muR%smuF%sIndex" % (var[0], var[1]) if not (var[0] == "1" and var[1] == "1") else "centralIndex"
print name, getattr(matching, name)()
else:
print "uncertaintyType", "Hessian" if matching.uncertaintyType() == ROOT.gen.kHessianUnc else "MC"
print "Weights length?", len(weights), "Contained ids lenths?", len(matching.containedIds())
Expand Down
56 changes: 28 additions & 28 deletions SimDataFormats/GeneratorProducts/interface/ScaleWeightGroupInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ namespace gen {
class ScaleWeightGroupInfo : public WeightGroupInfo {
private:
bool isFunctionalFormVar_;
size_t icentral_;
size_t imuR1muF2_;
size_t imuR1muF05_;
size_t imuR2muF05_;
size_t imuR2muF1_;
size_t imuR2muF2_;
size_t imuR05muF05_;
size_t imuR05muF1_;
size_t imuR05muF2_;
size_t centralIndex_;
size_t muR1muF2Index_;
size_t muR1muF05Index_;
size_t muR2muF05Index_;
size_t muR2muF1Index_;
size_t muR2muF2Index_;
size_t muR05muF05Index_;
size_t muR05muF1Index_;
size_t muR05muF2Index_;
public:
ScaleWeightGroupInfo() : ScaleWeightGroupInfo("") {}
ScaleWeightGroupInfo(std::string header, std::string name) :
WeightGroupInfo(header, name) {
weightType_ = kScaleWeights;
isFunctionalFormVar_ = false;
icentral_ = 0;
imuR1muF2_ = 0;
imuR1muF05_ = 0;
imuR2muF05_ = 0;
imuR2muF1_ = 0;
imuR2muF2_ = 0;
imuR2muF05_ = 0;
imuR05muF05_ = 0;
imuR05muF1_ = 0;
imuR05muF2_ = 0;
centralIndex_ = 0;
muR1muF2Index_ = 0;
muR1muF05Index_ = 0;
muR2muF05Index_ = 0;
muR2muF1Index_ = 0;
muR2muF2Index_ = 0;
muR2muF05Index_ = 0;
muR05muF05Index_ = 0;
muR05muF1Index_ = 0;
muR05muF2Index_ = 0;
}
ScaleWeightGroupInfo(std::string header) :
ScaleWeightGroupInfo(header, header) { }
Expand All @@ -48,15 +48,15 @@ namespace gen {
// Is a variation of the functional form of the dynamic scale
bool isFunctionalFormVariation();
void setIsFunctionalFormVariation(bool functionalVar) {isFunctionalFormVar_ = functionalVar; }
size_t centralIndex() const {return icentral_; }
size_t muR1muF2Index() const { return imuR1muF2_; }
size_t muR1muF05Index() const { return imuR1muF05_; }
size_t muR2muF05Index() const { return imuR2muF05_; }
size_t muR2muF1Index() const { return imuR2muF1_; }
size_t muR2muF2Index() const { return imuR2muF2_; }
size_t muR05muF05Index() const { return imuR05muF05_; }
size_t muR05muF1Index() const { return imuR05muF1_; }
size_t muR05muF2Index() const { return imuR05muF2_; }
size_t centralIndex() const {return centralIndex_; }
size_t muR1muF2Index() const { return muR1muF2Index_; }
size_t muR1muF05Index() const { return muR1muF05Index_; }
size_t muR2muF05Index() const { return muR2muF05Index_; }
size_t muR2muF1Index() const { return muR2muF1Index_; }
size_t muR2muF2Index() const { return muR2muF2Index_; }
size_t muR05muF05Index() const { return muR05muF05Index_; }
size_t muR05muF1Index() const { return muR05muF1Index_; }
size_t muR05muF2Index() const { return muR05muF2Index_; }
};
}

Expand Down
36 changes: 18 additions & 18 deletions SimDataFormats/GeneratorProducts/src/ScaleWeightGroupInfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace gen {
void ScaleWeightGroupInfo::copy(const ScaleWeightGroupInfo &other) {
icentral_ = centralIndex();
imuR1muF2_ = muR1muF2Index();
imuR1muF05_ = muR1muF05Index();
imuR2muF05_ = muR2muF05Index();
imuR2muF1_ = muR2muF1Index();
imuR2muF2_ = muR2muF2Index();
imuR2muF05_ = muR2muF05Index();
imuR05muF1_ = muR05muF1Index();
imuR05muF2_ = muR05muF2Index();
centralIndex_ = other.centralIndex_;
muR1muF2Index_ = other.muR1muF2Index_;
muR1muF05Index_ = other.muR1muF05Index_;
muR2muF05Index_ = other.muR2muF05Index_;
muR2muF1Index_ = other.muR2muF1Index_;
muR2muF2Index_ = other.muR2muF2Index_;
muR2muF05Index_ = other.muR2muF05Index_;
muR05muF1Index_ = other.muR05muF1Index_;
muR05muF2Index_ = other.muR05muF2Index_;
WeightGroupInfo::copy(other);
}

Expand All @@ -28,23 +28,23 @@ namespace gen {

void ScaleWeightGroupInfo::setMuRMuFIndex(WeightMetaInfo info, float muR, float muF) {
if (muR == 0.5 && muF == 0.5)
imuR05muF05_ = info.localIndex;
muR05muF05Index_ = info.localIndex;
else if (muR == 0.5 && muF == 1.0)
imuR05muF1_ = info.localIndex;
muR05muF1Index_ = info.localIndex;
else if (muR == 0.5 && muF == 2.0)
imuR05muF2_ = info.localIndex;
muR05muF2Index_ = info.localIndex;
else if (muR == 1.0 && muF == 0.5)
imuR1muF05_ = info.localIndex;
muR1muF05Index_ = info.localIndex;
else if (muR == 1.0 && muF == 1.0)
icentral_ = info.localIndex;
centralIndex_ = info.localIndex;
else if (muR == 1.0 && muF == 2.0)
imuR1muF2_ = info.localIndex;
muR1muF2Index_ = info.localIndex;
else if (muR == 2.0 && muF == 0.5)
imuR2muF05_ = info.localIndex;
muR2muF05Index_ = info.localIndex;
else if (muR == 2.0 && muF == 1.0)
imuR2muF1_ = info.localIndex;
muR2muF1Index_ = info.localIndex;
else if (muR == 2.0 && muF == 2.0)
imuR2muF2_ = info.localIndex;
muR2muF2Index_ = info.localIndex;
else
throw std::invalid_argument("Invalid muF and muR variation is not a factor of two from central value");
}
Expand Down

0 comments on commit 8c0c98e

Please sign in to comment.