CMS 3D CMS Logo

MuonServiceProxy.cc
Go to the documentation of this file.
1 
14 // Class Header
16 
17 // Framework Headers
23 
24 #include <vector>
25 
26 // Constructor
29  UseEventSetupIn useEventSetupIn)
30  : theTrackingGeometry(nullptr),
31  theMGField(nullptr),
32  theDetLayerGeometry(nullptr),
33  theEventSetup(nullptr),
34  theSchool(nullptr) {
35  theMuonNavigationFlag = par.getUntrackedParameter<bool>("UseMuonNavigation", true);
36 
38  theRPCLayer = par.getParameter<bool>("RPCLayers");
39 
40  if (par.existsAs<bool>("CSCLayers"))
41  theCSCLayer = par.getParameter<bool>("CSCLayers");
42  else
43  theCSCLayer = true;
44 
45  if (par.existsAs<bool>("GEMLayers"))
46  theGEMLayer = par.getParameter<bool>("GEMLayers");
47  else
48  theGEMLayer = false;
49 
50  if (par.existsAs<bool>("ME0Layers"))
51  theME0Layer = par.getParameter<bool>("ME0Layers");
52  else
53  theME0Layer = false;
54 
55  } else {
56  theRPCLayer = true;
57  theCSCLayer = true;
58  theGEMLayer = true;
59  theME0Layer = true;
60  }
61 
62  // load the propagators map
63  std::vector<std::string> noPropagators;
64  std::vector<std::string> propagatorNames =
65  par.getUntrackedParameter<std::vector<std::string>>("Propagators", noPropagators);
66 
67  if (propagatorNames.empty())
68  LogDebug("Muon|RecoMuon|MuonServiceProxy") << "NO propagator(s) selected!";
69 
70  for (auto const& propagatorName : propagatorNames) {
72  }
73  theCacheId_GTG = 0;
74  theCacheId_MG = 0;
75  theCacheId_DG = 0;
76  theCacheId_P = 0;
78 
79  // Declare the products we get from the EventSetup and initialize the tokens used to get them
80  if (useEventSetupIn == UseEventSetupIn::Event || useEventSetupIn == UseEventSetupIn::RunAndEvent) {
84  for (auto& element : thePropagators) {
85  element.second.eventToken_ =
86  iC.esConsumes<Propagator, TrackingComponentsRecord>(edm::ESInputTag("", element.first));
87  }
88  }
89  if (useEventSetupIn == UseEventSetupIn::Run || useEventSetupIn == UseEventSetupIn::RunAndEvent) {
95  for (auto& element : thePropagators) {
96  element.second.runToken_ = iC.esConsumes<Propagator, TrackingComponentsRecord, edm::Transition::BeginRun>(
97  edm::ESInputTag("", element.first));
98  }
99  }
100 }
101 
102 // Destructor
104  if (theSchool)
105  delete theSchool;
106 }
107 
108 // Operations
109 
110 // update the services each event
111 void MuonServiceProxy::update(const edm::EventSetup& setup, bool duringEvent) {
112  const std::string metname = "Muon|RecoMuon|MuonServiceProxy";
113 
114  theEventSetup = &setup;
115 
116  // Global Tracking Geometry
117  unsigned long long newCacheId_GTG = setup.get<GlobalTrackingGeometryRecord>().cacheIdentifier();
118  if (newCacheId_GTG != theCacheId_GTG) {
119  LogTrace(metname) << "GlobalTrackingGeometry changed!";
120  theCacheId_GTG = newCacheId_GTG;
121  if (duringEvent) {
123  } else {
125  }
126  }
127 
128  // Magfield Field
129  unsigned long long newCacheId_MG = setup.get<IdealMagneticFieldRecord>().cacheIdentifier();
130  if (newCacheId_MG != theCacheId_MG) {
131  LogTrace(metname) << "Magnetic Field changed!";
132  theCacheId_MG = newCacheId_MG;
133  if (duringEvent) {
135  } else {
137  }
138  }
139 
140  // DetLayer Geometry
141  unsigned long long newCacheId_DG = setup.get<MuonRecoGeometryRecord>().cacheIdentifier();
142  if (newCacheId_DG != theCacheId_DG) {
143  LogTrace(metname) << "Muon Reco Geometry changed!";
144  theCacheId_DG = newCacheId_DG;
145  if (duringEvent) {
147  } else {
149  }
150  // MuonNavigationSchool should live until its validity expires, and then DELETE
151  // the NavigableLayers (this is implemented in MuonNavigationSchool's dtor)
152  if (theMuonNavigationFlag) {
153  if (theSchool)
154  delete theSchool;
156  }
157  }
158 
159  // Propagators
160  unsigned long long newCacheId_P = setup.get<TrackingComponentsRecord>().cacheIdentifier();
161  if (newCacheId_P != theCacheId_P) {
162  LogTrace(metname) << "Tracking Component changed!";
164  theCacheId_P = newCacheId_P;
165  for (auto& element : thePropagators) {
166  if (duringEvent) {
167  element.second.esHandle_ = setup.getHandle(element.second.eventToken_);
168  } else {
169  element.second.esHandle_ = setup.getHandle(element.second.runToken_);
170  }
171  }
172  } else
174 }
175 
176 // get the propagator
178  PropagatorMap::const_iterator prop = thePropagators.find(propagatorName);
179 
180  if (prop == thePropagators.end()) {
181  edm::LogError("Muon|RecoMuon|MuonServiceProxy") << "MuonServiceProxy: propagator with name: " << propagatorName
182  << " not found! Please load it in the MuonServiceProxy.cff";
183  return edm::ESHandle<Propagator>(nullptr);
184  }
185  return prop->second.esHandle_;
186 }
MuonServiceProxy::magneticFieldRunToken_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldRunToken_
Definition: MuonServiceProxy.h:102
MuonServiceProxy::UseEventSetupIn::Run
MuonNavigationSchool
Definition: MuonNavigationSchool.h:38
edm::ESInputTag
Definition: ESInputTag.h:87
MessageLogger.h
MuonServiceProxy::theChangeInTrackingComponentsRecord
bool theChangeInTrackingComponentsRecord
Definition: MuonServiceProxy.h:120
MuonServiceProxy::theMuonNavigationFlag
bool theMuonNavigationFlag
Definition: MuonServiceProxy.h:106
MuonServiceProxy::theDetLayerGeometry
edm::ESHandle< MuonDetLayerGeometry > theDetLayerGeometry
Definition: MuonServiceProxy.h:95
GlobalTrackingGeometryRecord
Definition: GlobalTrackingGeometryRecord.h:17
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
MuonServiceProxy::muonDetLayerGeometryRunToken_
edm::ESGetToken< MuonDetLayerGeometry, MuonRecoGeometryRecord > muonDetLayerGeometryRunToken_
Definition: MuonServiceProxy.h:103
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
MuonServiceProxy::globalTrackingGeometryEventToken_
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > globalTrackingGeometryEventToken_
Definition: MuonServiceProxy.h:97
MuonServiceProxy::magneticFieldEventToken_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldEventToken_
Definition: MuonServiceProxy.h:98
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
MuonRecoGeometryRecord
Definition: MuonRecoGeometryRecord.h:17
MuonDetLayerGeometry
Definition: MuonDetLayerGeometry.h:21
MuonServiceProxy::UseEventSetupIn::RunAndEvent
GlobalTrackingGeometry
Definition: GlobalTrackingGeometry.h:20
MuonServiceProxy::globalTrackingGeometryRunToken_
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > globalTrackingGeometryRunToken_
Definition: MuonServiceProxy.h:101
edm::ESHandle< Propagator >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MuonServiceProxy::theCacheId_GTG
unsigned long long theCacheId_GTG
Definition: MuonServiceProxy.h:115
MuonServiceProxy::update
void update(const edm::EventSetup &setup, bool duringEvent=true)
update the services each event
Definition: MuonServiceProxy.cc:111
HLT_FULL_cff.propagatorName
propagatorName
Definition: HLT_FULL_cff.py:9521
LaserSeedGenerator_cfi.Propagator
Propagator
Definition: LaserSeedGenerator_cfi.py:11
MuonServiceProxy::PropagatorInfo
Definition: MuonServiceProxy.h:84
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
MuonServiceProxy::UseEventSetupIn
UseEventSetupIn
Definition: MuonServiceProxy.h:40
MuonServiceProxy::muonDetLayerGeometryEventToken_
edm::ESGetToken< MuonDetLayerGeometry, MuonRecoGeometryRecord > muonDetLayerGeometryEventToken_
Definition: MuonServiceProxy.h:99
MuonServiceProxy::theMGField
edm::ESHandle< MagneticField > theMGField
Definition: MuonServiceProxy.h:94
MuonServiceProxy::propagator
edm::ESHandle< Propagator > propagator(std::string propagatorName) const
get the propagator
Definition: MuonServiceProxy.cc:177
MuonServiceProxy::theRPCLayer
bool theRPCLayer
Definition: MuonServiceProxy.h:107
MuonServiceProxy::theGEMLayer
bool theGEMLayer
Definition: MuonServiceProxy.h:109
MuonServiceProxy::~MuonServiceProxy
virtual ~MuonServiceProxy()
Destructor.
Definition: MuonServiceProxy.cc:103
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
MuonServiceProxy::MuonServiceProxy
MuonServiceProxy(const edm::ParameterSet &, edm::ConsumesCollector &&, UseEventSetupIn useEventSetupIn=UseEventSetupIn::Event)
Constructor.
Definition: MuonServiceProxy.cc:27
ESInputTag.h
MuonServiceProxy::theCacheId_P
unsigned long long theCacheId_P
Definition: MuonServiceProxy.h:118
MuonServiceProxy::theCacheId_MG
unsigned long long theCacheId_MG
Definition: MuonServiceProxy.h:116
MuonServiceProxy::theSchool
const MuonNavigationSchool * theSchool
Definition: MuonServiceProxy.h:111
edm::Transition::BeginRun
MuonServiceProxy.h
MuonServiceProxy::theME0Layer
bool theME0Layer
Definition: MuonServiceProxy.h:110
MuonServiceProxy::theCacheId_DG
unsigned long long theCacheId_DG
Definition: MuonServiceProxy.h:117
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MuonServiceProxy::theCSCLayer
bool theCSCLayer
Definition: MuonServiceProxy.h:108
MuonServiceProxy::UseEventSetupIn::Event
MuonServiceProxy::theTrackingGeometry
edm::ESHandle< GlobalTrackingGeometry > theTrackingGeometry
Definition: MuonServiceProxy.h:93
MuonServiceProxy::thePropagators
PropagatorMap thePropagators
Definition: MuonServiceProxy.h:113
ConsumesCollector.h
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
ParameterSet.h
SiStripFineDelayHit_cfi.MagneticField
MagneticField
Definition: SiStripFineDelayHit_cfi.py:7
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40
MuonServiceProxy::theEventSetup
const edm::EventSetup * theEventSetup
Definition: MuonServiceProxy.h:105
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12