00001 // -*- C++ -*- 00002 // 00003 // Package: MuonNumberingInitialization 00004 // Class: MuonNumberingInitialization 00005 // 00013 // 00014 // Original Author: Michael Case 00015 // Created: Thu Sep 28 16:40:29 PDT 2006 00016 // $Id: MuonNumberingInitialization.cc,v 1.4 2012/10/18 12:47:41 sunanda Exp $ 00017 // 00018 // 00019 00020 00021 // system include files 00022 #include <memory> 00023 #include <boost/shared_ptr.hpp> 00024 00025 // user include files 00026 #include <FWCore/Framework/interface/ModuleFactory.h> 00027 #include <FWCore/Framework/interface/ESProducer.h> 00028 #include <FWCore/Framework/interface/ESTransientHandle.h> 00029 //#include <FWCore/MessageLogger/interface/MessageLogger.h> 00030 00031 #include <DetectorDescription/Core/interface/DDFilter.h> 00032 #include <DetectorDescription/Core/interface/DDFilteredView.h> 00033 #include <DetectorDescription/Core/interface/DDsvalues.h> 00034 #include <Geometry/MuonNumbering/interface/MuonDDDConstants.h> 00035 #include <Geometry/Records/interface/MuonNumberingRecord.h> 00036 00037 #define LOCAL_DEBUG 00038 00039 class MuonNumberingInitialization : public edm::ESProducer { 00040 public: 00041 MuonNumberingInitialization(const edm::ParameterSet&); 00042 ~MuonNumberingInitialization(); 00043 00044 typedef std::auto_ptr<MuonDDDConstants> ReturnType; 00045 00046 ReturnType produce(const MuonNumberingRecord&); 00047 00048 void initializeMuonDDDConstants( const IdealGeometryRecord& igr); 00049 00050 private: 00051 std::string label_; 00052 MuonDDDConstants* muonDDDConst_; 00053 }; 00054 00055 MuonNumberingInitialization::MuonNumberingInitialization(const edm::ParameterSet& iConfig) : muonDDDConst_(0) 00056 { 00057 // std::cout <<"constructing MuonNumberingInitialization" << std::endl; 00058 setWhatProduced(this, dependsOn(&MuonNumberingInitialization::initializeMuonDDDConstants)); 00059 } 00060 00061 00062 MuonNumberingInitialization::~MuonNumberingInitialization() 00063 { } 00064 00065 00066 // ------------ method called to produce the data ------------ 00067 MuonNumberingInitialization::ReturnType 00068 MuonNumberingInitialization::produce(const MuonNumberingRecord& iRecord) 00069 { 00070 #ifdef LOCAL_DEBUG 00071 std::cout << "in MuonNumberingInitialization::produce" << std::endl; 00072 #endif 00073 using namespace edm::es; 00074 if ( muonDDDConst_ == 0 ) { 00075 std::cerr << "MuonNumberingInitialization::produceMuonDDDConstants has NOT been initialized!" << std::endl; 00076 throw; 00077 } 00078 return std::auto_ptr<MuonDDDConstants> (muonDDDConst_) ; 00079 } 00080 00081 void MuonNumberingInitialization::initializeMuonDDDConstants( const IdealGeometryRecord& igr ) { 00082 00083 edm::ESTransientHandle<DDCompactView> pDD; 00084 igr.get(label_, pDD ); 00085 #ifdef LOCAL_DEBUG 00086 std::cout << "in MuonNumberingInitialization::initializeMuonDDDConstants" << std::endl; 00087 #endif 00088 if ( muonDDDConst_ != 0 ) { 00089 delete muonDDDConst_; 00090 } 00091 #ifdef LOCAL_DEBUG 00092 std::cout << "about to make my new muonDDDConst_" << std::endl; 00093 #endif 00094 muonDDDConst_ = new MuonDDDConstants( *pDD ); 00095 } 00096 00097 //define this as a plug-in 00098 DEFINE_FWK_EVENTSETUP_MODULE(MuonNumberingInitialization);