CMS 3D CMS Logo

GeometryInfoDump.cc
Go to the documentation of this file.
11 
12 #include <cassert>
13 #include <fstream>
14 #include <map>
15 #include <set>
16 #include <vector>
17 
20 
21 // For output of values to four decimal places, round negative values
22 // equivalent to 0 within the precision to 0 to prevent printing "-0".
23 template <class valType>
24 static constexpr valType roundNeg0(valType value) {
25  if (value < 0. && value > -5.0e-5)
26  return (0.0);
27  else
28  return (value);
29 }
30 
32 
34 
36  bool dumpHistory, bool dumpSpecs, bool dumpPosInfo, const DDCompactView& cpv, std::string fname, int nVols) {
37  fname = "dump" + fname;
38  DDExpandedView epv(cpv);
39  std::cout << "Top Most LogicalPart =" << epv.logicalPart() << std::endl;
40  if (dumpHistory || dumpPosInfo) {
41  if (dumpPosInfo) {
42  std::cout << "After the GeoHistory in the output file dumpGeoHistoryOnRead you will see x, y, z, r11, r12, r13, "
43  "r21, r22, r23, r31, r32, r33"
44  << std::endl;
45  }
46  typedef DDExpandedView::nav_type nav_type;
47  typedef std::map<nav_type, int> id_type;
48  id_type idMap;
49  int id = 0;
50  std::ofstream dump(fname.c_str());
51  bool notReachedDepth(true);
52  char buf[256];
53 
54  do {
55  nav_type pos = epv.navPos();
56  idMap[pos] = id;
57  // dump << id
58  dump << " - " << epv.geoHistory();
59  DD3Vector x, y, z;
60  epv.rotation().GetComponents(x, y, z);
61  if (dumpPosInfo) {
62  size_t s = snprintf(buf,
63  256,
64  ",%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f",
65  roundNeg0(epv.translation().x()),
66  roundNeg0(epv.translation().y()),
67  roundNeg0(epv.translation().z()),
68  roundNeg0(x.X()),
69  roundNeg0(y.X()),
70  roundNeg0(z.X()),
71  roundNeg0(x.Y()),
72  roundNeg0(y.Y()),
73  roundNeg0(z.Y()),
74  roundNeg0(x.Z()),
75  roundNeg0(y.Z()),
76  roundNeg0(z.Z()));
77  assert(s < 256);
78  dump << buf;
79  }
80  dump << "\n";
81  ;
82  ++id;
83  if (nVols != 0 && id > nVols)
84  notReachedDepth = false;
85  } while (epv.next() && notReachedDepth);
86  dump << std::flush;
87  dump.close();
88  }
89  if (dumpSpecs) {
90  // dump specifics at every compact-view nodes to have the most detailed "true"
91  // final destination of the DDSpecifics
92  std::string dsname = "dumpSpecs" + fname;
93  std::ofstream dump(dsname.c_str());
94  const auto& gra = cpv.graph();
95  std::set<DDLogicalPart> lpStore;
96  adjl_iterator git = gra.begin();
97  adjl_iterator gend = gra.end();
98  Graph::index_type i = 0;
99  for (; git != gend; ++git) {
100  const DDLogicalPart& ddLP = gra.nodeData(git);
101  if (lpStore.find(ddLP) != lpStore.end() && !ddLP.attachedSpecifics().empty()) {
102  dump << ddLP.toString() << ": ";
104  }
105  lpStore.insert(ddLP);
106 
107  ++i;
108  if (!git->empty()) {
109  // ask for children of ddLP
110  for (const auto& cit : *git) {
111  const DDLogicalPart& ddcurLP = gra.nodeData(cit.first);
112  if (lpStore.find(ddcurLP) != lpStore.end() && !ddcurLP.attachedSpecifics().empty()) {
113  dump << ddcurLP.toString() << ": ";
114  dumpSpec(ddcurLP.attachedSpecifics(), dump);
115  }
116  lpStore.insert(ddcurLP);
117  } // iterate over children
118  } // if (children)
119  } // iterate over graph nodes
120  dump.close();
121  }
122 }
123 
124 void GeometryInfoDump::dumpSpec(const std::vector<std::pair<const DDPartSelection*, const DDsvalues_type*> >& attspec,
125  std::ostream& dump) {
126  std::vector<std::pair<const DDPartSelection*, const DDsvalues_type*> >::const_iterator bit(attspec.begin()),
127  eit(attspec.end());
128  for (; bit != eit; ++bit) {
129  // DDPartSelection is a std::vector<DDPartSelectionLevel>
130  std::vector<DDPartSelectionLevel>::const_iterator psit(bit->first->begin()), pseit(bit->first->end());
131  for (; psit != pseit; ++psit) {
132  switch (psit->selectionType_) {
133  case ddunknown:
134  throw cms::Exception("DetectorDescriptionSpecPar") << "Can not have an unknown selection type!";
135  break;
136  case ddanynode:
137  dump << "//*";
138  break;
139  case ddanychild:
140  dump << "/*";
141  break;
142  case ddanylogp:
143  dump << "//" << psit->lp_.toString();
144  break;
145  case ddanyposp:
146  dump << "//" << psit->lp_.toString() << "[" << psit->copyno_ << "]";
147  break;
148  case ddchildlogp:
149  dump << "/" << psit->lp_.toString();
150  break;
151  case ddchildposp:
152  dump << "/" << psit->lp_.toString() << "[" << psit->copyno_ << "]";
153  break;
154  default:
155  throw cms::Exception("DetectorDescriptionSpecPar")
156  << "Can not end up here! default of switch on selectionTyp_";
157  }
158  }
159  dump << " ";
160  // DDsvalues_type is typedef std::vector< std::pair<unsigned int, DDValue> > DDsvalues_type;
161  DDsvalues_type::const_iterator bsit(bit->second->begin()), bseit(bit->second->end());
162  for (; bsit != bseit; ++bsit) {
163  dump << bsit->second.name() << " ";
164  dump << (bsit->second.isEvaluated() ? "eval " : "NOT eval ");
165  size_t sdind(0);
166  for (; sdind != bsit->second.strings().size(); ++sdind) {
167  if (bsit->second.isEvaluated()) {
168  dump << bsit->second.doubles()[sdind];
169  } else {
170  dump << bsit->second.strings()[sdind];
171  }
172  if (sdind != bsit->second.strings().size() - 1)
173  dump << ", ";
174  }
175  if (!bsit->second.strings().empty() && bsit + 1 != bseit)
176  dump << " | ";
177  }
178  if (!bit->second->empty() && bit + 1 != eit)
179  dump << " | ";
180  }
181  dump << std::endl;
182 }
ddanychild
Definition: DDPartSelection.h:14
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
DDExpandedView::rotation
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
Definition: DDExpandedView.cc:48
ddanyposp
Definition: DDPartSelection.h:16
DDExpandedView::nav_type
std::vector< int > nav_type
std::vector of sibling numbers
Definition: DDExpandedView.h:48
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
DDExpandedView.h
cms::cuda::assert
assert(be >=bs)
DDExpandedView::next
bool next()
set current node to the next node in the expanded tree
Definition: DDExpandedView.cc:175
ddunknown
Definition: DDPartSelection.h:12
DDAxes::x
DDCompactView.h
DDPartSelection.h
GeometryInfoDump::GeometryInfoDump
GeometryInfoDump()
Definition: GeometryInfoDump.cc:31
alignCSCRings.s
s
Definition: alignCSCRings.py:92
GeometryInfoDump.h
DDCompactView::graph
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
Definition: DDCompactView.cc:59
ddchildposp
Definition: DDPartSelection.h:18
DDBase::toString
std::string toString() const
Definition: DDBase.h:63
adjl_iterator
Graph::const_adj_iterator adjl_iterator
Definition: GeometryInfoDump.cc:19
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDAxes::z
DDExpandedView
Provides an exploded view of the detector (tree-view)
Definition: DDExpandedView.h:41
DDValue.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDCompactView::Graph
math::Graph< DDLogicalPart, DDPosData * > Graph
Definition: DDCompactView.h:83
DD3Vector
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
Definition: PGeometricDetBuilder.cc:19
roundNeg0
static constexpr valType roundNeg0(valType value)
Definition: GeometryInfoDump.cc:24
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
FrontierConditions_GlobalTag_cff.dump
dump
Definition: FrontierConditions_GlobalTag_cff.py:12
ddanynode
Definition: DDPartSelection.h:13
value
Definition: value.py:1
DDTranslation.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
ddanylogp
Definition: DDPartSelection.h:15
DDLogicalPart.h
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
DDExpandedView::geoHistory
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
Definition: DDExpandedView.cc:50
math::Graph::begin
adj_iterator begin()
Definition: Graph.h:172
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
DDRotationMatrix.h
math::Graph< DDLogicalPart, DDPosData * >::index_type
std::vector< double >::size_type index_type
Definition: Graph.h:15
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
DDExpandedNode.h
Exception
Definition: hltDiff.cc:246
DDLogicalPart::attachedSpecifics
const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > & attachedSpecifics(void) const
Definition: DDLogicalPart.cc:340
DDExpandedView::navPos
nav_type navPos() const
return the stack of sibling numbers which indicates the current position in the DDExpandedView
Definition: DDExpandedView.cc:414
DDExpandedView::logicalPart
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the expanded-view.
Definition: DDExpandedView.cc:42
Exception.h
ddchildlogp
Definition: DDPartSelection.h:17
GeometryInfoDump::dumpInfo
void dumpInfo(bool dumpHistory, bool dumpSpecs, bool dumpPosInfo, const DDCompactView &cpv, std::string fname="GeoHistory", int nVols=0)
Definition: GeometryInfoDump.cc:35
GeometryInfoDump::dumpSpec
void dumpSpec(const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > &attspec, std::ostream &dump)
Definition: GeometryInfoDump.cc:124
math::Graph< DDLogicalPart, DDPosData * >
DDExpandedView::translation
const DDTranslation & translation() const
The absolute translation of the current node.
Definition: DDExpandedView.cc:46
GeometryInfoDump::~GeometryInfoDump
~GeometryInfoDump()
Definition: GeometryInfoDump.cc:33
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
math::Graph< DDLogicalPart, DDPosData * >::const_adj_iterator
adj_list::const_iterator const_adj_iterator
Definition: Graph.h:105