CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/GeneratorInterface/LHEInterface/plugins/LHEProvenanceHelper.cc

Go to the documentation of this file.
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                                                   // , "LHE"
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                                                   // , "LHE"
00038                                                   , "LHERunInfoProduct"
00039                                                   , "LHERunInfoProduct"
00040                                                   , ""
00041                                                   , "LHESource"
00042                                                   , ParameterSetID()
00043                                                   , TypeWithDict(runProductType.typeInfo())
00044                                                   , false))
00045         , eventProductProvenance_(eventProductBranchDescription_.branchID())
00046         , processParameterSet_() {
00047     
00048     // Now we create a process parameter set for the "LHC" process.
00049     // We don't currently use the untracked parameters, However, we make them available, just in case.
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     // Now we register the process parameter set.
00106     processParameterSet_.registerIt();
00107     //std::cerr << processParameterSet_.dump() << std::endl;
00108     // Now we need to set all the metadata
00109     // Add the products to the product registry  
00110     productRegistry.copyProduct(eventProductBranchDescription_.me());
00111     productRegistry.copyProduct(runProductBranchDescription_.me());
00112 
00113     // Insert an entry for this process in the process history registry
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     // Insert an entry for this process in the process configuration registry
00120     ProcessConfigurationRegistry::instance()->insertMapped(pc);
00121 
00122     // Save the process history ID for use every event.
00123     return ph.id();
00124   }
00125 
00126 }