CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
GeometryInfoDump Class Reference

#include <GeometryInfoDump.h>

Public Member Functions

void dumpInfo (bool dumpHistory, bool dumpSpecs, bool dumpPosInfo, const DDCompactView &cpv, std::string fname="GeoHistory", int nVols=0)
 
 GeometryInfoDump ()
 
 ~GeometryInfoDump ()
 

Private Member Functions

void dumpSpec (const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type *> > &attspec, std::ostream &dump)
 

Detailed Description

Definition at line 12 of file GeometryInfoDump.h.

Constructor & Destructor Documentation

◆ GeometryInfoDump()

GeometryInfoDump::GeometryInfoDump ( )

Definition at line 31 of file GeometryInfoDump.cc.

31 {}

◆ ~GeometryInfoDump()

GeometryInfoDump::~GeometryInfoDump ( )

Definition at line 33 of file GeometryInfoDump.cc.

33 {}

Member Function Documentation

◆ dumpInfo()

void GeometryInfoDump::dumpInfo ( bool  dumpHistory,
bool  dumpSpecs,
bool  dumpPosInfo,
const DDCompactView cpv,
std::string  fname = "GeoHistory",
int  nVols = 0 
)

Definition at line 35 of file GeometryInfoDump.cc.

References cms::cuda::assert(), DDLogicalPart::attachedSpecifics(), math::Graph< N, E >::begin(), visDQMUpload::buf, gather_cfg::cout, GCP_Ntuples_cfg::dump, dumpSpec(), alignmentValidation::fname, DDExpandedView::geoHistory(), DDCompactView::graph(), mps_fire::i, l1ctLayer2EG_cff::id, DDExpandedView::logicalPart(), DDExpandedView::navPos(), DDExpandedView::next(), DDExpandedView::rotation(), roundNeg0(), alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, DDBase< N, C >::toString(), DDExpandedView::translation(), x, y, and z.

36  {
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 }
std::vector< double >::size_type index_type
Definition: Graph.h:15
void dumpSpec(const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type *> > &attspec, std::ostream &dump)
assert(be >=bs)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
static constexpr valType roundNeg0(valType value)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
std::string toString() const
Definition: DDBase.h:63
Graph::const_adj_iterator adjl_iterator
adj_iterator begin()
Definition: Graph.h:172
string fname
main script
const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > & attachedSpecifics(void) const
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
Provides an exploded view of the detector (tree-view)
std::vector< int > nav_type
std::vector of sibling numbers

◆ dumpSpec()

void GeometryInfoDump::dumpSpec ( const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type *> > &  attspec,
std::ostream &  dump 
)
private

Definition at line 124 of file GeometryInfoDump.cc.

References triggerObjects_cff::bit, ddanychild, ddanylogp, ddanynode, ddanyposp, ddchildlogp, ddchildposp, ddunknown, GCP_Ntuples_cfg::dump, and Exception.

Referenced by dumpInfo().

125  {
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 }