Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:27

0001 #include <memory>
0002 #include <string>
0003 #include "FWCore/Framework/interface/ModuleFactory.h"
0004 #include "FWCore/Framework/interface/ESProducer.h"
0005 #include "FWCore/Framework/interface/ESProductHost.h"
0006 #include "FWCore/Framework/interface/ESHandle.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "CondFormats/DataRecord/interface/EcalLiteDTUPedestalsRcd.h"
0009 #include "CondFormats/EcalObjects/interface/EcalLiteDTUPedestals.h"
0010 #include "DataFormats/EcalDigi/interface/EcalConstants.h"
0011 
0012 //
0013 // class declaration
0014 //
0015 
0016 class EcalLiteDTUPedestalsESProducer : public edm::ESProducer {
0017 public:
0018   EcalLiteDTUPedestalsESProducer(const edm::ParameterSet& p);
0019 
0020   typedef std::unique_ptr<EcalLiteDTUPedestalsMap> ReturnType;
0021 
0022   ReturnType produce(const EcalLiteDTUPedestalsRcd& iRecord);
0023 
0024 private:
0025   double meanPedestalsGain10_;
0026   double rmsPedestalsGain10_;
0027   double meanPedestalsGain1_;
0028   double rmsPedestalsGain1_;
0029 };
0030 
0031 using namespace edm;
0032 
0033 EcalLiteDTUPedestalsESProducer::EcalLiteDTUPedestalsESProducer(const edm::ParameterSet& p) {
0034   std::string myname = p.getParameter<std::string>("ComponentName");
0035   meanPedestalsGain10_ = p.getParameter<double>("MeanPedestalsGain10");
0036   rmsPedestalsGain10_ = p.getParameter<double>("RMSPedestalsGain10");
0037   meanPedestalsGain1_ = p.getParameter<double>("MeanPedestalsGain1");
0038   rmsPedestalsGain1_ = p.getParameter<double>("RMSPedestalsGain1");
0039   setWhatProduced(this);
0040 }
0041 ////
0042 EcalLiteDTUPedestalsESProducer::ReturnType EcalLiteDTUPedestalsESProducer::produce(
0043     const EcalLiteDTUPedestalsRcd& iRecord) {
0044   auto prod = std::make_unique<EcalLiteDTUPedestalsMap>();
0045 
0046   for (unsigned int iChannel = 0; iChannel < ecalPh2::kEBChannels; iChannel++) {
0047     EBDetId myEBDetId = EBDetId::unhashIndex(iChannel);
0048     EcalLiteDTUPedestals ped;
0049     ped.setMean(0, meanPedestalsGain10_);
0050     ped.setRMS(0, rmsPedestalsGain10_);
0051 
0052     ped.setMean(1, meanPedestalsGain1_);
0053     ped.setRMS(1, rmsPedestalsGain1_);
0054 
0055     prod->insert(std::make_pair(myEBDetId, ped));
0056   }
0057 
0058   return prod;
0059 }
0060 
0061 //Define this as a plug-in
0062 DEFINE_FWK_EVENTSETUP_MODULE(EcalLiteDTUPedestalsESProducer);