CMS 3D CMS Logo

MTDMapDDDtoID.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("MTDMapDDDtoID")<<" Building the MTDMapDDDtoID map.";
20  MTDMapDDDtoID* me = const_cast<MTDMapDDDtoID*>(this);
21  me->buildAllStep2(iDet);
22 }
23 
25 
26  std::vector<const GeometricTimingDet*> allDetectors;
27  theTracker->deepComponents(allDetectors);
28 
29  //
30  // Also build a map! (for slower access)
31  //
32 
33  for (auto & allDetector : allDetectors){
34 
35  path2id_.insert(std::pair<nav_type,uint32_t>(allDetector->navType(),(allDetector->geographicalID())()));
36  revpath2id_.insert(std::pair<uint32_t,nav_type>((allDetector->geographicalID())(),allDetector->navType()));
37  navVec.emplace_back(allDetector->navType());
38  }
39  edm::LogInfo("MTDMapDDDtoID")<<"Created MTDMapDDDtoID; results in "<<allDetectors.size()<<" detectors numbered.";
40 }
41 
42 unsigned int MTDMapDDDtoID::id(const nav_type & n) const
43 {
44  std::map<nav_type,uint32_t>::const_iterator it = path2id_.find(n);
45  unsigned int result = 0;
46  if (it != path2id_.end())
47  result = it->second;
48  return result;
49 }
50 
51 
52 std::vector<MTDMapDDDtoID::nav_type> const & MTDMapDDDtoID::allNavTypes() const{
53  return navVec;
54 }
55 
56 namespace {
57  const MTDMapDDDtoID::nav_type nullresult;
58 }
59 
61 {
62  std::map<uint32_t,nav_type>::const_iterator it = revpath2id_.find(num);
63  if (it != revpath2id_.end())
64  return it->second;
65  return nullresult;
66 }
67 
69  path2id_.clear();
70  edm::LogInfo("MTDMapDDDtoID")<<" MTDMapDDDtoID maps deleted from memory.";
71 }
RevMapType revpath2id_
Definition: MTDMapDDDtoID.h:37
std::vector< nav_type > navVec
Definition: MTDMapDDDtoID.h:35
std::vector< nav_type > const & allNavTypes() const
MTDMapDDDtoID(const GeometricTimingDet *iDet)
Definition: MTDMapDDDtoID.cc:9
MapType path2id_
Definition: MTDMapDDDtoID.h:36
ConstGeometricTimingDetContainer deepComponents() const
nav_type const & navType(uint32_t) const
void buildAllStep2(const GeometricTimingDet *)
GeometricTimingDet::nav_type nav_type
Definition: MTDMapDDDtoID.h:17
unsigned int id(const nav_type &) const
calculate the id of a given node
void buildAll(const GeometricTimingDet *)