CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/Fireworks/Geometry/plugins/DumpSimGeometry.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    DumpSimGeometry
00004 // Class:      DumpSimGeometry
00005 // 
00013 //
00014 // Original Author:  Chris D Jones
00015 //         Created:  Wed Sep 26 08:27:23 EDT 2007
00016 // $Id: DumpSimGeometry.cc,v 1.2 2010/08/24 16:49:50 matevz Exp $
00017 //
00018 //
00019 
00020 // system include files
00021 #include <memory>
00022 #include <iostream>
00023 
00024 // user include files
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDAnalyzer.h"
00027 
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030 
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032 
00033 #include "FWCore/Framework/interface/ESHandle.h"
00034 #include "FWCore/Framework/interface/EventSetup.h"
00035 #include "FWCore/Framework/interface/ESTransientHandle.h"
00036 
00037 #include "Fireworks/Geometry/interface/DisplayGeomRecord.h"
00038 
00039 #include "TGeoManager.h"
00040 #include "TGeoMatrix.h"
00041 
00042 #include "TFile.h"
00043 #include "TError.h"
00044 
00045 //
00046 // class declaration
00047 //
00048 
00049 class DumpSimGeometry : public edm::EDAnalyzer
00050 {
00051 public:
00052   explicit DumpSimGeometry(const edm::ParameterSet&);
00053   ~DumpSimGeometry();
00054 
00055 private:
00056   // virtual void beginJob();
00057   // virtual void endJob();
00058 
00059   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00060 };
00061 
00062 
00063 //
00064 // constructors and destructor
00065 //
00066 DumpSimGeometry::DumpSimGeometry(const edm::ParameterSet&)
00067 {
00068    // now do what ever initialization is needed
00069 }
00070 
00071 
00072 DumpSimGeometry::~DumpSimGeometry()
00073 {
00074    // do anything here that needs to be done at desctruction time
00075    // (e.g. close files, deallocate resources etc.)
00076 }
00077 
00078 
00079 // ------------ method called to for each event  ------------
00080 void
00081 DumpSimGeometry::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00082 {
00083    std::cout << "In the DumpSimGeometry::analyze method..." << std::endl;
00084    using namespace edm;
00085 
00086    ESTransientHandle<TGeoManager> geoh;
00087    iSetup.get<DisplayGeomRecord>().get(geoh);
00088    TGeoManager *geom = const_cast<TGeoManager*>(geoh.product());
00089 
00090    int level = 1 + geom->GetTopVolume()->CountNodes(100, 3);
00091 
00092    std::cout << "In the DumpSimGeometry::analyze method...obtained main geometry, level="
00093              << level << std::endl;
00094    
00095    TFile f(TString::Format("cmsSimGeom-%d.root", level), "RECREATE");
00096    f.WriteTObject(geom);
00097    f.Close();
00098 }
00099 
00100 //define this as a plug-in
00101 DEFINE_FWK_MODULE(DumpSimGeometry);