G4BuildGeom.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // modified by I. Hrivnacova, 13.10.99 
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   // Read the call List and interpret to Generate Geant4 geometry
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   // Build the geometry
00077 
00078   G3VolTableEntry* topVTE = G3Vol.GetFirstVTE();
00079   G4cout << "G3toG4 top level volume is " << topVTE->GetName() << G4endl;
00080 
00081   // modified
00082   G3toG4BuildTree(topVTE, 0);
00083 
00084   // Retrieve the top-level G3toG4 logical mother volume pointer
00085 
00086   G4LogicalVolume* topLV = topVTE->GetLV();
00087 
00088   // position the top logical volume
00089   // (in Geant3 the top volume is not positioned)
00090   // 
00091   new G4PVPlacement(0, G4ThreeVector(), topLV->GetName(), topLV, 0, false, 0);
00092 
00093   // mark as invisible
00094 
00095   topLV->SetVisAttributes(G4VisAttributes::Invisible);
00096     
00097   G4cout << "Top-level G3toG4 logical volume " << topLV->GetName() << " "
00098          << *(topLV->GetVisAttributes()) << G4endl;
00099         
00100         // check the geometry here
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 

Generated on Mon May 27 17:47:48 2013 for Geant4 by  doxygen 1.4.7