35 {
36
37 PVConstLink theGeoPhysChild;
38 const GeoSerialTransformer* serialTransformerChild{nullptr};
39 G4LogicalVolume* theG4LogChild{nullptr};
40 unsigned int numChildNodes;
42 bool serialExists = false;
43 std::string nameChild;
44
47 }
48
49
50 static Geo2G4LVFactory LVFactory;
51
52 G4LogicalVolume* theG4LogVolume = LVFactory.Build(theGeoPhysVolume,
descend);
53
55 return theG4LogVolume;
56 }
57 numChildNodes = theGeoPhysVolume->getNChildVolAndST();
58
59
60
61
62
63
64
65
67 for(size_t counter1=0; counter1<numChildNodes; ++counter1) {
68 GeoAccessVolAndSTAction actionVolAndST(counter1);
69 theGeoPhysVolume->exec(&actionVolAndST);
70
71 serialTransformerChild=actionVolAndST.getSerialTransformer();
72 if(serialTransformerChild) {
73 nameChild = actionVolAndST.getName();
74 serialExists = true;
75 break;
76 }
77 }
78 }
79
80
81
82
83
84
85
86
87
88
89
90
91 if(serialExists && numChildNodes==1) {
92 theGeoPhysChild = serialTransformerChild->getVolume();
93
94
95 theG4LogChild =
Build(theGeoPhysChild,optical_volumes);
96 if(!theG4LogChild) {
97 return nullptr;
98 }
99 if (nameChild == "ANON") {
100 nameChild=theG4LogChild->GetName();
101 }
102 nameChild += "_Param";
103
104 Geo2G4STParameterisation* stParameterisation = new Geo2G4STParameterisation(serialTransformerChild->getFunction(),
105 serialTransformerChild->getNCopies());
106
107 [[maybe_unused]] G4VPhysicalVolume* pvParametrised = new G4PVParameterised(nameChild,
108 theG4LogChild,
109 theG4LogVolume,
110 kUndefined,
111 serialTransformerChild->getNCopies(),
112 stParameterisation);
113 } else {
114 if(serialExists) {
115 PrintSTInfo(theGeoPhysVolume->getLogVol()->getName());
116 }
117
118 GeoVolumeCursor av(theGeoPhysVolume);
119 while (!av.atEnd()) {
120 int id = 16969;
121
122
123 theGeoPhysChild = av.getVolume();
124
126
127 std::optional<int> Qint = av.getId();
128 if(Qint) {
129 id = *Qint;
130 }
131
132 const bool isEther = theGeoPhysChild->getLogVol()->getMaterial()->getName() =="special::Ether";
133 const bool isHypUr = theGeoPhysChild->getLogVol()->getMaterial()->getName() =="special::HyperUranium";
134
135 if(isEther) {
136 Geo2G4AssemblyVolume* assembly =
BuildAssembly(theGeoPhysChild);
137
138 if(Qint) {
139 assembly->
MakeImprint(theG4LogVolume,theG4Position,
id);
140 } else {
141 assembly->
MakeImprint(theG4LogVolume,theG4Position);
142 }
143 } else if(isHypUr) {
144 Geo2G4AssemblyVolume* assembly =
BuildAssembly(theGeoPhysChild);
145
146 if(Qint) {
147 assembly->
MakeImprint(theG4LogVolume,theG4Position,
id,
true);
148 } else {
149 assembly->
MakeImprint(theG4LogVolume,theG4Position,0,
true);
150 }
151 } else {
152 nameChild = av.getName();
153
154
155 theG4LogChild =
Build(theGeoPhysChild,optical_volumes);
156 if(!theG4LogChild) {
157 return nullptr;
158 }
159 if (nameChild == "ANON") {
160 nameChild=theG4LogChild->GetName();
161 }
162 G4PhysicalVolumesPair pvPair = G4ReflectionFactory::Instance()->Place(theG4Position, nameChild,
163 theG4LogChild, theG4LogVolume, false, id);
164
165
166 if(optical_volumes!=nullptr) {
167 const GeoOpticalPhysVol* opticalGeoPhysChild = dynamic_cast < const GeoOpticalPhysVol* >(theGeoPhysChild.get());
168 if(opticalGeoPhysChild) {
169 (*optical_volumes)[opticalGeoPhysChild] = pvPair.first;
170 }
171 }
172 }
173 av.next();
174 }
175 }
176
177 return theG4LogVolume;
178}
void descend(TDirectory *d, int level, int maxdepth, const std::vector< std::string > &labels)
void PrintSTInfo(const std::string &volume) const
Prints info when some PhysVol contains both types (PV and ST) of daughters.
virtual G4LogicalVolume * Build(PVConstLink pv, OpticalVolumesMap *optical_volumes=0) override
Geo2G4AssemblyVolume * BuildAssembly(const PVConstLink &pv)
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, const G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool ITkScheme=false, G4bool surfCheck=false)
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.