Geant4-11
Public Member Functions | Data Fields | Protected Member Functions | Private Attributes
test.MyDetectorConstruction Class Referenceabstract
Inheritance diagram for test.MyDetectorConstruction:
G4VUserDetectorConstruction G4VUserDetectorConstruction G4VUserDetectorConstruction G4VUserDetectorConstruction

Public Member Functions

def __init__ (self)
 
def __init__ (self)
 
def __init__ (self)
 
def __init__ (self)
 
virtual void CloneF ()
 
virtual void CloneSD ()
 
virtual G4VPhysicalVolumeConstruct ()=0
 
def Construct (self)
 
def Construct (self)
 
def Construct (self)
 
def Construct (self)
 
def ConstructBox (self)
 
def ConstructCons (self)
 
def ConstructEllipsoid (self)
 
def ConstructEllipticalCone (self)
 
def ConstructEllipticalTube (self)
 
def ConstructHype (self)
 
def ConstructIntersection (self)
 
def ConstructOrb (self)
 
def ConstructPara (self)
 
G4int ConstructParallelGeometries ()
 
void ConstructParallelSD ()
 
def ConstructPolycone (self)
 
def ConstructPolyhedra (self)
 
virtual void ConstructSDandField ()
 
def ConstructSphere (self)
 
def ConstructSubtraction (self)
 
def ConstructTet (self)
 
def ConstructTorus (self)
 
def ConstructTrap (self)
 
def ConstructTrd (self)
 
def ConstructTubs (self)
 
def ConstructTwistedBox (self)
 
def ConstructTwistedTrap (self)
 
def ConstructTwistedTrd (self)
 
def ConstructTwistedTubs (self)
 
def ConstructUnion (self)
 
def ConstructWorld (self)
 
def ConstructWorld (self)
 
G4int GetNumberOfParallelWorld () const
 
G4VUserParallelWorldGetParallelWorld (G4int i) const
 
void RegisterParallelWorld (G4VUserParallelWorld *)
 

Data Fields

 air
 
 lv_object
 
 sld_box
 
 sld_cyl
 
 va_blue
 
 va_cyan
 
 va_green
 
 va_magenta
 
 va_red
 
 world
 

Protected Member Functions

void SetSensitiveDetector (const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
 
void SetSensitiveDetector (G4LogicalVolume *logVol, G4VSensitiveDetector *aSD)
 

Private Attributes

std::vector< G4VUserParallelWorld * > parallelWorld
 

Detailed Description

Definition at line 15 of file test.py.

Constructor & Destructor Documentation

◆ __init__() [1/4]

def test.MyDetectorConstruction.__init__ (   self)

Definition at line 18 of file test.py.

18 def __init__(self):
19 G4VUserDetectorConstruction.__init__(self)
20 self.air= gNistManager.FindOrBuildMaterial("G4_AIR")
21 self.lv_object= None
22 self.world= self.ConstructWorld()
23
24 self.va_red= G4VisAttributes(G4Color(1.,0.,0.))
25 self.va_cyan= G4VisAttributes(G4Color(0.,1.,1.))
26 self.va_green= G4VisAttributes(G4Color(0.,1.,0.))
27 self.va_blue= G4VisAttributes(G4Color(0.,0.,1.))
28 self.va_magenta= G4VisAttributes(G4Color(1.,0.,1.))
29

◆ __init__() [2/4]

def test.MyDetectorConstruction.__init__ (   self)

Definition at line 17 of file test.py.

17 def __init__(self):
18 G4VUserDetectorConstruction.__init__(self)
19 self.air= gNistManager.FindOrBuildMaterial("G4_AIR")
20 self.lv_object= None
21 self.world= self.ConstructWorld()
22
23 self.va_red= G4VisAttributes(G4Color(1.,0.,0.))
24 self.va_cyan= G4VisAttributes(G4Color(0.,1.,1.))
25 self.va_green= G4VisAttributes(G4Color(0.,1.,0.))
26 self.va_blue= G4VisAttributes(G4Color(0.,0.,1.))
27 self.va_magenta= G4VisAttributes(G4Color(1.,0.,1.))
28
29 self.sld_box= G4Box("box",20.*cm, 20.*cm, 20.*cm);
30 self.sld_cyl= G4Tubs("cylinder",0., 10.*cm, 30.*cm, 0., twopi)
31
Definition: G4Box.hh:56
Definition: G4Tubs.hh:75

References test.MyDetectorConstruction.air, test.MyDetectorConstruction.ConstructWorld(), test.MyDetectorConstruction.lv_object, test.MyDetectorConstruction.va_blue, test.MyDetectorConstruction.va_cyan, test.MyDetectorConstruction.va_green, test.MyDetectorConstruction.va_magenta, test.MyDetectorConstruction.va_red, read_gdml.MyDetectorConstruction.world, G4EzWorld.world, test.MyDetectorConstruction.world, G4VMarker.world, and G4VSceneHandler.world.

◆ __init__() [3/4]

def test.MyDetectorConstruction.__init__ (   self)

Definition at line 17 of file test.py.

17 def __init__(self):
18 G4VUserDetectorConstruction.__init__(self)
19

◆ __init__() [4/4]

def test.MyDetectorConstruction.__init__ (   self)

Definition at line 17 of file test.py.

17 def __init__(self):
18 G4VUserDetectorConstruction.__init__(self)
19

Member Function Documentation

◆ CloneF()

void G4VUserDetectorConstruction::CloneF ( )
virtualinherited

Definition at line 126 of file G4VUserDetectorConstruction.cc.

127{
128 using FMtoFMmap = std::map<G4FieldManager*, G4FieldManager*>;
129 using FMpair = std::pair<G4FieldManager*, G4FieldManager*>;
130
131 FMtoFMmap masterToWorker;
133 for(auto it = logVolStore->cbegin(); it != logVolStore->cend(); ++it)
134 {
135 G4LogicalVolume* g4LogicalVolume = *it;
136 // Use shadow of master to get instance of FM
137 G4FieldManager* masterFM = nullptr; // g4LogicalVolume->fFieldManager;
138 G4FieldManager* clonedFM = nullptr;
139 if(masterFM != nullptr)
140 {
141 auto fmFound = masterToWorker.find(masterFM);
142 if(fmFound == masterToWorker.cend())
143 {
144 // First time we see this SD, let's clone and remember...
145 try
146 {
147 auto insertedEl =
148 masterToWorker.insert(FMpair(masterFM, masterFM->Clone()));
149 clonedFM = (insertedEl.first)->second;
150 } catch(...)
151 {
153 msg << "Cloning of G4FieldManager failed."
154 << " But derived class does not implement cloning. Cannot "
155 "continue.";
156 G4Exception("G4VUserDetectorConstruction::CloneSD()", "Run0053",
157 FatalException, msg);
158 }
159 }
160 else
161 {
162 // We have already seen this SD attached to a different LogicalVolume,
163 // let's re-use previous clone
164 clonedFM = (*fmFound).second;
165 }
166 } // masterFM != 0
167 // Note that we do not push FM to daughters (false argument), however, since
168 // we area looping on all logical volumes and we implemented the "trick" of
169 // the map master<->cloned the final effect is the same as using here the
170 // correct Boolean flag: log-volumes that originally were sharing the same
171 // FM they will have cloned ones
172 g4LogicalVolume->SetFieldManager(clonedFM, false);
173 }
174}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
static constexpr double second
Definition: G4SIunits.hh:137
virtual G4FieldManager * Clone() const
static G4LogicalVolumeStore * GetInstance()
void SetFieldManager(G4FieldManager *pFieldMgr, G4bool forceToAllDaughters)

References G4FieldManager::Clone(), FatalException, G4Exception(), G4LogicalVolumeStore::GetInstance(), second, and G4LogicalVolume::SetFieldManager().

◆ CloneSD()

void G4VUserDetectorConstruction::CloneSD ( )
virtualinherited

Definition at line 177 of file G4VUserDetectorConstruction.cc.

178{
179 // Loop on ALL logial volumes to search for attached SD
181
182 using SDtoSDmap = std::map<G4VSensitiveDetector*, G4VSensitiveDetector*>;
183 using SDpair = std::pair<G4VSensitiveDetector*, G4VSensitiveDetector*>;
184 SDtoSDmap masterToWorker;
185
186 for(auto it = logVolStore->cbegin(); it != logVolStore->cend(); ++it)
187 {
188 G4LogicalVolume* g4LogicalVolume = *it;
189 // Use shadow of master to get the instance of SD
190 G4VSensitiveDetector* masterSD = nullptr;
191 G4VSensitiveDetector* clonedSD = nullptr;
192 if(masterSD != nullptr)
193 {
194 auto sdFound = masterToWorker.find(masterSD);
195 if(sdFound == masterToWorker.cend())
196 {
197 // First time we see this SD, let's clone and remember...
198 try
199 {
200 auto insertedEl =
201 masterToWorker.insert(SDpair(masterSD, masterSD->Clone()));
202 clonedSD = (insertedEl.first)->second;
203 } catch(...)
204 {
206 msg << "Cloning of G4VSensitiveDetector requested for:"
207 << masterSD->GetName() << "\n"
208#ifndef WIN32
209 << " (full path name: " << masterSD->GetFullPathName() << ").\n"
210#endif
211 << " But derived class does not implement cloning. Cannot "
212 "continue.";
213 G4Exception("G4VUserDetectorConstruction::CloneSD()", "Run0053",
214 FatalException, msg);
215 }
216 }
217 else
218 {
219 // We have already seen this SD attached to a different LogicalVolume,
220 // let's re-use previous clone
221 clonedSD = (*sdFound).second;
222 }
223 } // masterSD!=0
224 g4LogicalVolume->SetSensitiveDetector(clonedSD);
225 }
226}
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)
virtual G4VSensitiveDetector * Clone() const
G4String GetFullPathName() const

References G4VSensitiveDetector::Clone(), FatalException, G4Exception(), G4VSensitiveDetector::GetFullPathName(), G4LogicalVolumeStore::GetInstance(), G4VSensitiveDetector::GetName(), second, and G4LogicalVolume::SetSensitiveDetector().

◆ Construct() [1/5]

virtual G4VPhysicalVolume * G4VUserDetectorConstruction::Construct ( )
pure virtualinherited

◆ Construct() [2/5]

def test.MyDetectorConstruction.Construct (   self)

Definition at line 251 of file test.py.

251 def Construct(self): # return the world volume
252 return self.world
253
254# ==================================================================
255# main
256# ==================================================================
257os.environ["G4VRML_DEST_DIR"]= "."
258os.environ["G4VRMLFILE_MAX_FILE_NUM"]= "1"
259os.environ["G4VRMLFILE_VIEWER"]= "echo"
260
261# set geometry
263gRunManager.SetUserInitialization(myDC)
264
265# minimal physics list
266g4pytest.ExN01pl.Construct()
267
268# set primary generator action
269g4pytest.ParticleGun.Construct()
270
271# initialize
272gRunManager.Initialize()
273
274# visualization
275gApplyUICommand("/vis/open VRML2FILE")
276gApplyUICommand("/vis/scene/create")
277gApplyUICommand("/vis/scene/add/volume")
278gApplyUICommand("/vis/sceneHandler/attach")
279gApplyUICommand("/vis/scene/add/axes 0. 0. 0. 10. cm")
280
281# create a vrml file for each solid type
282f_list= (
PhysicsListEMstd * Construct()
Definition: pyEMSTDpl.cc:47
gApplyUICommand
Definition: __init__.py:158

References source.gApplyUICommand, read_gdml.MyDetectorConstruction.world, G4EzWorld.world, test.MyDetectorConstruction.world, G4VMarker.world, and G4VSceneHandler.world.

◆ Construct() [3/5]

def test.MyDetectorConstruction.Construct (   self)

Definition at line 88 of file test.py.

88 def Construct(self): # return the world volume
89 return self.world
90
91# ==================================================================
92# main
93# ==================================================================
94# set geometry
96gRunManager.SetUserInitialization(myDC)
97
98# minimal physics list
99g4pytest.ExN01pl.Construct()
100
101# set primary generator action
102g4pytest.ParticleGun.Construct()
103
104# initialize
105gRunManager.Initialize()
106
107# visualization
108gApplyUICommand("/vis/open RayTracer")
109gApplyUICommand("/vis/rayTracer/headAngle 40.")
110gApplyUICommand("/vis/rayTracer/eyePosition 100 100 150 cm")
111
112# create a vrml file for each solid type
113f_list= (

References source.gApplyUICommand, read_gdml.MyDetectorConstruction.world, G4EzWorld.world, test.MyDetectorConstruction.world, G4VMarker.world, and G4VSceneHandler.world.

◆ Construct() [4/5]

def test.MyDetectorConstruction.Construct (   self)

Definition at line 21 of file test.py.

21 def Construct(self):
22 # Python has automatic garbage collection system.
23 # Geometry objects must be defined as GLOBAL not to be deleted.
24 air= gNistManager.FindOrBuildMaterial("G4_AIR")
25
26 # world volume
27 global sld_world, lv_world, pv_world
28 sld_world= G4Box("world", 1.*m, 1.*m, 1.*m)
29 lv_world= G4LogicalVolume(sld_world, air, "world")
30 pv_world= G4PVPlacement(G4Transform3D(), lv_world, "world",
31 None, False, 0)
32
33 # box
34 global sld_box, lv_box, pv_box
35 sld_box= G4Box("box", 10.*cm, 10.*cm, 10.*cm);
36 lv_box= G4LogicalVolume(sld_box, air, "box")
37 pv_box= G4PVPlacement(None, G4ThreeVector(), "box", lv_box,
38 pv_world, False, 0, True)
39
40 # cylinder
41 global sld_cyl, lv_cyl, pv_cyl1, pv_cyl2, pv_cyl3
42 sld_cyl= G4Tubs("cylinder",0., 2.*cm, 2.*cm, 0., twopi)
43 lv_cyl= G4LogicalVolume(sld_cyl, air, "cylinder")
44
45 #
46 # the following placements are !! overlapped !!
47 #
48 # doubly placed
49 pv_cyl1= G4PVPlacement(None, G4ThreeVector(), "cylinder", lv_cyl,
50 pv_world, False, 0, True)
51
52 # overlaped
53 pv_cyl2= G4PVPlacement(None, G4ThreeVector(10.*cm,0.,0.),
54 "cylinder", lv_cyl,
55 pv_world, False, 1, True)
56
57 # sticked out
58 pv_cyl3= G4PVPlacement(None, G4ThreeVector(10.*cm,0.,0.),
59 "cylinder", lv_cyl,
60 pv_box, False, 0, True)
61
62 return pv_world
63
64# ==================================================================
65# main
66# ==================================================================
67# set geometry
69gRunManager.SetUserInitialization(myDC)
70
71# minimal physics list
72g4pytest.ExN01pl.Construct()
73
74# set primary generator action
75g4pytest.ParticleGun.Construct()
76
77# initialize
78gRunManager.Initialize() # overlap should be detected !!
79
80

◆ Construct() [5/5]

def test.MyDetectorConstruction.Construct (   self)

Definition at line 21 of file test.py.

21 def Construct(self):
22 # Python has automatic garbage collection system.
23 # Geometry objects must be defined as GLOBAL not to be deleted.
24 air= gNistManager.FindOrBuildMaterial("G4_AIR")
25
26 # world volume
27 global sld_world, lv_world, pv_world
28 sld_world= G4Box("world", 1.*m, 1.*m, 1.*m)
29 lv_world= G4LogicalVolume(sld_world, air, "world")
30 pv_world= G4PVPlacement(G4Transform3D(), lv_world, "world",
31 None, False, 0)
32
33 return pv_world
34

◆ ConstructBox()

def test.MyDetectorConstruction.ConstructBox (   self)

Definition at line 55 of file test.py.

55 def ConstructBox(self):
56 global sld_box
57 sld_box= G4Box("box", 30.*cm, 40.*cm, 60.*cm)
58 self.lv_object.SetSolid(sld_box)
59 self.lv_object.SetVisAttributes(self.va_red)
60 gRunManager.GeometryHasBeenModified()
61

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_red.

◆ ConstructCons()

def test.MyDetectorConstruction.ConstructCons (   self)

Definition at line 71 of file test.py.

71 def ConstructCons(self):
72 global sld_cons
73 sld_cons= G4Cons("cons", 5.*cm, 10.*cm, 20.*cm, 25.*cm,
74 40.*cm, 0., 4./3.*pi)
75 self.lv_object.SetSolid(sld_cons)
76 self.lv_object.SetVisAttributes(self.va_green)
77 gRunManager.GeometryHasBeenModified()
78
Definition: G4Cons.hh:78

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_green.

◆ ConstructEllipsoid()

def test.MyDetectorConstruction.ConstructEllipsoid (   self)

Definition at line 173 of file test.py.

173 def ConstructEllipsoid(self):
174 global sld_es
175 sld_es= G4Ellipsoid("ellipsoid", 10.*cm, 20.*cm, 50.*cm,
176 -10.*cm, 40.*cm)
177 self.lv_object.SetSolid(sld_es)
178 self.lv_object.SetVisAttributes(self.va_red)
179 gRunManager.GeometryHasBeenModified()
180

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_red.

◆ ConstructEllipticalCone()

def test.MyDetectorConstruction.ConstructEllipticalCone (   self)

Definition at line 182 of file test.py.

182 def ConstructEllipticalCone(self):
183 global sld_ec
184 sld_ec= G4EllipticalCone("ellipticalcone", 30.*cm, 60.*cm,
185 50.*cm, 25.*cm)
186 self.lv_object.SetSolid(sld_ec)
187 self.lv_object.SetVisAttributes(self.va_magenta)
188 gRunManager.GeometryHasBeenModified()
189

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_magenta.

◆ ConstructEllipticalTube()

def test.MyDetectorConstruction.ConstructEllipticalTube (   self)

Definition at line 165 of file test.py.

165 def ConstructEllipticalTube(self):
166 global sld_et
167 sld_et= G4EllipticalTube("ellipticaltube", 5.*cm, 10.*cm, 20.*cm)
168 self.lv_object.SetSolid(sld_et)
169 self.lv_object.SetVisAttributes(self.va_cyan)
170 gRunManager.GeometryHasBeenModified()
171

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_cyan.

◆ ConstructHype()

def test.MyDetectorConstruction.ConstructHype (   self)

Definition at line 191 of file test.py.

191 def ConstructHype(self):
192 global sld_hype
193 sld_hype= G4Hype("hype", 20.*cm, 30.*cm, 0.7, 0.7, 50.*cm)
194 self.lv_object.SetSolid(sld_hype)
195 self.lv_object.SetVisAttributes(self.va_blue)
196 gRunManager.GeometryHasBeenModified()
197
Definition: G4Hype.hh:69

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_blue.

◆ ConstructIntersection()

def test.MyDetectorConstruction.ConstructIntersection (   self)

Definition at line 66 of file test.py.

66 def ConstructIntersection(self):
67 offset= G4ThreeVector(20.*cm, 20.*cm, 0.)
68 global sld_intersection
69 sld_intersection= G4IntersectionSolid("box*cylinder",
70 self.sld_box, self.sld_cyl,
71 None, offset)
72
73 self.lv_object.SetSolid(sld_intersection)
74 self.lv_object.SetVisAttributes(self.va_magenta)
75 gRunManager.GeometryHasBeenModified()
76

References test.MyDetectorConstruction.lv_object, test.MyDetectorConstruction.sld_box, test.MyDetectorConstruction.sld_cyl, and test.MyDetectorConstruction.va_magenta.

◆ ConstructOrb()

def test.MyDetectorConstruction.ConstructOrb (   self)

Definition at line 115 of file test.py.

115 def ConstructOrb(self):
116 global sld_orb
117 sld_orb= G4Orb("orb", 100.*cm)
118 self.lv_object.SetSolid(sld_orb)
119 self.lv_object.SetVisAttributes(self.va_red)
120 gRunManager.GeometryHasBeenModified()
121
Definition: G4Orb.hh:56

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_red.

◆ ConstructPara()

def test.MyDetectorConstruction.ConstructPara (   self)

Definition at line 80 of file test.py.

80 def ConstructPara(self):
81 global sld_para
82 sld_para= G4Para("para", 30.*cm, 40.*cm, 60.*cm, pi/4., pi/8., 0.)
83 self.lv_object.SetSolid(sld_para)
84 self.lv_object.SetVisAttributes(self.va_blue)
85 gRunManager.GeometryHasBeenModified()
86
Definition: G4Para.hh:79

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_blue.

◆ ConstructParallelGeometries()

G4int G4VUserDetectorConstruction::ConstructParallelGeometries ( )
inherited

Definition at line 73 of file G4VUserDetectorConstruction.cc.

74{
75 G4int nP = 0;
76 for(auto pwItr = parallelWorld.cbegin();
77 pwItr != parallelWorld.cend(); ++pwItr)
78 {
79 (*pwItr)->Construct();
80 ++nP;
81 }
82 return nP;
83}
int G4int
Definition: G4Types.hh:85
std::vector< G4VUserParallelWorld * > parallelWorld

References G4VUserDetectorConstruction::parallelWorld.

Referenced by G4RunManager::InitializeGeometry().

◆ ConstructParallelSD()

void G4VUserDetectorConstruction::ConstructParallelSD ( )
inherited

Definition at line 86 of file G4VUserDetectorConstruction.cc.

87{
88 for(auto pwItr = parallelWorld.cbegin();
89 pwItr != parallelWorld.cend(); ++pwItr)
90 {
91 (*pwItr)->ConstructSD();
92 }
93}

References G4VUserDetectorConstruction::parallelWorld.

Referenced by G4RunManager::InitializeGeometry(), and G4WorkerRunManager::InitializeGeometry().

◆ ConstructPolycone()

def test.MyDetectorConstruction.ConstructPolycone (   self)

Definition at line 131 of file test.py.

131 def ConstructPolycone(self):
132 zvec= G4doubleVector()
133 rinvec= G4doubleVector()
134 routvec= G4doubleVector()
135
136 zvec[:]= [ 5.*cm, 7.*cm, 9.*cm, 11.*cm, 25.*cm, 27.*cm, 29.*cm,
137 31.*cm, 35.*cm ]
138 rinvec[:]= [0.,0.,0.,0.,0.,0.,0.,0.,0.]
139 routvec[:]= [ 0., 10.*cm, 10.*cm, 5.*cm, 5.*cm, 10.*cm,
140 10.*cm, 2.*cm, 2.*cm ]
141
142 global sld_pcon
143 sld_pcon= CreatePolycone("pcon", 0., twopi, 9, zvec, rinvec,routvec)
144 self.lv_object.SetSolid(sld_pcon)
145 self.lv_object.SetVisAttributes(self.va_cyan)
146 gRunManager.GeometryHasBeenModified()
147
std::vector< G4double > G4doubleVector
Definition: pyglobals.cc:64

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_cyan.

◆ ConstructPolyhedra()

def test.MyDetectorConstruction.ConstructPolyhedra (   self)

Definition at line 149 of file test.py.

149 def ConstructPolyhedra(self):
150 zvec= G4doubleVector()
151 rinvec= G4doubleVector()
152 routvec= G4doubleVector()
153
154 zvec[:]= [ 0., 5.*cm, 8.*cm, 13.*cm, 30.*cm, 32.*cm, 35.*cm ]
155 rinvec[:]= [0.,0.,0.,0.,0.,0.,0. ]
156 routvec[:]= [ 0., 15.*cm, 15.*cm, 4.*cm, 4.*cm, 10.*cm, 10.*cm ]
157
158 global sld_pgon
159 sld_pgon= CreatePolyhedra("pgon", 0., twopi, 5, 7, zvec, rinvec,routvec)
160 self.lv_object.SetSolid(sld_pgon)
161 self.lv_object.SetVisAttributes(self.va_green)
162 gRunManager.GeometryHasBeenModified()
163

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_green.

◆ ConstructSDandField()

void G4VUserDetectorConstruction::ConstructSDandField ( )
virtualinherited

Definition at line 111 of file G4VUserDetectorConstruction.cc.

112{
113 // G4RunManager::RMType rmtype =
114 // G4RunManager::GetRunManager()->GetRunManagerType(); if(rmtype !=
115 // G4RunManager::sequentialRM)
116 // {
117 // G4cout
118 // << "User-derived detector construction class does not implement \n"
119 // << "ConstructSDandFiled method: workers will not have SD and fields!\n"
120 // << "The user can safely ignore this message if (s)he has no sensitive\n"
121 // << "detector or field in her/his application." << G4endl;
122 // }
123}

Referenced by G4RunManager::InitializeGeometry(), and G4WorkerRunManager::InitializeGeometry().

◆ ConstructSphere()

def test.MyDetectorConstruction.ConstructSphere (   self)

Definition at line 106 of file test.py.

106 def ConstructSphere(self):
107 global sld_sphere
108 sld_sphere= G4Sphere("sphere", 100.*cm, 120.*cm, 0., 180.*deg,
109 0., 180.*deg)
110 self.lv_object.SetSolid(sld_sphere)
111 self.lv_object.SetVisAttributes(self.va_cyan)
112 gRunManager.GeometryHasBeenModified()
113

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_cyan.

◆ ConstructSubtraction()

def test.MyDetectorConstruction.ConstructSubtraction (   self)

Definition at line 78 of file test.py.

78 def ConstructSubtraction(self):
79 global sld_subtraction
80 sld_subtraction= G4SubtractionSolid("box-cylinder",
81 self.sld_box, self.sld_cyl)
82
83 self.lv_object.SetSolid(sld_subtraction)
84 self.lv_object.SetVisAttributes(self.va_red)
85 gRunManager.GeometryHasBeenModified()
86

References test.MyDetectorConstruction.lv_object, test.MyDetectorConstruction.sld_box, test.MyDetectorConstruction.sld_cyl, and test.MyDetectorConstruction.va_red.

◆ ConstructTet()

def test.MyDetectorConstruction.ConstructTet (   self)

Definition at line 199 of file test.py.

199 def ConstructTet(self):
200 global sld_tet
201 p1= G4ThreeVector(0., 0., math.sqrt(3.)*cm)
202 p2= G4ThreeVector(0., 2*math.sqrt(2./3.)*cm, -1./math.sqrt(3)*cm)
203 p3= G4ThreeVector(-math.sqrt(2.)*cm, -math.sqrt(2./3.)*cm,
204 -1./math.sqrt(3)*cm)
205 p4= G4ThreeVector(math.sqrt(2)*cm, -math.sqrt(2./3.)*cm,
206 -1./math.sqrt(3)*cm)
207
208 sld_tet= G4Tet("tet", 20.*p1, 20.*p2, 20.*p3, 20.*p4)
209 self.lv_object.SetSolid(sld_tet)
210 self.lv_object.SetVisAttributes(self.va_green)
211 gRunManager.GeometryHasBeenModified()
212
Definition: G4Tet.hh:56

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_green.

◆ ConstructTorus()

def test.MyDetectorConstruction.ConstructTorus (   self)

Definition at line 123 of file test.py.

123 def ConstructTorus(self):
124 global sld_torus
125 sld_torus= G4Torus("torus", 40.*cm, 60.*cm, 200.*cm, 0., 90.*deg)
126 self.lv_object.SetSolid(sld_torus)
127 self.lv_object.SetVisAttributes(self.va_magenta)
128 gRunManager.GeometryHasBeenModified()
129

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_magenta.

◆ ConstructTrap()

def test.MyDetectorConstruction.ConstructTrap (   self)

Definition at line 96 of file test.py.

96 def ConstructTrap(self):
97 global sld_trap
98 sld_trap= G4Trap("trap", 60.*cm, 20.*degree, 5.*degree,
99 40.*cm, 30.*cm, 40.*cm, 10.*degree,
100 16.*cm, 10*cm, 14.*cm, 10.*deg)
101 self.lv_object.SetSolid(sld_trap)
102 self.lv_object.SetVisAttributes(self.va_green)
103 gRunManager.GeometryHasBeenModified()
104

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_green.

◆ ConstructTrd()

def test.MyDetectorConstruction.ConstructTrd (   self)

Definition at line 88 of file test.py.

88 def ConstructTrd(self):
89 global sld_trd
90 sld_trd= G4Trd("trd", 30.*cm, 10.*cm, 40.*cm, 15.*cm, 60.*cm)
91 self.lv_object.SetSolid(sld_trd)
92 self.lv_object.SetVisAttributes(self.va_blue)
93 gRunManager.GeometryHasBeenModified()
94
Definition: G4Trd.hh:63

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_blue.

◆ ConstructTubs()

def test.MyDetectorConstruction.ConstructTubs (   self)

Definition at line 63 of file test.py.

63 def ConstructTubs(self):
64 global sld_tubs
65 sld_tubs= G4Tubs("tubs", 10.*cm, 15.*cm, 20.*cm, 0., pi)
66 self.lv_object.SetSolid(sld_tubs)
67 self.lv_object.SetVisAttributes(self.va_cyan)
68 gRunManager.GeometryHasBeenModified()
69

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_cyan.

◆ ConstructTwistedBox()

def test.MyDetectorConstruction.ConstructTwistedBox (   self)

Definition at line 214 of file test.py.

214 def ConstructTwistedBox(self):
215 global sld_twb
216 sld_twb= G4TwistedBox("twistedbox", 30.*deg, 30.*cm, 40.*cm, 60.*cm)
217 self.lv_object.SetSolid(sld_twb)
218 self.lv_object.SetVisAttributes(self.va_cyan)
219 gRunManager.GeometryHasBeenModified()
220

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_cyan.

◆ ConstructTwistedTrap()

def test.MyDetectorConstruction.ConstructTwistedTrap (   self)

Definition at line 222 of file test.py.

222 def ConstructTwistedTrap(self):
223 global sld_twtrp
224 sld_twtrp= G4TwistedTrap("twistedtrap", 30.*deg,
225 60.*cm, 20.*deg, 5.*deg,
226 40.*cm, 30.*cm, 40.*cm,
227 16.*cm, 10.*cm, 14.*cm, 10.*deg)
228 self.lv_object.SetSolid(sld_twtrp)
229 self.lv_object.SetVisAttributes(self.va_blue)
230 gRunManager.GeometryHasBeenModified()
231

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_blue.

◆ ConstructTwistedTrd()

def test.MyDetectorConstruction.ConstructTwistedTrd (   self)

Definition at line 233 of file test.py.

233 def ConstructTwistedTrd(self):
234 global sld_twtrd
235 sld_twtrd= G4TwistedTrd("twistedtrd", 30.*cm, 10.*cm,
236 40.*cm, 15.*cm, 60.*cm, 30.*deg)
237 self.lv_object.SetSolid(sld_twtrd)
238 self.lv_object.SetVisAttributes(self.va_green)
239 gRunManager.GeometryHasBeenModified()
240

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_green.

◆ ConstructTwistedTubs()

def test.MyDetectorConstruction.ConstructTwistedTubs (   self)

Definition at line 242 of file test.py.

242 def ConstructTwistedTubs(self):
243 global sld_twt
244 sld_twt= G4TwistedTubs("twistedtube", 60.*deg,
245 10.*cm, 15.*cm, 20.*cm, 90.*deg)
246 self.lv_object.SetSolid(sld_twt)
247 self.lv_object.SetVisAttributes(self.va_magenta)
248 gRunManager.GeometryHasBeenModified()
249

References test.MyDetectorConstruction.lv_object, and test.MyDetectorConstruction.va_magenta.

◆ ConstructUnion()

def test.MyDetectorConstruction.ConstructUnion (   self)

Definition at line 57 of file test.py.

57 def ConstructUnion(self):
58 global sld_union
59 sld_union= G4UnionSolid("box+cylinder", self.sld_box, self.sld_cyl);
60
61 self.lv_object.SetSolid(sld_union)
62 self.lv_object.SetVisAttributes(self.va_blue)
63 gRunManager.GeometryHasBeenModified()
64

References test.MyDetectorConstruction.lv_object, test.MyDetectorConstruction.sld_box, test.MyDetectorConstruction.sld_cyl, and test.MyDetectorConstruction.va_blue.

◆ ConstructWorld() [1/2]

def test.MyDetectorConstruction.ConstructWorld (   self)

Definition at line 31 of file test.py.

31 def ConstructWorld(self):
32 # Python has automatic garbage collection system.
33 # Geometry objects must be defined as GLOBAL not to be deleted.
34 global sld_world, lv_world, pv_world, va_world
35
36 sld_world= G4Box("world", 1.*m, 1.*m, 1.*m)
37 lv_world= G4LogicalVolume(sld_world, self.air, "world")
38 pv_world= G4PVPlacement(G4Transform3D(), lv_world, "world",
39 None, False, 0)
40
41 va_world= G4VisAttributes()
42 va_world.SetVisibility(False)
43 lv_world.SetVisAttributes(va_world)
44
45 # solid object (dummy)
46 global sld_sld, lv_sld, pv_sld
47 sld_sld= G4Box("dummy", 10.*cm, 10.*cm, 10.*cm)
48 self.lv_object= lv_sld= G4LogicalVolume(sld_sld, self.air, "dummy")
49 pv_sld= G4PVPlacement(None, G4ThreeVector(), "dummy", lv_sld,
50 pv_world, False, 0)
51
52 return pv_world
53

References test.MyDetectorConstruction.air, and test.MyDetectorConstruction.lv_object.

Referenced by test.MyDetectorConstruction.__init__().

◆ ConstructWorld() [2/2]

def test.MyDetectorConstruction.ConstructWorld (   self)

Definition at line 33 of file test.py.

33 def ConstructWorld(self):
34 # Python has automatic garbage collection system.
35 # Geometry objects must be defined as GLOBAL not to be deleted.
36 global sld_world, lv_world, pv_world, va_world
37
38 sld_world= G4Box("world", 1.*m, 1.*m, 1.*m)
39 lv_world= G4LogicalVolume(sld_world, self.air, "world")
40 pv_world= G4PVPlacement(G4Transform3D(), lv_world, "world",
41 None, False, 0)
42
43 va_world= G4VisAttributes()
44 va_world.SetVisibility(False)
45 lv_world.SetVisAttributes(va_world)
46
47 # solid object (dummy)
48 global sld_sld, lv_sld, pv_sld
49 sld_sld= G4Box("dummy", 10.*cm, 10.*cm, 10.*cm)
50 self.lv_object= lv_sld= G4LogicalVolume(sld_sld, self.air, "dummy")
51 pv_sld= G4PVPlacement(None, G4ThreeVector(), "dummy", lv_sld,
52 pv_world, False, 0)
53
54 return pv_world
55

References test.MyDetectorConstruction.air, and test.MyDetectorConstruction.lv_object.

Referenced by test.MyDetectorConstruction.__init__().

◆ GetNumberOfParallelWorld()

G4int G4VUserDetectorConstruction::GetNumberOfParallelWorld ( ) const
inherited

◆ GetParallelWorld()

G4VUserParallelWorld * G4VUserDetectorConstruction::GetParallelWorld ( G4int  i) const
inherited

Definition at line 103 of file G4VUserDetectorConstruction.cc.

104{
105 if(i < 0 || i >= GetNumberOfParallelWorld())
106 return nullptr;
107 return parallelWorld[i];
108}

References G4VUserDetectorConstruction::GetNumberOfParallelWorld(), and G4VUserDetectorConstruction::parallelWorld.

◆ RegisterParallelWorld()

void G4VUserDetectorConstruction::RegisterParallelWorld ( G4VUserParallelWorld aPW)
inherited

Definition at line 57 of file G4VUserDetectorConstruction.cc.

59{
60 auto pwItr = std::find(parallelWorld.cbegin(), parallelWorld.cend(), aPW);
61 if (pwItr != parallelWorld.cend())
62 {
63 G4String eM = "A parallel world <";
64 eM += aPW->GetName();
65 eM += "> is already registered to the user detector construction.";
66 G4Exception("G4VUserDetectorConstruction::RegisterParallelWorld",
67 "Run0051", FatalErrorInArgument, eM);
68 }
69 parallelWorld.push_back(aPW);
70}
@ FatalErrorInArgument
const G4String & GetName()

References FatalErrorInArgument, G4Exception(), G4VUserParallelWorld::GetName(), and G4VUserDetectorConstruction::parallelWorld.

◆ SetSensitiveDetector() [1/2]

void G4VUserDetectorConstruction::SetSensitiveDetector ( const G4String logVolName,
G4VSensitiveDetector aSD,
G4bool  multi = false 
)
protectedinherited

Definition at line 229 of file G4VUserDetectorConstruction.cc.

232{
233 G4bool found = false;
235 auto volmap = store->GetMap();
236 auto pos = volmap.find(logVolName);
237 if(pos != volmap.cend())
238 {
239 if ((pos->second.size()>1) && !multi)
240 {
241 G4String eM = "More than one logical volumes of name <";
242 eM += pos->first;
243 eM += "> are found and thus the sensitive detector <";
244 eM += aSD->GetName();
245 eM += "> cannot be uniquely assigned.";
246 G4Exception("G4VUserDetectorConstruction::SetSensitiveDetector()",
247 "Run0052", FatalErrorInArgument, eM);
248 }
249 found = true;
250 for (std::size_t i = 0; i < pos->second.size(); ++i)
251 {
252 SetSensitiveDetector(pos->second[i], aSD);
253 }
254 }
255 if(!found)
256 {
257 G4String eM2 = "No logical volume of name <";
258 eM2 += logVolName;
259 eM2 += "> is found. The specified sensitive detector <";
260 eM2 += aSD->GetName();
261 eM2 += "> couldn't be assigned to any volume.";
262 G4Exception("G4VUserDetectorConstruction::SetSensitiveDetector()",
263 "Run0053", FatalErrorInArgument, eM2);
264 }
265}
static const G4double pos
bool G4bool
Definition: G4Types.hh:86
const std::map< G4String, std::vector< G4LogicalVolume * > > & GetMap() const
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)

References FatalErrorInArgument, G4Exception(), G4LogicalVolumeStore::GetInstance(), G4LogicalVolumeStore::GetMap(), G4VSensitiveDetector::GetName(), pos, and G4VUserDetectorConstruction::SetSensitiveDetector().

Referenced by MyDetectorConstruction::SetSDtoScoreVoxel(), and G4VUserDetectorConstruction::SetSensitiveDetector().

◆ SetSensitiveDetector() [2/2]

void G4VUserDetectorConstruction::SetSensitiveDetector ( G4LogicalVolume logVol,
G4VSensitiveDetector aSD 
)
protectedinherited

Definition at line 268 of file G4VUserDetectorConstruction.cc.

270{
271 assert(logVol != nullptr && aSD != nullptr);
272
273 // The aSD has already been added by user to the manager if needed
274 // G4SDManager::GetSDMpointer()->AddNewDetector(aSD);
275
276 // New Logic: allow for "multiple" SDs being attached to a single LV.
277 // To do that we use a special proxy SD called G4MultiSensitiveDetector
278
279 // Get existing SD if already set and check if it is of the special type
280 G4VSensitiveDetector* originalSD = logVol->GetSensitiveDetector();
281 if(originalSD == aSD)
282 {
284 msg << "Attempting to add multiple times the same sensitive detector (\"";
285 msg << originalSD->GetName() << "\") is not allowed, skipping.";
286 G4Exception("G4VUserDetectorConstruction::SetSensitiveDetector", "Run0054",
287 JustWarning, msg);
288 return;
289 }
290 if(originalSD == nullptr)
291 {
292 logVol->SetSensitiveDetector(aSD);
293 }
294 else
295 {
297 dynamic_cast<G4MultiSensitiveDetector*>(originalSD);
298 if(msd != nullptr)
299 {
300 msd->AddSD(aSD);
301 }
302 else
303 {
304 std::ostringstream mn;
305 mn << "/MultiSD_" << logVol->GetName() << "_" << logVol;
306 const G4String msdname = mn.str();
307 msd = new G4MultiSensitiveDetector(msdname);
308 // We need to register the proxy to have correct handling of IDs
310 msd->AddSD(originalSD);
311 msd->AddSD(aSD);
312 logVol->SetSensitiveDetector(msd);
313 }
314 }
315}
@ JustWarning
G4VSensitiveDetector * GetSensitiveDetector() const
const G4String & GetName() const
void AddSD(G4VSensitiveDetector *sd)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:38
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:70

References G4SDManager::AddNewDetector(), G4MultiSensitiveDetector::AddSD(), G4Exception(), G4VSensitiveDetector::GetName(), G4LogicalVolume::GetName(), G4SDManager::GetSDMpointer(), G4LogicalVolume::GetSensitiveDetector(), JustWarning, and G4LogicalVolume::SetSensitiveDetector().

Field Documentation

◆ air

test.MyDetectorConstruction.air

◆ lv_object

test.MyDetectorConstruction.lv_object

◆ parallelWorld

std::vector<G4VUserParallelWorld*> G4VUserDetectorConstruction::parallelWorld
privateinherited

◆ sld_box

test.MyDetectorConstruction.sld_box

◆ sld_cyl

test.MyDetectorConstruction.sld_cyl

◆ va_blue

test.MyDetectorConstruction.va_blue

◆ va_cyan

test.MyDetectorConstruction.va_cyan

◆ va_green

test.MyDetectorConstruction.va_green

◆ va_magenta

test.MyDetectorConstruction.va_magenta

◆ va_red

test.MyDetectorConstruction.va_red

◆ world

test.MyDetectorConstruction.world

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