Go to the documentation of this file.00001 #include "FWCore/Framework/interface/EDAnalyzer.h"
00002 #include "FWCore/Framework/interface/MakerMacros.h"
00003 #include "FWCore/Framework/interface/ESTransientHandle.h"
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005 #include "FWCore/Framework/interface/EventSetup.h"
00006 #include "Fireworks/Geometry/interface/FWRecoGeometry.h"
00007 #include "Fireworks/Geometry/interface/FWRecoGeometryRecord.h"
00008
00009 #include "TFile.h"
00010 #include "TTree.h"
00011 #include "TError.h"
00012
00013 class DumpFWRecoGeometry : public edm::EDAnalyzer
00014 {
00015 public:
00016 explicit DumpFWRecoGeometry( const edm::ParameterSet& config );
00017 virtual ~DumpFWRecoGeometry( void ) {}
00018
00019 private:
00020 virtual void analyze( const edm::Event& event, const edm::EventSetup& eventSetup );
00021 virtual void beginJob( void );
00022 virtual void endJob( void );
00023
00024 int m_level;
00025 };
00026
00027 DumpFWRecoGeometry::DumpFWRecoGeometry( const edm::ParameterSet& config )
00028 : m_level( config.getUntrackedParameter<int>( "level", 1 ))
00029 {}
00030
00031 void
00032 DumpFWRecoGeometry::analyze( const edm::Event& event, const edm::EventSetup& eventSetup )
00033 {
00034 using namespace edm;
00035
00036 ESTransientHandle<FWRecoGeometry> geoh;
00037 eventSetup.get<FWRecoGeometryRecord>().get( geoh );
00038
00039 std::stringstream s;
00040 s << "cmsRecoGeom" << m_level << ".root";
00041 TFile file( s.str().c_str(), "RECREATE" );
00042
00043 TTree *tree = new TTree( "idToGeo", "Raw detector id association with geometry" );
00044 UInt_t v_id;
00045 Float_t v_vertex[24];
00046 Float_t v_params[9];
00047 Float_t v_shape[5];
00048 Float_t v_translation[3];
00049 Float_t v_matrix[9];
00050
00051 tree->SetBranchStyle( 0 );
00052 tree->Branch( "id", &v_id, "id/i" );
00053 tree->Branch( "points", &v_vertex, "points[24]/F" );
00054 tree->Branch( "topology", &v_params, "topology[9]/F" );
00055 tree->Branch( "shape", &v_shape, "shape[5]/F" );
00056 tree->Branch( "translation", &v_translation, "translation[3]/F" );
00057 tree->Branch( "matrix", &v_matrix, "matrix[9]/F" );
00058
00059 for( FWRecoGeom::InfoMapItr it = geoh.product()->idToName.begin(),
00060 end = geoh.product()->idToName.end();
00061 it != end; ++it )
00062 {
00063 v_id = it->id;
00064 for( unsigned int i = 0; i < 24; ++i )
00065 v_vertex[i] = it->points[i];
00066 for( unsigned int i = 0; i < 9; ++i )
00067 v_params[i] = it->topology[i];
00068 for( unsigned int i = 0; i < 5; ++i )
00069 v_shape[i] = it->shape[i];
00070 for( unsigned int i = 0; i < 3; ++i )
00071 v_translation[i] = it->translation[i];
00072 for( unsigned int i = 0; i < 9; ++i )
00073 v_matrix[i] = it->matrix[i];
00074 tree->Fill();
00075 }
00076 file.WriteTObject( tree );
00077 file.Close();
00078 }
00079
00080 void
00081 DumpFWRecoGeometry::beginJob( void )
00082 {}
00083
00084 void
00085 DumpFWRecoGeometry::endJob( void )
00086 {}
00087
00088 DEFINE_FWK_MODULE( DumpFWRecoGeometry );