Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:30:15

0001 #include "DetectorDescription/Core/interface/DDCompactView.h"
0002 #include "FWCore/Framework/interface/ESProducer.h"
0003 #include "FWCore/Framework/interface/ESTransientHandle.h"
0004 #include "FWCore/Framework/interface/ModuleFactory.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "Geometry/HGCalCommonData/interface/FastTimeParameters.h"
0008 #include "Geometry/HGCalCommonData/interface/FastTimeParametersFromDD.h"
0009 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0010 
0011 //#define EDM_ML_DEBUG
0012 
0013 class FastTimeParametersESModule : public edm::ESProducer {
0014 public:
0015   FastTimeParametersESModule(const edm::ParameterSet&);
0016   ~FastTimeParametersESModule(void) override;
0017 
0018   using ReturnType = std::unique_ptr<FastTimeParameters>;
0019 
0020   static void fillDescriptions(edm::ConfigurationDescriptions&) {}
0021 
0022   ReturnType produce(const IdealGeometryRecord&);
0023 
0024 private:
0025   edm::ESGetToken<DDCompactView, IdealGeometryRecord> cpvToken_;
0026   std::vector<std::string> name_;
0027   std::vector<int> type_;
0028 };
0029 
0030 FastTimeParametersESModule::FastTimeParametersESModule(const edm::ParameterSet& iC)
0031     : cpvToken_{setWhatProduced(this).consumes<DDCompactView>(edm::ESInputTag{})} {
0032   name_ = iC.getUntrackedParameter<std::vector<std::string> >("Names");
0033   type_ = iC.getUntrackedParameter<std::vector<int> >("Types");
0034 #ifdef EDM_ML_DEBUG
0035   edm::LogVerbatim("HGCalGeom") << "FastTimeParametersESModule for " << name_.size() << " types:";
0036   for (unsigned int k = 0; k < name_.size(); ++k)
0037     edm::LogVerbatim("HGCalGeom") << " [" << k << "] " << name_[k] << ":" << type_[k];
0038 #endif
0039 }
0040 
0041 FastTimeParametersESModule::~FastTimeParametersESModule() {}
0042 
0043 FastTimeParametersESModule::ReturnType FastTimeParametersESModule::produce(const IdealGeometryRecord& iRecord) {
0044   edm::LogVerbatim("HGCalGeom") << "FastTimeParametersESModule::produce(const IdealGeometryRecord& iRecord)";
0045   edm::ESTransientHandle<DDCompactView> cpv = iRecord.getTransientHandle(cpvToken_);
0046 
0047   auto ptp = std::make_unique<FastTimeParameters>();
0048   FastTimeParametersFromDD builder;
0049   for (unsigned int k = 0; k < name_.size(); ++k)
0050     builder.build(cpv.product(), *ptp, name_[k], type_[k]);
0051 
0052 #ifdef EDM_ML_DEBUG
0053   edm::LogVerbatim("HGCalGeom") << "FastTimeParametersESModule:: Barrel Parameters: "
0054                                 << " number of cells along z|phi = " << ptp->nZBarrel_ << "|" << ptp->nPhiBarrel_
0055                                 << " Geometry parameters:";
0056   for (unsigned k = 0; k < ptp->geomParBarrel_.size(); ++k)
0057     edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << ptp->geomParBarrel_[k];
0058   edm::LogVerbatim("HGCalGeom") << "FastTimeParametersESModule:: Endcap Parameters: "
0059                                 << " number of cells along eta|phi = " << ptp->nEtaEndcap_ << "|" << ptp->nPhiEndcap_
0060                                 << " Geometry parameters:";
0061   for (unsigned k = 0; k < ptp->geomParEndcap_.size(); ++k)
0062     edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << ptp->geomParEndcap_[k];
0063 #endif
0064   return ptp;
0065 }
0066 
0067 // define this as a plug-in
0068 DEFINE_FWK_EVENTSETUP_MODULE(FastTimeParametersESModule);