Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include <memory>
0002 
0003 #include "CalibTracker/SiPixelESProducers/interface/SiPixelROCsStatusAndMappingWrapper.h"
0004 #include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h"
0005 #include "CondFormats/DataRecord/interface/SiPixelQualityRcd.h"
0006 #include "FWCore/Framework/interface/ESProducer.h"
0007 #include "FWCore/Framework/interface/ESTransientHandle.h"
0008 #include "FWCore/Framework/interface/EventSetup.h"
0009 #include "FWCore/Framework/interface/ModuleFactory.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0012 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0013 #include "RecoTracker/Record/interface/CkfComponentsRecord.h"  // TODO: eventually use something more limited
0014 
0015 class SiPixelROCsStatusAndMappingWrapperESProducer : public edm::ESProducer {
0016 public:
0017   explicit SiPixelROCsStatusAndMappingWrapperESProducer(const edm::ParameterSet& iConfig);
0018   std::unique_ptr<SiPixelROCsStatusAndMappingWrapper> produce(const CkfComponentsRecord& iRecord);
0019 
0020   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0021 
0022 private:
0023   edm::ESGetToken<SiPixelFedCablingMap, SiPixelFedCablingMapRcd> cablingMapToken_;
0024   edm::ESGetToken<SiPixelQuality, SiPixelQualityRcd> qualityToken_;
0025   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geometryToken_;
0026   bool useQuality_;
0027 };
0028 
0029 SiPixelROCsStatusAndMappingWrapperESProducer::SiPixelROCsStatusAndMappingWrapperESProducer(
0030     const edm::ParameterSet& iConfig)
0031     : useQuality_(iConfig.getParameter<bool>("UseQualityInfo")) {
0032   auto const& component = iConfig.getParameter<std::string>("ComponentName");
0033   auto cc = setWhatProduced(this, component);
0034   cablingMapToken_ = cc.consumes(edm::ESInputTag{"", iConfig.getParameter<std::string>("CablingMapLabel")});
0035   if (useQuality_) {
0036     qualityToken_ = cc.consumes();
0037   }
0038   geometryToken_ = cc.consumes();
0039 }
0040 
0041 void SiPixelROCsStatusAndMappingWrapperESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0042   edm::ParameterSetDescription desc;
0043   desc.add<std::string>("ComponentName", "");
0044   desc.add<std::string>("CablingMapLabel", "")->setComment("CablingMap label");
0045   desc.add<bool>("UseQualityInfo", false);
0046   descriptions.addWithDefaultLabel(desc);
0047 }
0048 
0049 std::unique_ptr<SiPixelROCsStatusAndMappingWrapper> SiPixelROCsStatusAndMappingWrapperESProducer::produce(
0050     const CkfComponentsRecord& iRecord) {
0051   auto cablingMap = iRecord.getTransientHandle(cablingMapToken_);
0052 
0053   const SiPixelQuality* quality = nullptr;
0054   if (useQuality_) {
0055     auto qualityInfo = iRecord.getTransientHandle(qualityToken_);
0056     quality = qualityInfo.product();
0057   }
0058 
0059   auto geom = iRecord.getTransientHandle(geometryToken_);
0060 
0061   return std::make_unique<SiPixelROCsStatusAndMappingWrapper>(*cablingMap, *geom, quality);
0062 }
0063 
0064 #include "FWCore/Framework/interface/MakerMacros.h"
0065 #include "FWCore/Utilities/interface/typelookup.h"
0066 #include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"
0067 
0068 DEFINE_FWK_EVENTSETUP_MODULE(SiPixelROCsStatusAndMappingWrapperESProducer);