Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:23:26

0001 #include "sstream"
0002 
0003 // user include files
0004 #include "FWCore/Framework/interface/ModuleFactory.h"
0005 #include "FWCore/Framework/interface/ESProducer.h"
0006 #include "FWCore/Framework/interface/ESHandle.h"
0007 #include "FWCore/Framework/interface/ESProducts.h"
0008 
0009 #include "CondFormats/L1TObjects/interface/L1TMuonOverlapParams.h"
0010 #include "CondFormats/DataRecord/interface/L1TMuonOverlapParamsRcd.h"
0011 
0012 #include "L1Trigger/L1TMuonOverlap/interface/XMLConfigReader.h"
0013 #include "L1Trigger/L1TMuonOverlap/plugins/L1TMuonOverlapParamsESProducer.h"
0014 
0015 ///////////////////////////////////////////////////////////////////
0016 ///////////////////////////////////////////////////////////////////
0017 L1TMuonOverlapParamsESProducer::L1TMuonOverlapParamsESProducer(const edm::ParameterSet& theConfig) {
0018   //the following line is needed to tell the framework what
0019   // data is being produced
0020   setWhatProduced(this, &L1TMuonOverlapParamsESProducer::produceParams);
0021 
0022   if (!theConfig.exists("configXMLFile"))
0023     return;
0024   std::string fName = theConfig.getParameter<edm::FileInPath>("configXMLFile").fullPath();
0025 
0026   ///WARNING: filling the CondFormats objects works only for a single XML patterns file.
0027   if (!theConfig.exists("patternsXMLFiles"))
0028     return;
0029   std::vector<std::string> fileNames;
0030   for (const auto& it : theConfig.getParameter<std::vector<edm::ParameterSet> >("patternsXMLFiles")) {
0031     fileNames.push_back(it.getParameter<edm::FileInPath>("patternsXMLFile").fullPath());
0032   }
0033 
0034   XMLConfigReader myReader;
0035   myReader.setConfigFile(fName);
0036   readConnectionsXML(myReader);
0037 
0038   for (const auto& it : fileNames) {
0039     myReader.setPatternsFile(it);
0040     readPatternsXML(myReader);
0041   }
0042 
0043   unsigned int patternsVersion = myReader.getPatternsVersion();
0044   unsigned int fwVersion = params.fwVersion();
0045 
0046   params.setFwVersion((fwVersion << 16) + patternsVersion);
0047 }
0048 ///////////////////////////////////////////////////////////////////
0049 ///////////////////////////////////////////////////////////////////
0050 L1TMuonOverlapParamsESProducer::~L1TMuonOverlapParamsESProducer() {}
0051 ///////////////////////////////////////////////////////////////////
0052 ///////////////////////////////////////////////////////////////////
0053 bool L1TMuonOverlapParamsESProducer::readConnectionsXML(const XMLConfigReader& aReader) {
0054   aReader.readConfig(&params);
0055 
0056   return true;
0057 }
0058 ///////////////////////////////////////////////////////////////////
0059 ///////////////////////////////////////////////////////////////////
0060 bool L1TMuonOverlapParamsESProducer::readPatternsXML(XMLConfigReader& aReader) {
0061   l1t::LUT chargeLUT;
0062   l1t::LUT etaLUT;
0063   l1t::LUT ptLUT;
0064   l1t::LUT meanDistPhiLUT;
0065   l1t::LUT pdfLUT;
0066 
0067   std::vector<l1t::LUT*> luts = {&chargeLUT, &etaLUT, &ptLUT, &meanDistPhiLUT, &pdfLUT};
0068   std::vector<std::string> types = {"iCharge", "iEta", "iPt", "meanDistPhi", "pdf"};
0069   aReader.readLUTs(luts, params, types);
0070 
0071   params.setChargeLUT(chargeLUT);
0072   params.setEtaLUT(etaLUT);
0073   params.setPtLUT(ptLUT);
0074   params.setMeanDistPhiLUT(meanDistPhiLUT);
0075   params.setPdfLUT(pdfLUT);
0076 
0077   return true;
0078 }
0079 ///////////////////////////////////////////////////////////////////
0080 ///////////////////////////////////////////////////////////////////
0081 L1TMuonOverlapParamsESProducer::ReturnType L1TMuonOverlapParamsESProducer::produceParams(
0082     const L1TMuonOverlapParamsRcd& iRecord) {
0083   return std::make_unique<L1TMuonOverlapParams>(params);
0084 }
0085 ///////////////////////////////////////////////////////////////////
0086 ///////////////////////////////////////////////////////////////////
0087 #include "FWCore/Framework/interface/MakerMacros.h"
0088 DEFINE_FWK_EVENTSETUP_MODULE(L1TMuonOverlapParamsESProducer);