test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
GeometryTree::Node Class Reference

Public Member Functions

 Node (DetGeomDesc *desc, int indent, bool isLast, bool useTreeOutput=true)
 
void print (void)
 

Public Attributes

DetGeomDescdesc
 
int indent
 
bool isLast
 
bool useTreeOutput
 

Detailed Description

Geometry Hierarchy node Used for DFS traversal, keeps tree printing data

Definition at line 86 of file GeometryTree.cc.

Constructor & Destructor Documentation

GeometryTree::Node::Node ( DetGeomDesc desc,
int  indent,
bool  isLast,
bool  useTreeOutput = true 
)
inline

Definition at line 88 of file GeometryTree.cc.

88  :
89  desc(desc),
90  indent(indent),
91  isLast(isLast),
93  }
DetGeomDesc * desc
Definition: GeometryTree.cc:95

Member Function Documentation

void GeometryTree::Node::print ( void  )
inline

Prints a line of tree output Prints a line formated accordingly to indent, isLast and useTreeOutput. Do remember to set useTreeOutput he same in all nodes, unpredictable output otherwise.

Definition at line 108 of file GeometryTree.cc.

References gather_cfg::cout, i, dataformats::indent(), and makeMuonMisalignmentScenario::rot.

Referenced by GeometryTree::analyze().

108  {
109  if (useTreeOutput) {
110  // compute indent
111  static vector<char> indentChars;
112  while ((int) indentChars.size() <= indent) {
113  indentChars.push_back(' ');
114  }
115 
116  // print indent
117  for (int i = 0; i < indent - 1; ++i) {
118  printf("%c ", indentChars[i]);
119  }
120  if (indent > 0) {
121  if (isLast) {
122  printf("`-- ");
123  indentChars[indent-1] = ' ';
124  }
125  else {
126  printf("|-- ");
127  indentChars[indent-1] = '|';
128  }
129  }
130  }
131  else {
132  // print indent
133  for (int i = 0; i < indent; ++i)
134  printf(" ");
135  }
136 
137  // print actual data
138  ROOT::Math::RotationZYX rot;
139  rot = desc->rotation();
140  double rotComponents[3] = {0.,};
141  rot.GetComponents(rotComponents);
142 
143  cout << desc->name().name() << " at " << desc->translation() << " rotated (ZYX) by (";
144  for (int i = 0; i < 3; ++i) {
145  printf("%.2f%c", (rotComponents[i] * 180 / 3.14159), ((i < 2) ? ' ' : ')'));
146  }
147  printf("\n");
148  }
int i
Definition: DBlmapReader.cc:9
DDRotationMatrix rotation() const
geometry information
Definition: DetGeomDesc.h:86
DetGeomDesc * desc
Definition: GeometryTree.cc:95
DDTranslation translation() const
Definition: DetGeomDesc.h:87
DDName name() const
Definition: DetGeomDesc.h:90
tuple cout
Definition: gather_cfg.py:145
const std::string & name() const
Returns the name.
Definition: DDName.cc:87

Member Data Documentation

DetGeomDesc* GeometryTree::Node::desc

Actual data

Definition at line 95 of file GeometryTree.cc.

Referenced by GeometryTree::analyze().

int GeometryTree::Node::indent

Indent, 0 for the top node, +1 for every next level

Definition at line 97 of file GeometryTree.cc.

Referenced by GeometryTree::analyze().

bool GeometryTree::Node::isLast

True for every first child put on the stack, false otherwise

Definition at line 99 of file GeometryTree.cc.

bool GeometryTree::Node::useTreeOutput

Tree output if true, simple indentation otherwise

Definition at line 101 of file GeometryTree.cc.