Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:50:35

0001 #pragma once
0002 
0003 #include "G4VPhysicalVolume.hh"
0004 #include "G4PVPlacement.hh"
0005 
0006 
0007 struct U4Traverse
0008 {
0009     static void Traverse(const G4VPhysicalVolume* const top );
0010     static void Traverse_r(const G4VPhysicalVolume* const pv, int depth, int sibex,       int& count, int parent_numsib );
0011     static void Visit(     const G4VPhysicalVolume* const pv, int depth, int sibex, const int& count, int numsib );
0012 };
0013 
0014 
0015 
0016 inline void U4Traverse::Traverse(const G4VPhysicalVolume* const top )
0017 {
0018     int count = 0 ;
0019     Traverse_r(top, 0, 0, count, 0 );
0020 }
0021 
0022 inline void U4Traverse::Traverse_r(const G4VPhysicalVolume* const pv, int depth, int sibex, int& count, int parent_numsib )
0023 {
0024     const G4LogicalVolume* const lv = pv->GetLogicalVolume();
0025     int num_child = int(lv->GetNoDaughters()) ;
0026 
0027     Visit(pv, depth, sibex, count, num_child );
0028     count += 1 ;
0029 
0030     for (int i=0 ; i < num_child ;i++ )
0031     {
0032         const G4VPhysicalVolume* const child_pv = lv->GetDaughter(i);
0033 
0034         Traverse_r(child_pv, depth+1, i, count, num_child );
0035     }
0036 }
0037 
0038 inline void U4Traverse::Visit( const G4VPhysicalVolume* const pv, int depth, int sibex, const int& count, int numsib )
0039 {
0040     const G4PVPlacement* placement = dynamic_cast<const G4PVPlacement*>(pv);
0041     assert(placement);
0042     G4int copy = placement->GetCopyNo() ;
0043 
0044     std::cout
0045          << " count " << std::setw(6) << count
0046          << " depth " << std::setw(6) << depth
0047          << " sibex " << std::setw(6) << sibex
0048          << " copy  " << std::setw(6) << copy
0049          << " numsib  " << std::setw(6) << numsib
0050          << std::endl
0051          ;
0052 }
0053 
0054 
0055