CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackerMapDDDtoID.cc
Go to the documentation of this file.
5 #include "CLHEP/Units/GlobalSystemOfUnits.h"
7 #include<algorithm>
8 
10 {
11  buildAll(iDet);
12  //
13  // loop over all the volumes which hahe a SpecPar called specpar with value value,
14  // and save in the map the association nav_type<->id
15  //
16 }
17 
19  edm::LogInfo("TrackerMapDDDtoID")<<" Building the TrackerMapDDDtoID map.";
20  TrackerMapDDDtoID* me = const_cast<TrackerMapDDDtoID*>(this);
21  me->buildAllStep2(iDet);
22 }
23 
25 
26  std::vector<const GeometricDet*> allDetectors;
27  theTracker->deepComponents(allDetectors);
28 
29  //
30  // Also build a map! (for slower access)
31  //
32 
33  for (unsigned int j=0; j<allDetectors.size(); j++){
34 
35  path2id_.insert(std::pair<nav_type,uint32_t>(allDetectors[j]->navType(),(allDetectors[j]->geographicalID())()));
36  revpath2id_.insert(std::pair<uint32_t,nav_type>((allDetectors[j]->geographicalID())(),allDetectors[j]->navType()));
37  navVec.push_back(allDetectors[j]->navType());
38  }
39  edm::LogInfo("TrackerMapDDDtoID")<<"Created TrackerMapDDDtoID; results in "<<allDetectors.size()<<" detectors numbered.";
40 }
41 
42 /*
43 unsigned int TrackerMapDDDtoID::id(const DDExpandedView & e) const
44 {
45  return id(e.navPos());
46 }
47 
48 
49 unsigned int TrackerMapDDDtoID::id(const DDFilteredView & f) const
50 {
51  return id(f.navPos());
52 }
53 */
54 
55 unsigned int TrackerMapDDDtoID::id(const nav_type & n) const
56 {
57  std::map<nav_type,uint32_t>::const_iterator it = path2id_.find(n);
58  unsigned int result = 0;
59  if (it != path2id_.end())
60  result = it->second;
61  return result;
62 }
63 
64 
65 std::vector<TrackerMapDDDtoID::nav_type> const & TrackerMapDDDtoID::allNavTypes() const{
66  return navVec;
67 }
68 
69 namespace {
70  const TrackerMapDDDtoID::nav_type nullresult;
71 }
72 
74 {
75  std::map<uint32_t,nav_type>::const_iterator it = revpath2id_.find(num);
76  if (it != revpath2id_.end())
77  return it->second;
78  return nullresult;
79 }
80 
82  path2id_.clear();
83  edm::LogInfo("TrackerMapDDDtoID")<<" TrackerMapDDDtoID maps deleted from memory.";
84 }
unsigned int id(const nav_type &) const
calculate the id of a given node
void buildAllStep2(const GeometricDet *)
TrackerMapDDDtoID(const GeometricDet *iDet)
GeometricDet::nav_type nav_type
void buildAll(const GeometricDet *)
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
std::vector< nav_type > navVec
ConstGeometricDetContainer deepComponents() const
nav_type const & navType(uint32_t) const
std::vector< nav_type > const & allNavTypes() const