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(), EcalPhiSymFlatTableProducers_cfi::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  for (; git != gend; ++git) {
99  const DDLogicalPart& ddLP = gra.nodeData(git);
100  if (lpStore.find(ddLP) != lpStore.end() && !ddLP.attachedSpecifics().empty()) {
101  dump << ddLP.toString() << ": ";
103  }
104  lpStore.insert(ddLP);
105 
106  if (!git->empty()) {
107  // ask for children of ddLP
108  for (const auto& cit : *git) {
109  const DDLogicalPart& ddcurLP = gra.nodeData(cit.first);
110  if (lpStore.find(ddcurLP) != lpStore.end() && !ddcurLP.attachedSpecifics().empty()) {
111  dump << ddcurLP.toString() << ": ";
112  dumpSpec(ddcurLP.attachedSpecifics(), dump);
113  }
114  lpStore.insert(ddcurLP);
115  } // iterate over children
116  } // if (children)
117  } // iterate over graph nodes
118  dump.close();
119  }
120 }
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:62
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 122 of file GeometryInfoDump.cc.

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

Referenced by dumpInfo().

123  {
124  std::vector<std::pair<const DDPartSelection*, const DDsvalues_type*> >::const_iterator bit(attspec.begin()),
125  eit(attspec.end());
126  for (; bit != eit; ++bit) {
127  // DDPartSelection is a std::vector<DDPartSelectionLevel>
128  std::vector<DDPartSelectionLevel>::const_iterator psit(bit->first->begin()), pseit(bit->first->end());
129  for (; psit != pseit; ++psit) {
130  switch (psit->selectionType_) {
131  case ddunknown:
132  throw cms::Exception("DetectorDescriptionSpecPar") << "Can not have an unknown selection type!";
133  break;
134  case ddanynode:
135  dump << "//*";
136  break;
137  case ddanychild:
138  dump << "/*";
139  break;
140  case ddanylogp:
141  dump << "//" << psit->lp_.toString();
142  break;
143  case ddanyposp:
144  dump << "//" << psit->lp_.toString() << "[" << psit->copyno_ << "]";
145  break;
146  case ddchildlogp:
147  dump << "/" << psit->lp_.toString();
148  break;
149  case ddchildposp:
150  dump << "/" << psit->lp_.toString() << "[" << psit->copyno_ << "]";
151  break;
152  default:
153  throw cms::Exception("DetectorDescriptionSpecPar")
154  << "Can not end up here! default of switch on selectionTyp_";
155  }
156  }
157  dump << " ";
158  // DDsvalues_type is typedef std::vector< std::pair<unsigned int, DDValue> > DDsvalues_type;
159  DDsvalues_type::const_iterator bsit(bit->second->begin()), bseit(bit->second->end());
160  for (; bsit != bseit; ++bsit) {
161  dump << bsit->second.name() << " ";
162  dump << (bsit->second.isEvaluated() ? "eval " : "NOT eval ");
163  size_t sdind(0);
164  for (; sdind != bsit->second.strings().size(); ++sdind) {
165  if (bsit->second.isEvaluated()) {
166  dump << bsit->second.doubles()[sdind];
167  } else {
168  dump << bsit->second.strings()[sdind];
169  }
170  if (sdind != bsit->second.strings().size() - 1)
171  dump << ", ";
172  }
173  if (!bsit->second.strings().empty() && bsit + 1 != bseit)
174  dump << " | ";
175  }
176  if (!bit->second->empty() && bit + 1 != eit)
177  dump << " | ";
178  }
179  dump << std::endl;
180 }