diff --git a/GeneratorInterface/LHEInterface/plugins/ExternalLHEProducer.cc b/GeneratorInterface/LHEInterface/plugins/ExternalLHEProducer.cc index f9f76cbcfbd41..614ac5e45627e 100644 --- a/GeneratorInterface/LHEInterface/plugins/ExternalLHEProducer.cc +++ b/GeneratorInterface/LHEInterface/plugins/ExternalLHEProducer.cc @@ -49,6 +49,7 @@ Description: [one line class summary] #include "SimDataFormats/GeneratorProducts/interface/LesHouches.h" #include "SimDataFormats/GeneratorProducts/interface/LHERunInfoProduct.h" +#include "SimDataFormats/GeneratorProducts/interface/LHEWeightInfoProduct.h" #include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h" #include "SimDataFormats/GeneratorProducts/interface/LHEXMLStringProduct.h" @@ -158,6 +159,7 @@ ExternalLHEProducer::ExternalLHEProducer(const edm::ParameterSet& iConfig) : produces(); produces(); produces(); + produces(); } @@ -326,6 +328,22 @@ ExternalLHEProducer::beginRunProduce(edm::Run& run, edm::EventSetup const& es) unsigned int skip = 0; reader_ = std::make_unique(infiles, skip); + std::cout << "Adding the Weight product!"; + std::unique_ptr weightInfoProduct(new LHEWeightInfoProduct); + gen::WeightGroupInfo scaleInfo( + "" + ); + scaleInfo.setWeightType(gen::scaleWeights); + + gen::WeightGroupInfo cenPdfInfo( + "" + ); + cenPdfInfo.setWeightType(gen::pdfWeights); + + weightInfoProduct->addWeightGroupInfo(scaleInfo); + weightInfoProduct->addWeightGroupInfo(cenPdfInfo); + run.put(std::move(weightInfoProduct)); + nextEvent(); if (runInfoLast) { runInfo = runInfoLast; @@ -343,12 +361,11 @@ ExternalLHEProducer::beginRunProduce(edm::Run& run, edm::EventSetup const& es) // keep a copy around in case of merging runInfoProducts.push_back(new LHERunInfoProduct(*product)); wasMerged = false; - + run.put(std::move(product)); runInfo.reset(); } - } // ------------ method called when ending the processing of a run ------------ @@ -360,7 +377,7 @@ ExternalLHEProducer::endRunProduce(edm::Run& run, edm::EventSetup const& es) std::unique_ptr product(runInfoProducts.pop_front().release()); run.put(std::move(product)); } - + nextEvent(); if (partonLevel) { throw edm::Exception(edm::errors::EventGenerationFailure) << "Error in ExternalLHEProducer::endRunProduce(). " @@ -373,7 +390,6 @@ ExternalLHEProducer::endRunProduce(edm::Run& run, edm::EventSetup const& es) if (unlink(outputFile_.c_str())) { throw cms::Exception("OutputDeleteError") << "Unable to delete original script output file " << outputFile_ << " (errno=" << errno << ", " << strerror(errno) << ")."; } - } // ------------ Close all the open file descriptors ------------ diff --git a/GeneratorInterface/LHEInterface/plugins/LHEProvenanceHelper.cc b/GeneratorInterface/LHEInterface/plugins/LHEProvenanceHelper.cc index 3947edb9af738..e5a3a461b8d84 100644 --- a/GeneratorInterface/LHEInterface/plugins/LHEProvenanceHelper.cc +++ b/GeneratorInterface/LHEInterface/plugins/LHEProvenanceHelper.cc @@ -2,6 +2,7 @@ #include #include "GeneratorInterface/LHEInterface/plugins/LHEProvenanceHelper.h" #include "GeneratorInterface/LHEInterface/interface/LHERunInfo.h" +#include "GeneratorInterface/LHEInterface/interface/LHERunInfo.h" #include "DataFormats/Provenance/interface/ProcessHistory.h" #include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h" @@ -15,7 +16,8 @@ #include "FWCore/Version/interface/GetReleaseVersion.h" namespace edm { - LHEProvenanceHelper::LHEProvenanceHelper(TypeID const& eventProductType, TypeID const& runProductType, ProductRegistry& productRegistry) + LHEProvenanceHelper::LHEProvenanceHelper(TypeID const& eventProductType, TypeID const& runProductType, + TypeID const& weightProductType, ProductRegistry& productRegistry) : eventProductBranchDescription_(BranchDescription( InEvent , "source" @@ -40,12 +42,25 @@ namespace edm { , ParameterSetID() , TypeWithDict(runProductType.typeInfo()) , false)) + , weightProductBranchDescription_(BranchDescription( + InRun + , "source" + , "LHEFile" + // , "LHE" + , "LHEWeightInfoProduct" + , "LHEWeightInfoProduct" + , "" + , "LHESource" + , ParameterSetID() + , TypeWithDict(weightProductType.typeInfo()) + , false)) , eventProductProvenance_(eventProductBranchDescription_.branchID()) , commonProcessParameterSet_(fillCommonProcessParameterSet()) , processParameterSet_() { // Add the products to the product registry productRegistry.copyProduct(eventProductBranchDescription_); + productRegistry.copyProduct(weightProductBranchDescription_); productRegistry.copyProduct(runProductBranchDescription_); } diff --git a/GeneratorInterface/LHEInterface/plugins/LHEProvenanceHelper.h b/GeneratorInterface/LHEInterface/plugins/LHEProvenanceHelper.h index 39fec2179fbb3..1f89820d3473c 100644 --- a/GeneratorInterface/LHEInterface/plugins/LHEProvenanceHelper.h +++ b/GeneratorInterface/LHEInterface/plugins/LHEProvenanceHelper.h @@ -17,12 +17,14 @@ namespace edm { struct LHEProvenanceHelper { explicit LHEProvenanceHelper(TypeID const& eventProductType, TypeID const& runProductType, + TypeID const& weightProductType, ProductRegistry& productRegistry); ParameterSet fillCommonProcessParameterSet(); void lheAugment(lhef::LHERunInfo const* runInfo); ProcessHistoryID lheInit(ProcessHistoryRegistry& processHistoryRegistry); BranchDescription const eventProductBranchDescription_; BranchDescription const runProductBranchDescription_; + BranchDescription const weightProductBranchDescription_; ProductProvenance eventProductProvenance_; ParameterSet const commonProcessParameterSet_; ParameterSet processParameterSet_; diff --git a/GeneratorInterface/LHEInterface/plugins/LHESource.cc b/GeneratorInterface/LHEInterface/plugins/LHESource.cc index a072d5ad54af7..c0598348fd5bf 100644 --- a/GeneratorInterface/LHEInterface/plugins/LHESource.cc +++ b/GeneratorInterface/LHEInterface/plugins/LHESource.cc @@ -23,6 +23,7 @@ #include "SimDataFormats/GeneratorProducts/interface/LesHouches.h" #include "SimDataFormats/GeneratorProducts/interface/LHERunInfoProduct.h" #include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h" +#include "SimDataFormats/GeneratorProducts/interface/LHEWeightInfoProduct.h" #include "GeneratorInterface/LHEInterface/interface/LHERunInfo.h" #include "GeneratorInterface/LHEInterface/interface/LHEEvent.h" @@ -36,7 +37,7 @@ LHESource::LHESource(const edm::ParameterSet ¶ms, const edm::InputSourceDescription &desc) : ProducerSourceFromFiles(params, desc, false), reader_(new LHEReader(fileNames(), params.getUntrackedParameter("skipEvents", 0))), - lheProvenanceHelper_(edm::TypeID(typeid(LHEEventProduct)), edm::TypeID(typeid(LHERunInfoProduct)), productRegistryUpdate()), + lheProvenanceHelper_(edm::TypeID(typeid(LHEEventProduct)), edm::TypeID(typeid(LHERunInfoProduct)), edm::TypeID(typeid(LHEWeightInfoProduct)), productRegistryUpdate()), phid_() { nextEvent(); @@ -116,6 +117,7 @@ LHESource::readRun_(edm::RunPrincipal& runPrincipal) { runPrincipal.fillRunPrincipal(processHistoryRegistryForUpdate()); putRunInfoProduct(runPrincipal); + putWeightInfoProduct(runPrincipal); } void @@ -132,6 +134,26 @@ void LHESource::putRunInfoProduct(edm::RunPrincipal& iRunPrincipal) { } } +void LHESource::putWeightInfoProduct(edm::RunPrincipal& iRunPrincipal) { + if (runInfoProductLast_) { + auto product = std::make_unique(); + gen::WeightGroupInfo scaleInfo( + "" + ); + scaleInfo.setWeightType(gen::scaleWeights); + + gen::WeightGroupInfo cenPdfInfo( + "" + ); + cenPdfInfo.setWeightType(gen::pdfWeights); + + product->addWeightGroupInfo(scaleInfo); + product->addWeightGroupInfo(cenPdfInfo); + std::unique_ptr rdp(new edm::Wrapper(std::move(product))); + iRunPrincipal.put(lheProvenanceHelper_.weightProductBranchDescription_, std::move(rdp)); + } +} + bool LHESource::setRunAndEventInfo(edm::EventID&, edm::TimeValue_t&, edm::EventAuxiliary::ExperimentType&) { nextEvent(); diff --git a/GeneratorInterface/LHEInterface/plugins/LHESource.h b/GeneratorInterface/LHEInterface/plugins/LHESource.h index c6e1457e8b2db..65cbac8f6e856 100644 --- a/GeneratorInterface/LHEInterface/plugins/LHESource.h +++ b/GeneratorInterface/LHEInterface/plugins/LHESource.h @@ -53,6 +53,7 @@ class LHESource : public edm::ProducerSourceFromFiles { void nextEvent(); void putRunInfoProduct(edm::RunPrincipal&); + void putWeightInfoProduct(edm::RunPrincipal&); void fillRunInfoProduct(lhef::LHERunInfo const&, LHERunInfoProduct& ); std::unique_ptr reader_; diff --git a/SimDataFormats/GeneratorProducts/interface/LHEWeightInfoProduct.h b/SimDataFormats/GeneratorProducts/interface/LHEWeightInfoProduct.h index cacc814d43b9c..ac16db65ae9fa 100644 --- a/SimDataFormats/GeneratorProducts/interface/LHEWeightInfoProduct.h +++ b/SimDataFormats/GeneratorProducts/interface/LHEWeightInfoProduct.h @@ -13,25 +13,16 @@ class LHEWeightInfoProduct { public: - LHEWeightInfoProduct() { - gen::WeightGroupInfo scaleInfo( - "" - ); - //scaleInfo.isPDF = false; - //scaleInfo.pdfLabel = ""; - //scaleInfo.pdfLHAID = ""; - - gen::WeightGroupInfo cenPdfInfo( - "" - ); - - //cenPdfInfo.isPDF = true; - //cenPdfInfo.pdfLabel = "NNPDF31_nnlo_hessian_pdfas"; - //cenPdfInfo.pdfLHAID = "3061000"; - - weightGroupsInfo_.push_back(scaleInfo); - weightGroupsInfo_.push_back(cenPdfInfo); - }; + LHEWeightInfoProduct() {} + LHEWeightInfoProduct(const LHEWeightInfoProduct& other) {weightGroupsInfo_ = other.weightGroupsInfo_;} + LHEWeightInfoProduct(LHEWeightInfoProduct&& other) {weightGroupsInfo_ = std::move(other.weightGroupsInfo_);} + ~LHEWeightInfoProduct() {} + LHEWeightInfoProduct(std::vector& weightGroups) { + weightGroupsInfo_ = weightGroups; + } + LHEWeightInfoProduct &operator = (const LHEWeightInfoProduct &other) {weightGroupsInfo_ = other.weightGroupsInfo_; return * this; } + LHEWeightInfoProduct &operator = (LHEWeightInfoProduct &&other) {weightGroupsInfo_ = std::move(other.weightGroupsInfo_); return *this;} + std::vector getWeightGroupsInfo() { return weightGroupsInfo_; } void addWeightGroupInfo(gen::WeightGroupInfo info) { weightGroupsInfo_.push_back(info); diff --git a/SimDataFormats/GeneratorProducts/interface/WeightGroupInfo.h b/SimDataFormats/GeneratorProducts/interface/WeightGroupInfo.h index 262f85a39d6b2..3f79786e6c7b3 100644 --- a/SimDataFormats/GeneratorProducts/interface/WeightGroupInfo.h +++ b/SimDataFormats/GeneratorProducts/interface/WeightGroupInfo.h @@ -18,6 +18,7 @@ namespace gen { class WeightGroupInfo { public: + WeightGroupInfo() {} WeightGroupInfo(std::string header): headerEntry_(header), name_(header), firstId_(0), lastId_(0) {} int getWeightVectorEntry(const std::string& wgtId, size_t weightEntry) { diff --git a/SimDataFormats/GeneratorProducts/src/classes.h b/SimDataFormats/GeneratorProducts/src/classes.h index 460a735e2e403..6ba5d46db727d 100644 --- a/SimDataFormats/GeneratorProducts/src/classes.h +++ b/SimDataFormats/GeneratorProducts/src/classes.h @@ -8,6 +8,7 @@ #include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h" #include "SimDataFormats/GeneratorProducts/interface/LHERunInfoProduct.h" +#include "SimDataFormats/GeneratorProducts/interface/WeightGroupInfo.h" #include "SimDataFormats/GeneratorProducts/interface/LHEWeightInfoProduct.h" #include "SimDataFormats/GeneratorProducts/interface/LHEXMLStringProduct.h" diff --git a/SimDataFormats/GeneratorProducts/src/classes_def.xml b/SimDataFormats/GeneratorProducts/src/classes_def.xml index bcf54ea90c7e3..b7b4126b900a3 100644 --- a/SimDataFormats/GeneratorProducts/src/classes_def.xml +++ b/SimDataFormats/GeneratorProducts/src/classes_def.xml @@ -197,6 +197,9 @@ + + + @@ -225,7 +228,9 @@ + +