Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    DetectorDescription/DDCMS
0004 // Class:      DDVectorRegistryESProducer
0005 //
0006 /**\class DDVectorRegistryESProducer
0007 
0008  Description: Produce Vector registry
0009 
0010  Implementation:
0011      Vectors are defined in XML
0012 */
0013 //
0014 // Original Author:  Ianna Osborne
0015 //         Created:  Fri, 07 Dec 2018 11:20:52 GMT
0016 //
0017 //
0018 
0019 #include <memory>
0020 
0021 #include "FWCore/Framework/interface/ModuleFactory.h"
0022 #include "FWCore/Framework/interface/ESProducer.h"
0023 #include "FWCore/Framework/interface/ESHandle.h"
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025 
0026 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0027 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0028 #include "Geometry/Records/interface/DDVectorRegistryRcd.h"
0029 #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h"
0030 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0031 #include "DetectorDescription/DDCMS/interface/DDDetector.h"
0032 #include "DD4hep/Detector.h"
0033 
0034 #include <unordered_map>
0035 #include <vector>
0036 
0037 using namespace std;
0038 using namespace cms;
0039 using namespace edm;
0040 
0041 using DDVectorsMap = std::unordered_map<std::string, std::vector<double>>;
0042 
0043 class DDVectorRegistryESProducer : public edm::ESProducer {
0044 public:
0045   DDVectorRegistryESProducer(const edm::ParameterSet&);
0046   ~DDVectorRegistryESProducer() override;
0047 
0048   using ReturnType = unique_ptr<DDVectorRegistry>;
0049 
0050   static void fillDescriptions(edm::ConfigurationDescriptions&);
0051 
0052   ReturnType produce(const DDVectorRegistryRcd&);
0053 
0054 private:
0055   const edm::ESGetToken<DDDetector, IdealGeometryRecord> m_token;
0056 };
0057 
0058 DDVectorRegistryESProducer::DDVectorRegistryESProducer(const edm::ParameterSet& iConfig)
0059     : m_token(setWhatProduced(this).consumes(edm::ESInputTag("", iConfig.getParameter<string>("appendToDataLabel")))) {}
0060 
0061 DDVectorRegistryESProducer::~DDVectorRegistryESProducer() {}
0062 
0063 void DDVectorRegistryESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0064   edm::ParameterSetDescription desc;
0065   descriptions.addDefault(desc);
0066 }
0067 
0068 DDVectorRegistryESProducer::ReturnType DDVectorRegistryESProducer::produce(const DDVectorRegistryRcd& iRecord) {
0069   LogDebug("Geometry") << "DDVectorRegistryESProducer::produce\n";
0070   const auto& registry = iRecord.get(m_token).vectors();
0071 
0072   auto product = std::make_unique<DDVectorRegistry>();
0073   product->vectors.insert(registry.begin(), registry.end());
0074   return product;
0075 }
0076 
0077 DEFINE_FWK_EVENTSETUP_MODULE(DDVectorRegistryESProducer);