Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G3toG4BuildTree.hh File Reference
#include "G3VolTableEntry.hh"

Go to the source code of this file.

Functions

void G3toG4BuildTree (G3VolTableEntry *curVTE, G3VolTableEntry *motherVTE)
 
void G3toG4BuildLVTree (G3VolTableEntry *curVTE, G3VolTableEntry *motherVTE)
 
void G3toG4BuildPVTree (G3VolTableEntry *curVTE)
 

Function Documentation

◆ G3toG4BuildLVTree()

void G3toG4BuildLVTree ( G3VolTableEntry curVTE,
G3VolTableEntry motherVTE 
)

Definition at line 49 of file G3toG4BuildTree.cc.

50{
51 // check existence of the solid
52 if (curVTE->GetSolid()) {
53 G4LogicalVolume* curLog = curVTE->GetLV();
54 if (!curLog) {
55 // skip creating logical volume
56 // in case it already exists
57
58 // material
59 G4Material* material = 0;
60 G3MedTableEntry* mte = G3Med.get(curVTE->GetNmed());
61 if (mte) material = mte->GetMaterial();
62 if (!material) {
63 G4String err_message = "VTE " + curVTE->GetName()
64 + " has not defined material!!";
65 G4Exception("G3toG4BuildLVTree()", "G3toG40001",
66 FatalException, err_message);
67 return;
68 }
69
70 // logical volume
71 curLog =
72 new G4LogicalVolume(curVTE->GetSolid(), material, curVTE->GetName());
73 curVTE->SetLV(curLog);
74
75 // insert logical volume to G3SensVol vector
76 // in case it is sensitive
77 if (mte->GetISVOL()) G3SensVol.push_back(curLog);
78 }
79 }
80 else {
81 if ( !(curVTE->GetDivision() && motherVTE->GetMasterClone() == motherVTE &&
82 motherVTE->GetNoClones()>1)) {
83 // ignore dummy vte's
84 // (this should be the only case when the vte is dummy but
85 // is present in mother <-> daughters tree
86 G4String err_message = "VTE " + curVTE->GetName()
87 + " has not defined solid!!";
88 G4Exception("G3toG4BuildLVTree()", "G3toG40002",
89 FatalException, err_message);
90 return;
91 }
92 }
93
94 // process daughters
95 G4int Ndau = curVTE->GetNoDaughters();
96 for (int Idau=0; Idau<Ndau; Idau++){
97 G3toG4BuildLVTree(curVTE->GetDaughter(Idau), curVTE);
98 }
99}
G3G4DLL_API G3MedTable G3Med
Definition: clparse.cc:56
G3G4DLL_API G3SensVolVector G3SensVol
Definition: clparse.cc:61
void G3toG4BuildLVTree(G3VolTableEntry *curVTE, G3VolTableEntry *motherVTE)
@ FatalException
int G4int
Definition: G4Types.hh:66
G4Material * GetMaterial() const
G4int GetISVOL() const
G3MedTableEntry * get(G4int id) const
Definition: G3MedTable.cc:44
G3VolTableEntry * GetMasterClone()
G4VSolid * GetSolid()
G3Division * GetDivision()
G4LogicalVolume * GetLV()
void SetLV(G4LogicalVolume *lv)
G3VolTableEntry * GetDaughter(G4int i)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Referenced by G3toG4BuildLVTree(), and G3toG4BuildTree().

◆ G3toG4BuildPVTree()

void G3toG4BuildPVTree ( G3VolTableEntry curVTE)

Definition at line 101 of file G3toG4BuildTree.cc.

102{
103 // check existence of the solid
104 if (curVTE->GetSolid()) {
105 G4LogicalVolume* curLog = curVTE->GetLV();
106
107 // positions in motherVTE
108 for (G4int i=0; i<curVTE->NPCopies(); i++){
109
110 G3Pos* theG3Pos = curVTE->GetG3PosCopy(i);
111 if (theG3Pos) {
112
113 // loop over all mothers
114 for (G4int im=0; im<curVTE->GetNoMothers(); im++) {
115
116 G3VolTableEntry* motherVTE = curVTE->GetMother(im);
117 if (theG3Pos->GetMotherName() == motherVTE->GetMasterClone()->GetName()) {
118
119 // get mother logical volume
120 G4LogicalVolume* mothLV=0;
121 G4String motherName = motherVTE->GetName();
122 if (!curVTE->FindMother(motherName)) continue;
123 if (curVTE->FindMother(motherName)->GetName() != motherName) {
124 // check consistency - tbr
125 G4String err_message =
126 "G3toG4BuildTree: Inconsistent mother <-> daughter !!";
127 G4Exception("G3toG4BuildPVTree()", "G3toG40003",
128 FatalException, err_message);
129 return;
130 }
131 mothLV = motherVTE->GetLV();
132
133 // copy number
134 // (in G3 numbering starts from 1 but in G4 from 0)
135 G4int copyNo = theG3Pos->GetCopy() - 1;
136
137 // position it if not top-level volume
138
139 if (mothLV != 0) {
140
141 // transformation
142 G4int irot = theG3Pos->GetIrot();
143 G4RotationMatrix* theMatrix = 0;
144 if (irot>0) theMatrix = G3Rot.Get(irot);
145 G4Rotate3D rotation;
146 if (theMatrix) {
147 rotation = G4Rotate3D(*theMatrix);
148 }
149
150 #ifndef G3G4_NO_REFLECTION
151 G4Translate3D translation(*(theG3Pos->GetPos()));
152 G4Transform3D transform3D = translation * (rotation.inverse());
153
155 ->Place(transform3D, // transformation
156 curVTE->GetName(), // PV name
157 curLog, // its logical volume
158 mothLV, // mother logical volume
159 false, // only
160 copyNo); // copy
161 #else
162 new G4PVPlacement(theMatrix, // rotation matrix
163 *(theG3Pos->GetPos()), // its position
164 curLog, // its LogicalVolume
165 curVTE->GetName(), // PV name
166 mothLV, // Mother LV
167 0, // only
168 copyNo); // copy
169 #endif
170
171 // verbose
172 #ifdef G3G4DEBUG
173 G4cout << "PV: " << i << "th copy of " << curVTE->GetName()
174 << " in " << motherVTE->GetName() << " copyNo: "
175 << copyNo << " irot: " << irot << " pos: "
176 << *(theG3Pos->GetPos()) << G4endl;
177 #endif
178 }
179 }
180 }
181 // clear this position
182 curVTE->ClearG3PosCopy(i);
183 i--;
184 }
185 }
186
187 // divisions
188 if (curVTE->GetDivision()) {
189 curVTE->GetDivision()->CreatePVReplica();
190 // verbose
191 #ifdef G3G4DEBUG
192 G4cout << "CreatePVReplica: " << curVTE->GetName()
193 << " in " << curVTE->GetMother()->GetName() << G4endl;
194 #endif
195
196 // clear this divison
197 curVTE->ClearDivision();
198 }
199 }
200
201 // process daughters
202 G4int Ndau = curVTE->GetNoDaughters();
203 for (int Idau=0; Idau<Ndau; Idau++){
204 G3toG4BuildPVTree(curVTE->GetDaughter(Idau));
205 }
206}
G3G4DLL_API G3RotTable G3Rot
Definition: clparse.cc:57
void G3toG4BuildPVTree(G3VolTableEntry *curVTE)
HepGeom::Rotate3D G4Rotate3D
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
void CreatePVReplica()
Definition: G3Division.cc:126
Definition: G3Pos.hh:44
G4ThreeVector * GetPos()
Definition: G3Pos.cc:73
G4int GetCopy()
Definition: G3Pos.cc:68
G4String & GetMotherName()
Definition: G3Pos.cc:58
G4int GetIrot()
Definition: G3Pos.cc:63
G4RotationMatrix * Get(G4int id) const
Definition: G3RotTable.cc:44
G3VolTableEntry * FindMother(const G4String &vname)
G3VolTableEntry * GetMother(G4int i)
void ClearG3PosCopy(G4int copy)
G3Pos * GetG3PosCopy(G4int copy=0)
static G4ReflectionFactory * Instance()
G4PhysicalVolumesPair Place(const G4Transform3D &transform3D, const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, G4bool isMany, G4int copyNo, G4bool surfCheck=false)
Transform3D inverse() const
Definition: Transform3D.cc:142

Referenced by G3toG4BuildPVTree(), and G3toG4BuildTree().

◆ G3toG4BuildTree()

void G3toG4BuildTree ( G3VolTableEntry curVTE,
G3VolTableEntry motherVTE 
)

Definition at line 43 of file G3toG4BuildTree.cc.

44{
45 G3toG4BuildLVTree(curVTE, motherVTE);
46 G3toG4BuildPVTree(curVTE);
47}

Referenced by G4BuildGeom().