File indexing completed on 2023-03-17 11:01:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021 #include <iostream>
0022
0023
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0026
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031
0032 #include "FWCore/Framework/interface/ESHandle.h"
0033 #include "FWCore/Framework/interface/EventSetup.h"
0034 #include "FWCore/Framework/interface/ESTransientHandle.h"
0035
0036 #include "Fireworks/Geometry/interface/DisplayGeomRecord.h"
0037
0038 #include "TGeoManager.h"
0039 #include "TGeoMatrix.h"
0040
0041 #include "TFile.h"
0042 #include "TError.h"
0043 #include "TSystem.h"
0044
0045
0046
0047
0048
0049 class DumpSimGeometry : public edm::one::EDAnalyzer<> {
0050 public:
0051 explicit DumpSimGeometry(const edm::ParameterSet&);
0052 ~DumpSimGeometry() override;
0053
0054 private:
0055 void analyze(const edm::Event&, const edm::EventSetup&) override;
0056
0057 std::string m_tag;
0058 std::string m_outputFileName;
0059 const edm::ESGetToken<TGeoManager, DisplayGeomRecord> m_geomToken;
0060 };
0061
0062
0063
0064
0065 DumpSimGeometry::DumpSimGeometry(const edm::ParameterSet& ps) : m_geomToken(esConsumes()) {
0066 m_tag = ps.getUntrackedParameter<std::string>("tag", "unknown");
0067 m_outputFileName = ps.getUntrackedParameter<std::string>("outputFileName", "cmsSimGeom.root");
0068 }
0069
0070 DumpSimGeometry::~DumpSimGeometry() {
0071
0072
0073 }
0074
0075
0076 void DumpSimGeometry::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0077 std::cout << "In the DumpSimGeometry::analyze method..." << std::endl;
0078 using namespace edm;
0079
0080 ESTransientHandle<TGeoManager> geoh = iSetup.getTransientHandle(m_geomToken);
0081 const TGeoManager* geom = geoh.product();
0082
0083 int level = 1 + geom->GetTopVolume()->CountNodes(100, 3);
0084
0085 std::cout << "In the DumpSimGeometry::analyze method...obtained main geometry, level=" << level << std::endl;
0086
0087
0088 TFile f(m_outputFileName.c_str(), "RECREATE");
0089 f.WriteTObject(geom);
0090 f.WriteTObject(new TNamed("CMSSW_VERSION", gSystem->Getenv("CMSSW_VERSION")));
0091 f.WriteTObject(new TNamed("tag", m_tag.c_str()));
0092 f.Close();
0093 }
0094
0095
0096 DEFINE_FWK_MODULE(DumpSimGeometry);