00001 #include <string>
00002 #include <vector>
00003 #include "GeneratorInterface/LHEInterface/plugins/LHEProvenanceHelper.h"
00004 #include "GeneratorInterface/LHEInterface/interface/LHERunInfo.h"
00005
00006 #include "DataFormats/Provenance/interface/ProcessConfiguration.h"
00007 #include "DataFormats/Provenance/interface/ProcessConfigurationRegistry.h"
00008 #include "DataFormats/Provenance/interface/ProcessHistory.h"
00009 #include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
00010 #include "DataFormats/Provenance/interface/ProductRegistry.h"
00011 #include "SimDataFormats/GeneratorProducts/interface/LesHouches.h"
00012
00013 #include "FWCore/Utilities/interface/GetPassID.h"
00014
00015 #include "FWCore/Utilities/interface/TypeID.h"
00016 #include "FWCore/Utilities/interface/TypeWithDict.h"
00017 #include "FWCore/Version/interface/GetReleaseVersion.h"
00018
00019 namespace edm {
00020 LHEProvenanceHelper::LHEProvenanceHelper(TypeID const& eventProductType, TypeID const& runProductType)
00021 : eventProductBranchDescription_(BranchDescription(
00022 InEvent
00023 , "source"
00024 , "LHEFile"
00025
00026 , "LHEEventProduct"
00027 , "LHEEventProduct"
00028 , ""
00029 , "LHESource"
00030 , ParameterSetID()
00031 , TypeWithDict(eventProductType.typeInfo())
00032 , false))
00033 , runProductBranchDescription_(BranchDescription(
00034 InRun
00035 , "source"
00036 , "LHEFile"
00037
00038 , "LHERunInfoProduct"
00039 , "LHERunInfoProduct"
00040 , ""
00041 , "LHESource"
00042 , ParameterSetID()
00043 , TypeWithDict(runProductType.typeInfo())
00044 , false))
00045 , eventProductProvenance_(eventProductBranchDescription_.branchID())
00046 , processParameterSet_() {
00047
00048
00049
00050 std::string const& moduleLabel = eventProductBranchDescription_.moduleLabel();
00051 std::string const& processName = eventProductBranchDescription_.processName();
00052 std::string const& moduleName = eventProductBranchDescription_.moduleName();
00053 typedef std::vector<std::string> vstring;
00054 vstring empty;
00055
00056 vstring modlbl;
00057 modlbl.reserve(1);
00058 modlbl.push_back(moduleLabel);
00059 processParameterSet_.addParameter("@all_sources", modlbl);
00060
00061 ParameterSet triggerPaths;
00062 triggerPaths.addParameter<vstring>("@trigger_paths", empty);
00063 processParameterSet_.addParameter<ParameterSet>("@trigger_paths", triggerPaths);
00064
00065 ParameterSet pseudoInput;
00066 pseudoInput.addParameter<std::string>("@module_edm_type", "Source");
00067 pseudoInput.addParameter<std::string>("@module_label", moduleLabel);
00068 pseudoInput.addParameter<std::string>("@module_type", moduleName);
00069 processParameterSet_.addParameter<ParameterSet>(moduleLabel, pseudoInput);
00070
00071 processParameterSet_.addParameter<vstring>("@all_esmodules", empty);
00072 processParameterSet_.addParameter<vstring>("@all_esprefers", empty);
00073 processParameterSet_.addParameter<vstring>("@all_essources", empty);
00074 processParameterSet_.addParameter<vstring>("@all_loopers", empty);
00075 processParameterSet_.addParameter<vstring>("@all_modules", empty);
00076 processParameterSet_.addParameter<vstring>("@end_paths", empty);
00077 processParameterSet_.addParameter<vstring>("@paths", empty);
00078 processParameterSet_.addParameter<std::string>("@process_name", processName);
00079 }
00080
00081 void
00082 LHEProvenanceHelper::lheAugment(lhef::LHERunInfo const* runInfo) {
00083 if(runInfo == nullptr) return;
00084 typedef std::vector<std::string> vstring;
00085 auto const& heprup = *runInfo->getHEPRUP();
00086 processParameterSet_.addParameter<int>("IDBMUP1", heprup.IDBMUP.first);
00087 processParameterSet_.addParameter<int>("IDBMUP2", heprup.IDBMUP.second);
00088 processParameterSet_.addParameter<int>("EBMUP1", heprup.EBMUP.first);
00089 processParameterSet_.addParameter<int>("EBMUP2", heprup.EBMUP.second);
00090 processParameterSet_.addParameter<int>("PDFGUP1", heprup.PDFGUP.first);
00091 processParameterSet_.addParameter<int>("PDFGUP2", heprup.PDFGUP.second);
00092 processParameterSet_.addParameter<int>("PDFSUP1", heprup.PDFSUP.first);
00093 processParameterSet_.addParameter<int>("PDFSUP2", heprup.PDFSUP.second);
00094 processParameterSet_.addParameter<int>("IDWTUP", heprup.IDWTUP);
00095 for(auto const& header : runInfo->getHeaders()) {
00096 if(!LHERunInfoProduct::isTagComparedInMerge(header.tag())) {
00097 continue;
00098 }
00099 processParameterSet_.addParameter<vstring>(header.tag(), header.lines());
00100 }
00101 }
00102
00103 ProcessHistoryID
00104 LHEProvenanceHelper::lheInit(ProductRegistry& productRegistry) {
00105
00106 processParameterSet_.registerIt();
00107
00108
00109
00110 productRegistry.copyProduct(eventProductBranchDescription_.me());
00111 productRegistry.copyProduct(runProductBranchDescription_.me());
00112
00113
00114 ProcessHistory ph;
00115 ph.emplace_back(eventProductBranchDescription_.processName(), processParameterSet_.id(), getReleaseVersion(), getPassID());
00116 ProcessConfiguration const& pc = ph.data().back();
00117 ProcessHistoryRegistry::instance()->insertMapped(ph);
00118
00119
00120 ProcessConfigurationRegistry::instance()->insertMapped(pc);
00121
00122
00123 return ph.id();
00124 }
00125
00126 }