CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/SLHCUpgradeSimulations/Geometry/src/PrintGeomMatInfo.cc

Go to the documentation of this file.
00001 #include "SLHCUpgradeSimulations/Geometry/interface/PrintGeomMatInfo.h"
00002 
00003 #include "SimG4Core/Notification/interface/BeginOfJob.h"
00004 #include "SimG4Core/Notification/interface/BeginOfRun.h"
00005 #include "SimG4Core/Notification/interface/SimG4Exception.h"
00006 
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008 #include "FWCore/Framework/interface/ESHandle.h"
00009 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00010 #include "DetectorDescription/Core/interface/DDCompactView.h"
00011 #include "DetectorDescription/Core/interface/DDFilter.h"
00012 #include "DetectorDescription/Core/interface/DDFilteredView.h"
00013 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00014 #include "DetectorDescription/Core/interface/DDSplit.h"
00015 #include "DetectorDescription/Core/interface/DDValue.h"
00016 
00017 #include "G4Run.hh"
00018 #include "G4PhysicalVolumeStore.hh"
00019 #include "G4LogicalVolumeStore.hh"
00020 #include "G4VPhysicalVolume.hh"
00021 #include "G4LogicalVolume.hh"
00022 #include "G4VSolid.hh"
00023 #include "G4Material.hh"
00024 #include "G4Track.hh"
00025 #include "G4VisAttributes.hh"
00026 #include "G4UserLimits.hh"
00027 #include "G4TransportationManager.hh"
00028 
00029 #include <set>
00030 #include <map>
00031 
00032 PrintGeomMatInfo::PrintGeomMatInfo(const edm::ParameterSet &p)
00033 {
00034     _dumpSummary = p.getUntrackedParameter<bool>("DumpSummary", true);
00035     _dumpLVTree  = p.getUntrackedParameter<bool>("DumpLVTree",  true);
00036     _dumpLVMatBudget = p.getUntrackedParameter<bool>("DumpLVMatBudget", false);
00037     _lvNames2Dump= p.getUntrackedParameter<std::vector<std::string> >("LVNames2Dump");
00038     _level2Dump = 0;
00039     _dumpIndex = 0;
00040     _dumpIt = false;
00041     _radiusLayer = p.getUntrackedParameter<std::vector<double> >("Radius2Use");
00042     _zLayer      = p.getUntrackedParameter<std::vector<double> >("Z2Use");
00043     _maxLevelsCounted = 50;
00044     _countsPerLevel.assign(_maxLevelsCounted,0);
00045     _dumpMaterial= p.getUntrackedParameter<bool>("DumpMaterial",false);
00046     _dumpLVList  = p.getUntrackedParameter<bool>("DumpLVList",  false);
00047     _dumpLV      = p.getUntrackedParameter<bool>("DumpLV",      false);
00048     _dumpSolid   = p.getUntrackedParameter<bool>("DumpSolid",   false);
00049     _dumpAtts    = p.getUntrackedParameter<bool>("DumpAttributes", false);
00050     _dumpPV      = p.getUntrackedParameter<bool>("DumpPV",      false);
00051     _dumpRotation= p.getUntrackedParameter<bool>("DumpRotation",false);
00052     _dumpReplica = p.getUntrackedParameter<bool>("DumpReplica", false);
00053     _dumpTouch   = p.getUntrackedParameter<bool>("DumpTouch",   false);
00054     _dumpSense   = p.getUntrackedParameter<bool>("DumpSense",   false);
00055     name  = p.getUntrackedParameter<std::string>("Name","*");
00056     nchar = name.find("*");
00057     name.assign(name,0,nchar);
00058     names = p.getUntrackedParameter<std::vector<std::string> >("Names");
00059     std::cout << "size of _lvNames2Dump = " << _lvNames2Dump.size()
00060               << " size of _radiusLayer = " << _radiusLayer.size()
00061               << " size of _zLayer = " << _zLayer.size() << std::endl;
00062     std::cout << "PrintGeomMatInfo:: initialised with verbosity levels:"
00063               << " Summary   " << _dumpSummary << " LVTree   " << _dumpLVTree
00064               << " LVList    " << _dumpLVList  << " Material " << _dumpMaterial
00065               << "\n                                                        "
00066               << " LVMatBudget   " << _dumpLVMatBudget << " for";
00067     _areaLayer.reserve(_lvNames2Dump.size());
00068     if(_lvNames2Dump.size() == _radiusLayer.size() &&
00069        _lvNames2Dump.size() == _zLayer.size()) {
00070        for (unsigned int i=0; i<_lvNames2Dump.size(); i++) {
00071           _areaLayer[i] = 2.0*3.14159*_radiusLayer[i]*_zLayer[i];
00072           std::cout << "\n                                                        "
00073                     << " " << _lvNames2Dump[i] << " radius = " << _radiusLayer[i]
00074                     << " z = " << _zLayer[i] << " area = " << _areaLayer[i];
00075        }
00076     } else {
00077           _areaLayer.assign(3,0.0);
00078           std::cout << "\n                                                        "
00079                     << " Problem with unequal sizes!! Fix and rerun";
00080     }
00081     std::cout << "\n                                                        "
00082               << " and max levels for count = " << _maxLevelsCounted;
00083     std::cout << "\n                                                        "
00084               << " LV        " << _dumpLV      << " Solid    " << _dumpSolid 
00085               << " Attribs   " << _dumpAtts
00086               << "\n                                                        "
00087               << " PV        " << _dumpPV      << " Rotation " << _dumpRotation
00088               << " Replica   " << _dumpReplica
00089               << "\n                                                        "
00090               << " Touchable " << _dumpTouch << " for names (0-" << nchar 
00091               << ") = " << name 
00092               << "\n                                                        "
00093               << " Sensitive " << _dumpSense << " for " << names.size()
00094               << " names";
00095     for (unsigned int i=0; i<names.size(); i++) std::cout << " " << names[i];
00096     std::cout << std::endl;
00097 }
00098  
00099 PrintGeomMatInfo::~PrintGeomMatInfo() {}
00100  
00101 void PrintGeomMatInfo::update(const BeginOfJob * job)
00102 {
00103     if (_dumpSense) {
00104         edm::ESHandle<DDCompactView> pDD;
00105         (*job)()->get<IdealGeometryRecord>().get(pDD);
00106 
00107         std::cout << "PrintGeomMatInfo::Get Printout of Sensitive Volumes " 
00108                   << "for " << names.size() << " Readout Units" << std::endl;
00109         for (unsigned int i=0; i<names.size(); i++) {
00110             std::string attribute = "ReadOutName";
00111             std::string sd        = names[i];
00112             DDSpecificsFilter filter;
00113             DDValue           ddv(attribute,sd,0);
00114             filter.setCriteria(ddv,DDSpecificsFilter::equals);
00115             DDFilteredView fv(*pDD);
00116             std::cout << "PrintGeomMatInfo:: Get Filtered view for " 
00117                       << attribute << " = " << sd << std::endl;
00118             fv.addFilter(filter);
00119             bool dodet = fv.firstChild();
00120  
00121             std::string spaces = spacesFromLeafDepth(1);
00122 
00123             while (dodet) {
00124                 const DDLogicalPart & log = fv.logicalPart();
00125                 std::string lvname = DDSplit(log.name()).first;
00126                 DDTranslation tran = fv.translation();
00127                 std::vector<int> copy = fv.copyNumbers();
00128 
00129                 unsigned int leafDepth = copy.size();
00130                 std::cout << leafDepth << spaces << "### VOLUME = " << lvname 
00131                           << " Copy No";
00132                 for (int k=leafDepth-1; k>=0; k--) std::cout << " " << copy[k];
00133                 std::cout << " Centre at " << tran << " (r = " << tran.Rho()
00134                           << ", phi = " << tran.phi()/deg << ")" << std::endl;
00135                 dodet = fv.next();
00136             }
00137         }
00138     }
00139 }
00140   
00141 void PrintGeomMatInfo::update(const BeginOfRun * run)
00142 {
00143     theTopPV = getTopPV();
00144 
00145     if (_dumpSummary)  dumpSummary(std::cout);
00146     if (_dumpLVTree)   dumpG4LVTree(std::cout);
00147     if (_dumpLVMatBudget)   dumpG4LVMatBudget(std::cout);
00148     
00149     //---------- Dump list of objects of each class with detail of parameters
00150     if (_dumpMaterial) dumpMaterialList(std::cout);
00151     if (_dumpLVList)   dumpG4LVList(std::cout);
00152 
00153     //---------- Dump LV and PV information
00154     if (_dumpLV || _dumpPV || _dumpTouch) dumpHierarchyTreePVLV(std::cout);
00155 }
00156 
00157 void PrintGeomMatInfo::dumpSummary(std::ostream & out)
00158 {
00159     //---------- Dump number of objects of each class
00160     out << " @@@@@@@@@@@@@@@@@@ Dumping G4 geometry objects Summary " << std::endl;
00161     if(theTopPV == 0) 
00162     {
00163         out << " No volume created " << std::endl;
00164         return;
00165     }
00166     out << " @@@ Geometry built inside world volume: " << theTopPV->GetName() << std::endl;
00167     // Get number of solids (< # LV if several LV share a solid)
00168     const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
00169     std::vector<G4LogicalVolume *>::const_iterator lvcite;
00170     std::set<G4VSolid *> theSolids;
00171     for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) 
00172         theSolids.insert((*lvcite)->GetSolid());
00173     out << " Number of G4VSolid's: " << theSolids.size() << std::endl;
00174     out << " Number of G4LogicalVolume's: " << lvs->size() << std::endl;
00175     const G4PhysicalVolumeStore * pvs = G4PhysicalVolumeStore::GetInstance();
00176     out << " Number of G4VPhysicalVolume's: " << pvs->size() << std::endl;
00177     out << " Number of Touchable's: " << countNoTouchables() << std::endl;
00178     const G4MaterialTable * matTab = G4Material::GetMaterialTable();
00179     out << " Number of G4Material's: " << matTab->size() << std::endl;
00180 }
00181 
00182 void PrintGeomMatInfo::dumpG4LVList(std::ostream & out)
00183 {
00184     out << " @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's List  " << std::endl;
00185     const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
00186     std::vector<G4LogicalVolume*>::const_iterator lvcite;
00187     for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) 
00188       out << "LV:" << (*lvcite)->GetName() << "\tMaterial: " << (*lvcite)->GetMaterial()->GetName() << std::endl;
00189 }
00190 
00191 void PrintGeomMatInfo::dumpG4LVTree(std::ostream & out)
00192 {
00193     out << " @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's Tree  " << std::endl;
00194     G4LogicalVolume * lv = getTopLV(); 
00195     dumpG4LVLeaf(lv,0,1,out);
00196 }
00197 
00198 void PrintGeomMatInfo::dumpMaterialList(std::ostream & out)
00199 {
00200     out << " @@@@@@@@@@@@@@@@ DUMPING G4Material List ";
00201     const G4MaterialTable * matTab = G4Material::GetMaterialTable();
00202     out << " with " << matTab->size() << " materials " << std::endl;
00203     std::vector<G4Material*>::const_iterator matite;
00204     for (matite = matTab->begin(); matite != matTab->end(); matite++)
00205         out << "Material: " << (*matite) << std::endl;
00206 }
00207 
00208 void PrintGeomMatInfo::dumpG4LVLeaf(G4LogicalVolume * lv, unsigned int leafDepth, unsigned int count, std::ostream & out)
00209 {
00210     for (unsigned int ii=0; ii < leafDepth; ii++) out << "  ";
00211     out << " LV:(" << leafDepth << ") " << lv->GetName() << " (" << count
00212         << ")" << std::endl;
00213     //--- If a volume is placed n types as daughter of this LV, it should only be counted once
00214     std::map<G4LogicalVolume*, unsigned int> lvCount;
00215     std::map<G4LogicalVolume*, unsigned int>::const_iterator cite;
00216     for (int ii = 0; ii < lv->GetNoDaughters(); ii++) {
00217         cite = lvCount.find(lv->GetDaughter(ii)->GetLogicalVolume());
00218         if (cite != lvCount.end()) lvCount[cite->first] = (cite->second) + 1;
00219         else lvCount.insert(std::pair< G4LogicalVolume*,unsigned int>(lv->GetDaughter(ii)->GetLogicalVolume(),1));
00220     }
00221     for (cite = lvCount.begin(); cite != lvCount.end(); cite++) 
00222         dumpG4LVLeaf((cite->first), leafDepth+1, (cite->second), out);
00223 }
00224 
00225 void PrintGeomMatInfo::dumpG4LVMatBudget(std::ostream & out)
00226 {
00227     out << " @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's Material Budget Tree  " << std::endl;
00228     G4LogicalVolume * lv = getTopLV(); 
00229     dumpG4LVLeafWithMat(lv,0,1,out);
00230 }
00231 
00232 void PrintGeomMatInfo::dumpG4LVLeafWithMat(G4LogicalVolume * lv, unsigned int leafDepth, unsigned int count, std::ostream & out)
00233 {
00234     // switch off dumping at the next same level as the dump
00235     if(_dumpIt && _level2Dump == leafDepth) {
00236         _dumpIt = false;
00237 //       std::cout << " stopped dumping " << std::endl;
00238     }
00239     // loop over volumes to dump: volumes cannot not overlap in hierarchy!!
00240     for (unsigned int i=0; i<_lvNames2Dump.size(); i++) {
00241        if(_lvNames2Dump[i].compare(lv->GetName()) == 0) {
00242           _dumpIt = true;
00243           _dumpIndex = i;
00244           _level2Dump = leafDepth;
00245 //          std::cout << " start dumping " << _lvNames2Dump[i] << " at level " << _level2Dump << std::endl;
00246           break;
00247        }
00248     }
00249 
00250     if(_dumpIt) {
00251        if(leafDepth < _maxLevelsCounted) _countsPerLevel[leafDepth] = count;
00252        unsigned int total_multipler = 1;
00253        for (unsigned int ii=_level2Dump; ii <= leafDepth; ii++) total_multipler *= _countsPerLevel[ii];
00254        double thick = (lv->GetSolid()->GetCubicVolume() * total_multipler)/_areaLayer[_dumpIndex];
00255        for (unsigned int ii=0; ii < leafDepth; ii++) out << "  ";
00256        // print out Level, Logical volume name, volume in mm**3, material name, rad len of mat in mm
00257        // total number of volumes from dump level start, equivalent thickness when spread over
00258        // a cylinder of _radiusLayer and length _zLayer; equivalent thick in rad len
00259        out << " LV::" << leafDepth << ": " << lv->GetName() << " :" << count
00260            << ": " << lv->GetSolid()->GetName() << " :" << lv->GetSolid()->GetCubicVolume()
00261            << ": "<< lv->GetMaterial()->GetName() << " :" << lv->GetMaterial()->GetRadlen() 
00262            << ":" << " :" << total_multipler << ":" 
00263            << " thk :" << thick << ": x/X0 :" << thick/lv->GetMaterial()->GetRadlen()
00264            << ":" << " Kg : " << lv->GetMass()/kg << std::endl;
00265     } else {
00266        for (unsigned int ii=0; ii < leafDepth; ii++) out << "  ";
00267        out << " LV:(" << leafDepth << ") " << lv->GetName() << " (" << count << ")" << std::endl;
00268     }
00269 
00270     //--- If a volume is placed n types as daughter of this LV, it should only be counted once
00271     std::map<G4LogicalVolume*, unsigned int> lvCount;
00272     std::map<G4LogicalVolume*, unsigned int>::const_iterator cite;
00273     for (int ii = 0; ii < lv->GetNoDaughters(); ii++) {
00274         cite = lvCount.find(lv->GetDaughter(ii)->GetLogicalVolume());
00275         if (cite != lvCount.end()) lvCount[cite->first] = (cite->second) + 1;
00276         else lvCount.insert(std::pair< G4LogicalVolume*,unsigned int>(lv->GetDaughter(ii)->GetLogicalVolume(),1));
00277     }
00278     for (cite = lvCount.begin(); cite != lvCount.end(); cite++) 
00279         dumpG4LVLeafWithMat((cite->first), leafDepth+1, (cite->second), out);
00280 }
00281 
00282 
00283 int PrintGeomMatInfo::countNoTouchables()
00284 {
00285     int nTouch = 0;
00286     G4LogicalVolume * lv = getTopLV();
00287     add1touchable(lv, nTouch);
00288     return nTouch;
00289 }
00290 
00291 
00292 void PrintGeomMatInfo::add1touchable(G4LogicalVolume * lv, int & nTouch)
00293 {
00294     int siz = lv->GetNoDaughters();
00295     for(int ii = 0; ii < siz; ii++)
00296         add1touchable(lv->GetDaughter(ii)->GetLogicalVolume(), ++nTouch);
00297 }
00298  
00299 void PrintGeomMatInfo::dumpHierarchyTreePVLV(std::ostream & out) 
00300 {
00301     //dumps in the following order: 
00302     //    1) a LV with details
00303     //    2) list of PVs daughters of this LV with details
00304     //    3) list of LVs daughters of this LV and for each go to 1)
00305 
00306     //----- Get top PV
00307     G4LogicalVolume*  topLV = getTopLV();
00308   
00309     //----- Dump this leaf (it will recursively dump all the tree)
00310     dumpHierarchyLeafPVLV(topLV, 0, out);
00311     dumpPV(theTopPV, 0, out);
00312   
00313     //----- Dump the touchables (it will recursively dump all the tree)
00314     if (_dumpTouch) dumpTouch(theTopPV, 0, out);
00315 }
00316 
00317 void PrintGeomMatInfo::dumpHierarchyLeafPVLV(G4LogicalVolume * lv, unsigned int leafDepth, std::ostream & out)
00318 {
00319     //----- Dump this LV 
00320     dumpLV(lv, leafDepth, out);
00321 
00322     //----- Get LV daughters from list of PV daughters
00323     mmlvpv lvpvDaughters;
00324     std::set< G4LogicalVolume * > lvDaughters;
00325     int NoDaughters = lv->GetNoDaughters();
00326     while ((NoDaughters--)>0)
00327     {
00328         G4VPhysicalVolume * pvD = lv->GetDaughter(NoDaughters);
00329         lvpvDaughters.insert(mmlvpv::value_type(pvD->GetLogicalVolume(), pvD));
00330         lvDaughters.insert(pvD->GetLogicalVolume());
00331     }
00332  
00333     std::set< G4LogicalVolume * >::const_iterator scite;
00334     mmlvpv::const_iterator mmcite;
00335 
00336     //----- Dump daughters PV and LV
00337     for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) 
00338     {
00339         std::pair< mmlvpv::iterator, mmlvpv::iterator > mmER = lvpvDaughters.equal_range(*scite);    
00340         //----- Dump daughters PV of this LV
00341         for (mmcite = mmER.first ; mmcite != mmER.second; mmcite++) 
00342             dumpPV((*mmcite).second, leafDepth+1, out);
00343         //----- Dump daughters LV
00344         dumpHierarchyLeafPVLV(*scite, leafDepth+1, out );
00345     }
00346 }
00347  
00348 void PrintGeomMatInfo::dumpLV(G4LogicalVolume * lv, unsigned int leafDepth, std::ostream & out)
00349 {
00350     std::string spaces = spacesFromLeafDepth(leafDepth);
00351 
00352     //----- dump name 
00353     if (_dumpLV) { 
00354         out << leafDepth << spaces << "$$$ VOLUME = " << lv->GetName()
00355             << "  Solid: " << lv->GetSolid()->GetName() << "  MATERIAL: "
00356             << lv->GetMaterial()->GetName() << std::endl;
00357         if (_dumpSolid)
00358           dumpSolid(lv->GetSolid(), leafDepth, out); //----- dump solid
00359 
00360     //----- dump LV info 
00361     //--- material 
00362         if (_dumpAtts) {
00363           //--- Visualisation attributes
00364           const G4VisAttributes * fVA = lv->GetVisAttributes();
00365           if (fVA!=0) {
00366             out <<  spaces << "  VISUALISATION ATTRIBUTES: " << std::endl;
00367             out <<  spaces << "    IsVisible " << fVA->IsVisible() << std::endl;
00368             out <<  spaces << "    IsDaughtersInvisible " << fVA->IsDaughtersInvisible() << std::endl;
00369             out <<  spaces << "    Colour " << fVA->GetColour() << std::endl;
00370             out <<  spaces << "    LineStyle " << fVA->GetLineStyle() << std::endl;
00371             out <<  spaces << "    LineWidth " << fVA->GetLineWidth() << std::endl;
00372             out <<  spaces << "    IsForceDrawingStyle " << fVA->IsForceDrawingStyle() << std::endl;
00373             out <<  spaces << "    ForcedDrawingStyle " << fVA->GetForcedDrawingStyle() << std::endl;
00374           }    
00375     
00376           //--- User Limits
00377           G4UserLimits * fUL = lv->GetUserLimits();
00378           G4Track dummy;
00379           if (fUL!=0) {
00380             out <<  spaces << "    MaxAllowedStep " << fUL->GetMaxAllowedStep(dummy) << std::endl;
00381             out <<  spaces << "    UserMaxTrackLength " << fUL->GetUserMaxTrackLength(dummy) << std::endl;
00382             out <<  spaces << "    UserMaxTime " << fUL->GetUserMaxTime(dummy) << std::endl;
00383             out <<  spaces << "    UserMinEkine " << fUL->GetUserMinEkine(dummy) << std::endl;
00384             out <<  spaces << "    UserMinRange " << fUL->GetUserMinRange(dummy) << std::endl;
00385           }
00386     
00387           //--- other LV info
00388           if (lv->GetSensitiveDetector()) 
00389             out << spaces << "  IS SENSITIVE DETECTOR " << std::endl;
00390           if (lv->GetFieldManager()) 
00391             out << spaces << "  FIELD ON " << std::endl;
00392 
00393           // Pointer (possibly NULL) to optimisation info objects.
00394           out <<  spaces  
00395               << "        Quality for optimisation, average number of voxels to be spent per content " 
00396               << lv->GetSmartless() << std::endl;
00397 
00398           // Pointer (possibly NULL) to G4FastSimulationManager object.
00399           if (lv->GetFastSimulationManager()) 
00400             out << spaces << "     Logical Volume is an envelope for a FastSimulationManager " 
00401                 << std::endl;
00402           out << spaces << "     Weight used in the event biasing technique = " 
00403               << lv->GetBiasWeight() << std::endl;
00404         } 
00405     }
00406 }       
00407 
00408 void PrintGeomMatInfo::dumpPV(G4VPhysicalVolume * pv, unsigned int leafDepth, std::ostream & out)
00409 {
00410     std::string spaces = spacesFromLeafDepth(leafDepth);
00411 
00412     //----- PV info
00413     if (_dumpPV) 
00414     {
00415         std::string mother = "World";
00416         if (pv->GetMotherLogical()) mother = pv->GetMotherLogical()->GetName();
00417         out << leafDepth << spaces << "### VOLUME = " << pv->GetName() 
00418             << " Copy No " << pv->GetCopyNo() << " in " << mother
00419             << " at " << pv->GetTranslation();
00420     }
00421     if (!pv->IsReplicated()) 
00422     {
00423         if (_dumpPV) 
00424         {
00425             if(pv->GetRotation() == 0) out << " with no rotation" << std::endl;
00426             else  if(!_dumpRotation)   out << " with rotation" << std::endl; //just rotation name
00427             else                       out << " with rotation " << *(pv->GetRotation()) << std::endl;
00428         }
00429     }  
00430     else 
00431     {
00432         if (_dumpReplica )
00433         {
00434             out << spaces << "    It is replica: " << std::endl;
00435             EAxis axis; 
00436             int nReplicas; 
00437             double width; 
00438             double offset; 
00439             bool consuming;
00440             pv->GetReplicationData(axis, nReplicas, width, offset, consuming);
00441             out << spaces << "     axis " << axis << std::endl
00442                 << spaces << "     nReplicas " << nReplicas << std::endl;
00443             if (pv->GetParameterisation() != 0) 
00444                 out << spaces << "    It is parameterisation " << std::endl;
00445             else 
00446                 out << spaces << "     width " << width << std::endl
00447                     << spaces << "     offset " << offset << std::endl
00448                     << spaces << "     consuming" <<  consuming << std::endl;
00449             if (pv->GetParameterisation() != 0) 
00450                 out << spaces << "    It is parameterisation " << std::endl;
00451         }
00452     }
00453 }
00454 
00455 void PrintGeomMatInfo::dumpTouch(G4VPhysicalVolume * pv, unsigned int leafDepth, std::ostream & out)
00456 {
00457     std::string spaces = spacesFromLeafDepth(leafDepth);
00458     if (leafDepth == 0) fHistory.SetFirstEntry(pv);
00459     else fHistory.NewLevel(pv, kNormal, pv->GetCopyNo());
00460 
00461     G4ThreeVector globalpoint = fHistory.GetTopTransform().Inverse().
00462                                 TransformPoint(G4ThreeVector(0,0,0));
00463     G4LogicalVolume * lv = pv->GetLogicalVolume();
00464 
00465     std::string mother = "World";
00466     if (pv->GetMotherLogical()) mother = pv->GetMotherLogical()->GetName();
00467     std::string lvname = lv->GetName();
00468     lvname.assign(lvname,0,nchar);
00469     if (lvname == name)
00470         out << leafDepth << spaces << "### VOLUME = " << lv->GetName() 
00471             << " Copy No " << pv->GetCopyNo() << " in " << mother
00472             << " global position of centre " << globalpoint << " (r = " 
00473             <<  globalpoint.perp() << ", phi = " <<  globalpoint.phi()/deg
00474             << ")" << std::endl;
00475 
00476     int NoDaughters = lv->GetNoDaughters();
00477     while ((NoDaughters--)>0) 
00478     {
00479         G4VPhysicalVolume * pvD = lv->GetDaughter(NoDaughters);
00480         if (!pvD->IsReplicated()) dumpTouch(pvD, leafDepth+1, out);
00481     }
00482 
00483     if (leafDepth > 0) fHistory.BackLevel();
00484 }
00485 
00486 std::string PrintGeomMatInfo::spacesFromLeafDepth(unsigned int leafDepth)
00487 {
00488     std::string spaces;
00489     unsigned int ii;
00490     for(ii = 0; ii < leafDepth; ii++) { spaces += "  "; }
00491     return spaces;
00492 }
00493 
00494 void PrintGeomMatInfo::dumpSolid(G4VSolid * sol, unsigned int leafDepth, std::ostream & out)
00495 {
00496     std::string spaces = spacesFromLeafDepth(leafDepth);
00497     out << spaces << *(sol) << std::endl;
00498 }
00499 
00500 G4VPhysicalVolume * PrintGeomMatInfo::getTopPV()
00501 {
00502     return G4TransportationManager::GetTransportationManager()
00503         ->GetNavigatorForTracking()->GetWorldVolume();
00504 }
00505 
00506 G4LogicalVolume * PrintGeomMatInfo::getTopLV()
00507 { return theTopPV->GetLogicalVolume(); }
00508 
00509