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