CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
DDDefaultNumberingScheme Class Reference

Default numbering scheme. More...

#include <DDNumberingScheme.h>

Inheritance diagram for DDDefaultNumberingScheme:
DDNumberingScheme

Public Types

typedef DDNumberingScheme::nav_type nav_type
 
- Public Types inherited from DDNumberingScheme
typedef std::vector< int > nav_type
 

Public Member Functions

 DDDefaultNumberingScheme (const DDExpandedView &e)
 
 DDDefaultNumberingScheme (const DDFilteredView &f)
 
virtual int id (const DDExpandedView &) const
 calculate the id of a given node More...
 
virtual int id (const DDNumberingScheme::nav_type &) const
 calculate the id of a given node More...
 
virtual int id (const DDFilteredView &) const
 calculate the id of a given node More...
 
virtual bool node (int id, DDExpandedView &view) const
 calculate the node given an id More...
 
virtual bool node (int id, DDFilteredView &view) const
 calculate the node given an id More...
 
virtual ~DDDefaultNumberingScheme ()
 
- Public Member Functions inherited from DDNumberingScheme
virtual ~DDNumberingScheme ()
 

Protected Member Functions

DDNumberingScheme::nav_type idToNavType (int id) const
 

Protected Attributes

std::vector< std::map
< nav_type, int >::iterator > 
id2path_
 
std::map< nav_type, int > path2id_
 

Detailed Description

Default numbering scheme.

implements a default - numbering scheme throws an DDException when it fails ...

Definition at line 54 of file DDNumberingScheme.h.

Member Typedef Documentation

Definition at line 57 of file DDNumberingScheme.h.

Constructor & Destructor Documentation

DDDefaultNumberingScheme::DDDefaultNumberingScheme ( const DDExpandedView e)

Definition at line 11 of file DDNumberingScheme.cc.

References KineDebug3::count(), alignCSCRings::e, id2path_, DDExpandedView::navPos(), DDExpandedView::next(), path2id_, and DDExpandedView::reset().

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 }
bool next()
set current node to the next node in the expanded tree
std::map< nav_type, int > path2id_
nav_type navPos() const
return the stack of sibling numbers which indicates the current position in the DDExpandedView ...
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_
Provides an exploded view of the detector (tree-view)
DDDefaultNumberingScheme::DDDefaultNumberingScheme ( const DDFilteredView f)

Definition at line 36 of file DDNumberingScheme.cc.

References KineDebug3::count(), f, id2path_, DDFilteredView::navPos(), DDFilteredView::next(), path2id_, and DDFilteredView::reset().

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 }
std::map< nav_type, int > path2id_
nav_type navPos() const
return the stack of sibling numbers
bool next()
set current node to the next node in the filtered tree
std::vector< std::map< nav_type, int >::iterator > id2path_
void reset()
clears the scope and sets the filtered view to its root-node
DDDefaultNumberingScheme::~DDDefaultNumberingScheme ( )
virtual

Definition at line 55 of file DDNumberingScheme.cc.

56 { }

Member Function Documentation

int DDDefaultNumberingScheme::id ( const DDExpandedView e) const
virtual

calculate the id of a given node

Implements DDNumberingScheme.

Definition at line 59 of file DDNumberingScheme.cc.

References DDExpandedView::navPos().

Referenced by id(), and idToNavType().

60 {
61  return id(e.navPos());
62 }
nav_type navPos() const
return the stack of sibling numbers which indicates the current position in the DDExpandedView ...
virtual int id(const DDExpandedView &) const
calculate the id of a given node
int DDDefaultNumberingScheme::id ( const DDNumberingScheme::nav_type n) const
virtual

calculate the id of a given node

Implements DDNumberingScheme.

Definition at line 71 of file DDNumberingScheme.cc.

References path2id_, and mps_fire::result.

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 }
std::map< nav_type, int > path2id_
tuple result
Definition: mps_fire.py:84
int DDDefaultNumberingScheme::id ( const DDFilteredView f) const
virtual

calculate the id of a given node

Implements DDNumberingScheme.

Definition at line 65 of file DDNumberingScheme.cc.

References id(), and DDFilteredView::navPos().

66 {
67  return id(f.navPos());
68 }
nav_type navPos() const
return the stack of sibling numbers
virtual int id(const DDExpandedView &) const
calculate the id of a given node
DDNumberingScheme::nav_type DDDefaultNumberingScheme::idToNavType ( int  id) const
protected

Definition at line 95 of file DDNumberingScheme.cc.

References id(), id2path_, and mps_fire::result.

Referenced by node().

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 }
uint16_t size_type
tuple result
Definition: mps_fire.py:84
virtual int id(const DDExpandedView &) const
calculate the id of a given node
DDNumberingScheme::nav_type nav_type
std::vector< std::map< nav_type, int >::iterator > id2path_
bool DDDefaultNumberingScheme::node ( int  id,
DDExpandedView view 
) const
virtual

calculate the node given an id

returns true, if a node was found. view then corresponds to this node.

Implements DDNumberingScheme.

Definition at line 81 of file DDNumberingScheme.cc.

References DDExpandedView::goTo(), and idToNavType().

82 {
83  return view.goTo(idToNavType(id));
84 }
DDNumberingScheme::nav_type idToNavType(int id) const
bool goTo(const nav_type &)
transversed the DDExpandedView according to the given stack of sibling numbers
bool DDDefaultNumberingScheme::node ( int  id,
DDFilteredView view 
) const
virtual

calculate the node given an id

returns true, if a node was found. view then corresponds to this node.

Implements DDNumberingScheme.

Definition at line 87 of file DDNumberingScheme.cc.

References DDFilteredView::goTo(), and idToNavType().

88 {
89  edm::LogError("DDNumberingScheme") << "DDDefaultNumberingScheme::node(int,DDFilteredView&) NOT IMPLEMENTED!"
90  << std::endl;
91  return view.goTo(idToNavType(id));
92 }
DDNumberingScheme::nav_type idToNavType(int id) const
bool goTo(const nav_type &)

Member Data Documentation

std::vector<std::map<nav_type,int>::iterator> DDDefaultNumberingScheme::id2path_
protected

Definition at line 88 of file DDNumberingScheme.h.

Referenced by DDDefaultNumberingScheme(), and idToNavType().

std::map<nav_type,int> DDDefaultNumberingScheme::path2id_
protected

Definition at line 87 of file DDNumberingScheme.h.

Referenced by DDDefaultNumberingScheme(), and id().