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