CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDNumberingScheme.cc
Go to the documentation of this file.
4 
5 // Message logger.
7 
9 
10 
12 {
13  // extremely memory consuming & slow.
14 
15  /* - assign a node-number (from 0, ...) to every node in the view
16  - save the node-number in a map, key is the stack of sibling-numbers of the node
17  -> enables node to id calculation (slow O(log(max. node-number))).
18  - save in a std::vector the stack of sibling-numbers; index in the std::vector is the
19  assigned node number -> enables id to node calculation (fast)
20  */
21  typedef std::map<nav_type,int>::iterator m_it;
22 
23  DDExpandedView e = ex;
24  e.reset();
25  bool go = true;
26  int count = 0;
27  while (go) {
28  std::pair<m_it,bool> res = path2id_.insert(std::make_pair(e.navPos(),count));
29  id2path_.push_back(res.first);
30  ++count;
31  go = e.next();
32  }
33 }
34 
35 
37 {
38  // very memory consuming & slow, depending on the amount of nodes
39  // selected by the FilteredView; same algorithm then in ctor above
40  typedef std::map<nav_type,int>::iterator m_it;
41 
42  DDFilteredView f = fv;
43  f.reset();
44  bool go = true;
45  int count = 0;
46  while (go) {
47  std::pair<m_it,bool> res = path2id_.insert(std::make_pair(f.navPos(),count));
48  id2path_.push_back(res.first);
49  ++count;
50  go = f.next();
51  }
52 }
53 
54 
56 { }
57 
58 
60 {
61  return id(e.navPos());
62 }
63 
64 
66 {
67  return id(f.navPos());
68 }
69 
70 
72 {
73  std::map<nav_type,int>::const_iterator it = path2id_.find(n);
74  int result = -1;
75  if (it != path2id_.end())
76  result = it->second;
77  return result;
78 }
79 
80 
82 {
83  return view.goTo(idToNavType(id));
84 }
85 
86 
88 {
89  edm::LogError("DDNumberingScheme") << "DDDefaultNumberingScheme::node(int,DDFilteredView&) NOT IMPLEMENTED!"
90  << std::endl;
91  return view.goTo(idToNavType(id));
92 }
93 
94 
96 {
99  if ( (id>=(int)id2path_.size()) || ( id < 0) )
100  ;
101 
102  else {
103  std::map<nav_type,int>::iterator it = id2path_[pos];
104  result = it->first;
105  }
106  return result;
107 }
108 
bool next()
set current node to the next node in the expanded tree
DDNumberingScheme::nav_type idToNavType(int id) const
std::map< nav_type, int > path2id_
virtual bool node(int id, DDExpandedView &view) const
calculate the node given an id
virtual ~DDNumberingScheme()
nav_type navPos() const
return the stack of sibling numbers
uint16_t size_type
std::vector< int > nav_type
nav_type navPos() const
return the stack of sibling numbers which indicates the current position in the DDExpandedView ...
tuple result
Definition: mps_fire.py:84
bool goTo(const nav_type &)
virtual int id(const DDExpandedView &) const
calculate the id of a given node
bool next()
set current node to the next node in the filtered tree
double f[11][100]
DDNumberingScheme::nav_type nav_type
void reset()
true, if a call to firstChild() would succeed (current node has at least one child) ...
std::vector< std::map< nav_type, int >::iterator > id2path_
bool goTo(const nav_type &)
transversed the DDExpandedView according to the given stack of sibling numbers
void reset()
clears the scope and sets the filtered view to its root-node
Provides an exploded view of the detector (tree-view)
DDDefaultNumberingScheme(const DDExpandedView &e)