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