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