Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
ExTGDetectorConstructionWithCpp Class Reference

Detector construction class using text geometry file and C++ code. More...

#include <Doxymodules_persistency.h>

Inheritance diagram for ExTGDetectorConstructionWithCpp:
G4VUserDetectorConstruction

Public Member Functions

 ExTGDetectorConstructionWithCpp ()
 
 ~ExTGDetectorConstructionWithCpp ()
 
G4VPhysicalVolumeConstruct ()
 

Private Attributes

G4tgrMessengerfMessenger
 

Detailed Description

Detector construction class using text geometry file and C++ code.

Definition at line 116 of file Doxymodules_persistency.h.

Constructor & Destructor Documentation

◆ ExTGDetectorConstructionWithCpp()

ExTGDetectorConstructionWithCpp::ExTGDetectorConstructionWithCpp ( )

◆ ~ExTGDetectorConstructionWithCpp()

ExTGDetectorConstructionWithCpp::~ExTGDetectorConstructionWithCpp ( )

Definition at line 45 of file ExTGDetectorConstructionWithCpp.cc.

46{
47 delete fMessenger;
48}

Member Function Documentation

◆ Construct()

G4VPhysicalVolume * ExTGDetectorConstructionWithCpp::Construct ( )

Definition at line 51 of file ExTGDetectorConstructionWithCpp.cc.

52{
53 //------------------------------------------------
54 // Define one or several text files containing the geometry description
55 //------------------------------------------------
56 G4String filename = "g4geom_simple.txt";
57 G4tgbVolumeMgr* volmgr = G4tgbVolumeMgr::GetInstance();
58 volmgr->AddTextFile(filename);
59
60 //------------------------------------------------
61 // Read the text files and construct the GEANT4 geometry
62 //------------------------------------------------
63 G4VPhysicalVolume* physiWorld = volmgr->ReadAndConstructDetector();
64
65 //------------------------------------------------
66 // Build another volume and place it in the text geometry
67 //------------------------------------------------
68 G4Box* solid = new G4Box("mybox",2.,2.,3.);
69
70 G4Material* water = G4NistManager::Instance()->FindOrBuildMaterial("G4_Fe");
71
72 G4LogicalVolume* logicVol = new G4LogicalVolume(solid,water,"mybox",0,0,0);
73
74 //----- Place the volume in the world of the text geometry
75 G4LogicalVolume* textWorldVol = physiWorld->GetLogicalVolume();
76
77 // NOTE: if you want to place your full text geometry in the C++ geometry,
78 // you should use this G4LogicalVolume and place it in a C++ logical
79 // volume
80 new G4PVPlacement(0, // no rotation
81 G4ThreeVector(0.,-20.,0), // at (x,y,z)
82 logicVol, // its logical volume
83 "myBox1", // its name
84 textWorldVol, // its mother volume
85 false, // no boolean operations
86 0); // copy number
87
88 //----- Place the volume inside a volume of the text geometry
89 G4LogicalVolume* textSphereVol =
90 G4tgbVolumeMgr::GetInstance()->FindG4LogVol("sphere",1);
91 new G4PVPlacement(0, // no rotation
92 G4ThreeVector(0.,0.,0), // at (x,y,z)
93 logicVol, // its logical volume
94 "myBox2", // its name
95 textSphereVol, // its mother volume
96 false, // no boolean operations
97 1); // copy number
98
99 return physiWorld;
100}

Member Data Documentation

◆ fMessenger

G4tgrMessenger* ExTGDetectorConstructionWithCpp::fMessenger
private

Definition at line 51 of file ExTGDetectorConstructionWithCpp.hh.


The documentation for this class was generated from the following files:

Applications | User Support | Publications | Collaboration