Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-13 23:27:37

0001 #include <memory>
0002 #include <string>
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "FWCore/Framework/interface/ModuleFactory.h"
0005 #include "FWCore/Framework/interface/ESProducer.h"
0006 #include "FWCore/Framework/interface/ESProductHost.h"
0007 #include "FWCore/Framework/interface/ESHandle.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "CondFormats/DataRecord/interface/EcalCATIAGainRatiosRcd.h"
0010 #include "CondFormats/EcalObjects/interface/EcalCATIAGainRatios.h"
0011 #include "DataFormats/EcalDigi/interface/EcalConstants.h"
0012 //
0013 // class declaration
0014 //
0015 const int kEBChannels = ecalPh2::kEBChannels;
0016 
0017 class EcalCATIAGainRatiosESProducer : public edm::ESProducer {
0018 public:
0019   EcalCATIAGainRatiosESProducer(const edm::ParameterSet& p);
0020 
0021   typedef std::unique_ptr<EcalCATIAGainRatios> ReturnType;
0022 
0023   ReturnType produce(const EcalCATIAGainRatiosRcd& iRecord);
0024 
0025 private:
0026   double catiaGainRatio_;
0027 };
0028 
0029 using namespace edm;
0030 
0031 EcalCATIAGainRatiosESProducer::EcalCATIAGainRatiosESProducer(const edm::ParameterSet& p) {
0032   std::string myname = p.getParameter<std::string>("ComponentName");
0033   catiaGainRatio_ = p.getParameter<double>("CATIAGainRatio");
0034   setWhatProduced(this);
0035 }
0036 ////
0037 EcalCATIAGainRatiosESProducer::ReturnType EcalCATIAGainRatiosESProducer::produce(const EcalCATIAGainRatiosRcd& iRecord) {
0038   auto prod = std::make_unique<EcalCATIAGainRatios>();
0039   for (int iChannel = 0; iChannel < kEBChannels; iChannel++) {
0040     EBDetId myEBDetId = EBDetId::unhashIndex(iChannel);
0041     double val = catiaGainRatio_;
0042     prod->setValue(myEBDetId.rawId(), val);
0043   }
0044 
0045   return prod;
0046 }
0047 
0048 //Define this as a plug-in
0049 DEFINE_FWK_EVENTSETUP_MODULE(EcalCATIAGainRatiosESProducer);