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/DDName.h"
00006
00007
00008 #include <iostream>
00009 #include <fstream>
00010
00011
00012 #include <cmath>
00013 #include <iomanip>
00014 #include <vector>
00015 #include <map>
00016 #include <sstream>
00017
00018 GeometryInfoDump::GeometryInfoDump () { }
00019
00020 GeometryInfoDump::~GeometryInfoDump () { }
00021
00022
00023 void GeometryInfoDump::dumpInfo ( bool dumpHistory, bool dumpSpecs, bool dumpPosInfo
00024 , const DDCompactView& cpv ) {
00025
00026 DDExpandedView epv(cpv);
00027 std::cout << "Top Most LogicalPart =" << epv.logicalPart() << std::endl;
00028 if ( dumpHistory || dumpPosInfo) {
00029 if ( dumpPosInfo ) {
00030 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;
00031 }
00032 typedef DDExpandedView::nav_type nav_type;
00033 typedef std::map<nav_type,int> id_type;
00034 id_type idMap;
00035 int id=0;
00036 std::ofstream dump("dumpGeoHistory");
00037 do {
00038 nav_type pos = epv.navPos();
00039 idMap[pos]=id;
00040 dump << id << " - " << 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 } while (epv.next());
00077 dump.close();
00078 }
00079 if ( dumpSpecs ) {
00080 DDSpecifics::iterator<DDSpecifics> spit(DDSpecifics::begin()), spend(DDSpecifics::end());
00081
00082 std::ofstream dump("dumpSpecs");
00083 for (; spit != spend; ++spit) {
00084 if ( !spit->isDefined().second ) continue;
00085 const DDSpecifics & sp = *spit;
00086 dump << sp << std::endl;
00087 }
00088 dump.close();
00089 }
00090 }
00091