Go to the documentation of this file.00001
00013
00014 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
00015
00016
00017 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
00018 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00019 #include "RecoMuon/Records/interface/MuonRecoGeometryRecord.h"
00020 #include "RecoMuon/Navigation/interface/MuonNavigationSchool.h"
00021 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
00022
00023
00024 #include "FWCore/Framework/interface/EventSetup.h"
00025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00027
00028 #include "TrackingTools/DetLayers/interface/NavigationSetter.h"
00029
00030
00031 #include <map>
00032
00033 using namespace std;
00034 using namespace edm;
00035
00036
00037 MuonServiceProxy::MuonServiceProxy(const edm::ParameterSet& par):theTrackingGeometry(0),theMGField(0),theDetLayerGeometry(0),theEventSetup(0),theSchool(0){
00038
00039
00040 vector<string> noPropagators;
00041 vector<string> propagatorNames;
00042
00043 theMuonNavigationFlag = par.getUntrackedParameter<bool>("UseMuonNavigation",true);
00044 if(theMuonNavigationFlag) theRPCLayer = par.getParameter<bool>("RPCLayers");
00045 else theRPCLayer = true;
00046
00047 propagatorNames = par.getUntrackedParameter<vector<string> >("Propagators", noPropagators);
00048
00049 if(propagatorNames.empty())
00050 LogDebug("Muon|RecoMuon|MuonServiceProxy") << "NO propagator(s) selected!";
00051
00052 for(vector<string>::iterator propagatorName = propagatorNames.begin();
00053 propagatorName != propagatorNames.end(); ++propagatorName)
00054 thePropagators[ *propagatorName ] = ESHandle<Propagator>(0);
00055
00056 theCacheId_GTG = 0;
00057 theCacheId_MG = 0;
00058 theCacheId_DG = 0;
00059 theCacheId_P = 0;
00060 theChangeInTrackingComponentsRecord = false;
00061
00062 }
00063
00064
00065
00066 MuonServiceProxy::~MuonServiceProxy(){
00067
00068
00069
00070
00071
00072
00073
00074 thePropagators.clear();
00075 if(theSchool) delete theSchool;
00076 }
00077
00078
00079
00080
00081 void MuonServiceProxy::update(const edm::EventSetup& setup){
00082 const std::string metname = "Muon|RecoMuon|MuonServiceProxy";
00083
00084 theEventSetup = &setup;
00085
00086
00087 unsigned long long newCacheId_GTG = setup.get<GlobalTrackingGeometryRecord>().cacheIdentifier();
00088 if ( newCacheId_GTG != theCacheId_GTG ) {
00089 LogTrace(metname) << "GlobalTrackingGeometry changed!";
00090 theCacheId_GTG = newCacheId_GTG;
00091 setup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
00092 }
00093
00094
00095 unsigned long long newCacheId_MG = setup.get<IdealMagneticFieldRecord>().cacheIdentifier();
00096 if ( newCacheId_MG != theCacheId_MG ) {
00097 LogTrace(metname) << "Magnetic Field changed!";
00098 theCacheId_MG = newCacheId_MG;
00099 setup.get<IdealMagneticFieldRecord>().get(theMGField);
00100 }
00101
00102
00103 unsigned long long newCacheId_DG = setup.get<MuonRecoGeometryRecord>().cacheIdentifier();
00104 if ( newCacheId_DG != theCacheId_DG ) {
00105 LogTrace(metname) << "Muon Reco Geometry changed!";
00106 theCacheId_DG = newCacheId_DG;
00107 setup.get<MuonRecoGeometryRecord>().get(theDetLayerGeometry);
00108
00109
00110 if ( theMuonNavigationFlag ) {
00111 if(theSchool) delete theSchool;
00112 theSchool = new MuonNavigationSchool(&*theDetLayerGeometry,theRPCLayer);
00113 }
00114 }
00115
00116
00117 unsigned long long newCacheId_P = setup.get<TrackingComponentsRecord>().cacheIdentifier();
00118 if ( newCacheId_P != theCacheId_P ) {
00119 LogTrace(metname) << "Tracking Component changed!";
00120 theChangeInTrackingComponentsRecord = true;
00121 theCacheId_P = newCacheId_P;
00122 for(propagators::iterator prop = thePropagators.begin(); prop != thePropagators.end();
00123 ++prop)
00124 setup.get<TrackingComponentsRecord>().get( prop->first , prop->second );
00125 }
00126 else
00127 theChangeInTrackingComponentsRecord = false;
00128
00129 }
00130
00131
00132 ESHandle<Propagator> MuonServiceProxy::propagator(std::string propagatorName) const{
00133
00134 propagators::const_iterator prop = thePropagators.find(propagatorName);
00135
00136 if (prop == thePropagators.end()){
00137 LogError("Muon|RecoMuon|MuonServiceProxy")
00138 << "MuonServiceProxy: propagator with name: "<< propagatorName <<" not found! Please load it in the MuonServiceProxy.cff";
00139 return ESHandle<Propagator>(0);
00140 }
00141
00142 return prop->second;
00143 }
00144
00145
00146