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 ( )

Definition at line 18 of file GeometryInfoDump.cc.

18 { }
GeometryInfoDump::~GeometryInfoDump ( )

Definition at line 20 of file GeometryInfoDump.cc.

20 { }

Member Function Documentation

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

Definition at line 23 of file GeometryInfoDump.cc.

References DDLogicalPart::attachedSpecifics(), graph< N, E >::begin(), gather_cfg::cout, FrontierConditions_GlobalTag_cff::dump, dumpSpec(), alignmentValidation::fname, DDExpandedView::geoHistory(), DDCompactView::graph(), mps_fire::i, hcalTTPDigis_cfi::id, DDExpandedView::logicalPart(), DDExpandedView::navPos(), DDExpandedView::next(), DDExpandedView::rotation(), alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, DDBase< N, C >::toString(), DDExpandedView::translation(), x, y, and z.

24  {
25  fname = "dump" + fname;
26  DDExpandedView epv(cpv);
27  std::cout << "Top Most LogicalPart =" << epv.logicalPart() << std::endl;
28  if ( dumpHistory || dumpPosInfo) {
29  if ( dumpPosInfo ) {
30  std::cout << "After the GeoHistory in the output file dumpGeoHistoryOnRead you will see x, y, z, r11, r12, r13, r21, r22, r23, r31, r32, r33" << std::endl;
31  }
32  typedef DDExpandedView::nav_type nav_type;
33  typedef std::map<nav_type,int> id_type;
34  id_type idMap;
35  int id=0;
36  std::ofstream dump(fname.c_str());
37  bool notReachedDepth(true);
38  char buf[256];
39 
40  do {
41  nav_type pos = epv.navPos();
42  idMap[pos]=id;
43  // dump << id
44  dump << " - " << epv.geoHistory();
45  DD3Vector x, y, z;
46  epv.rotation().GetComponents(x,y,z);
47  if ( dumpPosInfo ) {
48  size_t s = snprintf(buf, 256, ",%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f",
49  epv.translation().x(), epv.translation().y(), epv.translation().z(),
50  x.X(), y.X(), z.X(),
51  x.Y(), y.Y(), z.Y(),
52  x.Z(), y.Z(), z.Z());
53  assert(s < 256);
54  dump << buf;
55  }
56  dump << "\n";;
57  ++id;
58  if ( nVols != 0 && id > nVols ) notReachedDepth = false;
59  } while (epv.next() && notReachedDepth);
60  dump << std::flush;
61  dump.close();
62  }
63  if ( dumpSpecs ) {
64  // dump specifics at every compact-view nodes to have the most detailed "true"
65  // final destination of the DDSpecifics
66  std::string dsname = "dumpSpecs" + fname;
67  std::ofstream dump(dsname.c_str());
68  DDCompactView::DDCompactView::graph_type gra = cpv.graph();
69  std::set<DDLogicalPart> lpStore;
71  adjl_iterator git = gra.begin();
72  adjl_iterator gend = gra.end();
74  for (; git != gend; ++git)
75  {
76  const DDLogicalPart & ddLP = gra.nodeData(git);
77  if ( lpStore.find(ddLP) != lpStore.end() && ddLP.attachedSpecifics().size() != 0 ) {
78  dump << ddLP.toString() << ": ";
79  dumpSpec( ddLP.attachedSpecifics(), dump );
80  }
81  lpStore.insert(ddLP);
82 
83  ++i;
84  if (git->size())
85  {
86  // ask for children of ddLP
87  for( const auto& cit : *git )
88  {
89  const DDLogicalPart & ddcurLP = gra.nodeData(cit.first);
90  if (lpStore.find(ddcurLP) != lpStore.end() && ddcurLP.attachedSpecifics().size() != 0 ) {
91  dump << ddcurLP.toString() << ": ";
92  dumpSpec( ddcurLP.attachedSpecifics(), dump );
93  }
94  lpStore.insert(ddcurLP);
95  } // iterate over children
96  } // if (children)
97  } // iterate over graph nodes
98  dump.close();
99  }
100  }
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
std::vector< double >::size_type index_type
Definition: adjgraph.h:15
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
void dumpSpec(const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > &attspec, std::ostream &dump)
std::string toString() const
Definition: DDBase.h:82
adj_list::const_iterator const_adj_iterator
Definition: adjgraph.h:125
string fname
main script
adj_iterator begin()
Definition: adjgraph.h:197
const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > & attachedSpecifics(void) const
Provides an exploded view of the detector (tree-view)
std::vector< int > nav_type
std::vector of sibling numbers
void GeometryInfoDump::dumpSpec ( const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > &  attspec,
std::ostream &  dump 
)
private

Definition at line 102 of file GeometryInfoDump.cc.

References ddanychild, ddanylogp, ddanynode, ddanyposp, ddchildlogp, ddchildposp, ddunknown, and Exception.

Referenced by dumpInfo().

102  {
103  std::vector<std::pair< const DDPartSelection*, const DDsvalues_type*> >::const_iterator bit(attspec.begin()), eit(attspec.end());
104  for( ; bit != eit; ++bit ) {
105  // DDPartSelection is a std::vector<DDPartSelectionLevel>
106  std::vector<DDPartSelectionLevel>::const_iterator psit(bit->first->begin()), pseit(bit->first->end());
107  for ( ; psit != pseit; ++psit ) {
108  switch ( psit->selectionType_ ) {
109  case ddunknown:
110  throw cms::Exception("DetectorDescriptionSpecPar") << "Can not have an unknown selection type!";
111  break;
112  case ddanynode:
113  dump << "//*";
114  break;
115  case ddanychild:
116  dump << "/*";
117  break;
118  case ddanylogp:
119  dump << "//" << psit->lp_.toString();
120  break;
121  case ddanyposp:
122  dump << "//" << psit->lp_.toString() << "[" << psit->copyno_ << "]" ;
123  break;
124  case ddchildlogp:
125  dump << "/" << psit->lp_.toString();
126  break;
127  case ddchildposp:
128  dump << "/" << psit->lp_.toString() << "[" << psit->copyno_ << "]" ;
129  break;
130  default:
131  throw cms::Exception("DetectorDescriptionSpecPar") << "Can not end up here! default of switch on selectionTyp_";
132  }
133  }
134  dump << " ";
135  // DDsvalues_type is typedef std::vector< std::pair<unsigned int, DDValue> > DDsvalues_type;
136  DDsvalues_type::const_iterator bsit(bit->second->begin()), bseit(bit->second->end());
137  for( ; bsit != bseit; ++bsit ) {
138  dump << bsit->second.name() << " ";
139  dump << ( bsit->second.isEvaluated() ? "eval " : "NOT eval " );
140  size_t sdind(0);
141  for ( ; sdind != bsit->second.strings().size() ; ++sdind ) {
142  if (bsit->second.isEvaluated()) {
143  dump << bsit->second.doubles()[sdind] ;
144  } else {
145  dump << bsit->second.strings()[sdind] ;
146  }
147  if (sdind != bsit->second.strings().size() - 1) dump << ", ";
148  }
149  if ( bsit->second.strings().size() > 0 && bsit + 1 != bseit ) dump << " | ";
150  }
151  if ( bit->second->size() > 0 && bit + 1 != eit) dump << " | ";
152  }
153  dump << std::endl;
154 }