Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    CalibTracker/PixelFEDChannelCollectionProducer
0004 // Class:      PixelFEDChannelCollectionProducer
0005 //
0006 /**\class PixelFEDChannelCollectionProducer
0007 
0008  Description: [one line class summary]
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Marco Musich
0015 //         Created:  Thu, 13 Dec 2018 08:48:22 GMT
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/EventSetup.h"
0024 #include "FWCore/Framework/interface/ModuleFactory.h"
0025 #include "FWCore/Framework/interface/ESProducer.h"
0026 
0027 #include "CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h"
0028 #include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h"
0029 #include "CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h"
0030 
0031 // Need to add #include statements for definitions of
0032 // the data type and record type here
0033 
0034 //
0035 // class declaration
0036 //
0037 
0038 class PixelFEDChannelCollectionProducer : public edm::ESProducer {
0039 public:
0040   PixelFEDChannelCollectionProducer(const edm::ParameterSet&);
0041   ~PixelFEDChannelCollectionProducer() override;
0042 
0043   typedef std::unordered_map<std::string, PixelFEDChannelCollection> PixelFEDChannelCollectionMap;
0044   using ReturnType = std::unique_ptr<PixelFEDChannelCollectionMap>;
0045 
0046   ReturnType produce(const SiPixelFEDChannelContainerESProducerRcd&);
0047 
0048 private:
0049   // ----------member data ---------------------------
0050   const edm::ESGetToken<SiPixelFEDChannelContainer, SiPixelStatusScenariosRcd> qualityToken_;
0051 };
0052 
0053 PixelFEDChannelCollectionProducer::PixelFEDChannelCollectionProducer(const edm::ParameterSet& iConfig)
0054     : qualityToken_(setWhatProduced(this).consumes()) {}
0055 
0056 PixelFEDChannelCollectionProducer::~PixelFEDChannelCollectionProducer() {
0057   // do anything here that needs to be done at destruction time
0058   // (e.g. close files, deallocate resources etc.)
0059 }
0060 
0061 //
0062 // member functions
0063 //
0064 
0065 // ------------ method called to produce the data  ------------
0066 PixelFEDChannelCollectionProducer::ReturnType PixelFEDChannelCollectionProducer::produce(
0067     const SiPixelFEDChannelContainerESProducerRcd& iRecord) {
0068   const auto& qualityCollection = iRecord.get(qualityToken_);
0069 
0070   auto out = std::make_unique<PixelFEDChannelCollectionMap>();
0071 
0072   for (const auto& it : qualityCollection.getScenarioMap()) {
0073     const std::string& scenario = it.first;
0074     // getScenarioMap() is an unordered_map<string, ...>, so each scenario appears exactly once
0075     PixelFEDChannelCollection& disabled_channelcollection = (*out)[scenario];
0076 
0077     const auto& SiPixelBadFedChannels = it.second;
0078     for (const auto& entry : SiPixelBadFedChannels) {
0079       disabled_channelcollection.insert(entry.first, entry.second.data(), entry.second.size());
0080     }
0081   }
0082 
0083   return out;
0084 }
0085 
0086 //define this as a plug-in
0087 DEFINE_FWK_EVENTSETUP_MODULE(PixelFEDChannelCollectionProducer);