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 
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(nullptr),theMGField(nullptr),theDetLayerGeometry(nullptr),theEventSetup(nullptr),theSchool(nullptr){
38 
39  // load the propagators map
40  vector<string> noPropagators;
41  vector<string> propagatorNames;
42 
43  theMuonNavigationFlag = par.getUntrackedParameter<bool>("UseMuonNavigation",true);
44 
46  theRPCLayer = par.getParameter<bool>("RPCLayers");
47 
48  if( par.existsAs<bool>("CSCLayers"))
49  theCSCLayer = par.getParameter< bool >("CSCLayers");
50  else theCSCLayer = true ;
51 
52  if( par.existsAs<bool>("GEMLayers"))
53  theGEMLayer = par.getParameter< bool >("GEMLayers");
54  else theGEMLayer = false ;
55 
56  if( par.existsAs<bool>("ME0Layers"))
57  theME0Layer = par.getParameter< bool >("ME0Layers");
58  else theME0Layer = false ;
59 
60  }
61  else {
62  theRPCLayer = true;
63  theCSCLayer = true;
64  theGEMLayer = true;
65  theME0Layer = true;
66  }
67 
68  propagatorNames = par.getUntrackedParameter<vector<string> >("Propagators", noPropagators);
69 
70  if(propagatorNames.empty())
71  LogDebug("Muon|RecoMuon|MuonServiceProxy") << "NO propagator(s) selected!";
72 
73  for(vector<string>::iterator propagatorName = propagatorNames.begin();
74  propagatorName != propagatorNames.end(); ++propagatorName)
76 
77  theCacheId_GTG = 0;
78  theCacheId_MG = 0;
79  theCacheId_DG = 0;
80  theCacheId_P = 0;
82 
83 }
84 
85 
86 // Destructor
88 
89  // FIXME: how do that?
90  // delete theTrackingGeometry;
91  // delete theMGField;
92  // delete theDetLayerGeometry;
93 
94  // FIXME: is it enough?
95  thePropagators.clear();
96  if(theSchool) delete theSchool;
97 }
98 
99 // Operations
100 
101 // update the services each event
103  const std::string metname = "Muon|RecoMuon|MuonServiceProxy";
104 
105  theEventSetup = &setup;
106 
107  // Global Tracking Geometry
108  unsigned long long newCacheId_GTG = setup.get<GlobalTrackingGeometryRecord>().cacheIdentifier();
109  if ( newCacheId_GTG != theCacheId_GTG ) {
110  LogTrace(metname) << "GlobalTrackingGeometry changed!";
111  theCacheId_GTG = newCacheId_GTG;
113  }
114 
115  // Magfield Field
116  unsigned long long newCacheId_MG = setup.get<IdealMagneticFieldRecord>().cacheIdentifier();
117  if ( newCacheId_MG != theCacheId_MG ) {
118  LogTrace(metname) << "Magnetic Field changed!";
119  theCacheId_MG = newCacheId_MG;
121  }
122 
123  // DetLayer Geometry
124  unsigned long long newCacheId_DG = setup.get<MuonRecoGeometryRecord>().cacheIdentifier();
125  if ( newCacheId_DG != theCacheId_DG ) {
126  LogTrace(metname) << "Muon Reco Geometry changed!";
127  theCacheId_DG = newCacheId_DG;
129  // MuonNavigationSchool should live until its validity expires, and then DELETE
130  // the NavigableLayers (this is implemented in MuonNavigationSchool's dtor)
131  if ( theMuonNavigationFlag ) {
132  if(theSchool) delete theSchool;
134  }
135  }
136 
137  // Propagators
138  unsigned long long newCacheId_P = setup.get<TrackingComponentsRecord>().cacheIdentifier();
139  if ( newCacheId_P != theCacheId_P ) {
140  LogTrace(metname) << "Tracking Component changed!";
142  theCacheId_P = newCacheId_P;
143  for(propagators::iterator prop = thePropagators.begin(); prop != thePropagators.end();
144  ++prop)
145  setup.get<TrackingComponentsRecord>().get( prop->first , prop->second );
146  }
147  else
149 
150 }
151 
152 // get the propagator
154 
155  propagators::const_iterator prop = thePropagators.find(propagatorName);
156 
157  if (prop == thePropagators.end()){
158  LogError("Muon|RecoMuon|MuonServiceProxy")
159  << "MuonServiceProxy: propagator with name: "<< propagatorName <<" not found! Please load it in the MuonServiceProxy.cff";
160  return ESHandle<Propagator>(nullptr);
161  }
162 
163  return prop->second;
164 }
165 
166 
167 
#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:185
const std::string metname
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
#define nullptr
virtual ~MuonServiceProxy()
Destructor.
edm::ESHandle< MagneticField > theMGField
bool theChangeInTrackingComponentsRecord
unsigned long long theCacheId_DG
void get(HolderT &iHolder) const
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:62
edm::ESHandle< MuonDetLayerGeometry > theDetLayerGeometry
edm::ESHandle< Propagator > propagator(std::string propagatorName) const
get the propagator