CMS 3D CMS Logo

MuonServiceProxy.cc
Go to the documentation of this file.
1 
14 // Class Header
16 
17 // Service Records
23 
24 // Framework Headers
28 
29 // C++ Headers
30 #include <map>
31 
32 using namespace std;
33 using namespace edm;
34 
35 // Constructor
37  : theTrackingGeometry(nullptr),
38  theMGField(nullptr),
39  theDetLayerGeometry(nullptr),
40  theEventSetup(nullptr),
41  theSchool(nullptr) {
42  // load the propagators map
43  vector<string> noPropagators;
44  vector<string> propagatorNames;
45 
46  theMuonNavigationFlag = par.getUntrackedParameter<bool>("UseMuonNavigation", true);
47 
49  theRPCLayer = par.getParameter<bool>("RPCLayers");
50 
51  if (par.existsAs<bool>("CSCLayers"))
52  theCSCLayer = par.getParameter<bool>("CSCLayers");
53  else
54  theCSCLayer = true;
55 
56  if (par.existsAs<bool>("GEMLayers"))
57  theGEMLayer = par.getParameter<bool>("GEMLayers");
58  else
59  theGEMLayer = false;
60 
61  if (par.existsAs<bool>("ME0Layers"))
62  theME0Layer = par.getParameter<bool>("ME0Layers");
63  else
64  theME0Layer = false;
65 
66  } else {
67  theRPCLayer = true;
68  theCSCLayer = true;
69  theGEMLayer = true;
70  theME0Layer = true;
71  }
72 
73  propagatorNames = par.getUntrackedParameter<vector<string> >("Propagators", noPropagators);
74 
75  if (propagatorNames.empty())
76  LogDebug("Muon|RecoMuon|MuonServiceProxy") << "NO propagator(s) selected!";
77 
78  for (vector<string>::iterator propagatorName = propagatorNames.begin(); propagatorName != propagatorNames.end();
81 
82  theCacheId_GTG = 0;
83  theCacheId_MG = 0;
84  theCacheId_DG = 0;
85  theCacheId_P = 0;
87 }
88 
89 // Destructor
91  // FIXME: how do that?
92  // delete theTrackingGeometry;
93  // delete theMGField;
94  // delete theDetLayerGeometry;
95 
96  // FIXME: is it enough?
97  thePropagators.clear();
98  if (theSchool)
99  delete theSchool;
100 }
101 
102 // Operations
103 
104 // update the services each event
106  const std::string metname = "Muon|RecoMuon|MuonServiceProxy";
107 
108  theEventSetup = &setup;
109 
110  // Global Tracking Geometry
111  unsigned long long newCacheId_GTG = setup.get<GlobalTrackingGeometryRecord>().cacheIdentifier();
112  if (newCacheId_GTG != theCacheId_GTG) {
113  LogTrace(metname) << "GlobalTrackingGeometry changed!";
114  theCacheId_GTG = newCacheId_GTG;
116  }
117 
118  // Magfield Field
119  unsigned long long newCacheId_MG = setup.get<IdealMagneticFieldRecord>().cacheIdentifier();
120  if (newCacheId_MG != theCacheId_MG) {
121  LogTrace(metname) << "Magnetic Field changed!";
122  theCacheId_MG = newCacheId_MG;
124  }
125 
126  // DetLayer Geometry
127  unsigned long long newCacheId_DG = setup.get<MuonRecoGeometryRecord>().cacheIdentifier();
128  if (newCacheId_DG != theCacheId_DG) {
129  LogTrace(metname) << "Muon Reco Geometry changed!";
130  theCacheId_DG = newCacheId_DG;
132  // MuonNavigationSchool should live until its validity expires, and then DELETE
133  // the NavigableLayers (this is implemented in MuonNavigationSchool's dtor)
134  if (theMuonNavigationFlag) {
135  if (theSchool)
136  delete theSchool;
138  }
139  }
140 
141  // Propagators
142  unsigned long long newCacheId_P = setup.get<TrackingComponentsRecord>().cacheIdentifier();
143  if (newCacheId_P != theCacheId_P) {
144  LogTrace(metname) << "Tracking Component changed!";
146  theCacheId_P = newCacheId_P;
147  for (propagators::iterator prop = thePropagators.begin(); prop != thePropagators.end(); ++prop)
148  setup.get<TrackingComponentsRecord>().get(prop->first, prop->second);
149  } else
151 }
152 
153 // get the propagator
155  propagators::const_iterator prop = thePropagators.find(propagatorName);
156 
157  if (prop == thePropagators.end()) {
158  LogError("Muon|RecoMuon|MuonServiceProxy") << "MuonServiceProxy: propagator with name: " << propagatorName
159  << " not found! Please load it in the MuonServiceProxy.cff";
160  return ESHandle<Propagator>(nullptr);
161  }
162 
163  return prop->second;
164 }
#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
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:160
const std::string metname
#define nullptr
virtual ~MuonServiceProxy()
Destructor.
edm::ESHandle< MagneticField > theMGField
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
bool theChangeInTrackingComponentsRecord
unsigned long long theCacheId_DG
const MuonNavigationSchool * theSchool
edm::ESHandle< GlobalTrackingGeometry > theTrackingGeometry
propagators thePropagators
#define LogTrace(id)
const edm::EventSetup * theEventSetup
MuonServiceProxy(const edm::ParameterSet &par)
Constructor.
unsigned long long theCacheId_GTG
HLT enums.
T get() const
Definition: EventSetup.h:73
edm::ESHandle< MuonDetLayerGeometry > theDetLayerGeometry
edm::ESHandle< Propagator > propagator(std::string propagatorName) const
get the propagator