CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/L1TriggerConfig/RPCTriggerConfig/src/RPCTriggerHwConfig.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    RPCTriggerHwConfig
00004 // Class:      RPCTriggerHwConfig
00005 // 
00013 //
00014 // Original Author:  Tomasz Maciej Frueboes
00015 //         Created:  Wed Apr  9 13:57:29 CEST 2008
00016 // $Id: RPCTriggerHwConfig.cc,v 1.5 2010/02/26 15:50:59 fruboes Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 #include "boost/shared_ptr.hpp"
00024 
00025 // user include files
00026 #include "FWCore/Framework/interface/ModuleFactory.h"
00027 #include "FWCore/Framework/interface/ESProducer.h"
00028 
00029 #include "FWCore/Framework/interface/ESHandle.h"
00030 
00031 #include "CondFormats/DataRecord/interface/L1RPCHwConfigRcd.h"
00032 #include "CondFormats/RPCObjects/interface/L1RPCHwConfig.h"
00033 
00034 
00035 
00036 //
00037 // class decleration
00038 //
00039 
00040 class RPCTriggerHwConfig : public edm::ESProducer {
00041    public:
00042       RPCTriggerHwConfig(const edm::ParameterSet&);
00043       ~RPCTriggerHwConfig();
00044 
00045       typedef std::auto_ptr<L1RPCHwConfig> ReturnType;
00046 
00047       ReturnType produce(const L1RPCHwConfigRcd&);
00048    private:
00049       // ----------member data ---------------------------
00050     std::vector<int> m_disableTowers;
00051     std::vector<int>   m_disableCrates;
00052     std::vector<int> m_disableTowersInCrates;
00053 
00054     std::vector<int> m_enableTowers;
00055     std::vector<int> m_enableCrates;
00056     std::vector<int> m_enableTowersInCrates;
00057 
00058     bool m_disableAll;
00059 
00060 };
00061 
00062 //
00063 // constants, enums and typedefs
00064 //
00065 
00066 //
00067 // static data member definitions
00068 //
00069 
00070 //
00071 // constructors and destructor
00072 //
00073 RPCTriggerHwConfig::RPCTriggerHwConfig(const edm::ParameterSet& iConfig)
00074 {
00075    //the following line is needed to tell the framework what
00076    // data is being produced
00077    setWhatProduced(this);
00078 
00079    //now do what ever other initialization is needed
00080     m_disableTowers =  iConfig.getParameter<std::vector<int> >("disableTowers");
00081     m_disableCrates =  iConfig.getParameter<std::vector<int> >("disableCrates");
00082     m_disableTowersInCrates =  iConfig.getParameter<std::vector<int> >("disableTowersInCrates");
00083 
00084     m_disableAll = iConfig.getParameter<bool>("disableAll");
00085 
00086     m_enableTowers =  iConfig.getParameter<std::vector<int> >("enableTowers");
00087     m_enableCrates =  iConfig.getParameter<std::vector<int> >("enableCrates");
00088     m_enableTowersInCrates =  iConfig.getParameter<std::vector<int> >("enableTowersInCrates");
00089 
00090     if (m_disableAll) {
00091       m_disableTowers.clear();
00092       m_disableCrates.clear();
00093       m_disableTowersInCrates.clear();
00094       // check if m_enableTowers  & m_enableCrates are not empty?
00095     }
00096 
00097 
00098 
00099 }
00100 
00101 
00102 RPCTriggerHwConfig::~RPCTriggerHwConfig()
00103 {
00104  
00105    // do anything here that needs to be done at desctruction time
00106    // (e.g. close files, deallocate resources etc.)
00107 
00108 }
00109 
00110 
00111 //
00112 // member functions
00113 //
00114 
00115 // ------------ method called to produce the data  ------------
00116 RPCTriggerHwConfig::ReturnType
00117 RPCTriggerHwConfig::produce(const L1RPCHwConfigRcd& iRecord)
00118 {
00119    using namespace edm::es;
00120    std::auto_ptr<L1RPCHwConfig> pL1RPCHwConfig = std::auto_ptr<L1RPCHwConfig>( new L1RPCHwConfig() );
00121 
00122    if (m_disableAll) {
00123      pL1RPCHwConfig->enableAll(false);
00124      std::vector<int>::iterator crIt = m_enableCrates.begin();
00125      std::vector<int>::iterator twIt = m_enableTowers.begin();
00126      for (; crIt!=m_enableCrates.end(); ++crIt){
00127        pL1RPCHwConfig->enableCrate(*crIt,true);
00128      }
00129      for (; twIt!=m_enableTowers.end(); ++twIt){
00130        pL1RPCHwConfig->enableTower(*twIt,true);
00131      }
00132      for (unsigned int It=0; It<m_enableTowersInCrates.size(); It++) {
00133        if (It%2 == 0)
00134        pL1RPCHwConfig->enableTowerInCrate(m_enableTowersInCrates[It+1], m_enableTowersInCrates[It], true);
00135      }
00136    } else {
00137      std::vector<int>::iterator crIt = m_disableCrates.begin();
00138      std::vector<int>::iterator twIt = m_disableTowers.begin();
00139      for (; crIt!=m_disableCrates.end(); ++crIt){
00140        pL1RPCHwConfig->enableCrate(*crIt,false);
00141      }
00142      for (; twIt!=m_disableTowers.end(); ++twIt){
00143        pL1RPCHwConfig->enableTower(*twIt,false);
00144      }
00145      for (unsigned int It=0; It<m_disableTowersInCrates.size(); It++) {
00146        if (It%2 == 0)
00147        pL1RPCHwConfig->enableTowerInCrate(m_disableTowersInCrates[It+1], m_disableTowersInCrates[It], false);
00148      }
00149 
00150    }
00151 
00152    return pL1RPCHwConfig ;
00153 }
00154 
00155 //define this as a plug-in
00156 DEFINE_FWK_EVENTSETUP_MODULE(RPCTriggerHwConfig);