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 #include <fstream>
00009 #include <cmath>
00010 #include <iomanip>
00011 #include <vector>
00012 #include <map>
00013 #include <sstream>
00014 #include <set>
00015
00016 GeometryInfoDump::GeometryInfoDump () { }
00017
00018 GeometryInfoDump::~GeometryInfoDump () { }
00019
00020
00021 void GeometryInfoDump::dumpInfo ( bool dumpHistory, bool dumpSpecs, bool dumpPosInfo
00022 , const DDCompactView& cpv, std::string fname, int nVols ) {
00023 fname = "dump" + fname;
00024 DDExpandedView epv(cpv);
00025 std::cout << "Top Most LogicalPart =" << epv.logicalPart() << std::endl;
00026 if ( dumpHistory || dumpPosInfo) {
00027 if ( dumpPosInfo ) {
00028 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;
00029 }
00030 typedef DDExpandedView::nav_type nav_type;
00031 typedef std::map<nav_type,int> id_type;
00032 id_type idMap;
00033 int id=0;
00034 std::ofstream dump(fname.c_str());
00035 bool notReachedDepth(true);
00036 do {
00037 nav_type pos = epv.navPos();
00038 idMap[pos]=id;
00039
00040 dump << " - " << epv.geoHistory();
00041 DD3Vector x, y, z;
00042 epv.rotation().GetComponents(x,y,z);
00043 if ( dumpPosInfo ) {
00044 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << epv.translation().x();
00045 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << epv.translation().y();
00046 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << epv.translation().z();
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << x.X();
00065 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << y.X();
00066 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << z.X();
00067 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << x.Y();
00068 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << y.Y();
00069 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << z.Y();
00070 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << x.Z();
00071 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << y.Z();
00072 dump << "," << std::setw(12) << std::fixed << std::setprecision(4) << z.Z();
00073 }
00074 dump << std::endl;;
00075 ++id;
00076 if ( nVols != 0 && id > nVols ) notReachedDepth = false;
00077 } while (epv.next() && notReachedDepth);
00078 dump.close();
00079 }
00080 if ( dumpSpecs ) {
00081
00082
00083 std::string dsname = "dumpSpecs" + fname;
00084 std::ofstream dump(dsname.c_str());
00085
00086 DDCompactView::DDCompactView::graph_type gra = cpv.graph();
00087 std::set<DDLogicalPart> lpStore;
00088 typedef DDCompactView::graph_type::const_adj_iterator adjl_iterator;
00089 adjl_iterator git = gra.begin();
00090 adjl_iterator gend = gra.end();
00091 DDCompactView::graph_type::index_type i=0;
00092 git = gra.begin();
00093 for (; git != gend; ++git)
00094 {
00095 const DDLogicalPart & ddLP = gra.nodeData(git);
00096 if ( lpStore.find(ddLP) != lpStore.end() && ddLP.attachedSpecifics().size() != 0 ) {
00097 dump << ddLP.toString() << ": ";
00098 dumpSpec( ddLP.attachedSpecifics(), dump );
00099
00100 }
00101 lpStore.insert(ddLP);
00102
00103 ++i;
00104 if (git->size())
00105 {
00106
00107 DDCompactView::graph_type::edge_list::const_iterator cit = git->begin();
00108 DDCompactView::graph_type::edge_list::const_iterator cend = git->end();
00109 for (; cit != cend; ++cit)
00110 {
00111 const DDLogicalPart & ddcurLP = gra.nodeData(cit->first);
00112 if (lpStore.find(ddcurLP) != lpStore.end() && ddcurLP.attachedSpecifics().size() != 0 ) {
00113 dump << ddcurLP.toString() << ": ";
00114 dumpSpec( ddcurLP.attachedSpecifics(), dump );
00115
00116 }
00117 lpStore.insert(ddcurLP);
00118 }
00119 }
00120 }
00121 dump.close();
00122
00123
00124
00125
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 void GeometryInfoDump::dumpSpec( const std::vector<std::pair< DDPartSelection*, DDsvalues_type*> >& attspec, std::ostream& dump) {
00229 std::vector<std::pair< DDPartSelection*, DDsvalues_type*> >::const_iterator bit(attspec.begin()), eit(attspec.end());
00230 for ( ; bit != eit; ++bit ) {
00231
00232 std::vector<DDPartSelectionLevel>::iterator psit(bit->first->begin()), pseit(bit->first->end());
00233 for ( ; psit != pseit; ++psit ) {
00234 switch ( psit->selectionType_ ) {
00235 case ddunknown:
00236 throw cms::Exception("DetectorDescriptionSpecPar") << "Can not have an unknown selection type!";
00237 break;
00238 case ddanynode:
00239 dump << "//*";
00240 break;
00241 case ddanychild:
00242 dump << "/*";
00243 break;
00244 case ddanylogp:
00245 dump << "//" << psit->lp_.toString();
00246 break;
00247 case ddanyposp:
00248 dump << "//" << psit->lp_.toString() << "[" << psit->copyno_ << "]" ;
00249 break;
00250 case ddchildlogp:
00251 dump << "/" << psit->lp_.toString();
00252 break;
00253 case ddchildposp:
00254 dump << "/" << psit->lp_.toString() << "[" << psit->copyno_ << "]" ;
00255 break;
00256 default:
00257 throw cms::Exception("DetectorDescriptionSpecPar") << "Can not end up here! default of switch on selectionTyp_";
00258 }
00259 }
00260 dump << " ";
00261
00262 DDsvalues_type::iterator bsit(bit->second->begin()), bseit(bit->second->end());
00263 for ( ; bsit != bseit; ++bsit ) {
00264 dump << bsit->second.name() << " ";
00265 dump << ( bsit->second.isEvaluated() ? "eval " : "NOT eval " );
00266 size_t sdind(0);
00267 for ( ; sdind != bsit->second.strings().size() ; ++sdind ) {
00268 if (bsit->second.isEvaluated()) {
00269 dump << bsit->second.doubles()[sdind] ;
00270 } else {
00271 dump << bsit->second.strings()[sdind] ;
00272 }
00273 if (sdind != bsit->second.strings().size() - 1) dump << ", ";
00274 }
00275 if ( bsit->second.strings().size() > 0 && bsit + 1 != bseit ) dump << " | ";
00276 }
00277 if ( bit->second->size() > 0 && bit + 1 != eit) dump << " | ";
00278 }
00279 dump << std::endl;
00280 }