CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonServiceProxy.cc
Go to the documentation of this file.
1 
13 // Class Header
15 
16 // Service Records
22 
23 // Framework Headers
27 
29 
30 // C++ Headers
31 #include <map>
32 
33 using namespace std;
34 using namespace edm;
35 
36 // Constructor
37 MuonServiceProxy::MuonServiceProxy(const edm::ParameterSet& par):theTrackingGeometry(0),theMGField(0),theDetLayerGeometry(0),theEventSetup(0),theSchool(0){
38 
39  // load the propagators map
40  vector<string> noPropagators;
41  vector<string> propagatorNames;
42 
43  theMuonNavigationFlag = par.getUntrackedParameter<bool>("UseMuonNavigation",true);
44  if(theMuonNavigationFlag) theRPCLayer = par.getParameter<bool>("RPCLayers");
45  else theRPCLayer = true;
46 
47  propagatorNames = par.getUntrackedParameter<vector<string> >("Propagators", noPropagators);
48 
49  if(propagatorNames.empty())
50  LogDebug("Muon|RecoMuon|MuonServiceProxy") << "NO propagator(s) selected!";
51 
52  for(vector<string>::iterator propagatorName = propagatorNames.begin();
53  propagatorName != propagatorNames.end(); ++propagatorName)
54  thePropagators[ *propagatorName ] = ESHandle<Propagator>(0);
55 
56  theCacheId_GTG = 0;
57  theCacheId_MG = 0;
58  theCacheId_DG = 0;
59  theCacheId_P = 0;
61 
62 }
63 
64 
65 // Destructor
67 
68  // FIXME: how do that?
69  // delete theTrackingGeometry;
70  // delete theMGField;
71  // delete theDetLayerGeometry;
72 
73  // FIXME: is it enough?
74  thePropagators.clear();
75  if(theSchool) delete theSchool;
76 }
77 
78 // Operations
79 
80 // update the services each event
82  const std::string metname = "Muon|RecoMuon|MuonServiceProxy";
83 
84  theEventSetup = &setup;
85 
86  // Global Tracking Geometry
87  unsigned long long newCacheId_GTG = setup.get<GlobalTrackingGeometryRecord>().cacheIdentifier();
88  if ( newCacheId_GTG != theCacheId_GTG ) {
89  LogTrace(metname) << "GlobalTrackingGeometry changed!";
90  theCacheId_GTG = newCacheId_GTG;
91  setup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
92  }
93 
94  // Magfield Field
95  unsigned long long newCacheId_MG = setup.get<IdealMagneticFieldRecord>().cacheIdentifier();
96  if ( newCacheId_MG != theCacheId_MG ) {
97  LogTrace(metname) << "Magnetic Field changed!";
98  theCacheId_MG = newCacheId_MG;
99  setup.get<IdealMagneticFieldRecord>().get(theMGField);
100  }
101 
102  // DetLayer Geometry
103  unsigned long long newCacheId_DG = setup.get<MuonRecoGeometryRecord>().cacheIdentifier();
104  if ( newCacheId_DG != theCacheId_DG ) {
105  LogTrace(metname) << "Muon Reco Geometry changed!";
106  theCacheId_DG = newCacheId_DG;
107  setup.get<MuonRecoGeometryRecord>().get(theDetLayerGeometry);
108  // MuonNavigationSchool should live until its validity expires, and then DELETE
109  // the NavigableLayers (this is implemented in MuonNavigationSchool's dtor)
110  if ( theMuonNavigationFlag ) {
111  if(theSchool) delete theSchool;
112  theSchool = new MuonNavigationSchool(&*theDetLayerGeometry,theRPCLayer);
113  }
114  }
115 
116  // Propagators
117  unsigned long long newCacheId_P = setup.get<TrackingComponentsRecord>().cacheIdentifier();
118  if ( newCacheId_P != theCacheId_P ) {
119  LogTrace(metname) << "Tracking Component changed!";
120  theChangeInTrackingComponentsRecord = true;
121  theCacheId_P = newCacheId_P;
122  for(propagators::iterator prop = thePropagators.begin(); prop != thePropagators.end();
123  ++prop)
124  setup.get<TrackingComponentsRecord>().get( prop->first , prop->second );
125  }
126  else
127  theChangeInTrackingComponentsRecord = false;
128 
129 }
130 
131 // get the propagator
132 ESHandle<Propagator> MuonServiceProxy::propagator(std::string propagatorName) const{
133 
134  propagators::const_iterator prop = thePropagators.find(propagatorName);
135 
136  if (prop == thePropagators.end()){
137  LogError("Muon|RecoMuon|MuonServiceProxy")
138  << "MuonServiceProxy: propagator with name: "<< propagatorName <<" not found! Please load it in the MuonServiceProxy.cff";
139  return ESHandle<Propagator>(0);
140  }
141 
142  return prop->second;
143 }
144 
145 
146 
#define LogDebug(id)
void update(const edm::EventSetup &setup)
update the services each event
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
unsigned long long theCacheId_MG
unsigned long long theCacheId_P
const std::string metname
virtual ~MuonServiceProxy()
Destructor.
bool theChangeInTrackingComponentsRecord
unsigned long long theCacheId_DG
void get(HolderT &iHolder) const
propagators thePropagators
#define LogTrace(id)
MuonServiceProxy(const edm::ParameterSet &par)
Constructor.
const T & get() const
Definition: EventSetup.h:55
unsigned long long theCacheId_GTG
edm::ESHandle< Propagator > propagator(std::string propagatorName) const
get the propagator
const double par[8 *NPar][4]