CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Types | Private Attributes
MuonServiceProxy Class Reference

#include <MuonServiceProxy.h>

Classes

class  PropagatorInfo
 

Public Types

enum  UseEventSetupIn { UseEventSetupIn::Run, UseEventSetupIn::Event, UseEventSetupIn::RunAndEvent }
 

Public Member Functions

edm::ESHandle< MuonDetLayerGeometrydetLayerGeometry () const
 get the detLayer geometry More...
 
const edm::EventSetupeventSetup () const
 
bool isTrackingComponentsRecordChanged () const
 check if the MuonReco Geometry has been changed More...
 
edm::ESHandle< MagneticFieldmagneticField () const
 get the magnetic field More...
 
const MuonNavigationSchoolmuonNavigationSchool () const
 
 MuonServiceProxy (const edm::ParameterSet &, edm::ConsumesCollector &&, UseEventSetupIn useEventSetupIn=UseEventSetupIn::Event)
 Constructor. More...
 
edm::ESHandle< Propagatorpropagator (std::string propagatorName) const
 get the propagator More...
 
edm::ESHandle< GlobalTrackingGeometrytrackingGeometry () const
 get the tracking geometry More...
 
void update (const edm::EventSetup &setup, bool duringEvent=true)
 update the services each event More...
 
virtual ~MuonServiceProxy ()
 Destructor. More...
 

Private Types

using PropagatorMap = std::map< std::string, PropagatorInfo >
 

Private Attributes

edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecordglobalTrackingGeometryEventToken_
 
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecordglobalTrackingGeometryRunToken_
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagneticFieldEventToken_
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagneticFieldRunToken_
 
edm::ESGetToken< MuonDetLayerGeometry, MuonRecoGeometryRecordmuonDetLayerGeometryEventToken_
 
edm::ESGetToken< MuonDetLayerGeometry, MuonRecoGeometryRecordmuonDetLayerGeometryRunToken_
 
unsigned long long theCacheId_DG
 
unsigned long long theCacheId_GTG
 
unsigned long long theCacheId_MG
 
unsigned long long theCacheId_P
 
bool theChangeInTrackingComponentsRecord
 
bool theCSCLayer
 
edm::ESHandle< MuonDetLayerGeometrytheDetLayerGeometry
 
const edm::EventSetuptheEventSetup
 
bool theGEMLayer
 
bool theME0Layer
 
edm::ESHandle< MagneticFieldtheMGField
 
bool theMuonNavigationFlag
 
PropagatorMap thePropagators
 
bool theRPCLayer
 
const MuonNavigationSchooltheSchool
 
edm::ESHandle< GlobalTrackingGeometrytheTrackingGeometry
 

Detailed Description

Class to handle the services needed by the muon reconstruction This class avoid the EventSetup percolation. The update method is called each event in order to update the pointers.

Author
N. Amapane - CERN nicol.nosp@m.a.am.nosp@m.apane.nosp@m.@cer.nosp@m.n.ch
R. Bellan - INFN Torino ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch

Modified by C. Calabria Modified by D. Nash

Class to handle the services needed by the muon reconstruction This class avoid the EventSetup percolation. The update method is called each event in order to update the pointers.

Author
N. Amapane - CERN nicol.nosp@m.a.am.nosp@m.apane.nosp@m.@cer.nosp@m.n.ch
R. Bellan - INFN Torino ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch

Modified by C. Calabria & A. Sharma Modified by D. Nash

Definition at line 38 of file MuonServiceProxy.h.

Member Typedef Documentation

◆ PropagatorMap

using MuonServiceProxy::PropagatorMap = std::map<std::string, PropagatorInfo>
private

Definition at line 91 of file MuonServiceProxy.h.

Member Enumeration Documentation

◆ UseEventSetupIn

Enumerator
Run 
Event 
RunAndEvent 

Definition at line 40 of file MuonServiceProxy.h.

40 { Run, Event, RunAndEvent };

Constructor & Destructor Documentation

◆ MuonServiceProxy()

MuonServiceProxy::MuonServiceProxy ( const edm::ParameterSet par,
edm::ConsumesCollector &&  iC,
UseEventSetupIn  useEventSetupIn = UseEventSetupIn::Event 
)

Constructor.

Definition at line 27 of file MuonServiceProxy.cc.

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) {
71  thePropagators[propagatorName] = PropagatorInfo();
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_ =
87  }
88  }
89  if (useEventSetupIn == UseEventSetupIn::Run || useEventSetupIn == UseEventSetupIn::RunAndEvent) {
95  for (auto& element : thePropagators) {
97  edm::ESInputTag("", element.first));
98  }
99  }
100 }

References edm::BeginRun, Event, edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), globalTrackingGeometryEventToken_, globalTrackingGeometryRunToken_, LogDebug, SiStripFineDelayHit_cfi::MagneticField, magneticFieldEventToken_, magneticFieldRunToken_, muonDetLayerGeometryEventToken_, muonDetLayerGeometryRunToken_, LaserSeedGenerator_cfi::Propagator, HLT_2018_cff::propagatorName, Run, RunAndEvent, theCacheId_DG, theCacheId_GTG, theCacheId_MG, theCacheId_P, theChangeInTrackingComponentsRecord, theCSCLayer, theGEMLayer, theME0Layer, theMuonNavigationFlag, thePropagators, and theRPCLayer.

◆ ~MuonServiceProxy()

MuonServiceProxy::~MuonServiceProxy ( )
virtual

Destructor.

Definition at line 103 of file MuonServiceProxy.cc.

103  {
104  if (theSchool)
105  delete theSchool;
106 }

References theSchool.

Member Function Documentation

◆ detLayerGeometry()

edm::ESHandle<MuonDetLayerGeometry> MuonServiceProxy::detLayerGeometry ( ) const
inline

get the detLayer geometry

Definition at line 62 of file MuonServiceProxy.h.

62 { return theDetLayerGeometry; }

References theDetLayerGeometry.

Referenced by MuonSimHitProducer::produce().

◆ eventSetup()

const edm::EventSetup& MuonServiceProxy::eventSetup ( ) const
inline

get the whole EventSetup (Note: this is a dangerous function. I would delete it if modules were not using it. If this function is called for an event where the function 'update' was not called, then the pointer stored in 'theEventSetup' will point to an object that no longer exists even if all the ESHandles are still valid! Be careful. As long as 'update' is called every event and this is only used while processing that single corresponding event, it will work OK... This function also makes it difficult to examine code in a module and understand which parts of a module use the EventSetup to get data.)

Definition at line 76 of file MuonServiceProxy.h.

76 { return *theEventSetup; }

References theEventSetup.

Referenced by TSGFromPropagation::init(), GlobalTrackQualityProducer::produce(), TSGFromPropagation::setEvent(), TSGForRoadSearch::setEvent(), GlobalTrajectoryBuilderBase::setEvent(), and TrackerSeedGenerator::trackerSeeds().

◆ isTrackingComponentsRecordChanged()

bool MuonServiceProxy::isTrackingComponentsRecordChanged ( ) const
inline

check if the MuonReco Geometry has been changed

Definition at line 79 of file MuonServiceProxy.h.

References theChangeInTrackingComponentsRecord.

◆ magneticField()

edm::ESHandle<MagneticField> MuonServiceProxy::magneticField ( ) const
inline

◆ muonNavigationSchool()

const MuonNavigationSchool* MuonServiceProxy::muonNavigationSchool ( ) const
inline

Definition at line 81 of file MuonServiceProxy.h.

81 { return theSchool; }

References theSchool.

◆ propagator()

edm::ESHandle< Propagator > MuonServiceProxy::propagator ( std::string  propagatorName) const

◆ trackingGeometry()

edm::ESHandle<GlobalTrackingGeometry> MuonServiceProxy::trackingGeometry ( ) const
inline

◆ update()

void MuonServiceProxy::update ( const edm::EventSetup setup,
bool  duringEvent = true 
)

update the services each event

Definition at line 111 of file MuonServiceProxy.cc.

111  {
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 }

References globalTrackingGeometryEventToken_, globalTrackingGeometryRunToken_, LogTrace, magneticFieldEventToken_, magneticFieldRunToken_, metname, muonDetLayerGeometryEventToken_, muonDetLayerGeometryRunToken_, singleTopDQM_cfi::setup, AlCaHLTBitMon_QueryRunRegistry::string, theCacheId_DG, theCacheId_GTG, theCacheId_MG, theCacheId_P, theChangeInTrackingComponentsRecord, theCSCLayer, theDetLayerGeometry, theEventSetup, theGEMLayer, theME0Layer, theMGField, theMuonNavigationFlag, thePropagators, theRPCLayer, theSchool, and theTrackingGeometry.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), ResidualRefitting::analyze(), MuonSimHitProducer::beginRun(), AlignmentMonitorTracksFromTrajectories::event(), progressbar.ProgressBar::finish(), MatrixUtil.Steps::overwrite(), GlobalTrackQualityProducer::produce(), and MuonSeedCleaner::seedCleaner().

Member Data Documentation

◆ globalTrackingGeometryEventToken_

edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> MuonServiceProxy::globalTrackingGeometryEventToken_
private

Definition at line 97 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ globalTrackingGeometryRunToken_

edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> MuonServiceProxy::globalTrackingGeometryRunToken_
private

Definition at line 101 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ magneticFieldEventToken_

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> MuonServiceProxy::magneticFieldEventToken_
private

Definition at line 98 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ magneticFieldRunToken_

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> MuonServiceProxy::magneticFieldRunToken_
private

Definition at line 102 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ muonDetLayerGeometryEventToken_

edm::ESGetToken<MuonDetLayerGeometry, MuonRecoGeometryRecord> MuonServiceProxy::muonDetLayerGeometryEventToken_
private

Definition at line 99 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ muonDetLayerGeometryRunToken_

edm::ESGetToken<MuonDetLayerGeometry, MuonRecoGeometryRecord> MuonServiceProxy::muonDetLayerGeometryRunToken_
private

Definition at line 103 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ theCacheId_DG

unsigned long long MuonServiceProxy::theCacheId_DG
private

Definition at line 117 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ theCacheId_GTG

unsigned long long MuonServiceProxy::theCacheId_GTG
private

Definition at line 115 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ theCacheId_MG

unsigned long long MuonServiceProxy::theCacheId_MG
private

Definition at line 116 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ theCacheId_P

unsigned long long MuonServiceProxy::theCacheId_P
private

Definition at line 118 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ theChangeInTrackingComponentsRecord

bool MuonServiceProxy::theChangeInTrackingComponentsRecord
private

Definition at line 120 of file MuonServiceProxy.h.

Referenced by isTrackingComponentsRecordChanged(), MuonServiceProxy(), and update().

◆ theCSCLayer

bool MuonServiceProxy::theCSCLayer
private

Definition at line 108 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ theDetLayerGeometry

edm::ESHandle<MuonDetLayerGeometry> MuonServiceProxy::theDetLayerGeometry
private

Definition at line 95 of file MuonServiceProxy.h.

Referenced by detLayerGeometry(), and update().

◆ theEventSetup

const edm::EventSetup* MuonServiceProxy::theEventSetup
private

Definition at line 105 of file MuonServiceProxy.h.

Referenced by eventSetup(), and update().

◆ theGEMLayer

bool MuonServiceProxy::theGEMLayer
private

Definition at line 109 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ theME0Layer

bool MuonServiceProxy::theME0Layer
private

Definition at line 110 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ theMGField

edm::ESHandle<MagneticField> MuonServiceProxy::theMGField
private

Definition at line 94 of file MuonServiceProxy.h.

Referenced by magneticField(), and update().

◆ theMuonNavigationFlag

bool MuonServiceProxy::theMuonNavigationFlag
private

Definition at line 106 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ thePropagators

PropagatorMap MuonServiceProxy::thePropagators
private

Definition at line 113 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), propagator(), and update().

◆ theRPCLayer

bool MuonServiceProxy::theRPCLayer
private

Definition at line 107 of file MuonServiceProxy.h.

Referenced by MuonServiceProxy(), and update().

◆ theSchool

const MuonNavigationSchool* MuonServiceProxy::theSchool
private

Definition at line 111 of file MuonServiceProxy.h.

Referenced by muonNavigationSchool(), update(), and ~MuonServiceProxy().

◆ theTrackingGeometry

edm::ESHandle<GlobalTrackingGeometry> MuonServiceProxy::theTrackingGeometry
private
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
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:160
edm::ConsumesCollector::esConsumes
auto esConsumes()
Definition: ConsumesCollector.h:86
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
HLT_2018_cff.propagatorName
propagatorName
Definition: HLT_2018_cff.py:8200
edm::ESHandle< Propagator >
Event
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MuonServiceProxy::theCacheId_GTG
unsigned long long theCacheId_GTG
Definition: MuonServiceProxy.h:115
LaserSeedGenerator_cfi.Propagator
Propagator
Definition: LaserSeedGenerator_cfi.py:11
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::LogError
Definition: MessageLogger.h:183
MuonServiceProxy::muonDetLayerGeometryEventToken_
edm::ESGetToken< MuonDetLayerGeometry, MuonRecoGeometryRecord > muonDetLayerGeometryEventToken_
Definition: MuonServiceProxy.h:99
MuonServiceProxy::theMGField
edm::ESHandle< MagneticField > theMGField
Definition: MuonServiceProxy.h:94
MuonServiceProxy::theRPCLayer
bool theRPCLayer
Definition: MuonServiceProxy.h:107
MuonServiceProxy::theGEMLayer
bool theGEMLayer
Definition: MuonServiceProxy.h:109
l1t::UseEventSetupIn::RunAndEvent
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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::theME0Layer
bool theME0Layer
Definition: MuonServiceProxy.h:110
MuonServiceProxy::theCacheId_DG
unsigned long long theCacheId_DG
Definition: MuonServiceProxy.h:117
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
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
SiStripFineDelayHit_cfi.MagneticField
MagneticField
Definition: SiStripFineDelayHit_cfi.py:7
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:43
MuonServiceProxy::theEventSetup
const edm::EventSetup * theEventSetup
Definition: MuonServiceProxy.h:105
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12
Run