Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:15

0001 // -*- C++ -*-
0002 //
0003 // Package:    RPCTriggerConfig
0004 // Class:      RPCTriggerConfig
0005 //
0006 /**\class RPCTriggerConfig RPCTriggerConfig.h L1TriggerConfig/RPCTriggerConfig/interface/RPCTriggerConfig.h
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Tomasz Maciej Frueboes
0015 //         Created:  Tue Mar 20 12:30:19 CET 2007
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/ModuleFactory.h"
0024 #include "FWCore/Framework/interface/ESProducer.h"
0025 
0026 #include "FWCore/Framework/interface/ESHandle.h"
0027 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0028 #include <FWCore/ParameterSet/interface/FileInPath.h>
0029 
0030 #include "CondFormats/DataRecord/interface/L1RPCConfigRcd.h"
0031 #include "CondFormats/L1TObjects/interface/L1RPCConfig.h"
0032 #include <string>
0033 
0034 #include "L1Trigger/RPCTrigger/interface/RPCPatternsParser.h"
0035 //
0036 // class decleration
0037 //
0038 
0039 class RPCTriggerConfig : public edm::ESProducer {
0040 public:
0041   RPCTriggerConfig(const edm::ParameterSet&);
0042   ~RPCTriggerConfig() override;
0043 
0044   typedef std::unique_ptr<L1RPCConfig> ReturnType;
0045 
0046   ReturnType produce(const L1RPCConfigRcd&);
0047 
0048 private:
0049   // ----------member data ---------------------------
0050 
0051   int m_ppt;
0052   std::string m_patternsDir;
0053 };
0054 
0055 //
0056 // constants, enums and typedefs
0057 //
0058 
0059 //
0060 // static data member definitions
0061 //
0062 
0063 //
0064 // constructors and destructor
0065 //
0066 RPCTriggerConfig::RPCTriggerConfig(const edm::ParameterSet& iConfig) {
0067   //the following line is needed to tell the framework what
0068   // data is being produced
0069   setWhatProduced(this);
0070 
0071   //now do what ever other initialization is needed
0072 
0073   m_ppt = iConfig.getUntrackedParameter<int>("PACsPerTower");
0074   std::string dataDir = iConfig.getUntrackedParameter<std::string>("filedir");
0075 
0076   edm::FileInPath fp(dataDir + "pacPat_t0sc0sg0.xml");
0077   std::string patternsDirNameUnstriped = fp.fullPath();
0078   m_patternsDir = patternsDirNameUnstriped.substr(0, patternsDirNameUnstriped.find_last_of('/') + 1);
0079 }
0080 
0081 RPCTriggerConfig::~RPCTriggerConfig() {
0082   // do anything here that needs to be done at desctruction time
0083   // (e.g. close files, deallocate resources etc.)
0084 }
0085 
0086 //
0087 // member functions
0088 //
0089 
0090 // ------------ method called to produce the data  ------------
0091 RPCTriggerConfig::ReturnType RPCTriggerConfig::produce(const L1RPCConfigRcd& iRecord) {
0092   auto pL1RPCConfig = std::make_unique<L1RPCConfig>();
0093 
0094   pL1RPCConfig->setPPT(m_ppt);
0095 
0096   // parse and isert patterns
0097   int scCnt = 0, sgCnt = 0;
0098   if (m_ppt == 1) {
0099     scCnt = 1;
0100     sgCnt = 1;
0101   } else if (m_ppt == 12) {
0102     scCnt = 1;
0103     sgCnt = 12;
0104   } else if (m_ppt == 144) {
0105     scCnt = 12;
0106     sgCnt = 12;
0107   } else {
0108     throw cms::Exception("BadConfig") << "Bad number of ppt requested: " << m_ppt << "\n";
0109   }
0110 
0111   for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; ++tower) {
0112     for (int logSector = 0; logSector < scCnt; ++logSector) {
0113       for (int logSegment = 0; logSegment < sgCnt; ++logSegment) {
0114         std::stringstream fname;
0115         fname << m_patternsDir << "pacPat_t" << tower << "sc" << logSector << "sg" << logSegment << ".xml";
0116 
0117         // TODO: this should go to logSth
0118         LogDebug("RPCTriggerConfig") << "Parsing: " << fname.str() << std::endl;
0119 
0120         RPCPatternsParser parser;
0121         parser.parse(fname.str());
0122 
0123         RPCPattern::RPCPatVec npats = parser.getPatternsVec(tower, logSector, logSegment);
0124         for (unsigned int ip = 0; ip < npats.size(); ip++) {
0125           npats[ip].setCoords(tower, logSector, logSegment);
0126           pL1RPCConfig->m_pats.push_back(npats[ip]);
0127         }
0128 
0129         RPCPattern::TQualityVec nquals = parser.getQualityVec();
0130         for (unsigned int iq = 0; iq < nquals.size(); iq++) {
0131           nquals[iq].m_tower = tower;
0132           nquals[iq].m_logsector = logSector;
0133           nquals[iq].m_logsegment = logSegment;
0134           pL1RPCConfig->m_quals.push_back(nquals[iq]);
0135         }
0136 
0137         LogDebug("RPCTriggerConfig") << "  RPCPatterns: " << npats.size() << " qualities: " << nquals.size()
0138                                      << std::endl;
0139 
0140       }  // segments
0141     }    // sectors
0142   }      // towers
0143 
0144   return pL1RPCConfig;
0145 }
0146 
0147 //define this as a plug-in
0148 DEFINE_FWK_EVENTSETUP_MODULE(RPCTriggerConfig);