File indexing completed on 2024-04-06 12:13:50
0001 #include <string>
0002 #include <vector>
0003 #include "GeneratorInterface/LHEInterface/plugins/LHEProvenanceHelper.h"
0004 #include "GeneratorInterface/LHEInterface/interface/LHERunInfo.h"
0005
0006 #include "DataFormats/Provenance/interface/ProcessHistory.h"
0007 #include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
0008 #include "DataFormats/Provenance/interface/ProductRegistry.h"
0009 #include "DataFormats/Provenance/interface/BranchIDList.h"
0010 #include "DataFormats/Provenance/interface/BranchIDListHelper.h"
0011 #include "SimDataFormats/GeneratorProducts/interface/LesHouches.h"
0012
0013 #include "FWCore/Utilities/interface/GetPassID.h"
0014
0015 #include "FWCore/Utilities/interface/TypeID.h"
0016 #include "FWCore/Reflection/interface/TypeWithDict.h"
0017 #include "FWCore/Version/interface/GetReleaseVersion.h"
0018
0019 namespace edm {
0020 LHEProvenanceHelper::LHEProvenanceHelper(TypeID const& eventProductType,
0021 TypeID const& runProductType,
0022 ProductRegistry& productRegistry,
0023 BranchIDListHelper& branchIDListHelper)
0024 : eventProductBranchDescription_(BranchDescription(InEvent,
0025 "source",
0026 "LHEFile"
0027
0028 ,
0029 "LHEEventProduct",
0030 "LHEEventProduct",
0031 "",
0032 "LHESource",
0033 ParameterSetID(),
0034 TypeWithDict(eventProductType.typeInfo()),
0035 false)),
0036 runProductBranchDescription_(BranchDescription(InRun,
0037 "source",
0038 "LHEFile"
0039
0040 ,
0041 "LHERunInfoProduct",
0042 "LHERunInfoProduct",
0043 "",
0044 "LHESource",
0045 ParameterSetID(),
0046 TypeWithDict(runProductType.typeInfo()),
0047 false)),
0048 eventProductProvenance_(eventProductBranchDescription_.branchID()),
0049 commonProcessParameterSet_(fillCommonProcessParameterSet()),
0050 processParameterSet_(),
0051 branchListIndexes_(1, 0) {
0052
0053 auto ep = eventProductBranchDescription_;
0054 ep.setIsProvenanceSetOnRead();
0055 productRegistry.copyProduct(ep);
0056 auto rp = runProductBranchDescription_;
0057 rp.setIsProvenanceSetOnRead();
0058 productRegistry.copyProduct(rp);
0059 BranchIDList bli(1UL, ep.branchID().id());
0060 branchIDListHelper.updateFromInput({{bli}});
0061 }
0062
0063 ParameterSet LHEProvenanceHelper::fillCommonProcessParameterSet() {
0064
0065
0066
0067 ParameterSet pset;
0068 std::string const& moduleLabel = eventProductBranchDescription_.moduleLabel();
0069 std::string const& processName = eventProductBranchDescription_.processName();
0070 std::string const& moduleName = eventProductBranchDescription_.moduleName();
0071 typedef std::vector<std::string> vstring;
0072 vstring empty;
0073
0074 vstring modlbl;
0075 modlbl.reserve(1);
0076 modlbl.push_back(moduleLabel);
0077 pset.addParameter("@all_sources", modlbl);
0078
0079 ParameterSet triggerPaths;
0080 triggerPaths.addParameter<vstring>("@trigger_paths", empty);
0081 pset.addParameter<ParameterSet>("@trigger_paths", triggerPaths);
0082
0083 ParameterSet pseudoInput;
0084 pseudoInput.addParameter<std::string>("@module_edm_type", "Source");
0085 pseudoInput.addParameter<std::string>("@module_label", moduleLabel);
0086 pseudoInput.addParameter<std::string>("@module_type", moduleName);
0087 pset.addParameter<ParameterSet>(moduleLabel, pseudoInput);
0088
0089 pset.addParameter<vstring>("@all_esmodules", empty);
0090 pset.addParameter<vstring>("@all_esprefers", empty);
0091 pset.addParameter<vstring>("@all_essources", empty);
0092 pset.addParameter<vstring>("@all_loopers", empty);
0093 pset.addParameter<vstring>("@all_modules", empty);
0094 pset.addParameter<vstring>("@end_paths", empty);
0095 pset.addParameter<vstring>("@paths", empty);
0096 pset.addParameter<std::string>("@process_name", processName);
0097 return pset;
0098 }
0099
0100 void LHEProvenanceHelper::lheAugment(lhef::LHERunInfo const* runInfo) {
0101 processParameterSet_ = commonProcessParameterSet_;
0102 if (runInfo == nullptr)
0103 return;
0104 typedef std::vector<std::string> vstring;
0105 auto const& heprup = *runInfo->getHEPRUP();
0106 processParameterSet_.addParameter<int>("IDBMUP1", heprup.IDBMUP.first);
0107 processParameterSet_.addParameter<int>("IDBMUP2", heprup.IDBMUP.second);
0108 processParameterSet_.addParameter<int>("EBMUP1", heprup.EBMUP.first);
0109 processParameterSet_.addParameter<int>("EBMUP2", heprup.EBMUP.second);
0110 processParameterSet_.addParameter<int>("PDFGUP1", heprup.PDFGUP.first);
0111 processParameterSet_.addParameter<int>("PDFGUP2", heprup.PDFGUP.second);
0112 processParameterSet_.addParameter<int>("PDFSUP1", heprup.PDFSUP.first);
0113 processParameterSet_.addParameter<int>("PDFSUP2", heprup.PDFSUP.second);
0114 processParameterSet_.addParameter<int>("IDWTUP", heprup.IDWTUP);
0115 for (auto const& header : runInfo->getHeaders()) {
0116 if (!LHERunInfoProduct::isTagComparedInMerge(header.tag())) {
0117 continue;
0118 }
0119 processParameterSet_.addParameter<vstring>(header.tag(), header.lines());
0120 }
0121 }
0122
0123 ProcessHistoryID LHEProvenanceHelper::lheInit(ProcessHistoryRegistry& processHistoryRegistry) {
0124
0125 processParameterSet_.registerIt();
0126
0127
0128
0129 ProcessHistory ph;
0130 ph.emplace_back(
0131 eventProductBranchDescription_.processName(), processParameterSet_.id(), getReleaseVersion(), getPassID());
0132 processHistoryRegistry.registerProcessHistory(ph);
0133
0134
0135 return ph.id();
0136 }
0137
0138 }