Warning, file /geant4/examples/extended/optical/OpNovice/src/OpNoviceGDMLDetectorConstruction.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #include "OpNoviceGDMLDetectorConstruction.hh"
0028
0029 #include "OpNoviceDetectorMessenger.hh"
0030
0031 #include "G4GDMLParser.hh"
0032 #include "G4LogicalVolumeStore.hh"
0033 #include "G4NistManager.hh"
0034 #include "G4PhysicalVolumeStore.hh"
0035 #include "G4RunManager.hh"
0036 #include "G4VisAttributes.hh"
0037 #include "globals.hh"
0038
0039
0040 OpNoviceGDMLDetectorConstruction::OpNoviceGDMLDetectorConstruction(G4String fname)
0041 : G4VUserDetectorConstruction()
0042 {
0043 fGdmlFile = fname;
0044
0045 fDetectorMessenger = new OpNoviceDetectorMessenger(this);
0046
0047 G4cout << "Building detector from GDML file: " << fname << G4endl << G4endl;
0048 }
0049
0050
0051 OpNoviceGDMLDetectorConstruction::~OpNoviceGDMLDetectorConstruction()
0052 {
0053 delete fDetectorMessenger;
0054 delete fParser;
0055 }
0056
0057
0058 G4VPhysicalVolume* OpNoviceGDMLDetectorConstruction::Construct()
0059 {
0060 ReadGDML();
0061 G4VPhysicalVolume* worldPhysVol = fParser->GetWorldVolume();
0062 if (fDumpGdml) fParser->Write(fDumpGdmlFileName, worldPhysVol);
0063 return worldPhysVol;
0064 }
0065
0066
0067 void OpNoviceGDMLDetectorConstruction::ConstructSDandField() {}
0068
0069
0070 void OpNoviceGDMLDetectorConstruction::ReadGDML()
0071 {
0072 fParser = new G4GDMLParser();
0073 fParser->Read(fGdmlFile, false);
0074 G4VPhysicalVolume* world = fParser->GetWorldVolume();
0075
0076 G4LogicalVolume* pworldLogical = world->GetLogicalVolume();
0077 pworldLogical->SetVisAttributes(nullptr);
0078 G4cout << world->GetTranslation() << G4endl << G4endl;
0079 if (fVerbose) {
0080 G4cout << "Found world: " << world->GetName() << G4endl;
0081 G4cout << "world LV: " << world->GetLogicalVolume()->GetName() << G4endl;
0082 }
0083 G4LogicalVolumeStore* pLVStore = G4LogicalVolumeStore::GetInstance();
0084 if (fVerbose) {
0085 G4cout << "Found " << pLVStore->size() << " logical volumes." << G4endl << G4endl;
0086 }
0087 G4PhysicalVolumeStore* pPVStore = G4PhysicalVolumeStore::GetInstance();
0088 if (fVerbose) {
0089 G4cout << "Found " << pPVStore->size() << " physical volumes." << G4endl << G4endl;
0090 }
0091 }
0092
0093
0094 void OpNoviceGDMLDetectorConstruction::UpdateGeometry()
0095 {
0096 G4RunManager::GetRunManager()->DefineWorldVolume(Construct());
0097 }
0098
0099
0100 void OpNoviceGDMLDetectorConstruction::SetDumpGdml(G4bool val)
0101 {
0102 fDumpGdml = val;
0103 }
0104
0105
0106 G4bool OpNoviceGDMLDetectorConstruction::IsDumpGdml() const
0107 {
0108 return fDumpGdml;
0109 }
0110
0111
0112 void OpNoviceGDMLDetectorConstruction::SetVerbose(G4bool val)
0113 {
0114 fVerbose = val;
0115 }
0116
0117
0118 G4bool OpNoviceGDMLDetectorConstruction::IsVerbose() const
0119 {
0120 return fVerbose;
0121 }
0122
0123
0124 void OpNoviceGDMLDetectorConstruction::SetDumpGdmlFile(G4String val)
0125 {
0126 fDumpGdmlFileName = val;
0127 }
0128
0129
0130 G4String OpNoviceGDMLDetectorConstruction::GetDumpGdmlFileName() const
0131 {
0132 return fDumpGdmlFileName;
0133 }