VGM Version 5.5
Loading...
Searching...
No Matches
Factory.cxx
Go to the documentation of this file.
1// $Id$
2
3// -----------------------------------------------------------------------
4// The Geant4GM package of the Virtual Geometry Model
5// Copyright (C) 2007, Ivana Hrivnacova
6// All rights reserved.
7//
8// For the licensing terms see vgm/LICENSE.
9// Contact: ivana@ipno.in2p3.fr
10// -----------------------------------------------------------------------
11
12//
13// Class Factory
14// ---------------
15// The interface to geometry factory.
16//
17// Author: Ivana Hrivnacova; IPN Orsay
18
20#include "ClhepVGM/Units.h"
21#include "ClhepVGM/transform.h"
22
29#include "Geant4GM/solids/Box.h"
48#include "Geant4GM/solids/Trd.h"
55
56#include "G4BooleanSolid.hh"
57#include "G4Box.hh"
58#include "G4Cons.hh"
59#include "G4CutTubs.hh"
60#include "G4DisplacedSolid.hh"
61#include "G4Ellipsoid.hh"
62#include "G4EllipticalTube.hh"
63#include "G4ExtrudedSolid.hh"
64#include "G4GenericTrap.hh"
65#include "G4Hype.hh"
66#include "G4LogicalVolume.hh"
67#include "G4LogicalVolumeStore.hh"
68#include "G4MultiUnion.hh"
69#include "G4PVDivisionFactory.hh"
70#include "G4PVParameterised.hh"
71#include "G4Para.hh"
72#include "G4Paraboloid.hh"
73#include "G4Polycone.hh"
74#include "G4Polyhedra.hh"
75#include "G4ReflectedSolid.hh"
76#include "G4ReplicatedSlice.hh"
77#include "G4ScaledSolid.hh"
78#include "G4Sphere.hh"
79#include "G4SystemOfUnits.hh"
80#include "G4TessellatedSolid.hh"
81#include "G4Torus.hh"
82#include "G4Trap.hh"
83#include "G4Trd.hh"
84#include "G4Tubs.hh"
85#include "G4VPhysicalVolume.hh"
86#include "G4VSolid.hh"
87
88#include <set>
89
90bool Geant4GM::Factory::fgSurfCheck = false;
91
92//
93// static methods
94//
95
96//_____________________________________________________________________________
98{
101
102 fgSurfCheck = surfCheck;
103}
104
105//_____________________________________________________________________________
107{
109
110 return fgSurfCheck;
111}
112
113//
114// ctors, dtor
115//
116
117//_____________________________________________________________________________
119 : VGM::IFactory(),
120 BaseVGM::VFactory("Geant4_GM_Factory", new Geant4GM::MaterialFactory()),
121 fTop(0),
122 fSolid(0)
123{
125}
126
127//_____________________________________________________________________________
129 : VGM::IFactory(rhs), BaseVGM::VFactory(rhs)
130{
132}
133
134//_____________________________________________________________________________
136{
137 //
138 // delete map singletons
142 // There is inconsistence in using the singleton maps
143 // via a factory which is not a singleton
144 // TO DO: to be improved later
145}
146
147//
148// private functions
149//
150
151//_____________________________________________________________________________
152void Geant4GM::Factory::ImportConstituentSolid(int index, G4BooleanSolid* solid)
153{
155
156 G4VSolid* consSolid =
158
159 if (!Geant4GM::SolidMap::Instance()->GetSolid(consSolid)) {
160 VGM::ISolid* vgmSolid = ImportSolid(consSolid);
161 if (Debug()) {
163 if (vgmSolid)
164 std::cout << " Imported solid: " << *vgmSolid << std::endl;
165 else
166 std::cout << " Imported solid: "
167 << "0x0" << std::endl;
168 }
169 }
170}
171
172//_____________________________________________________________________________
173void Geant4GM::Factory::ImportConstituentSolid(int index, G4MultiUnion* solid)
174{
176
177 G4VSolid* consSolid = solid->GetSolid(index);
178
179 if (!Geant4GM::SolidMap::Instance()->GetSolid(consSolid)) {
180 VGM::ISolid* vgmSolid = ImportSolid(consSolid);
181 if (Debug()) {
183 if (vgmSolid)
184 std::cout << " Imported solid: " << *vgmSolid << std::endl;
185 else
186 std::cout << " Imported solid: "
187 << "0x0" << std::endl;
188 }
189 }
190}
191
192//_____________________________________________________________________________
193VGM::ISolid* Geant4GM::Factory::ImportSolid(G4VSolid* solid)
194{
196
197 // Do not import the same solid twice
198 //
199 VGM::ISolid* importedSolid = Geant4GM::SolidMap::Instance()->GetSolid(solid);
200 if (importedSolid) return importedSolid;
201
202 if (Debug() > 0) {
204 std::cout << "Importing solid: ";
205 if (Debug() > 1) std::cout << solid << " ";
206 std::cout << solid->GetName() << std::endl;
207 }
208
209 G4VSolid* consSolid = solid;
210
211 // Get constituent solid if the solid is a reflected solid
212 //
213 G4ReflectedSolid* reflSolid = dynamic_cast<G4ReflectedSolid*>(solid);
214 if (reflSolid) consSolid = reflSolid->GetConstituentMovedSolid();
215
216 G4Box* box = dynamic_cast<G4Box*>(consSolid);
217 if (box) {
218 return Register(new Geant4GM::Box(box, reflSolid));
219 }
220
221 G4Cons* cons = dynamic_cast<G4Cons*>(consSolid);
222 if (cons) {
223 return Register(new Geant4GM::Cons(cons, reflSolid));
224 }
225
226 G4CutTubs* ctubs = dynamic_cast<G4CutTubs*>(consSolid);
227 if (ctubs) {
228 return Register(new Geant4GM::Ctubs(ctubs, reflSolid));
229 }
230
231 G4Ellipsoid* ellipsoid = dynamic_cast<G4Ellipsoid*>(consSolid);
232 if (ellipsoid) {
233 return Register(new Geant4GM::Ellipsoid(ellipsoid, reflSolid));
234 }
235
236 G4EllipticalTube* eltu = dynamic_cast<G4EllipticalTube*>(consSolid);
237 if (eltu) {
238 return Register(new Geant4GM::EllipticalTube(eltu, reflSolid));
239 }
240
241 G4ExtrudedSolid* xtru = dynamic_cast<G4ExtrudedSolid*>(consSolid);
242 if (xtru) {
243 return Register(new Geant4GM::ExtrudedSolid(xtru, reflSolid));
244 }
245
246 G4GenericTrap* gtrap = dynamic_cast<G4GenericTrap*>(consSolid);
247 if (gtrap) {
248 return Register(new Geant4GM::Arb8(gtrap, reflSolid));
249 }
250
251 G4Hype* hype = dynamic_cast<G4Hype*>(consSolid);
252 if (hype) {
253 return Register(new Geant4GM::Hype(hype, reflSolid));
254 }
255
256 G4Para* para = dynamic_cast<G4Para*>(consSolid);
257 if (para) {
258 return Register(new Geant4GM::Para(para, reflSolid));
259 }
260
261 G4Paraboloid* paraboloid = dynamic_cast<G4Paraboloid*>(consSolid);
262 if (paraboloid) {
263 return Register(new Geant4GM::Paraboloid(paraboloid, reflSolid));
264 }
265
266 G4Polycone* polycone = dynamic_cast<G4Polycone*>(consSolid);
267 if (polycone) {
268 return Register(new Geant4GM::Polycone(polycone, reflSolid));
269 }
270
271 G4Polyhedra* polyhedra = dynamic_cast<G4Polyhedra*>(consSolid);
272 if (polyhedra) {
273 return Register(new Geant4GM::Polyhedra(polyhedra, reflSolid));
274 }
275
276 G4Sphere* sphere = dynamic_cast<G4Sphere*>(consSolid);
277 if (sphere) {
278 return Register(new Geant4GM::Sphere(sphere, reflSolid));
279 }
280
281 G4TessellatedSolid* tessel = dynamic_cast<G4TessellatedSolid*>(consSolid);
282 if (tessel) {
283 return Register(new Geant4GM::TessellatedSolid(tessel, reflSolid));
284 }
285
286 G4Torus* torus = dynamic_cast<G4Torus*>(consSolid);
287 if (torus) {
288 return Register(new Geant4GM::Torus(torus, reflSolid));
289 }
290
291 G4Trap* trap = dynamic_cast<G4Trap*>(consSolid);
292 if (trap) {
293 return Register(new Geant4GM::Trap(trap, reflSolid));
294 }
295
296 G4Trd* trd = dynamic_cast<G4Trd*>(consSolid);
297 if (trd) {
298 return Register(new Geant4GM::Trd(trd, reflSolid));
299 }
300
301 G4Tubs* tubs = dynamic_cast<G4Tubs*>(consSolid);
302 if (tubs) {
303 return Register(new Geant4GM::Tubs(tubs, reflSolid));
304 }
305
306 G4DisplacedSolid* displaced = dynamic_cast<G4DisplacedSolid*>(consSolid);
307 if (displaced) {
308 ImportSolid(displaced->GetConstituentMovedSolid());
309 return Register(new Geant4GM::DisplacedSolid(displaced, reflSolid));
310 }
311
312 G4ScaledSolid* scaled = dynamic_cast<G4ScaledSolid*>(consSolid);
313 if (scaled) {
314 ImportSolid(scaled->GetUnscaledSolid());
315 return Register(new Geant4GM::ScaledSolid(scaled, reflSolid));
316 }
317
318 G4BooleanSolid* boolean = dynamic_cast<G4BooleanSolid*>(consSolid);
319 if (boolean) {
320 ImportConstituentSolid(0, boolean);
321 ImportConstituentSolid(1, boolean);
322 VGM::IBooleanSolid* vgmBoolean =
323 new Geant4GM::BooleanSolid(boolean, reflSolid);
324 Register(vgmBoolean);
325
326 if (Debug() > 0) {
328 std::cout << "Imported Boolean solid: ";
329 if (Debug() > 1) std::cout << vgmBoolean;
330 std::cout << std::endl;
332 std::cout << *vgmBoolean << std::endl;
333 }
334
335 return vgmBoolean;
336 }
337
338 G4MultiUnion* multiUnion = dynamic_cast<G4MultiUnion*>(consSolid);
339 if (multiUnion) {
340 for (G4int i = 0; i < multiUnion->GetNumberOfSolids(); ++i) {
341 ImportConstituentSolid(i, multiUnion);
342 }
343 VGM::IMultiUnion* vgmMultiUnion =
344 new Geant4GM::MultiUnion(multiUnion, reflSolid);
345 Register(vgmMultiUnion);
346
347 if (Debug() > 0) {
349 std::cout << "Imported MultiUnion solid: ";
350 if (Debug() > 1) std::cout << vgmMultiUnion;
351 std::cout << std::endl;
353 std::cout << *vgmMultiUnion << std::endl;
354 }
355
356 return vgmMultiUnion;
357 }
358
359 std::cerr << "Geant4GM::Factory::ImportSolid: " << std::endl;
360 std::cerr << "Unsupported solid type (solid \"" << solid->GetName() << "\""
361 << " type \"" << solid->GetEntityType() << "\")" << std::endl;
362
363 if (Ignore()) {
364 std::cerr << "*** Warning: Using a box instead ***" << std::endl;
365 return Register(new Geant4GM::Box(solid->GetName(),
366 DummyBoxDimensions() / ClhepVGM::Units::Length(),
367 DummyBoxDimensions() / ClhepVGM::Units::Length(),
368 DummyBoxDimensions() / ClhepVGM::Units::Length()));
369 }
370 else {
371 std::cerr << "*** Error: Aborting execution ***" << std::endl;
372 exit(1);
373 }
374}
375
376//_____________________________________________________________________________
377VGM::IVolume* Geant4GM::Factory::ImportLV(G4LogicalVolume* lv)
378{
380
381 if (Debug()) {
383 std::cout << "Importing LV: " << lv->GetName() << std::endl;
384 }
385
386 // Import solid
387 VGM::ISolid* solid = ImportSolid(lv->GetSolid());
388
389 if (Debug()) {
391 if (solid)
392 std::cout << " Imported solid: " << *solid << std::endl;
393 else
394 std::cout << " Imported solid: "
395 << "0x0" << std::endl;
396 }
397
398 // Create vgm volume
399 VGM::IVolume* volume =
400 new Geant4GM::Volume(solid, lv, lv->GetMaterial()->GetName());
401 VolumeStore().push_back(volume);
402 return volume;
403}
404
405//_____________________________________________________________________________
406VGM::IVolume* Geant4GM::Factory::ImportLV(
407 G4LogicalVolume* lv, const std::string& mediumName)
408{
410
411 if (Debug()) {
413 std::cout << "Importing LV: " << lv->GetName() << std::endl;
414 }
415
416 // Import solid
417 VGM::ISolid* solid = ImportSolid(lv->GetSolid());
418
419 // Create vgm volume
420 VGM::IVolume* volume = new Geant4GM::Volume(solid, lv, mediumName);
421 VolumeStore().push_back(volume);
422 return volume;
423}
424
425//_____________________________________________________________________________
426void Geant4GM::Factory::ImportDaughters(G4LogicalVolume* lv)
427{
428 // Import recursively all daughters logical volumes.
429
430 if (Debug()) {
432 std::cout << "ImportDaughters for " << lv->GetName() << std::endl;
433 }
434
435 // For parameterised volumes, the daugthers might change in solids and
436 // materials. Geant4 internally can not account for this while looping over
437 // daugthers because the logical volume is always the same. During
438 // parameterisation, only the solid and material is replaced. The actual
439 // logical volume pointer stays the same. To overcome this issue, we introduce
440 // a map of solids and materials to determine if we need a new volume to
441 // describe certain parts in parameterised volumes. All non parameterised
442 // volumes should be unaffected since there is no change in solid / material
443
444 std::map<std::pair<G4VSolid*, G4Material*>, G4LogicalVolume*> localSolidMaterialStore;
445
446 for (size_t i = 0; i < lv->GetNoDaughters(); i++) {
447 // first we try to import the daugther
448 G4LogicalVolume* dLV = lv->GetDaughter(i)->GetLogicalVolume();
449 VGM::IVolume* dVolume = Geant4GM::VolumeMap::Instance()->GetVolume(dLV);
450
451 if (!dVolume) {
452 // Import logical volume
453 ImportLV(dLV);
454 }
455
456 // we also import in our local store
457 localSolidMaterialStore.insert(
458 std::make_pair(std::make_pair(dLV->GetSolid(), dLV->GetMaterial()), dLV));
459
460 // now we check if the daugther is parameterised.
461 G4PVParameterised* paraPhysVol =
462 dynamic_cast<G4PVParameterised*>(lv->GetDaughter(i));
463 if (paraPhysVol) {
464
465 if (Debug()) {
467 std::cout << "Processing parameterised daughter " << paraPhysVol->GetName()
468 << " (multiplicity = " << paraPhysVol->GetMultiplicity() << ")"
469 << std::endl;
470 }
471
472 G4LogicalVolume* localLV = paraPhysVol->GetLogicalVolume();
473 std::vector< G4LogicalVolume*> paramVolumes;
474 // Loop over parameterisations and check if the solids / materials change
475 // during parameterisation
476 for (int k = 0; k < paraPhysVol->GetMultiplicity(); ++k) {
477 // compute transformations.
478 G4VPVParameterisation* pParam = paraPhysVol->GetParameterisation();
479 G4VSolid* pSolid = pParam->ComputeSolid(k, paraPhysVol);
480 pSolid->ComputeDimensions(pParam, k, paraPhysVol);
481 G4Material* pMat = pParam->ComputeMaterial(k, paraPhysVol);
482
483 // If the solid / material changes, create new logical volume and import
484
485 auto itv = localSolidMaterialStore.find(std::make_pair(pSolid, pMat));
486 if (itv == localSolidMaterialStore.end()) {
487
488 // Naming convention: Original name + "_" + first place in
489 // parameterisation where this new volume is needed.
490 auto newName = localLV->GetName() + "_" + std::to_string(k);
491
492 if (Debug()) {
494 std::cout << " Going to create LV " << newName << std::endl;
495 }
496
497 auto newLV = new G4LogicalVolume(pSolid, pMat, newName);
498 localSolidMaterialStore.insert(std::make_pair(std::make_pair(pSolid, pMat), newLV));
499 paramVolumes.emplace_back(newLV);
500 ImportLV(newLV);
501 }
502 else {
503 if (Debug()) {
504 auto newName = localLV->GetName() + "_" + std::to_string(k);
506 std::cout << " Skipping creating LV " << newName << std::endl;
507 }
508 paramVolumes.emplace_back(itv->second);
509 }
510 }
511 // Save all volumes for parameterised elements in the volume map
512 Geant4GM::VolumeMap::Instance()->AddParamVolume(localLV, paramVolumes);
513 }
514
515 if (!dVolume) {
516 // Process daughters of this logical volume
517 ImportDaughters(dLV);
518 }
519 }
520}
521
522//_____________________________________________________________________________
523void Geant4GM::Factory::ImportPositions()
524{
525 // Import placements for all volumes imported
526
527 if (Debug() > 0) {
529 std::cout << "Import positions: " << std::endl;
530 }
531
532 for (unsigned int i = 0; i < Volumes().size(); i++) {
533
534 VGM::IVolume* volume = Volumes()[i];
535 G4LogicalVolume* lv = Geant4GM::VolumeMap::Instance()->GetVolume(volume);
536
537 if (Debug() > 0) {
539 std::cout << i << "th volume: " << lv->GetName() << " ";
540 if (Debug() > 1)
541 std::cout << " lv: " << lv << " "
542 << " vgm: " << volume;
543 std::cout << std::endl;
544 }
545
546 for (size_t id = 0; id < lv->GetNoDaughters(); id++) {
547
548 G4VPhysicalVolume* dPV = lv->GetDaughter(id);
549 G4LogicalVolume* dLV = dPV->GetLogicalVolume();
550
551 if (Debug() > 0) {
553 std::cout << " " << id << "th daughter pv = ";
554 if (Debug() > 1) std::cout << dPV << " ";
555 std::cout << dPV->GetName() << " lv = ";
556 if (Debug() > 1) std::cout << dLV << " ";
557 std::cout << dLV->GetName();
558 }
559
560 VGM::IVolume* dVolume = Geant4GM::VolumeMap::Instance()->GetVolume(dLV);
561
562 // Create placement
563 VGM::IPlacement* dPlacement =
564 new Geant4GM::Placement(dVolume, volume, dPV);
565
566 if (Debug() > 0) {
567 std::cout << " vgmPl = ";
568 if (Debug() > 1) std::cout << dPlacement << " ";
569 std::cout << dPlacement->Name() << " vgmVol = ";
570 if (Debug() > 1) std::cout << dVolume << " ";
571 std::cout << dVolume->Name() << std::endl;
572 }
573 }
574 }
575}
576
577//_____________________________________________________________________________
578void Geant4GM::Factory::ImportPositions(G4LogicalVolume* lv)
579{
580 // Import placements for daughters tree of specified lv.
581 // Check if the placement has been already imported.
582
583 if (Debug() > 0) {
585 std::cout << "ImportPositions for lv " << lv->GetName()
586 << " nofDaughters: " << lv->GetNoDaughters() << std::endl;
587 }
588
589 VGM::IVolume* volume = Geant4GM::VolumeMap::Instance()->GetVolume(lv);
590
591 for (size_t id = 0; id < lv->GetNoDaughters(); id++) {
592
593 G4VPhysicalVolume* dPV = lv->GetDaughter(id);
594
595 if (Debug()) {
597 std::cout << id << "th daugher: " << dPV->GetName() << std::endl;
598 }
599
600 if (!Geant4GM::PlacementMap::Instance()->GetPlacement(dPV)) {
601 /*
602 if (Debug()>0) {
603 BaseVGM::DebugInfo();
604 std::cout <<
605 "Geant4GM::PlacementMap::Instance()->GetPlacement(dPV) *not* found"
606 << std::endl;
607 BaseVGM::DebugInfo();
608 std::cout << " go to import position" << std::endl;
609 }
610 */
611 G4LogicalVolume* dLV = dPV->GetLogicalVolume();
612 VGM::IVolume* dVolume = Geant4GM::VolumeMap::Instance()->GetVolume(dLV);
613
614 // Create placement
615 new Geant4GM::Placement(dVolume, volume, dPV);
616
617 // Recursively import positions of daughters
618 ImportPositions(dLV);
619 }
620 /*
621 else
622 if (Debug()>0) {
623 BaseVGM::DebugInfo();
624 std::cout << "Geant4GM::PlacementMap::Instance()->GetPlacement(dPV)
625 found"
626 << std::endl;
627 BaseVGM::DebugInfo();
628 std::cout << " do not import position" << std::endl;
629 }
630 */
631 }
632}
633
634//_____________________________________________________________________________
635VGM::IPlacement* Geant4GM::Factory::ImportPVPair(VGM::IVolume* volume,
636 VGM::IVolume* motherVolume, G4PhysicalVolumesPair pvPair)
637{
638 G4ReflectionFactory* g4ReflectionFactory = G4ReflectionFactory::Instance();
639
640 // Get info about created PV
641 G4VPhysicalVolume* pv1 = pvPair.first;
642 G4LogicalVolume* lv1 = pv1->GetLogicalVolume();
643 VGM::IVolume* iv1 = Geant4GM::VolumeMap::Instance()->GetVolume(lv1);
644 if (!iv1) {
645 // a new logical volume has been created by G4 reflection factory
646 // has to be imported into VGM
647 iv1 = ImportLV(lv1, volume->MediumName());
648 ImportDaughters(lv1);
649 ImportPositions(lv1);
650 }
651 VGM::IPlacement* placement1 = new Geant4GM::Placement(iv1, motherVolume, pv1);
652 // Register physical volume in the map
654
655 G4VPhysicalVolume* pv2 = pvPair.second;
656 if (pv2) {
657 G4LogicalVolume* g4MotherLV =
659
660 // mother volume is the other volume in the pair
661 // constituen/reflected mother lv
662 G4LogicalVolume* mlv2 = 0;
663 if (g4ReflectionFactory->IsReflected(g4MotherLV))
664 mlv2 = g4ReflectionFactory->GetConstituentLV(g4MotherLV);
665 if (g4ReflectionFactory->IsConstituent(g4MotherLV))
666 mlv2 = g4ReflectionFactory->GetReflectedLV(g4MotherLV);
667 if (!mlv2) {
668 // should not happen
669 std::cerr << " Geant4GM::Factory::CreatePlacement: " << std::endl;
670 std::cerr << " Misundersood G4ReflectionFactory behavior "
671 << std::endl;
672 std::cerr << "*** Error: Aborting execution ***" << std::endl;
673 exit(1);
674 }
675 else {
676 VGM::IVolume* miv2 = Geant4GM::VolumeMap::Instance()->GetVolume(mlv2);
677 if (!miv2) {
678 // should not happen
679 std::cerr << " Geant4GM::Factory::CreatePlacement: " << std::endl;
680 std::cerr << " Missing mapping of existing LV to VGM" << std::endl;
681 std::cerr << "*** Error: Aborting execution ***" << std::endl;
682 exit(1);
683 }
684
685 G4LogicalVolume* lv2 = pv2->GetLogicalVolume();
686 VGM::IVolume* iv2 = Geant4GM::VolumeMap::Instance()->GetVolume(lv2);
687 if (!iv2) {
688 // a new logical volume has been created by G4 reflection factory
689 // has to be imported into VGM
690 iv2 = ImportLV(lv2, volume->MediumName());
691 ImportDaughters(lv2);
692 ImportPositions(lv2);
693 }
694 VGM::IPlacement* placement2 = new Geant4GM::Placement(iv2, miv2, pv2);
695 // Register physical volume in the map
697 }
698 }
699
700 // Register physical volume in the map
702
703 return placement1;
704 // should allow to return a list of placements
705}
706
707//_____________________________________________________________________________
708bool Geant4GM::Factory::SwitchSolid(
709 VGM::IVolume* volume, G4LogicalVolume* g4LV, G4LogicalVolume* g4MotherLV)
710{
716
717 if (g4LV->GetSolid()->GetEntityType() == "G4Cons" &&
718 g4MotherLV->GetSolid()->GetEntityType() == "G4Polycone") {
719
720 G4Cons* cons = static_cast<G4Cons*>(g4LV->GetSolid());
721 VGM::ISolid* vgmSolid = new Geant4GM::Polycone(cons);
722 dynamic_cast<Geant4GM::Volume*>(volume)->ResetSolid(vgmSolid);
723
724 return true;
725 }
726
727 if (g4LV->GetSolid()->GetEntityType() == "G4Tubs" &&
728 g4MotherLV->GetSolid()->GetEntityType() == "G4Polycone") {
729
730 G4Tubs* tubs = static_cast<G4Tubs*>(g4LV->GetSolid());
731 VGM::ISolid* vgmSolid = new Geant4GM::Polycone(tubs);
732 dynamic_cast<Geant4GM::Volume*>(volume)->ResetSolid(vgmSolid);
733
734 return true;
735 }
736
737 return false;
738}
739
740//_____________________________________________________________________________
741bool Geant4GM::Factory::Import(void* topVolume)
742{
744
745 G4VPhysicalVolume* worldPV = static_cast<G4VPhysicalVolume*>(topVolume);
746
747 return Import(worldPV);
748}
749
750//_____________________________________________________________________________
751bool Geant4GM::Factory::ImportSolid(void* solid)
752{
754
755 G4VSolid* g4Solid = static_cast<G4VSolid*>(solid);
756
757 return Import(g4Solid);
758}
759
760//_____________________________________________________________________________
761VGM::ISolid* Geant4GM::Factory::Register(VGM::ISolid* vgmSolid)
762{
764
765 SolidStore().push_back(vgmSolid);
766 return vgmSolid;
767}
768
769//
770// protected functions
771//
772
773//_____________________________________________________________________________
775{
777
778 fSolid = solid;
779}
780
781//
782// public functions
783//
784
785//_____________________________________________________________________________
787 const std::string& name, double hz, std::vector<VGM::TwoVector> vertices)
788{
789 // Twisted Arb8 solids are represented by one G4GenericTrap, or by two of
790 // them when their common permitted split interval is non-empty.
791 if (Geant4GM::Arb8::IsTwisted(vertices) &&
792 Geant4GM::Arb8::MaxTwistAngle(vertices) > 90.) {
794 if (Geant4GM::SplitArb8ForGenericTrap(hz, vertices, split) !=
796 std::cerr << "*** Error: Cannot create Arb8 solid \"" << name
797 << "\" in Geant4: it cannot be represented by one or two "
798 "G4GenericTrap solids ***"
799 << std::endl;
800 if (Ignore()) {
801 std::cerr << "*** Warning: Using a box instead ***" << std::endl;
802 return Register(new Geant4GM::Box(name, 1., 1., 1.));
803 }
804 else {
805 std::cerr << "*** Error: Aborting execution ***" << std::endl;
806 exit(1);
807 }
808 }
809 }
810
811 return Register(new Geant4GM::Arb8(name, hz, vertices));
812}
813
814//_____________________________________________________________________________
816 const std::string& name, double hx, double hy, double hz)
817{
818 //
819 return Register(new Geant4GM::Box(name, hx, hy, hz));
820}
821
822//_____________________________________________________________________________
823VGM::ISolid* Geant4GM::Factory::CreateCons(const std::string& name, double rin1,
824 double rout1, double rin2, double rout2, double hz, double sphi, double dphi)
825{
826 //
827 return Register(
828 new Geant4GM::Cons(name, rin1, rout1, rin2, rout2, hz, sphi, dphi));
829}
830
831//_____________________________________________________________________________
832VGM::ISolid* Geant4GM::Factory::CreateCtubs(const std::string& name, double rin,
833 double rout, double hz, double sphi, double dphi, double nxlow, double nylow,
834 double nzlow, double nxhigh, double nyhigh, double nzhigh)
835{
836 //
837 return Register(new Geant4GM::Ctubs(name, rin, rout, hz, sphi, dphi, nxlow,
838 nylow, nzlow, nxhigh, nyhigh, nzhigh));
839}
840
841//_____________________________________________________________________________
843 double dx, double dy, double dz, double zBottomCut, double zTopCut)
844{
845 //
846 return Register(
847 new Geant4GM::Ellipsoid(name, dx, dy, dz, zBottomCut, zTopCut));
848}
849
850//_____________________________________________________________________________
852 const std::string& name, double dx, double dy, double hz)
853{
854 //
855 return Register(new Geant4GM::EllipticalTube(name, dx, dy, hz));
856}
857
858//_____________________________________________________________________________
859VGM::ISolid* Geant4GM::Factory::CreateHype(const std::string& name, double r1,
860 double r2, double stereo1, double stereo2, double hz)
861{
862 //
863 return Register(new Geant4GM::Hype(name, r1, r2, stereo1, stereo2, hz));
864}
865
866//_____________________________________________________________________________
867VGM::ISolid* Geant4GM::Factory::CreatePara(const std::string& name, double dx,
868 double dy, double dz, double alpha, double theta, double phi)
869{
870 //
871 return Register(new Geant4GM::Para(name, dx, dy, dz, alpha, theta, phi));
872}
873
874//_____________________________________________________________________________
876 const std::string& name, double r1, double r2, double hz)
877{
878 //
879 return Register(new Geant4GM::Paraboloid(name, r1, r2, hz));
880}
881
882//_____________________________________________________________________________
884 double sphi, double dphi, int nofZplanes, double* z, double* rin,
885 double* rout)
886{
887 //
888 return Register(
889 new Geant4GM::Polycone(name, sphi, dphi, nofZplanes, z, rin, rout));
890}
891
892//_____________________________________________________________________________
894 double sphi, double dphi, int nofSides, int nofZplanes, double* z,
895 double* rin, double* rout)
896{
897 //
898 return Register(new Geant4GM::Polyhedra(
899 name, sphi, dphi, nofSides, nofZplanes, z, rin, rout));
900}
901
902//_____________________________________________________________________________
904 double rin, double rout, double sphi, double dphi, double stheta,
905 double dtheta)
906{
907 //
908 return Register(
909 new Geant4GM::Sphere(name, rin, rout, sphi, dphi, stheta, dtheta));
910}
911
912//_____________________________________________________________________________
914 const std::string& name, std::vector<std::vector<VGM::ThreeVector> > facets)
915{
916 //
917 return Register(new Geant4GM::TessellatedSolid(name, facets));
918}
919
920//_____________________________________________________________________________
921VGM::ISolid* Geant4GM::Factory::CreateTorus(const std::string& name, double rin,
922 double rout, double rax, double sphi, double dphi)
923{
924 //
925 return Register(new Geant4GM::Torus(name, rin, rout, rax, sphi, dphi));
926}
927
928//_____________________________________________________________________________
929VGM::ISolid* Geant4GM::Factory::CreateTrap(const std::string& name, double hz,
930 double theta, double phi, double dy1, double dx1, double dx2, double alpha1,
931 double dy2, double dx3, double dx4, double alpha2)
932{
933 //
934 return Register(new Geant4GM::Trap(
935 name, hz, theta, phi, dy1, dx1, dx2, alpha1, dy2, dx3, dx4, alpha2));
936}
937
938//_____________________________________________________________________________
939VGM::ISolid* Geant4GM::Factory::CreateTrd(const std::string& name, double hx1,
940 double hx2, double hy1, double hy2, double hz)
941{
942 //
943 return Register(new Geant4GM::Trd(name, hx1, hx2, hy1, hy2, hz));
944}
945
946//_____________________________________________________________________________
947VGM::ISolid* Geant4GM::Factory::CreateTubs(const std::string& name, double rin,
948 double rout, double hz, double sphi, double dphi)
949{
950 //
951 return Register(new Geant4GM::Tubs(name, rin, rout, hz, sphi, dphi));
952}
953
954//_____________________________________________________________________________
956 std::vector<VGM::TwoVector> polygon,
957 std::vector<std::vector<double> > zsections)
958{
959 //
960 return Register(new Geant4GM::ExtrudedSolid(name, polygon, zsections));
961}
962
963//_____________________________________________________________________________
965 VGM::ISolid* solidA, VGM::ISolid* solidB, const VGM::Transform& transform)
966{
967 //
968 if (ClhepVGM::HasReflection(transform)) {
969 std::cerr << " Geant4GM::Factory::CreateIntersectionSolid:" << std::endl;
970 std::cerr << " Reflection in Boolean solid not supported in Geant4."
971 << std::endl;
972 std::cerr << "*** Error: Aborting execution ***" << std::endl;
973 exit(1);
974 }
975
976 return Register(new Geant4GM::BooleanSolid(name, VGM::kIntersection, solidA,
977 solidB, new CLHEP::HepRotation(ClhepVGM::Rotation(transform).inverse()),
978 ClhepVGM::Translation(transform)));
979}
980
981//_____________________________________________________________________________
983 VGM::ISolid* solidA, VGM::ISolid* solidB, const VGM::Transform& transform)
984{
985 //
986
987 if (ClhepVGM::HasReflection(transform)) {
988 std::cerr << " Geant4GM::Factory::CreateSubtractionSolid:" << std::endl;
989 std::cerr << " Reflection in Boolean solid not supported in Geant4."
990 << std::endl;
991 std::cerr << "*** Error: Aborting execution ***" << std::endl;
992 exit(1);
993 }
994
995 return Register(new Geant4GM::BooleanSolid(name, VGM::kSubtraction, solidA,
996 solidB, new CLHEP::HepRotation(ClhepVGM::Rotation(transform).inverse()),
997 ClhepVGM::Translation(transform)));
998}
999
1000//_____________________________________________________________________________
1002 VGM::ISolid* solidA, VGM::ISolid* solidB, const VGM::Transform& transform)
1003{
1004 //
1005 if (ClhepVGM::HasReflection(transform)) {
1006 std::cerr << " Geant4GM::Factory::CreateUnionSolid:" << std::endl;
1007 std::cerr << " Reflection in Boolean solid not supported in Geant4."
1008 << std::endl;
1009 std::cerr << "*** Error: Aborting execution ***" << std::endl;
1010 exit(1);
1011 }
1012
1013 return Register(new Geant4GM::BooleanSolid(name, VGM::kUnion, solidA, solidB,
1014 new CLHEP::HepRotation(ClhepVGM::Rotation(transform).inverse()),
1015 ClhepVGM::Translation(transform)));
1016}
1017
1018//_____________________________________________________________________________
1020 const std::string& name, VGM::ISolid* solid, const VGM::Transform& transform)
1021{
1022 //
1023 if (ClhepVGM::HasReflection(transform)) {
1024 std::cerr << " Geant4GM::Factory::CreateDisplacedSolid:" << std::endl;
1025 std::cerr << " Reflection in Displaced solid not supported in Geant4."
1026 << std::endl;
1027 std::cerr << "*** Error: Aborting execution ***" << std::endl;
1028 exit(1);
1029 }
1030
1031 return Register(new Geant4GM::DisplacedSolid(name, solid,
1032 new CLHEP::HepRotation(ClhepVGM::Rotation(transform).inverse()),
1033 ClhepVGM::Translation(transform)));
1034}
1035
1036//_____________________________________________________________________________
1038 const std::string& name, VGM::ISolid* solid, const VGM::Transform& transform)
1039{
1040 //
1041 if (ClhepVGM::HasReflection(transform)) {
1042 std::cerr << " Geant4GM::Factory::CreateDisplacedSolid:" << std::endl;
1043 std::cerr << " Reflection in ScaledSolid solid not supported in Geant4."
1044 << std::endl;
1045 std::cerr << "*** Error: Aborting execution ***" << std::endl;
1046 exit(1);
1047 }
1048
1049 return Register(
1050 new Geant4GM::ScaledSolid(name, solid, ClhepVGM::Scale(transform)));
1051}
1052
1053//_____________________________________________________________________________
1055 std::vector<VGM::ISolid*> constituents,
1056 std::vector<VGM::Transform> transforms)
1057{
1058 //
1059 std::vector<G4Transform3D> g4Transforms;
1060 for (auto transform : transforms) {
1061 if (ClhepVGM::HasReflection(transform)) {
1062 std::cerr << " Geant4GM::Factory::CreateMultiUnion:" << std::endl;
1063 std::cerr
1064 << " Reflection in MultiUnion solid is not supported in Geant4."
1065 << std::endl;
1066 std::cerr << "*** Error: Aborting execution ***" << std::endl;
1067 exit(1);
1068 }
1069 g4Transforms.push_back(ClhepVGM::Transform(transform));
1070 }
1071
1072 return Register(new Geant4GM::MultiUnion(name, constituents, g4Transforms));
1073}
1074
1075//_____________________________________________________________________________
1077 const std::string& name, VGM::ISolid* solid, const std::string& mediumName)
1078{
1079 //
1080 // Get material name from medium
1081 const VGM::IMedium* medium = MaterialFactory()->Medium(mediumName);
1082 if (!medium) {
1083 std::cerr << "Geant4GM::Factory::CreateVolume: " << std::endl;
1084 std::cerr << " Medium " << mediumName << " not found." << std::endl;
1085 exit(1);
1086 }
1087 const VGM::IMaterial* material = medium->Material();
1088 if (!material) {
1089 std::cerr << "Geant4GM::Factory::CreateVolume: " << std::endl;
1090 std::cerr << " No material is defined for medium " << mediumName
1091 << std::endl;
1092 exit(1);
1093 }
1094 std::string materialName = material->Name();
1095
1096 VGM::IVolume* volume =
1097 new Geant4GM::Volume(name, solid, materialName, mediumName);
1098
1099 VolumeStore().push_back(volume);
1100 return volume;
1101}
1102
1103//_____________________________________________________________________________
1105 int copyNo, VGM::IVolume* volume, VGM::IVolume* motherVolume,
1106 const VGM::Transform& transform)
1107{
1108 //
1109 /*
1110 if (!ClhepVGM::HasReflection(transform)) {
1111 return CreateSimplePlacement(name, copyNo, volume, motherVolume,
1112 transform);
1113 }
1114 */
1115 // Get logical volumes from the volumes map
1116 G4LogicalVolume* g4LV = Geant4GM::VolumeMap::Instance()->GetVolume(volume);
1117
1118 G4LogicalVolume* g4MotherLV =
1120
1121 // Create PV placement
1122 // for a general transformation we have to use G4 reflection factory
1123 G4ReflectionFactory* g4ReflectionFactory = G4ReflectionFactory::Instance();
1124
1125 G4PhysicalVolumesPair pvPair =
1126 g4ReflectionFactory->Place(ClhepVGM::Transform(transform), name, g4LV,
1127 g4MotherLV, false, copyNo, fgSurfCheck);
1128
1129 // Import volumes created via G4 reflection factory
1130 VGM::IPlacement* placement1 = ImportPVPair(volume, motherVolume, pvPair);
1131
1132 // Top volume
1133 if (!motherVolume) {
1134 if (!fTop)
1135 fTop = placement1;
1136 else {
1137 std::cerr << " Geant4GM::Factory::CreatePlacement:" << std::endl;
1138 std::cerr << " Top volume defined twice!" << std::endl;
1139 std::cerr << "*** Error: Aborting execution ***" << std::endl;
1140 exit(1);
1141 }
1142 }
1143
1144 return placement1;
1145 // should allow to return a list of placements
1146}
1147
1148//_____________________________________________________________________________
1150 const std::string& name, VGM::IVolume* volume, VGM::IVolume* motherVolume,
1151 VGM::Axis axis, int nofItems, double width, double offset, double halfGap)
1152{
1153 //
1154
1155 // Top volume
1156 if (!motherVolume) {
1157 std::cerr << "Geant4GM::Factory::CreateMultiplePlacement: "
1158 << " Mother volume not defined!" << std::endl;
1159 std::cerr << "*** Error: Aborting execution ***" << std::endl;
1160 exit(1);
1161 }
1162
1163 // Get logical volumes from the volumes map
1164 G4LogicalVolume* g4LV = Geant4GM::VolumeMap::Instance()->GetVolume(volume);
1165
1166 G4LogicalVolume* g4MotherLV =
1168
1169 // Geant4 requires the same type of solid in both
1170 // volume and mother volume
1171 VGM::SolidType solidType = volume->Solid()->Type();
1172 VGM::SolidType motherSolidType = motherVolume->Solid()->Type();
1173 if (solidType != motherSolidType) {
1174 bool result = SwitchSolid(volume, g4LV, g4MotherLV);
1175 if (!result) {
1176 std::cerr << " Geant4GM::Factory::CreateMultiplePlacement: "
1177 << std::endl
1178 << " Different solid types in volume and mother!"
1179 << std::endl
1180 << " volume: " << volume->Name() << " "
1181 << VGM::SolidTypeName(solidType)
1182 << " mother: " << motherVolume->Name() << " "
1183 << VGM::SolidTypeName(motherSolidType) << std::endl
1184 << "*** Error: Aborting execution ***" << std::endl;
1185 exit(1);
1186 }
1187 }
1188
1189 // Apply units
1190 width /= ClhepVGM::Units::AxisUnit(axis);
1191 offset /= ClhepVGM::Units::AxisUnit(axis);
1192
1193 // Update offset if it goes beyond mother dhi
1194 if (axis == VGM::kPhi && offset + nofItems * width > 2 * CLHEP::pi)
1195 offset = offset - 2 * CLHEP::pi;
1196
1197 // The instance of G4PVDivisionFactory must exist
1198 G4PVDivisionFactory::GetInstance();
1199
1200 // The halfGap is not yet supported by G4ReflectionFactory
1201 G4PhysicalVolumesPair pvPair;
1202 if (halfGap != 0.) {
1203 G4VPhysicalVolume* replicatedSlice =
1204 new G4ReplicatedSlice(name, g4LV, g4MotherLV,
1205 Geant4GM::Placement::GetAxis(axis), nofItems, width, halfGap, offset);
1206 pvPair.first = replicatedSlice;
1207 pvPair.second = 0;
1208 }
1209 else {
1210 // Create PV division
1211 // for a general transformation we have to use G4 reflection factory
1212 G4ReflectionFactory* g4ReflectionFactory = G4ReflectionFactory::Instance();
1213
1214 // G4PhysicalVolumesPair pvPair
1215 pvPair = g4ReflectionFactory->Divide(name, g4LV, g4MotherLV,
1216 Geant4GM::Placement::GetAxis(axis), nofItems, width, offset);
1217 }
1218
1219 // Import volumes created via G4 reflection factory
1220 VGM::IPlacement* placement1 = ImportPVPair(volume, motherVolume, pvPair);
1221
1222 return placement1;
1223 // should allow to return a list of placements
1224}
1225
1226//_____________________________________________________________________________
1228 const std::string& name, VGM::IVolume* motherVolume,
1229 const std::vector<VGM::Transform>& transforms,
1230 const std::vector<VGM::IVolume*>& volumes)
1231{
1232 //
1233 bool failure = false;
1234 std::string failureMessage;
1235
1236 // Cannot be top volume
1237 if (!motherVolume) {
1238 failureMessage = " Mother volume not defined!";
1239 failure = true;
1240 }
1241
1242 // Vector sizes cannot differ
1243 if (transforms.size() != volumes.size()) {
1244 failureMessage = " Transformations and Volumes vector sizes cannot differ!";
1245 failure = true;
1246 }
1247
1248 if (failure) {
1249 std::cerr << " Geant4GM::Factory::CreateParameterisedPlacement:"
1250 << std::endl << failureMessage << std::endl;
1251 std::cerr << "*** Error: Aborting execution ***" << std::endl;
1252 exit(1);
1253 }
1254
1255 for (size_t i = 0; i < transforms.size(); ++i) {
1256 CreatePlacement(name, i, volumes[i], motherVolume, transforms[i]);
1257 }
1258 return 0;
1259}
1260
1261//_____________________________________________________________________________
1263{
1265
1266 return fTop;
1267}
1268
1269//_____________________________________________________________________________
1271{
1273
1274 return fSolid;
1275}
1276
1277//_____________________________________________________________________________
1278G4VPhysicalVolume* Geant4GM::Factory::World() const
1279{
1281
1283}
1284
1285//_____________________________________________________________________________
1287{
1289
1290 return Geant4GM::SolidMap::Instance()->GetSolid(fSolid);
1291}
1292
1293//_____________________________________________________________________________
1294bool Geant4GM::Factory::Import(G4VPhysicalVolume* worldPV)
1295{
1297
1298 if (Debug() > 0) {
1300 std::cout << "Geant4GM::Factory::Import started ...";
1301 if (Debug() > 1) std::cout << worldPV;
1302 std::cout << std::endl;
1303 }
1304
1305 // Inactivate single mode (if it was switch previously)
1306 //
1307 SetSingleMode(false);
1308
1309 // Import materials
1310 //
1311 MaterialFactory()->Import();
1312
1313 // Get logical volume
1314 G4LogicalVolume* worldLV = worldPV->GetLogicalVolume();
1315
1316 // Import the top volume
1317 VGM::IVolume* worldVolume = ImportLV(worldLV);
1318
1319 // Import recursively all daughters
1320 ImportDaughters(worldLV);
1321
1322 // Import positions
1323 ImportPositions();
1324
1325 if (Debug() > 0) {
1327 std::cout << std::endl;
1328 PrintSolids();
1329 PrintVolumes();
1331 }
1332
1333 // Position the top volume
1334 fTop = new Geant4GM::Placement(worldVolume, 0, worldPV);
1335
1336 if (Debug() > 0) {
1338 std::cout << "Geant4GM::Factory::Import finished." << std::endl;
1339 }
1340
1341 return true;
1342}
1343
1344//_____________________________________________________________________________
1345bool Geant4GM::Factory::Import(G4VSolid* solid)
1346{
1349
1350 if (Debug() > 0) {
1352 std::cout << "Geant4GM::Factory::Import of one solid started ...";
1353 if (Debug() > 1) std::cout << solid;
1354 std::cout << std::endl;
1355 }
1356
1357 // Clear solid store
1358 // (Do not delete objects as they are also referenced in a singleton mao)
1359 SolidStore().clear();
1360
1361 // Activate single mode
1362 //
1363 SetSingleMode(true);
1364
1365 // Import solid
1366 fSolid = ImportSolid(solid);
1367
1368 if (Debug() > 0) {
1370 std::cout << "Geant4GM::Factory::Import of one solid finished."
1371 << std::endl;
1372 }
1373
1374 return (fSolid != 0);
1375}
VFactory(const std::string &name, VGM::IMaterialFactory *materialFactory)
Definition VFactory.cxx:75
virtual void PrintSolids() const
Print all solids.
Definition VFactory.cxx:713
virtual void SetSingleMode(bool singleMode)
Set single mode option.
Definition VFactory.h:177
virtual VGM::IMaterialFactory * MaterialFactory() const
Return the associated material factory.
Definition VFactory.h:139
virtual void PrintVolumes() const
Print all volumes.
Definition VFactory.cxx:728
virtual bool Ignore() const
Return the ignore option.
Definition VFactory.h:158
virtual VGM::SolidStore & SolidStore()
Definition VFactory.h:144
virtual int Debug() const
Return the debug level.
Definition VFactory.h:156
virtual VGM::VolumeStore & VolumeStore()
Definition VFactory.h:150
static double Length()
Return CLHEP default length unit in VGM units.
Definition Units.cxx:83
static double AxisUnit(VGM::Axis axis)
Convert CLHEP default unit for given axis type in VGM units.
Definition Units.cxx:63
VGM implementation for Geant4 Arb8 solid, the shape is implemented using G4TessellatedSolid,...
Definition Arb8.h:44
static bool IsTwisted(std::vector< VGM::TwoVector > vertices)
Definition Arb8.cxx:81
static double MaxTwistAngle(const std::vector< VGM::TwoVector > &vertices)
Definition Arb8.cxx:65
VGM implementation for Geant4 Boolean solid.
static G4VSolid * GetConstituentSolid(int index, G4BooleanSolid *booleanSolid)
VGM implementation for Geant4 box solid.
Definition Box.h:33
VGM implementation for Geant4 cons solid.
Definition Cons.h:33
VGM implementation for cut tubs solid in Geant4.
Definition Ctubs.h:38
VGM implementation for Geant4 displaced solid.
VGM implementation for Geant4 ellipsoid solid.
Definition Ellipsoid.h:33
VGM implementation for Geant4 elliptical tube solid.
VGM implementation for Geant4 xtru solid.
virtual VGM::ISolid * CreateTrap(const std::string &name, double hz, double theta, double phi, double dy1, double dx1, double dx2, double alpha1, double dy2, double dx3, double dx4, double alpha2)
Create the trap solid = general trapezoid ( Note that of the 11 parameters described below,...
Definition Factory.cxx:929
G4VSolid * Solid() const
Definition Factory.cxx:1286
virtual VGM::ISolid * CreateEllipsoid(const std::string &name, double dx, double dy, double dz, double zBottomCut, double zTopCut)
Create the ellipsoid solid.
Definition Factory.cxx:842
virtual VGM::ISolid * CreateScaledSolid(const std::string &name, VGM::ISolid *solid, const VGM::Transform &transform)
Create scaled solid.
Definition Factory.cxx:1037
virtual VGM::ISolid * CreateBox(const std::string &name, double hx, double hy, double hz)
Create the box solid.
Definition Factory.cxx:815
virtual VGM::ISolid * CreateMultiUnion(const std::string &name, std::vector< VGM::ISolid * > constituents, std::vector< VGM::Transform > transforms)
Create the multi union of solids.
Definition Factory.cxx:1054
virtual VGM::IPlacement * CreateParameterisedPlacement(const std::string &name, VGM::IVolume *motherVolume, const std::vector< VGM::Transform > &transforms, const std::vector< VGM::IVolume * > &volumes)
Create the parameterised volume placement.
Definition Factory.cxx:1227
bool Import(G4VPhysicalVolume *topVolume)
Definition Factory.cxx:1294
virtual VGM::ISolid * SingleSolid() const
Return solid (if in one solid conversion mode).
Definition Factory.cxx:1270
virtual VGM::ISolid * CreateSphere(const std::string &name, double rin, double rout, double sphi, double dphi, double stheta, double dtheta)
Create the sphere solid = phi segment of a spherical shell.
Definition Factory.cxx:903
virtual VGM::ISolid * CreateEllipticalTube(const std::string &name, double dx, double dy, double hz)
Create the elliptical tube solid.
Definition Factory.cxx:851
virtual VGM::ISolid * CreateTorus(const std::string &name, double rin, double rout, double rax, double sphi, double dphi)
Create the torus solid = phi segment of a torus.
Definition Factory.cxx:921
virtual VGM::ISolid * CreateExtrudedSolid(const std::string &name, std::vector< VGM::TwoVector > polygon, std::vector< std::vector< double > > zsections)
Create the extruded solid.
Definition Factory.cxx:955
virtual VGM::ISolid * CreateArb8(const std::string &name, double hz, std::vector< VGM::TwoVector > vertices)
Create the arbitrary trapezoid with 8 vertices standing on two paralel planes perpendicular to Z axis...
Definition Factory.cxx:786
virtual VGM::ISolid * CreateTessellatedSolid(const std::string &name, std::vector< std::vector< VGM::ThreeVector > > facets)
Create tessellated solid = solid composed from triangular and rectangular facets.
Definition Factory.cxx:913
virtual VGM::ISolid * CreateDisplacedSolid(const std::string &name, VGM::ISolid *solid, const VGM::Transform &transform)
Create displaced solid.
Definition Factory.cxx:1019
virtual VGM::ISolid * CreateHype(const std::string &name, double r1, double r2, double stereo1, double stereo2, double hz)
Create the hyperboloid solid.
Definition Factory.cxx:859
virtual VGM::IPlacement * Top() const
Return the top volume placement.
Definition Factory.cxx:1262
virtual VGM::ISolid * CreatePolyhedra(const std::string &name, double sphi, double dphi, int nofSides, int nofZplanes, double *z, double *rin, double *rout)
Create the polyhedra solid = phi segment of a polyhedra (polygone).
Definition Factory.cxx:893
virtual VGM::ISolid * CreatePara(const std::string &name, double dx, double dy, double dz, double alpha, double theta, double phi)
Create the para solid = parallelepiped.
Definition Factory.cxx:867
virtual VGM::ISolid * CreateIntersectionSolid(const std::string &name, VGM::ISolid *solidA, VGM::ISolid *solidB, const VGM::Transform &transform)
Create the intersection of two solids.
Definition Factory.cxx:964
virtual VGM::IPlacement * CreatePlacement(const std::string &name, int copyNo, VGM::IVolume *volume, VGM::IVolume *motherVolume, const VGM::Transform &transform)
Create the simple volume placement.
Definition Factory.cxx:1104
virtual VGM::ISolid * CreateCons(const std::string &name, double rin1, double rout1, double rin2, double rout2, double hz, double sphi, double dphi)
Create the cons solid = phi segment of a conical tube.
Definition Factory.cxx:823
static bool GetSurfCheck()
Definition Factory.cxx:106
virtual ~Factory()
Definition Factory.cxx:135
virtual VGM::ISolid * CreateTrd(const std::string &name, double hx1, double hx2, double hy1, double hy2, double hz)
Create the trd solid = a trapezoid with the x and y dimensions varying along z.
Definition Factory.cxx:939
virtual VGM::ISolid * CreateSubtractionSolid(const std::string &name, VGM::ISolid *solidA, VGM::ISolid *solidB, const VGM::Transform &transform)
Create the subtraction of two solids.
Definition Factory.cxx:982
virtual void SetSolid(VGM::ISolid *solid)
Set solid (in single mode).
Definition Factory.cxx:774
virtual VGM::ISolid * CreateTubs(const std::string &name, double rin, double rout, double hz, double sphi, double dphi)
Create the trd solid = phi segment of a tube.
Definition Factory.cxx:947
virtual VGM::IPlacement * CreateMultiplePlacement(const std::string &name, VGM::IVolume *volume, VGM::IVolume *motherVolume, VGM::Axis axis, int nofItems, double width, double offset, double halfGap)
Create the multiple volume placement.
Definition Factory.cxx:1149
virtual VGM::ISolid * CreateUnionSolid(const std::string &name, VGM::ISolid *solidA, VGM::ISolid *solidB, const VGM::Transform &transform)
Create the union of two solids.
Definition Factory.cxx:1001
virtual VGM::ISolid * CreateCtubs(const std::string &name, double rin, double rout, double hz, double sphi, double dphi, double nxlow, double nylow, double nzlow, double nxhigh, double nyhigh, double nzhigh)
Create the cut tubs solid = phi segment of a tube cut with two planes.
Definition Factory.cxx:832
virtual VGM::IVolume * CreateVolume(const std::string &name, VGM::ISolid *solid, const std::string &mediumName)
Create the volume.
Definition Factory.cxx:1076
virtual VGM::ISolid * CreatePolycone(const std::string &name, double sphi, double dphi, int nofZplanes, double *z, double *rin, double *rout)
Create the polycone solid = phi segment of a polycone.
Definition Factory.cxx:883
static void SetSurfCheck(bool surfCheck)
Definition Factory.cxx:97
G4VPhysicalVolume * World() const
Definition Factory.cxx:1278
virtual VGM::ISolid * CreateParaboloid(const std::string &name, double r1, double r2, double hz)
Create the paraboloid solid.
Definition Factory.cxx:875
VGM implementation for Geant4 hyperboloid solid.
Definition Hype.h:33
VGM implementation for Geant4 Boolean solid.
Definition MultiUnion.h:40
VGM implementation for Geant4 para solid.
Definition Para.h:33
VGM implementation for Geant4 paraboloid solid.
Definition Paraboloid.h:33
static PlacementMap * Instance()
void AddPlacement(VGM::IPlacement *, G4VPhysicalVolume *)
G4VPhysicalVolume * GetPlacement(VGM::IPlacement *iPlacement) const
VGM implementation for Geant4 positions of volumes.
Definition Placement.h:40
static EAxis GetAxis(VGM::Axis axis)
Definition Placement.cxx:82
VGM implementation for Geant4 polycone solid.
Definition Polycone.h:35
VGM implementation for Geant4 polyhedra solid.
Definition Polyhedra.h:33
VGM implementation for Geant4 Scaled solid.
Definition ScaledSolid.h:36
G4VSolid * GetSolid(VGM::ISolid *iSolid) const
Definition SolidMap.cxx:68
static SolidMap * Instance()
Definition SolidMap.cxx:28
VGM implementation for Geant4 sphere solid.
Definition Sphere.h:33
VGM implementation for Geant4 tessellated solid.
VGM implementation for Geant4 torus solid.
Definition Torus.h:33
VGM implementation for Geant4 trap solid.
Definition Trap.h:33
VGM implementation for Geant4 trd solid.
Definition Trd.h:33
VGM implementation for Geant4 tubs solid.
Definition Tubs.h:36
void AddParamVolume(G4LogicalVolume *, const std::vector< G4LogicalVolume * > &)
Definition VolumeMap.cxx:70
void Print() const
Definition VolumeMap.cxx:77
static VolumeMap * Instance()
Definition VolumeMap.cxx:28
G4LogicalVolume * GetVolume(VGM::IVolume *iVolume) const
Definition VolumeMap.cxx:95
VGM implementation for Geant4 volume.
Definition Volume.h:36
The VGM interface to materials.
Definition IMaterial.h:44
virtual std::string Name() const =0
Return the name of this element.
The VGM interface to tracking medium.
Definition IMedium.h:31
virtual IMaterial * Material() const =0
Return its associated material.
The VGM interface to positions of volumes.
Definition IPlacement.h:44
virtual std::string Name() const =0
Return the name of this placement.
The VGM interface to solids.
Definition ISolid.h:58
virtual SolidType Type() const =0
Return the type of this solid.
The VGM interface to volumes.
Definition IVolume.h:32
virtual ISolid * Solid() const =0
Return the associated solid.
virtual std::string Name() const =0
Return the name of this volume.
virtual std::string MediumName() const =0
Return the name of the associated medium.
BaseVGM utilities.
Definition utilities.h:23
void DebugInfo()
Debug printing.
Definition utilities.cxx:27
bool HasReflection(const HepGeom::Transform3D &transform)
VGM::Transform Transform(const CLHEP::HepRotation &rotation, const CLHEP::Hep3Vector &translation)
Definition transform.cxx:26
CLHEP::Hep3Vector Translation(const VGM::Transform &transform)
CLHEP::HepRotation Rotation(const VGM::Transform &transform)
HepGeom::Scale3D Scale(const VGM::Transform &transform)
VGM implementation for Geant4.
Definition Element.h:29
Arb8SplitResult SplitArb8ForGenericTrap(double halfLength, const std::vector< VGM::TwoVector > &vertices, Arb8Split &split)
Split an Arb8 whose corresponding end edges form angles greater than 90 degrees into two pieces accep...
VGM interfaces.
Definition VMedium.h:28
std::vector< double > Transform
Definition Transform.h:40
std::string SolidTypeName(VGM::SolidType typeId)
Definition solid.cxx:27
@ kIntersection
@ kSubtraction
std::vector< IVolume * > VolumeStore
Definition IFactory.h:43
Axis
Definition Axis.h:34
@ kPhi
Definition Axis.h:40
std::vector< ISolid * > SolidStore
Definition IFactory.h:42
SolidType
Definition ISolid.h:29
Parameters of two G4GenericTrap-compatible pieces obtained by cutting an Arb8 with a plane perpendicu...