Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:14:52

0001 #include "FWCore/Framework/interface/ESProducer.h"
0002 #include "FWCore/Framework/interface/ModuleFactory.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "CalibTracker/Records/interface/SiStripFecCablingRcd.h"
0005 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
0006 #include "CalibFormats/SiStripObjects/interface/SiStripFecCabling.h"
0007 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
0008 
0009 #include <memory>
0010 
0011 class SiStripConnectivity : public edm::ESProducer {
0012 public:
0013   SiStripConnectivity(const edm::ParameterSet&);
0014   ~SiStripConnectivity() override;
0015 
0016   std::unique_ptr<SiStripFecCabling> produceFecCabling(const SiStripFecCablingRcd&);
0017   std::unique_ptr<SiStripDetCabling> produceDetCabling(const SiStripDetCablingRcd&);
0018 
0019 private:
0020   struct FecTokens {
0021     FecTokens(edm::ESConsumesCollector&& cc) : fedCabling(cc.consumes()) {}
0022     const edm::ESGetToken<SiStripFedCabling, SiStripFedCablingRcd> fedCabling;
0023   };
0024   struct DetTokens {
0025     DetTokens(edm::ESConsumesCollector&& cc) : fedCabling(cc.consumes()), tTopo(cc.consumes()) {}
0026     const edm::ESGetToken<SiStripFedCabling, SiStripFedCablingRcd> fedCabling;
0027     const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopo;
0028   };
0029   const FecTokens fecTokens_;
0030   const DetTokens detTokens_;
0031 };
0032 
0033 SiStripConnectivity::SiStripConnectivity(const edm::ParameterSet& p)
0034     : fecTokens_(setWhatProduced(this, &SiStripConnectivity::produceFecCabling)),
0035       detTokens_(setWhatProduced(this, &SiStripConnectivity::produceDetCabling)) {}
0036 
0037 SiStripConnectivity::~SiStripConnectivity() {
0038   // do anything here that needs to be done at desctruction time
0039   // (e.g. close files, deallocate resources etc.)
0040 }
0041 
0042 // ------------ methods called to produce the data  ------------
0043 
0044 std::unique_ptr<SiStripFecCabling> SiStripConnectivity::produceFecCabling(const SiStripFecCablingRcd& iRecord) {
0045   //here build an object of type SiStripFecCabling using  **ONLY** the information from class SiStripFedCabling,
0046   return std::make_unique<SiStripFecCabling>(iRecord.get(fecTokens_.fedCabling));
0047 }
0048 
0049 std::unique_ptr<SiStripDetCabling> SiStripConnectivity::produceDetCabling(const SiStripDetCablingRcd& iRecord) {
0050   //here build an object of type SiStripDetCabling using  **ONLY** the information from class SiStripFedCabling,
0051   return std::make_unique<SiStripDetCabling>(iRecord.get(detTokens_.fedCabling), &iRecord.get(detTokens_.tTopo));
0052 }
0053 
0054 // define this as a plug-in
0055 DEFINE_FWK_EVENTSETUP_MODULE(SiStripConnectivity);