Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "FWCore/Framework/interface/one/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/IdealGeometryRecord.h"
0007 #include "DetectorDescription/DDCMS/interface/DDDetector.h"
0008 #include "DD4hep/Detector.h"
0009 #include "DD4hep/DD4hepRootPersistency.h"
0010 
0011 #include "TGeoManager.h"
0012 #include "TFile.h"
0013 #include "TSystem.h"
0014 
0015 #include <iostream>
0016 #include <string>
0017 
0018 using namespace std;
0019 using namespace cms;
0020 using namespace edm;
0021 
0022 class DDTestDumpGeometry : public one::EDAnalyzer<> {
0023 public:
0024   explicit DDTestDumpGeometry(const ParameterSet&);
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_token;
0033 };
0034 
0035 DDTestDumpGeometry::DDTestDumpGeometry(const ParameterSet& iConfig)
0036     : m_tag(iConfig.getParameter<ESInputTag>("DDDetector")), m_token(esConsumes(m_tag)) {}
0037 
0038 void DDTestDumpGeometry::analyze(const Event&, const EventSetup& iEventSetup) {
0039   LogVerbatim("Geometry") << "DDTestDumpGeometry::analyze: " << m_tag;
0040   ESTransientHandle<DDDetector> det = iEventSetup.getTransientHandle(m_token);
0041 
0042   TGeoManager const& geom = det->manager();
0043 
0044   TGeoIterator next(geom.GetTopVolume());
0045   TGeoNode* node;
0046   TString path;
0047   while ((node = next())) {
0048     next.GetPath(path);
0049     path.ReplaceAll("xml-memory-buffer:", "");  // Remove artifact of DB reading
0050     TString nodeName(node->GetVolume()->GetName());
0051     nodeName.ReplaceAll("xml-memory-buffer:", "");  // Remove artifact of DB reading
0052     LogVerbatim("DumpGeometry") << path << ": " << nodeName;
0053   }
0054 }
0055 
0056 DEFINE_FWK_MODULE(DDTestDumpGeometry);