Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-15 01:25:12

0001 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0002 #include "FWCore/ParameterSet/interface/FileInPath.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "FWCore/Framework/interface/MakerMacros.h"
0005 #include "FWCore/Framework/interface/ESTransientHandle.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0009 #include "DetectorDescription/DDCMS/interface/DDDetector.h"
0010 #include "Geometry/Records/interface/DDVectorRegistryRcd.h"
0011 #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h"
0012 #include "DD4hep/Detector.h"
0013 
0014 #include <memory>
0015 #include <string>
0016 
0017 using namespace std;
0018 using namespace cms;
0019 using namespace edm;
0020 using namespace dd4hep;
0021 
0022 class DDCMSDetector : public one::EDAnalyzer<> {
0023 public:
0024   explicit DDCMSDetector(const ParameterSet& p);
0025 
0026   void beginJob() override {}
0027   void analyze(Event const& iEvent, EventSetup const&) override;
0028   void endJob() override;
0029 
0030 private:
0031   const ESInputTag m_tag;
0032   const ESGetToken<DDDetector, IdealGeometryRecord> m_detectorToken;
0033   const ESGetToken<DDVectorRegistry, DDVectorRegistryRcd> m_registryToken;
0034 };
0035 
0036 DDCMSDetector::DDCMSDetector(const ParameterSet& iConfig)
0037     : m_tag(iConfig.getParameter<ESInputTag>("DDDetector")),
0038       m_detectorToken(esConsumes(m_tag)),
0039       m_registryToken(esConsumes(m_tag)) {}
0040 
0041 void DDCMSDetector::analyze(const Event&, const EventSetup& iEventSetup) {
0042   ESTransientHandle<DDDetector> det = iEventSetup.getTransientHandle(m_detectorToken);
0043 
0044   LogVerbatim("Geometry") << "Iterate over the detectors:\n";
0045   LogVerbatim("Geometry").log([&](auto& log) {
0046     for (auto const& it : det->description()->detectors()) {
0047       dd4hep::DetElement det(it.second);
0048       log << it.first << ": " << det.path();
0049     }
0050   });
0051   LogVerbatim("Geometry") << "..done!";
0052 
0053   ESTransientHandle<DDVectorRegistry> registry = iEventSetup.getTransientHandle(m_registryToken);
0054 
0055   LogVerbatim("Geometry") << "DD Vector Registry size: " << registry->vectors.size();
0056   LogVerbatim("Geometry").log([&](auto& log) {
0057     for (const auto& p : registry->vectors) {
0058       log << " " << p.first << " => ";
0059       for (const auto& i : p.second)
0060         log << i << ", ";
0061       log << '\n';
0062     }
0063   });
0064 }
0065 
0066 void DDCMSDetector::endJob() {}
0067 
0068 DEFINE_FWK_MODULE(DDCMSDetector);