Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:24

0001 // -*- C++ -*-
0002 //
0003 // Package:     RecoLocalTracker/SiPixelRecHits
0004 // Class  :     SiPixelTemplateStoreESProducer
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  Christopher Jones
0010 //         Created:  Tue, 08 Aug 2023 14:21:50 GMT
0011 //
0012 
0013 // system include files
0014 
0015 // user include files
0016 #include "FWCore/Framework/interface/ESProducer.h"
0017 #include "FWCore/Framework/interface/ModuleFactory.h"
0018 
0019 #include "CondFormats/SiPixelTransient/interface/SiPixelTemplate.h"
0020 #include "CondFormats/SiPixelObjects/interface/SiPixel2DTemplateDBObject.h"
0021 
0022 #include "CalibTracker/Records/interface/SiPixelTemplateDBObjectESProducerRcd.h"
0023 
0024 class SiPixelTemplateStoreESProducer : public edm::ESProducer {
0025 public:
0026   SiPixelTemplateStoreESProducer(edm::ParameterSet const&);
0027   static void fillDescriptions(edm::ConfigurationDescriptions&);
0028 
0029   std::unique_ptr<std::vector<SiPixelTemplateStore>> produce(const SiPixelTemplateDBObjectESProducerRcd&);
0030 
0031 private:
0032   edm::ESGetToken<SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd> token_;
0033 };
0034 
0035 //
0036 // constants, enums and typedefs
0037 //
0038 
0039 //
0040 // static data member definitions
0041 //
0042 
0043 //
0044 // constructors and destructor
0045 //
0046 SiPixelTemplateStoreESProducer::SiPixelTemplateStoreESProducer(edm::ParameterSet const& iPSet) {
0047   token_ = setWhatProduced(this).consumes();
0048 }
0049 
0050 //
0051 // member functions
0052 //
0053 std::unique_ptr<std::vector<SiPixelTemplateStore>> SiPixelTemplateStoreESProducer::produce(
0054     const SiPixelTemplateDBObjectESProducerRcd& iRecord) {
0055   auto returnValue = std::make_unique<std::vector<SiPixelTemplateStore>>();
0056 
0057   if (not SiPixelTemplate::pushfile(iRecord.get(token_), *returnValue)) {
0058     throw cms::Exception("SiPixelTemplateDBObjectFailure")
0059         << "Templates not filled correctly. Check the DB. Using SiPixelTemplateDBObject version "
0060         << iRecord.get(token_).version();
0061   }
0062 
0063   return returnValue;
0064 }
0065 
0066 //
0067 // const member functions
0068 //
0069 
0070 //
0071 // static member functions
0072 //
0073 void SiPixelTemplateStoreESProducer::fillDescriptions(edm::ConfigurationDescriptions& iDesc) {
0074   edm::ParameterSetDescription iPSet;
0075   iDesc.addDefault(iPSet);
0076   iDesc.add("SiPixelTemplateStoreESProducer", iPSet);
0077 }
0078 
0079 DEFINE_FWK_EVENTSETUP_MODULE(SiPixelTemplateStoreESProducer);
0080 ;