Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0002 #include "FWCore/Framework/interface/MakerMacros.h"
0003 #include "FWCore/Framework/interface/ESTransientHandle.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "Geometry/Records/interface/DDSpecParRegistryRcd.h"
0007 #include <DD4hep/SpecParRegistry.h>
0008 
0009 #include <iostream>
0010 
0011 using namespace std;
0012 using namespace cms;
0013 using namespace edm;
0014 
0015 class DDTestSpecPars : public global::EDAnalyzer<> {
0016 public:
0017   explicit DDTestSpecPars(const ParameterSet& iConfig)
0018       : m_tag(iConfig.getParameter<ESInputTag>("DDDetector")), m_token(esConsumes(m_tag)) {}
0019 
0020   void beginJob() override {}
0021   void analyze(StreamID, Event const& iEvent, EventSetup const&) const override;
0022   void endJob() override {}
0023 
0024 private:
0025   const ESInputTag m_tag;
0026   const ESGetToken<dd4hep::SpecParRegistry, DDSpecParRegistryRcd> m_token;
0027 };
0028 
0029 void DDTestSpecPars::analyze(StreamID, const Event&, const EventSetup& iEventSetup) const {
0030   ESTransientHandle<dd4hep::SpecParRegistry> registry = iEventSetup.getTransientHandle(m_token);
0031 
0032   LogVerbatim("Geometry").log([&registry, this](auto& log) {
0033     log << "DDTestSpecPars::analyze: " << m_tag;
0034     log << "DD SpecPar Registry size: " << registry->specpars.size();
0035     for (const auto& i : registry->specpars) {
0036       log << " " << i.first << " =>";
0037       log << "\npaths:\n";
0038       for (const auto& k : i.second.paths)
0039         log << k << ", ";
0040       log << "\nstring parameters:\n";
0041       for (const auto& l : i.second.spars) {
0042         log << l.first << " == " << i.second.strValue(l.first) << " = ";
0043         for (const auto& il : l.second) {
0044           log << il << ", ";
0045         }
0046       }
0047       log << "\nnumeric parameters\n";
0048       for (const auto& m : i.second.numpars) {
0049         log << m.first << " => ";
0050         for (const auto& im : m.second) {
0051           log << im << ", ";
0052         }
0053       }
0054       log << '\n';
0055     }
0056   });
0057 }
0058 
0059 DEFINE_FWK_MODULE(DDTestSpecPars);