00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <iomanip>
00032 #include <fstream>
00033 #include "globals.hh"
00034 #include "G3toG4.hh"
00035 #include "G3MatTable.hh"
00036 #include "G3MedTable.hh"
00037 #include "G3RotTable.hh"
00038 #include "G3VolTable.hh"
00039 #include "G3PartTable.hh"
00040 #include "G3DetTable.hh"
00041 #include "G3toG4BuildTree.hh"
00042 #include "G4GeometryManager.hh"
00043 #include "G4LogicalVolume.hh"
00044 #include "G4LogicalVolumeStore.hh"
00045 #include "G4PVPlacement.hh"
00046 #include "G4VisAttributes.hh"
00047
00048 extern std::ofstream ofile;
00049
00050 void G3CLRead(G4String &, char *);
00051 void checkVol(G4LogicalVolume*, G4int);
00052 void checkVol();
00053
00054
00055 G4LogicalVolume* G4BuildGeom(G4String& inFile){
00056
00057 G4int irot=0;
00058 G4gsrotm(0, 90, 0, 90, 90, 0, 0);
00059
00060 G4cout << "Instantiated unit rotation matrix irot=" << irot << G4endl;
00061
00062
00063
00064 G4cout << "Reading the call List file " << inFile << "..." << G4endl;
00065
00066 G3CLRead(inFile, 0);
00067
00068 G3Part.PrintAll();
00069
00070 G3Det.PrintAll();
00071
00072 G3Vol.PrintAll();
00073
00074 G4cout << "Call List file read completed. Build geometry" << G4endl;
00075
00076
00077
00078 G3VolTableEntry* topVTE = G3Vol.GetFirstVTE();
00079 G4cout << "G3toG4 top level volume is " << topVTE->GetName() << G4endl;
00080
00081
00082 G3toG4BuildTree(topVTE, 0);
00083
00084
00085
00086 G4LogicalVolume* topLV = topVTE->GetLV();
00087
00088
00089
00090
00091 new G4PVPlacement(0, G4ThreeVector(), topLV->GetName(), topLV, 0, false, 0);
00092
00093
00094
00095 topLV->SetVisAttributes(G4VisAttributes::Invisible);
00096
00097 G4cout << "Top-level G3toG4 logical volume " << topLV->GetName() << " "
00098 << *(topLV->GetVisAttributes()) << G4endl;
00099
00100
00101
00102 #ifdef G3G4DEBUG
00103 G4cout << "scan through G4LogicalVolumeStore:" << G4endl;
00104 checkVol();
00105 #endif
00106
00107 return topLV;
00108 }
00109
00110 void checkVol()
00111 {
00112 G4LogicalVolumeStore* theStore = G4LogicalVolumeStore::GetInstance();
00113 G4LogicalVolume* ll = (*theStore)[0];
00114 G4int level=0;
00115 checkVol(ll, level);
00116 }
00117
00118 void checkVol(G4LogicalVolume* _lvol, G4int level)
00119 {
00120 G4LogicalVolume* _ldvol;
00121 G4VPhysicalVolume* _pdvol;
00122 level++;
00123
00124 G4int ndau = _lvol -> GetNoDaughters();
00125
00126 G4cout << "G44LogicalVolume " << _lvol->GetName() << " at level " << level
00127 << " contains " << ndau << " daughters." << G4endl;
00128 for (G4int idau=0; idau<ndau; idau++){
00129 _pdvol = _lvol-> GetDaughter(idau);
00130 _ldvol = _pdvol -> GetLogicalVolume();
00131 G4cout << "G4VPhysical volume " << std::setw(5) << _pdvol -> GetName()
00132 << " (G4LogicalVolume " << std::setw(5) << _ldvol->GetName() << ")"
00133 << G4endl;
00134 checkVol(_ldvol, level);
00135 }
00136 return;
00137 }
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148