File indexing completed on 2024-04-06 12:11:47
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/ESHandle.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "Fireworks/Geometry/interface/FWTGeoRecoGeometry.h"
0007 #include "Fireworks/Geometry/interface/FWTGeoRecoGeometryRecord.h"
0008
0009 #include "TGeoManager.h"
0010 #include "TFile.h"
0011 #include "TTree.h"
0012 #include "TError.h"
0013 #include "TSystem.h"
0014
0015 class DumpFWTGeoRecoGeometry : public edm::one::EDAnalyzer<> {
0016 public:
0017 explicit DumpFWTGeoRecoGeometry(const edm::ParameterSet& config);
0018 ~DumpFWTGeoRecoGeometry(void) override {}
0019
0020 private:
0021 void analyze(const edm::Event& event, const edm::EventSetup& eventSetup) override;
0022 void beginJob(void) override;
0023 void endJob(void) override;
0024
0025 std::string m_tag;
0026 std::string m_outputFileName;
0027 const edm::ESGetToken<FWTGeoRecoGeometry, FWTGeoRecoGeometryRecord> m_geomToken;
0028 };
0029
0030 DumpFWTGeoRecoGeometry::DumpFWTGeoRecoGeometry(const edm::ParameterSet& config)
0031 : m_tag(config.getUntrackedParameter<std::string>("tagInfo", "unknown")),
0032 m_outputFileName(config.getUntrackedParameter<std::string>("outputFileName", "cmsTGeoReco.root")),
0033 m_geomToken(esConsumes()) {}
0034
0035 void DumpFWTGeoRecoGeometry::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) {
0036 using namespace edm;
0037
0038 ESTransientHandle<FWTGeoRecoGeometry> geoh = eventSetup.getTransientHandle(m_geomToken);
0039 TGeoManager* geom = geoh.product()->manager();
0040
0041 TFile file(m_outputFileName.c_str(), "RECREATE");
0042 file.WriteTObject(&*geom);
0043 file.WriteTObject(new TNamed("CMSSW_VERSION", gSystem->Getenv("CMSSW_VERSION")));
0044 file.WriteTObject(new TNamed("tag", m_tag.c_str()));
0045 file.Close();
0046 }
0047
0048 void DumpFWTGeoRecoGeometry::beginJob(void) {}
0049
0050 void DumpFWTGeoRecoGeometry::endJob(void) {}
0051
0052 DEFINE_FWK_MODULE(DumpFWTGeoRecoGeometry);