Go to the documentation of this file.00001 #include <DetectorDescription/OfflineDBLoader/interface/GeometryInfoDump.h>
00002
00003 #include <DetectorDescription/Core/interface/DDValue.h>
00004 #include <DetectorDescription/Core/interface/DDSpecifics.h>
00005 #include <DetectorDescription/Core/interface/DDPartSelection.h>
00006 #include "DetectorDescription/Core/interface/DDName.h"
00007
00008
00009 #include <iostream>
00010 #include <fstream>
00011
00012
00013 #include <cmath>
00014 #include <iomanip>
00015 #include <vector>
00016 #include <map>
00017 #include <sstream>
00018 #include <set>
00019
00020 GeometryInfoDump::GeometryInfoDump () { }
00021
00022 GeometryInfoDump::~GeometryInfoDump () { }
00023
00024
00025 void GeometryInfoDump::dumpInfo ( bool dumpHistory, bool dumpSpecs, bool dumpPosInfo
00026 , const DDCompactView& cpv, std::string fname, int nVols ) {
00027 fname = "dump" + fname;
00028 DDExpandedView epv(cpv);
00029 std::cout << "Top Most LogicalPart =" << epv.logicalPart() << std::endl;
00030 if ( dumpHistory || dumpPosInfo) {
00031 if ( dumpPosInfo ) {
00032 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;
00033 }
00034 typedef DDExpandedView::nav_type nav_type;
00035 typedef std::map<nav_type,int> id_type;
00036 id_type idMap;
00037 int id=0;
00038 std::ofstream dump(fname.c_str());
00039 bool notReachedDepth(true);
00040 do {
00041 nav_type pos = epv.navPos();
00042 idMap[pos]=id;
00043
00044 dump << " - " << epv.geoHistory();
00045 DD3Vector x, y, z;
00046 epv.rotation().GetComponents(x,y,z);
00047 if ( dumpPosInfo ) {
00048 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << epv.translation().x();
00049 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << epv.translation().y();
00050 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << epv.translation().z();
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << x.X();
00069 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << y.X();
00070 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << z.X();
00071 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << x.Y();
00072 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << y.Y();
00073 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << z.Y();
00074 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << x.Z();
00075 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << y.Z();
00076 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << z.Z();
00077 }
00078 dump << std::endl;;
00079 ++id;
00080 if ( nVols != 0 && id > nVols ) notReachedDepth = false;
00081 } while (epv.next() && notReachedDepth);
00082 dump.close();
00083 }
00084 if ( dumpSpecs ) {
00085
00086
00087 std::string dsname = "dumpSpecs" + fname;
00088 std::ofstream dump(dsname.c_str());
00089
00090 DDCompactView::DDCompactView::graph_type gra = cpv.graph();
00091 std::set<DDLogicalPart> lpStore;
00092 typedef DDCompactView::graph_type::const_adj_iterator adjl_iterator;
00093 adjl_iterator git = gra.begin();
00094 adjl_iterator gend = gra.end();
00095 DDCompactView::graph_type::index_type i=0;
00096 git = gra.begin();
00097 for (; git != gend; ++git)
00098 {
00099 const DDLogicalPart & ddLP = gra.nodeData(git);
00100 if ( lpStore.find(ddLP) != lpStore.end() && ddLP.attachedSpecifics().size() != 0 ) {
00101 dump << ddLP.toString() << ": ";
00102 dumpSpec( ddLP.attachedSpecifics(), dump );
00103
00104 }
00105 lpStore.insert(ddLP);
00106
00107 ++i;
00108 if (git->size())
00109 {
00110
00111 DDCompactView::graph_type::edge_list::const_iterator cit = git->begin();
00112 DDCompactView::graph_type::edge_list::const_iterator cend = git->end();
00113 for (; cit != cend; ++cit)
00114 {
00115 const DDLogicalPart & ddcurLP = gra.nodeData(cit->first);
00116 if (lpStore.find(ddcurLP) != lpStore.end() && ddcurLP.attachedSpecifics().size() != 0 ) {
00117 dump << ddcurLP.toString() << ": ";
00118 dumpSpec( ddcurLP.attachedSpecifics(), dump );
00119
00120 }
00121 lpStore.insert(ddcurLP);
00122 }
00123 }
00124 }
00125 dump.close();
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 }
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 }
00231
00232 void GeometryInfoDump::dumpSpec( const std::vector<std::pair< DDPartSelection*, DDsvalues_type*> >& attspec, std::ostream& dump) {
00233 std::vector<std::pair< DDPartSelection*, DDsvalues_type*> >::const_iterator bit(attspec.begin()), eit(attspec.end());
00234 for ( ; bit != eit; ++bit ) {
00235
00236 std::vector<DDPartSelectionLevel>::iterator psit(bit->first->begin()), pseit(bit->first->end());
00237 for ( ; psit != pseit; ++psit ) {
00238 switch ( psit->selectionType_ ) {
00239 case ddunknown:
00240 throw cms::Exception("DetectorDescriptionSpecPar") << "Can not have an unknown selection type!";
00241 break;
00242 case ddanynode:
00243 dump << "//*";
00244 break;
00245 case ddanychild:
00246 dump << "/*";
00247 break;
00248 case ddanylogp:
00249 dump << "//" << psit->lp_.toString();
00250 break;
00251 case ddanyposp:
00252 dump << "//" << psit->lp_.toString() << "[" << psit->copyno_ << "]" ;
00253 break;
00254 case ddchildlogp:
00255 dump << "/" << psit->lp_.toString();
00256 break;
00257 case ddchildposp:
00258 dump << "/" << psit->lp_.toString() << "[" << psit->copyno_ << "]" ;
00259 break;
00260 default:
00261 throw cms::Exception("DetectorDescriptionSpecPar") << "Can not end up here! default of switch on selectionTyp_";
00262 }
00263 }
00264 dump << " ";
00265
00266 DDsvalues_type::iterator bsit(bit->second->begin()), bseit(bit->second->end());
00267 for ( ; bsit != bseit; ++bsit ) {
00268 dump << bsit->second.name() << " ";
00269 dump << ( bsit->second.isEvaluated() ? "eval " : "NOT eval " );
00270 size_t sdind(0);
00271 for ( ; sdind != bsit->second.strings().size() ; ++sdind ) {
00272 if (bsit->second.isEvaluated()) {
00273 dump << bsit->second.doubles()[sdind] ;
00274 } else {
00275 dump << bsit->second.strings()[sdind] ;
00276 }
00277 if (sdind != bsit->second.strings().size() - 1) dump << ", ";
00278 }
00279 if ( bsit->second.strings().size() > 0 && bsit + 1 != bseit ) dump << " | ";
00280 }
00281 if ( bit->second->size() > 0 && bit + 1 != eit) dump << " | ";
00282 }
00283 dump << std::endl;
00284 }