Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:12:51

0001 #include "L1TMuonOverlapPhase1ParamsESProducer.h"
0002 
0003 #include "CondFormats/L1TObjects/interface/L1TMuonOverlapParams.h"
0004 #include "CondFormats/DataRecord/interface/L1TMuonOverlapParamsRcd.h"
0005 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLConfigReader.h"
0006 
0007 #include "FWCore/Framework/interface/ModuleFactory.h"
0008 #include "FWCore/Framework/interface/ESProducer.h"
0009 #include "FWCore/Framework/interface/ESHandle.h"
0010 #include "FWCore/Framework/interface/ESProducts.h"
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 
0013 #include <sstream>
0014 
0015 ///////////////////////////////////////////////////////////////////
0016 ///////////////////////////////////////////////////////////////////
0017 L1TMuonOverlapPhase1ParamsESProducer::L1TMuonOverlapPhase1ParamsESProducer(const edm::ParameterSet& theConfig) {
0018   //the following line is needed to tell the framework what
0019   // data is being produced
0020   setWhatProduced(this, &L1TMuonOverlapPhase1ParamsESProducer::produceParams);
0021 
0022   if (!theConfig.exists("configXMLFile"))
0023     return;
0024   std::string fName = theConfig.getParameter<edm::FileInPath>("configXMLFile").fullPath();
0025 
0026   edm::LogVerbatim("OMTFReconstruction") << "L1TMuonOverlapPhase1ParamsESProducer - reading config from file: " << fName
0027                                          << std::endl;
0028 
0029   if (!theConfig.exists("patternsXMLFiles"))
0030     return;
0031   std::vector<std::string> fileNames;
0032   for (const auto& it : theConfig.getParameter<std::vector<edm::ParameterSet> >("patternsXMLFiles")) {
0033     std::string fName = it.getParameter<edm::FileInPath>("patternsXMLFile").fullPath();
0034     fileNames.push_back(fName);
0035     edm::LogVerbatim("OMTFReconstruction")
0036         << "L1TMuonOverlapPhase1ParamsESProducer - reading patterns from file: " << fName << std::endl;
0037   }
0038 
0039   XMLConfigReader myReader;
0040   myReader.setConfigFile(fName);
0041   readConnectionsXML(myReader);
0042 
0043   myReader.setPatternsFiles(fileNames);
0044   readPatternsXML(myReader);
0045 
0046   unsigned int patternsVersion = myReader.getPatternsVersion();
0047   unsigned int fwVersion = params.fwVersion();
0048 
0049   params.setFwVersion((fwVersion << 16) + patternsVersion);
0050 }
0051 ///////////////////////////////////////////////////////////////////
0052 ///////////////////////////////////////////////////////////////////
0053 L1TMuonOverlapPhase1ParamsESProducer::~L1TMuonOverlapPhase1ParamsESProducer() {}
0054 ///////////////////////////////////////////////////////////////////
0055 ///////////////////////////////////////////////////////////////////
0056 bool L1TMuonOverlapPhase1ParamsESProducer::readConnectionsXML(const XMLConfigReader& aReader) {
0057   aReader.readConfig(&params);
0058 
0059   return true;
0060 }
0061 ///////////////////////////////////////////////////////////////////
0062 ///////////////////////////////////////////////////////////////////
0063 bool L1TMuonOverlapPhase1ParamsESProducer::readPatternsXML(XMLConfigReader& aReader) {
0064   l1t::LUT chargeLUT;
0065   l1t::LUT etaLUT;
0066   l1t::LUT ptLUT;
0067   l1t::LUT meanDistPhiLUT;
0068   l1t::LUT selDistPhiShiftLUT;
0069   l1t::LUT pdfLUT;
0070 
0071   std::vector<l1t::LUT*> luts = {&chargeLUT, &etaLUT, &ptLUT, &meanDistPhiLUT, &selDistPhiShiftLUT, &pdfLUT};
0072   std::vector<std::string> types = {"iCharge", "iEta", "iPt", "meanDistPhi", "selDistPhiShift", "pdf"};
0073 
0074   //in the luts we want to have the empty patterns (pt == 0), because it is the way to have the info about the patterns grouping
0075   aReader.readLUTs(luts, params, types);
0076 
0077   params.setChargeLUT(chargeLUT);
0078   params.setEtaLUT(etaLUT);
0079   params.setPtLUT(ptLUT);
0080   params.setMeanDistPhiLUT(meanDistPhiLUT);
0081   params.setDistPhiShiftLUT(selDistPhiShiftLUT);
0082   params.setPdfLUT(pdfLUT);
0083 
0084   return true;
0085 }
0086 ///////////////////////////////////////////////////////////////////
0087 ///////////////////////////////////////////////////////////////////
0088 L1TMuonOverlapPhase1ParamsESProducer::ReturnType L1TMuonOverlapPhase1ParamsESProducer::produceParams(
0089     const L1TMuonOverlapParamsRcd& iRecord) {
0090   using namespace edm::es;
0091 
0092   return std::make_shared<L1TMuonOverlapParams>(params);
0093 }
0094 ///////////////////////////////////////////////////////////////////
0095 ///////////////////////////////////////////////////////////////////
0096 #include "FWCore/Framework/interface/MakerMacros.h"
0097 DEFINE_FWK_EVENTSETUP_MODULE(L1TMuonOverlapPhase1ParamsESProducer);