CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Geometry/MuonNumbering/plugins/MuonNumberingInitialization.cc

Go to the documentation of this file.
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.3 2010/03/25 22:08:44 case 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 
00038 class MuonNumberingInitialization : public edm::ESProducer {
00039    public:
00040       MuonNumberingInitialization(const edm::ParameterSet&);
00041       ~MuonNumberingInitialization();
00042 
00043       typedef std::auto_ptr<MuonDDDConstants> ReturnType;
00044 
00045       ReturnType produce(const MuonNumberingRecord&);
00046 
00047       void initializeMuonDDDConstants( const IdealGeometryRecord& igr);
00048 
00049    private:
00050       std::string label_;
00051       MuonDDDConstants* muonDDDConst_;
00052 };
00053 
00054 MuonNumberingInitialization::MuonNumberingInitialization(const edm::ParameterSet& iConfig) : muonDDDConst_(0)
00055 {
00056   //  std::cout <<"constructing MuonNumberingInitialization" << std::endl;
00057   setWhatProduced(this, dependsOn(&MuonNumberingInitialization::initializeMuonDDDConstants));
00058 }
00059 
00060 
00061 MuonNumberingInitialization::~MuonNumberingInitialization()
00062 {  }
00063 
00064 
00065 // ------------ method called to produce the data  ------------
00066 MuonNumberingInitialization::ReturnType
00067 MuonNumberingInitialization::produce(const MuonNumberingRecord& iRecord)
00068 {
00069   //   std::cout << "in MuonNumberingInitialization::produce" << std::endl;
00070    using namespace edm::es;
00071    if ( muonDDDConst_ == 0 ) {
00072      std::cerr << "MuonNumberingInitialization::produceMuonDDDConstants has NOT been initialized!" << std::endl;
00073      throw;
00074    }
00075    return std::auto_ptr<MuonDDDConstants> (muonDDDConst_) ;
00076 }
00077 
00078 void MuonNumberingInitialization::initializeMuonDDDConstants( const IdealGeometryRecord& igr ) {
00079 
00080    edm::ESTransientHandle<DDCompactView> pDD;
00081    igr.get(label_, pDD );
00082    //   std::cout << "in MuonNumberingInitialization::initializeMuonDDDConstants" << std::endl;
00083    if ( muonDDDConst_ != 0 ) {
00084      delete muonDDDConst_;
00085    }
00086    //    std::cout << "about to make my new muonDDDConst_" << std::endl;
00087    muonDDDConst_ = new MuonDDDConstants( *pDD );
00088 }
00089 
00090 //define this as a plug-in
00091 DEFINE_FWK_EVENTSETUP_MODULE(MuonNumberingInitialization);