Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4tgbGeometryDumper Class Reference

#include <G4tgbGeometryDumper.hh>

Public Member Functions

 ~G4tgbGeometryDumper ()
 
void DumpGeometry (const G4String &fname)
 
G4VPhysicalVolumeGetTopPhysVol ()
 
void DumpPhysVol (G4VPhysicalVolume *pv)
 
void DumpPVPlacement (G4VPhysicalVolume *pv, const G4String &lvName, G4int copyNo=-999)
 
void DumpPVParameterised (G4PVParameterised *pv)
 
void DumpPVReplica (G4PVReplica *pv, const G4String &lvName)
 
G4String DumpLogVol (G4LogicalVolume *lv, G4String extraName="", G4VSolid *solid=0, G4Material *mate=0)
 
G4String DumpMaterial (G4Material *mat)
 
void DumpElement (G4Element *ele)
 
void DumpIsotope (G4Isotope *ele)
 
G4String DumpSolid (G4VSolid *solid, const G4String &extraName="")
 
void DumpBooleanVolume (const G4String &solidType, G4VSolid *so)
 
void DumpSolidParams (G4VSolid *so)
 
std::vector< G4doubleGetSolidParams (const G4VSolid *so)
 
void DumpPolySections (G4int zPlanes, G4double *z, G4double *rmin, G4double *rmax)
 
G4String DumpRotationMatrix (G4RotationMatrix *rotm)
 

Static Public Member Functions

static G4tgbGeometryDumperGetInstance ()
 

Detailed Description

Definition at line 56 of file G4tgbGeometryDumper.hh.

Constructor & Destructor Documentation

◆ ~G4tgbGeometryDumper()

G4tgbGeometryDumper::~G4tgbGeometryDumper ( )

Definition at line 135 of file G4tgbGeometryDumper.cc.

136{
137}

Member Function Documentation

◆ DumpBooleanVolume()

void G4tgbGeometryDumper::DumpBooleanVolume ( const G4String solidType,
G4VSolid so 
)

Definition at line 699 of file G4tgbGeometryDumper.cc.

701{
702 G4BooleanSolid * bso = dynamic_cast < G4BooleanSolid * > (so);
703 if (!bso) { return; }
704 G4VSolid* solid0 = bso->GetConstituentSolid( 0 );
705 G4VSolid* solid1 = bso->GetConstituentSolid( 1 );
706 G4DisplacedSolid* solid1Disp = 0;
707 G4bool displaced = dynamic_cast<G4DisplacedSolid*>(solid1);
708 if( displaced )
709 {
710 solid1Disp = dynamic_cast<G4DisplacedSolid*>(solid1);
711 if (solid1Disp) { solid1 = solid1Disp->GetConstituentMovedSolid(); }
712 }
713 DumpSolid( solid0 );
714 DumpSolid( solid1 );
715
716 G4String rotName;
717 G4ThreeVector pos;
718 if( displaced )
719 {
720 pos = solid1Disp->GetObjectTranslation(); // translation is of mother frame
721 rotName = DumpRotationMatrix( new G4RotationMatrix( (solid1Disp->
722 GetTransform().NetRotation()).inverse() ) );
723 }
724 else // no displacement
725 {
726 rotName = DumpRotationMatrix( new G4RotationMatrix );
727 pos = G4ThreeVector();
728 }
729
730 G4String bsoName = GetObjectName(so,theSolids);
731 if( theSolids.find( bsoName ) != theSolids.end() ) return; // alredy dumped
732 G4String solid0Name = FindSolidName( solid0 );
733 G4String solid1Name = FindSolidName( solid1 );
734
735 (*theFile) << ":SOLID "
736 << AddQuotes(bsoName) << " "
737 << AddQuotes(solidType) << " "
738 << AddQuotes(solid0Name) << " "
739 << AddQuotes(solid1Name) << " "
740 << AddQuotes(rotName) << " "
741 << approxTo0(pos.x()) << " "
742 << approxTo0(pos.y()) << " "
743 << approxTo0(pos.z()) << " " << G4endl;
744
745 theSolids[bsoName] = bso;
746}
CLHEP::HepRotation G4RotationMatrix
CLHEP::Hep3Vector G4ThreeVector
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
double z() const
double x() const
double y() const
virtual const G4VSolid * GetConstituentSolid(G4int no) const
G4VSolid * GetConstituentMovedSolid() const
G4ThreeVector GetObjectTranslation() const
G4String DumpRotationMatrix(G4RotationMatrix *rotm)
G4String DumpSolid(G4VSolid *solid, const G4String &extraName="")

Referenced by DumpSolid().

◆ DumpElement()

void G4tgbGeometryDumper::DumpElement ( G4Element ele)

Definition at line 579 of file G4tgbGeometryDumper.cc.

580{
581 G4String elemName = GetObjectName(ele,theElements);
582
583 if( theElements.find( elemName ) != theElements.end() ) // alredy dumped
584 {
585 return;
586 }
587
588 //--- Add symbol name: Material mixtures store the components as elements
589 // (even if the input are materials), but without symbol
590 //
591 G4String symbol = ele->GetSymbol();
592 if( symbol == "" || symbol == " " )
593 {
594 symbol = elemName;
595 }
596
597 if( ele->GetNumberOfIsotopes() == 0 )
598 {
599 (*theFile) << ":ELEM " << AddQuotes(elemName) << " "
600 << AddQuotes(symbol) << " " << ele->GetZ() << " "
601 << ele->GetA()/(g/mole) << " " << G4endl;
602 }
603 else
604 {
605 const G4IsotopeVector* isots = ele->GetIsotopeVector();
606 for (size_t ii = 0; ii < ele->GetNumberOfIsotopes(); ii++)
607 {
608 DumpIsotope( (*isots)[ii] );
609 }
610
611 (*theFile) << ":ELEM_FROM_ISOT " << AddQuotes(elemName) << " "
612 << AddQuotes(symbol) << " " << ele->GetNumberOfIsotopes()
613 << G4endl;
614 const G4double* fractions = ele->GetRelativeAbundanceVector();
615 for (size_t ii = 0; ii < ele->GetNumberOfIsotopes(); ii++)
616 {
617 (*theFile) << " "
618 << AddQuotes(GetObjectName((*isots)[ii],theIsotopes)) << " "
619 << fractions[ii] << G4endl;
620 }
621 }
622 theElements[elemName] = ele;
623}
std::vector< G4Isotope * > G4IsotopeVector
double G4double
Definition: G4Types.hh:64
const G4String & GetSymbol() const
Definition: G4Element.hh:128
G4double * GetRelativeAbundanceVector() const
Definition: G4Element.hh:166
G4double GetZ() const
Definition: G4Element.hh:131
G4double GetA() const
Definition: G4Element.hh:138
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:158
G4IsotopeVector * GetIsotopeVector() const
Definition: G4Element.hh:162
void DumpIsotope(G4Isotope *ele)

Referenced by DumpMaterial().

◆ DumpGeometry()

void G4tgbGeometryDumper::DumpGeometry ( const G4String fname)

Definition at line 100 of file G4tgbGeometryDumper.cc.

101{
102 theFile = new std::ofstream(fname);
103
105 DumpPhysVol( pv ); // dump volume and recursively it will dump all hierarchy
106}
void DumpPhysVol(G4VPhysicalVolume *pv)
G4VPhysicalVolume * GetTopPhysVol()

◆ DumpIsotope()

void G4tgbGeometryDumper::DumpIsotope ( G4Isotope ele)

Definition at line 627 of file G4tgbGeometryDumper.cc.

628{
629 G4String isotName = GetObjectName(isot,theIsotopes);
630 if( theIsotopes.find( isotName ) != theIsotopes.end() ) // alredy dumped
631 {
632 return;
633 }
634
635 (*theFile) << ":ISOT " << AddQuotes(isotName) << " "
636 << isot->GetZ() << " " << isot->GetN() << " "
637 << isot->GetA()/(g/mole) << " " << G4endl;
638
639 theIsotopes[isotName] = isot;
640}

Referenced by DumpElement().

◆ DumpLogVol()

G4String G4tgbGeometryDumper::DumpLogVol ( G4LogicalVolume lv,
G4String  extraName = "",
G4VSolid solid = 0,
G4Material mate = 0 
)

Definition at line 461 of file G4tgbGeometryDumper.cc.

463{
464 G4String lvName;
465
466 if( extraName == "" ) //--- take out the '_refl' in the name
467 {
468 lvName = GetObjectName(lv,theLogVols);
469 }
470 else
471 {
472 lvName = lv->GetName()+extraName;
473 }
474
475 if( theLogVols.find( lvName ) != theLogVols.end() ) // alredy dumped
476 {
477 return lvName;
478 }
479
480 if( !solid ) { solid = lv->GetSolid(); }
481
482 //---- Dump solid
483 G4String solidName = DumpSolid( solid, extraName );
484
485 //---- Dump material
486 if( !mate ) { mate = lv->GetMaterial(); }
487 G4String mateName = DumpMaterial( mate );
488
489 //---- Dump logical volume (solid + material)
490 (*theFile) << ":VOLU " << SubstituteRefl(AddQuotes(lvName)) << " "
491 << SupressRefl(AddQuotes(solidName))
492 << " " << AddQuotes(mateName) << G4endl;
493
494 theLogVols[lvName] = lv;
495
496 return lvName;
497}
G4VSolid * GetSolid() const
G4String GetName() const
G4Material * GetMaterial() const
G4String DumpMaterial(G4Material *mat)

Referenced by DumpPhysVol(), and DumpPVParameterised().

◆ DumpMaterial()

G4String G4tgbGeometryDumper::DumpMaterial ( G4Material mat)

Definition at line 501 of file G4tgbGeometryDumper.cc.

502{
503 G4String mateName = GetObjectName(mat,theMaterials);
504 if( theMaterials.find( mateName ) != theMaterials.end() ) // alredy dumped
505 {
506 return mateName;
507 }
508
509 size_t numElements = mat->GetNumberOfElements();
510 G4double density = mat->GetDensity()/g*cm3;
511
512
513 // start tag
514 //
515 if (numElements == 1)
516 {
517 (*theFile) << ":MATE " << AddQuotes(mateName) << " "
518 << mat->GetZ() << " " << mat->GetA()/(g/mole) << " "
519 << density << G4endl;
520 }
521 else
522 {
523 const G4ElementVector* elems = mat->GetElementVector();
524 const G4double* fractions = mat->GetFractionVector();
525 for (size_t ii = 0; ii < numElements; ii++)
526 {
527 DumpElement( (*elems)[ii] );
528 }
529
530 (*theFile) << ":MIXT "<< AddQuotes(mateName) << " "
531 << density << " " << numElements << G4endl;
532 // close start element tag and get ready to do composit "parts"
533 for (size_t ii = 0; ii < numElements; ii++)
534 {
535 (*theFile) << " "
536 << AddQuotes(GetObjectName((*elems)[ii],theElements)) << " "
537 << fractions[ii] << G4endl;
538 }
539
540 }
541
542 (*theFile) << ":MATE_MEE " << AddQuotes(mateName) << " "
544 << "*eV" << G4endl;
545
546 (*theFile) << ":MATE_TEMPERATURE " << AddQuotes(mateName) << " "
547 << mat->GetTemperature()/kelvin << "*kelvin" << G4endl;
548
549 (*theFile) << ":MATE_PRESSURE " << AddQuotes(mateName) << " "
550 << mat->GetPressure()/atmosphere << "*atmosphere" << G4endl;
551
552 G4State state = mat->GetState();
553 G4String stateStr;
554 switch (state) {
555 case kStateUndefined:
556 stateStr = "Undefined";
557 break;
558 case kStateSolid:
559 stateStr = "Solid";
560 break;
561 case kStateLiquid:
562 stateStr = "Liquid";
563 break;
564 case kStateGas:
565 stateStr = "Gas";
566 break;
567 }
568
569 (*theFile) << ":MATE_STATE " << AddQuotes(mateName) << " "
570 << stateStr << G4endl;
571
572 theMaterials[mateName] = mat;
573
574 return mateName;
575}
std::vector< G4Element * > G4ElementVector
G4State
Definition: G4Material.hh:114
@ kStateSolid
Definition: G4Material.hh:114
@ kStateLiquid
Definition: G4Material.hh:114
@ kStateGas
Definition: G4Material.hh:114
@ kStateUndefined
Definition: G4Material.hh:114
G4double GetMeanExcitationEnergy() const
G4double GetPressure() const
Definition: G4Material.hh:182
G4double GetDensity() const
Definition: G4Material.hh:179
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:189
G4State GetState() const
Definition: G4Material.hh:180
G4double GetTemperature() const
Definition: G4Material.hh:181
G4double GetZ() const
Definition: G4Material.cc:604
const G4double * GetFractionVector() const
Definition: G4Material.hh:193
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:225
size_t GetNumberOfElements() const
Definition: G4Material.hh:185
G4double GetA() const
Definition: G4Material.cc:617
void DumpElement(G4Element *ele)

Referenced by DumpLogVol().

◆ DumpPhysVol()

void G4tgbGeometryDumper::DumpPhysVol ( G4VPhysicalVolume pv)

Definition at line 140 of file G4tgbGeometryDumper.cc.

141{
142
143 //--- Dump logical volume first
145
147
148 //--- It is not needed to dump _refl volumes created when parent is reflected
149 // !!WARNING : it must be avoided to reflect a volume hierarchy if children
150 // has also been reflected, as both will have same name
151
152 if( reffact->IsReflected( lv )
153 && reffact->IsReflected( pv->GetMotherLogical() ) ) { return; }
154
155
156 G4bool bVolExists = CheckIfLogVolExists( lv->GetName(), lv );
157
158 //---- Construct this PV
159 if( pv->GetMotherLogical() != 0 ) // not WORLD volume
160 {
161 if( !pv->IsReplicated() )
162 {
163 G4String lvName = lv->GetName();
164 if( !bVolExists )
165 {
166 lvName = DumpLogVol( lv );
167 }
168 DumpPVPlacement( pv, lvName );
169 }
170 else if( pv->IsParameterised() )
171 {
172 G4PVParameterised* pvparam = (G4PVParameterised*)(pv);
173 DumpPVParameterised( pvparam );
174 }
175 else
176 {
177 G4String lvName = lv->GetName();
178 if( !bVolExists )
179 {
180 lvName = DumpLogVol( lv );
181 }
182 G4PVReplica* pvrepl = (G4PVReplica*)(pv);
183 DumpPVReplica( pvrepl, lvName );
184 }
185
186 }
187 else
188 {
189 DumpLogVol( lv );
190 }
191
192 if( !bVolExists )
193 {
194 //---- Construct PV's who has this LV as mother
195 std::vector<G4VPhysicalVolume*> pvChildren = GetPVChildren( lv );
196 std::vector<G4VPhysicalVolume*>::const_iterator ite;
197 for( ite = pvChildren.begin(); ite != pvChildren.end(); ite++ )
198 {
199 DumpPhysVol( *ite );
200 }
201 }
202}
G4bool IsReflected(G4LogicalVolume *lv) const
static G4ReflectionFactory * Instance()
G4LogicalVolume * GetMotherLogical() const
virtual G4bool IsReplicated() const =0
G4LogicalVolume * GetLogicalVolume() const
virtual G4bool IsParameterised() const =0
G4String DumpLogVol(G4LogicalVolume *lv, G4String extraName="", G4VSolid *solid=0, G4Material *mate=0)
void DumpPVReplica(G4PVReplica *pv, const G4String &lvName)
void DumpPVParameterised(G4PVParameterised *pv)
void DumpPVPlacement(G4VPhysicalVolume *pv, const G4String &lvName, G4int copyNo=-999)

Referenced by DumpGeometry(), and DumpPhysVol().

◆ DumpPolySections()

void G4tgbGeometryDumper::DumpPolySections ( G4int  zPlanes,
G4double z,
G4double rmin,
G4double rmax 
)

◆ DumpPVParameterised()

void G4tgbGeometryDumper::DumpPVParameterised ( G4PVParameterised pv)

Definition at line 268 of file G4tgbGeometryDumper.cc.

269{
270 G4String pvName = pv->GetName();
271
272 EAxis axis;
273 G4int nReplicas;
274 G4double width;
275 G4double offset;
276 G4bool consuming;
277 pv->GetReplicationData(axis, nReplicas, width, offset, consuming);
278
280
282 G4VSolid* solid1st = param->ComputeSolid(0, pv);
283 G4Material* mate1st = param->ComputeMaterial(0, pv );
284 std::vector<G4double> params1st = GetSolidParams( solid1st );
285 std::vector<G4double> newParams;
286 G4VSolid* newSolid = solid1st;
287 G4String lvName;
288
289 for( G4int ii = 0; ii < nReplicas; ii++ )
290 {
291 G4Material* newMate = param->ComputeMaterial(ii, pv );
292 if( solid1st->GetEntityType() == "G4Box")
293 {
294 G4Box* box = (G4Box*)(solid1st);
295 param->ComputeDimensions(*box, ii, pv );
296 newParams = GetSolidParams( box );
297 newSolid = (G4VSolid*)box;
298 }
299 else if( solid1st->GetEntityType() == "G4Tubs")
300 {
301 G4Tubs* tubs = (G4Tubs*)(solid1st);
302 param->ComputeDimensions(*tubs, ii, pv );
303 newParams = GetSolidParams( tubs );
304 newSolid = (G4VSolid*)tubs;
305 }
306 else if( solid1st->GetEntityType() == "G4Trd")
307 {
308 G4Trd* trd = (G4Trd*)(solid1st);
309 param->ComputeDimensions(*trd, ii, pv );
310 newParams = GetSolidParams( trd );
311 newSolid = (G4VSolid*)trd;
312 }
313 else if( solid1st->GetEntityType() == "G4Trap")
314 {
315 G4Trap* trap = (G4Trap*)(solid1st);
316 param->ComputeDimensions(*trap, ii, pv );
317 newParams = GetSolidParams( trap );
318 newSolid = (G4VSolid*)trap;
319 }
320 else if( solid1st->GetEntityType() == "G4Cons")
321 {
322 G4Cons* cons = (G4Cons*)(solid1st);
323 param->ComputeDimensions(*cons, ii, pv );
324 newParams = GetSolidParams( cons );
325 newSolid = (G4VSolid*)cons;
326 }
327 else if( solid1st->GetEntityType() == "G4Sphere")
328 {
329 G4Sphere* sphere = (G4Sphere*)(solid1st);
330 param->ComputeDimensions(*sphere, ii, pv );
331 newParams = GetSolidParams( sphere );
332 newSolid = (G4VSolid*)sphere;
333 }
334 else if( solid1st->GetEntityType() == "G4Orb")
335 {
336 G4Orb* orb = (G4Orb*)(solid1st);
337 param->ComputeDimensions(*orb, ii, pv );
338 newParams = GetSolidParams( orb );
339 newSolid = (G4VSolid*)orb;
340 }
341 else if( solid1st->GetEntityType() == "G4Torus")
342 {
343 G4Torus* torus = (G4Torus*)(solid1st);
344 param->ComputeDimensions(*torus, ii, pv );
345 newParams = GetSolidParams( torus );
346 newSolid = (G4VSolid*)torus;
347 }
348 else if( solid1st->GetEntityType() == "G4Para")
349 {
350 G4Para* para = (G4Para*)(solid1st);
351 param->ComputeDimensions(*para, ii, pv );
352 newParams = GetSolidParams( para );
353 newSolid = (G4VSolid*)para;
354 }
355 else if( solid1st->GetEntityType() == "G4Polycone")
356 {
357 G4Polycone* polycone = (G4Polycone*)(solid1st);
358 param->ComputeDimensions(*polycone, ii, pv );
359 newParams = GetSolidParams( polycone );
360 newSolid = (G4VSolid*)polycone;
361 }
362 else if( solid1st->GetEntityType() == "G4Polyhedra")
363 {
364 G4Polyhedra* polyhedra = (G4Polyhedra*)(solid1st);
365 param->ComputeDimensions(*polyhedra, ii, pv );
366 newParams = GetSolidParams( polyhedra );
367 newSolid = (G4VSolid*)polyhedra;
368 }
369 else if( solid1st->GetEntityType() == "G4Hype")
370 {
371 G4Hype* hype = (G4Hype*)(solid1st);
372 param->ComputeDimensions(*hype, ii, pv );
373 newParams = GetSolidParams( hype );
374 newSolid = (G4VSolid*)hype;
375 }
376 if( ii == 0 || mate1st != newMate || params1st[0] != newParams[0] )
377 {
378 G4String extraName = "";
379 if( ii != 0 )
380 {
381 extraName= "#"+G4UIcommand::ConvertToString(ii)
382 +"/"+pv->GetMotherLogical()->GetName();
383 }
384 lvName = DumpLogVol( lv, extraName, newSolid, newMate );
385 }
386
387 param->ComputeTransformation(ii, pv);
388 DumpPVPlacement( pv, lvName, ii );
389 }
390}
int G4int
Definition: G4Types.hh:66
Definition: G4Box.hh:55
Definition: G4Cons.hh:75
Definition: G4Hype.hh:67
Definition: G4Orb.hh:52
void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
G4VPVParameterisation * GetParameterisation() const
Definition: G4Para.hh:77
Definition: G4Trd.hh:63
Definition: G4Tubs.hh:77
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:349
virtual G4Material * ComputeMaterial(const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=0)
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
virtual void ComputeTransformation(const G4int, G4VPhysicalVolume *) const =0
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
const G4String & GetName() const
virtual G4GeometryType GetEntityType() const =0
std::vector< G4double > GetSolidParams(const G4VSolid *so)
EAxis
Definition: geomdefs.hh:54

Referenced by DumpPhysVol().

◆ DumpPVPlacement()

void G4tgbGeometryDumper::DumpPVPlacement ( G4VPhysicalVolume pv,
const G4String lvName,
G4int  copyNo = -999 
)

Definition at line 206 of file G4tgbGeometryDumper.cc.

208{
209 G4String pvName = pv->GetName();
210
211 G4RotationMatrix* rotMat = pv->GetRotation();
212 if( !rotMat ) rotMat = new G4RotationMatrix();
213
214 //---- Check if it is reflected
217 if( reffact->IsReflected( lv ) )
218 {
219#ifdef G4VERBOSE
221 {
222 G4cout << " G4tgbGeometryDumper::DumpPVPlacement() - Reflected volume: "
223 << pv->GetName() << G4endl;
224 }
225#endif
226 G4ThreeVector colx = rotMat->colX();
227 G4ThreeVector coly = rotMat->colY();
228 G4ThreeVector colz = rotMat->colZ();
229 // apply a Z reflection (reflection matrix is decomposed in new
230 // reflection-free rotation + z-reflection)
231 colz *= -1.;
232 G4Rep3x3 rottemp(colx.x(),coly.x(),colz.x(),
233 colx.y(),coly.y(),colz.y(),
234 colx.z(),coly.z(),colz.z());
235 // matrix representation (inverted)
236 *rotMat = G4RotationMatrix(rottemp);
237 *rotMat = (*rotMat).inverse();
238 pvName += "_refl";
239 }
240 G4String rotName = DumpRotationMatrix( rotMat );
241 G4ThreeVector pos = pv->GetTranslation();
242
243 if( copyNo == -999 ) //for parameterisations copy number is provided
244 {
245 copyNo = pv->GetCopyNo();
246 }
247
248 G4String fullname = pvName
250 +"/"+pv->GetMotherLogical()->GetName();
251
252 if( !CheckIfPhysVolExists(fullname, pv ))
253 {
254 (*theFile)
255 << ":PLACE "
256 << SubstituteRefl(AddQuotes(lvName))
257 << " " << copyNo << " "
258 << SubstituteRefl(AddQuotes(pv->GetMotherLogical()->GetName()))
259 << " " << AddQuotes(rotName) << " "
260 << pos.x() << " " << pos.y() << " " << pos.z() << G4endl;
261
262 thePhysVols[fullname] = pv;
263 }
264}
G4DLLIMPORT std::ostream G4cout
Hep3Vector colX() const
HepRotation inverse() const
Hep3Vector colY() const
Hep3Vector colZ() const
const G4RotationMatrix * GetRotation() const
virtual G4int GetCopyNo() const =0
const G4ThreeVector & GetTranslation() const
static G4int GetVerboseLevel()

Referenced by DumpPhysVol(), and DumpPVParameterised().

◆ DumpPVReplica()

void G4tgbGeometryDumper::DumpPVReplica ( G4PVReplica pv,
const G4String lvName 
)

Definition at line 394 of file G4tgbGeometryDumper.cc.

396{
397 EAxis axis;
398 G4int nReplicas;
399 G4double width;
400 G4double offset;
401 G4bool consuming;
402 pv->GetReplicationData(axis, nReplicas, width, offset, consuming);
403 G4String axisName;
404 switch (axis )
405 {
406 case kXAxis:
407 axisName = "X";
408 break;
409 case kYAxis:
410 axisName = "Y";
411 break;
412 case kZAxis:
413 axisName = "Z";
414 break;
415 case kRho:
416 axisName = "R";
417 break;
418 case kPhi:
419 axisName = "PHI";
420 break;
421 case kRadial3D:
422 case kUndefined:
423 G4String ErrMessage = "Unknown axis of replication for volume"
424 + pv->GetName();
425 G4Exception("G4tgbGeometryDumper::DumpPVReplica",
426 "Wrong axis ", FatalException, ErrMessage);
427 break;
428 }
429
430 G4String fullname = lvName
431 +"/"+pv->GetMotherLogical()->GetName();
432
433 if( !CheckIfPhysVolExists(fullname, pv ))
434 {
435 (*theFile)
436 << ":REPL "
437 << SubstituteRefl(AddQuotes(lvName))
438 << " " << SubstituteRefl(AddQuotes(pv->GetMotherLogical()->GetName()))
439 << " " << axisName
440 << " " << nReplicas;
441 if( axis != kPhi )
442 {
443 (*theFile)
444 << " " << width
445 << " " << offset << G4endl;
446 }
447 else
448 {
449 (*theFile)
450 << " " << width/deg << "*deg"
451 << " " << offset/deg << "*deg" << G4endl;
452 }
453
454 thePhysVols[fullname] = pv;
455 }
456}
@ FatalException
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
Definition: G4PVReplica.cc:219
@ kPhi
Definition: geomdefs.hh:54
@ kYAxis
Definition: geomdefs.hh:54
@ kRadial3D
Definition: geomdefs.hh:54
@ kXAxis
Definition: geomdefs.hh:54
@ kZAxis
Definition: geomdefs.hh:54
@ kUndefined
Definition: geomdefs.hh:54
@ kRho
Definition: geomdefs.hh:54
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Referenced by DumpPhysVol().

◆ DumpRotationMatrix()

G4String G4tgbGeometryDumper::DumpRotationMatrix ( G4RotationMatrix rotm)

Definition at line 991 of file G4tgbGeometryDumper.cc.

992{
993 if (!rotm) { rotm = new G4RotationMatrix(); }
994
995 G4double de = MatDeterminant(rotm);
996 G4String rotName = LookForExistingRotation( rotm );
997 if( rotName != "" ) { return rotName; }
998
999 G4ThreeVector v(1.,1.,1.);
1000 if (de < -0.9 ) // a reflection ....
1001 {
1002 (*theFile) << ":ROTM ";
1003 rotName = "RRM";
1004 rotName += G4UIcommand::ConvertToString(theRotationNumber++);
1005
1006 (*theFile) << AddQuotes(rotName) << std::setprecision(9) << " "
1007 << approxTo0(rotm->xx()) << " "
1008 << approxTo0(rotm->yx()) << " "
1009 << approxTo0(rotm->zx()) << " "
1010 << approxTo0(rotm->xy()) << " "
1011 << approxTo0(rotm->yy()) << " "
1012 << approxTo0(rotm->zy()) << " "
1013 << approxTo0(rotm->xz()) << " "
1014 << approxTo0(rotm->yz()) << " "
1015 << approxTo0(rotm->zz()) << G4endl;
1016 }
1017 else if(de > 0.9 ) // a rotation ....
1018 {
1019 (*theFile) << ":ROTM ";
1020 rotName = "RM";
1021 rotName += G4UIcommand::ConvertToString(theRotationNumber++);
1022
1023 (*theFile) << AddQuotes(rotName) << " "
1024 << approxTo0(rotm->thetaX()/deg) << " "
1025 << approxTo0(rotm->phiX()/deg) << " "
1026 << approxTo0(rotm->thetaY()/deg) << " "
1027 << approxTo0(rotm->phiY()/deg) << " "
1028 << approxTo0(rotm->thetaZ()/deg) << " "
1029 << approxTo0(rotm->phiZ()/deg) << G4endl;
1030 }
1031
1032 theRotMats[rotName] = rotm;
1033
1034 return rotName;
1035}
double zz() const
double yz() const
double zx() const
double thetaY() const
Definition: Rotation.cc:145
double phiY() const
Definition: Rotation.cc:133
double yx() const
double zy() const
double thetaX() const
Definition: Rotation.cc:141
double xx() const
double phiX() const
Definition: Rotation.cc:129
double yy() const
double xz() const
double thetaZ() const
Definition: Rotation.cc:149
double xy() const
double phiZ() const
Definition: Rotation.cc:137

Referenced by DumpBooleanVolume(), and DumpPVPlacement().

◆ DumpSolid()

G4String G4tgbGeometryDumper::DumpSolid ( G4VSolid solid,
const G4String extraName = "" 
)

Definition at line 644 of file G4tgbGeometryDumper.cc.

646{
647 G4String solidName;
648 if( extraName == "" )
649 {
650 solidName = GetObjectName(solid,theSolids);
651 }
652 else
653 {
654 solidName = solid->GetName()+extraName;
655 }
656
657 if( theSolids.find( solidName ) != theSolids.end() ) // alredy dumped
658 {
659 return solidName;
660 }
661
662 G4String solidType = solid->GetEntityType();
663 solidType = GetTGSolidType( solidType );
664
665 if (solidType == "UNIONSOLID")
666 {
667 DumpBooleanVolume( "UNION", solid );
668
669 } else if (solidType == "SUBTRACTIONSOLID") {
670 DumpBooleanVolume( "SUBTRACTION", solid );
671
672 } else if (solidType == "INTERSECTIONSOLID") {
673 DumpBooleanVolume( "INTERSECTION", solid );
674
675 } else if (solidType == "REFLECTEDSOLID") {
676 G4ReflectedSolid* solidrefl = dynamic_cast<G4ReflectedSolid*>(solid);
677 if (!solidrefl)
678 {
679 G4Exception("G4tgbGeometryDumper::DumpSolid()",
680 "InvalidType", FatalException, "Invalid reflected solid!");
681 return solidName;
682 }
683 G4VSolid* solidori = solidrefl->GetConstituentMovedSolid();
684 DumpSolid( solidori );
685 }
686 else
687 {
688 (*theFile) << ":SOLID " << AddQuotes(solidName) << " ";
689 (*theFile) << AddQuotes(solidType) << " ";
690 DumpSolidParams( solid );
691 theSolids[solidName] = solid;
692 }
693
694 return solidName;
695}
G4VSolid * GetConstituentMovedSolid() const
G4String GetName() const
void DumpBooleanVolume(const G4String &solidType, G4VSolid *so)
void DumpSolidParams(G4VSolid *so)

Referenced by DumpBooleanVolume(), DumpLogVol(), and DumpSolid().

◆ DumpSolidParams()

void G4tgbGeometryDumper::DumpSolidParams ( G4VSolid so)

Definition at line 750 of file G4tgbGeometryDumper.cc.

751{
752 std::vector<G4double> params = GetSolidParams( so );
753 for( size_t ii = 0 ; ii < params.size(); ii++ )
754 {
755 (*theFile) << params[ii] << " " ;
756 }
757 (*theFile) << G4endl;
758}

Referenced by DumpSolid().

◆ GetInstance()

G4tgbGeometryDumper * G4tgbGeometryDumper::GetInstance ( )
static

Definition at line 89 of file G4tgbGeometryDumper.cc.

90{
91 if( theInstance == 0 ){
92 theInstance = new G4tgbGeometryDumper;
93 }
94
95 return theInstance;
96
97}

◆ GetSolidParams()

std::vector< G4double > G4tgbGeometryDumper::GetSolidParams ( const G4VSolid so)

Definition at line 762 of file G4tgbGeometryDumper.cc.

763{
764 std::vector<G4double> params;
765
766 G4String solidType = so->GetEntityType();
767 solidType = GetTGSolidType( solidType );
768
769 if (solidType == "BOX") {
770 const G4Box * sb = dynamic_cast < const G4Box*>(so);
771 if (sb) {
772 params.push_back( sb->GetXHalfLength() );
773 params.push_back( sb->GetYHalfLength() );
774 params.push_back( sb->GetZHalfLength() );
775 }
776 } else if (solidType == "TUBS") {
777 const G4Tubs * tu = dynamic_cast < const G4Tubs * > (so);
778 if (tu) {
779 params.push_back( tu->GetInnerRadius() );
780 params.push_back( tu->GetOuterRadius() );
781 params.push_back( tu->GetZHalfLength() );
782 params.push_back( tu->GetStartPhiAngle()/deg );
783 params.push_back( tu->GetDeltaPhiAngle()/deg );
784 }
785 } else if (solidType == "TRAP") {
786 const G4Trap * trp = dynamic_cast < const G4Trap * > (so);
787 if (trp) {
788 G4ThreeVector symAxis(trp->GetSymAxis());
789 G4double theta = symAxis.theta()/deg;
790 G4double phi = symAxis.phi()/deg;
791 params.push_back( trp->GetZHalfLength() );
792 params.push_back( theta );
793 params.push_back( phi);
794 params.push_back( trp->GetYHalfLength1() );
795 params.push_back( trp->GetXHalfLength1() );
796 params.push_back( trp->GetXHalfLength2() );
797 params.push_back( std::atan(trp->GetTanAlpha1())/deg );
798 params.push_back( trp->GetYHalfLength2() );
799 params.push_back( trp->GetXHalfLength3() );
800 params.push_back( trp->GetXHalfLength4() );
801 params.push_back( std::atan(trp->GetTanAlpha2())/deg );
802 }
803 } else if (solidType == "TRD") {
804 const G4Trd * tr = dynamic_cast < const G4Trd * > (so);
805 if (tr) {
806 params.push_back( tr->GetXHalfLength1() );
807 params.push_back( tr->GetXHalfLength2() );
808 params.push_back( tr->GetYHalfLength1() );
809 params.push_back( tr->GetYHalfLength2() );
810 params.push_back( tr->GetZHalfLength());
811 }
812 } else if (solidType == "PARA") {
813 const G4Para * para = dynamic_cast < const G4Para * > (so);
814 if (para) {
815 G4double phi = 0.;
816 if(para->GetSymAxis().z()!=1.0)
817 { phi = std::atan(para->GetSymAxis().y()/para->GetSymAxis().x()); }
818 params.push_back( para->GetXHalfLength());
819 params.push_back( para->GetYHalfLength());
820 params.push_back( para->GetZHalfLength());
821 params.push_back( std::atan(para->GetTanAlpha())/deg);
822 params.push_back( std::acos(para->GetSymAxis().z())/deg);
823 params.push_back( phi/deg);
824 }
825 } else if (solidType == "CONS") {
826 const G4Cons * cn = dynamic_cast < const G4Cons * > (so);
827 if (cn) {
828 params.push_back( cn->GetInnerRadiusMinusZ() );
829 params.push_back( cn->GetOuterRadiusMinusZ() );
830 params.push_back( cn->GetInnerRadiusPlusZ() );
831 params.push_back( cn->GetOuterRadiusPlusZ() );
832 params.push_back( cn->GetZHalfLength() );
833 params.push_back( cn->GetStartPhiAngle()/deg );
834 params.push_back( cn->GetDeltaPhiAngle()/deg );
835 }
836 } else if (solidType == "SPHERE") {
837 const G4Sphere * sphere = dynamic_cast < const G4Sphere * > (so);
838 if (sphere) {
839 params.push_back( sphere->GetInnerRadius());
840 params.push_back( sphere->GetOuterRadius());
841 params.push_back( sphere->GetStartPhiAngle()/deg);
842 params.push_back( sphere->GetDeltaPhiAngle()/deg);
843 params.push_back( sphere->GetStartThetaAngle()/deg);
844 params.push_back( sphere->GetDeltaThetaAngle()/deg);
845 }
846 } else if (solidType == "ORB") {
847 const G4Orb * orb = dynamic_cast < const G4Orb * > (so);
848 if (orb) {
849 params.push_back( orb->GetRadius());
850 }
851 } else if (solidType == "TORUS") {
852 const G4Torus * torus = dynamic_cast < const G4Torus * > (so);
853 if (torus) {
854 params.push_back( torus->GetRmin());
855 params.push_back( torus->GetRmax());
856 params.push_back( torus->GetRtor());
857 params.push_back( torus->GetSPhi()/deg);
858 params.push_back( torus->GetDPhi()/deg);
859 }
860 } else if (solidType == "POLYCONE") {
861 //--- Dump RZ corners, as original parameters will not be present
862 // if it was build from RZ corners
863 const G4Polycone * plc = dynamic_cast < const G4Polycone * > (so);
864 if (plc) {
865 G4double angphi = plc->GetStartPhi()/deg;
866 if( angphi > 180*deg ) { angphi -= 360*deg; }
867 G4int ncor = plc->GetNumRZCorner();
868 params.push_back( angphi );
869 params.push_back( plc->GetOriginalParameters()->Opening_angle/deg );
870 params.push_back( ncor );
871
872 for( G4int ii = 0; ii < ncor; ii++ )
873 {
874 params.push_back( plc->GetCorner(ii).r );
875 params.push_back( plc->GetCorner(ii).z );
876 }
877 }
878 } else if (solidType == "POLYHEDRA") {
879 //--- Dump RZ corners, as original parameters will not be present
880 // if it was build from RZ corners
881 const G4Polyhedra * ph = (dynamic_cast < const G4Polyhedra * > (so));
882 if (ph) {
883 G4double angphi = ph->GetStartPhi()/deg;
884 if( angphi > 180*deg ) angphi -= 360*deg;
885
886 G4int ncor = ph->GetNumRZCorner();
887
888 params.push_back( angphi );
889 params.push_back( ph->GetOriginalParameters()->Opening_angle/deg );
890 params.push_back( ph->GetNumSide() );
891 params.push_back( ncor );
892
893 for( G4int ii = 0; ii < ncor; ii++ )
894 {
895 params.push_back( ph->GetCorner(ii).r );
896 params.push_back( ph->GetCorner(ii).z );
897 }
898 }
899 } else if (solidType == "ELLIPTICALTUBE") {
900 const G4EllipticalTube * eltu =
901 dynamic_cast < const G4EllipticalTube * > (so);
902 if (eltu) {
903 params.push_back( eltu->GetDx());
904 params.push_back( eltu->GetDy());
905 params.push_back( eltu->GetDz());
906 }
907 } else if (solidType == "ELLIPSOID" ){
908 const G4Ellipsoid* dso = dynamic_cast < const G4Ellipsoid * > (so);
909 if (dso) {
910 params.push_back( dso->GetSemiAxisMax(0) );
911 params.push_back( dso->GetSemiAxisMax(1) );
912 params.push_back( dso->GetSemiAxisMax(2) );
913 params.push_back( dso->GetZBottomCut() );
914 params.push_back( dso->GetZTopCut() );
915 }
916 } else if (solidType == "ELLIPTICAL_CONE") {
917 const G4EllipticalCone * elco =
918 dynamic_cast < const G4EllipticalCone * > (so);
919 if (elco) {
920 params.push_back( elco-> GetSemiAxisX() );
921 params.push_back( elco-> GetSemiAxisY() );
922 params.push_back( elco-> GetZMax() );
923 params.push_back( elco-> GetZTopCut() );
924 }
925 } else if (solidType == "HYPE") {
926 const G4Hype* hype = dynamic_cast < const G4Hype * > (so);
927 if (hype) {
928 params.push_back( hype->GetInnerRadius());
929 params.push_back( hype->GetOuterRadius());
930 params.push_back( hype->GetInnerStereo()/deg);
931 params.push_back( hype->GetOuterStereo()/deg);
932 params.push_back( 2*hype->GetZHalfLength());
933 }
934// } else if( solidType == "TET" ) {
935
936 } else if( solidType == "TWISTEDBOX" ) {
937 const G4TwistedBox* tbox = dynamic_cast < const G4TwistedBox * > (so);
938 if (tbox) {
939 params.push_back( tbox->GetPhiTwist()/deg );
940 params.push_back( tbox->GetXHalfLength() );
941 params.push_back( tbox->GetYHalfLength() );
942 params.push_back( tbox->GetZHalfLength() );
943 }
944 } else if( solidType == "TWISTEDTRAP" ) {
945 const G4TwistedTrap * ttrap = dynamic_cast < const G4TwistedTrap * > (so);
946 if (ttrap) {
947 params.push_back( ttrap->GetPhiTwist()/deg );
948 params.push_back( ttrap->GetZHalfLength() );
949 params.push_back( ttrap->GetPolarAngleTheta()/deg );
950 params.push_back( ttrap->GetAzimuthalAnglePhi()/deg );
951 params.push_back( ttrap->GetY1HalfLength() );
952 params.push_back( ttrap->GetX1HalfLength() );
953 params.push_back( ttrap->GetX2HalfLength() );
954 params.push_back( ttrap->GetY2HalfLength() );
955 params.push_back( ttrap->GetX3HalfLength() );
956 params.push_back( ttrap->GetX4HalfLength() );
957 params.push_back( ttrap->GetTiltAngleAlpha()/deg );
958 }
959 } else if( solidType == "TWISTEDTRD" ) {
960 const G4TwistedTrd * ttrd = dynamic_cast < const G4TwistedTrd * > (so);
961 if (ttrd) {
962 params.push_back( ttrd->GetX1HalfLength());
963 params.push_back( ttrd->GetX2HalfLength() );
964 params.push_back( ttrd->GetY1HalfLength() );
965 params.push_back( ttrd->GetY2HalfLength() );
966 params.push_back( ttrd->GetZHalfLength() );
967 params.push_back( ttrd->GetPhiTwist()/deg );
968 }
969 } else if( solidType == "TWISTEDTUBS" ) {
970 const G4TwistedTubs * ttub = dynamic_cast < const G4TwistedTubs * > (so);
971 if (ttub) {
972 params.push_back( ttub->GetInnerRadius() );
973 params.push_back( ttub->GetOuterRadius() );
974 params.push_back( ttub->GetZHalfLength() );
975 params.push_back( ttub->GetDPhi()/deg );
976 params.push_back( ttub->GetPhiTwist()/deg );
977 }
978 }
979 else
980 {
981 G4String ErrMessage = "Solid type not supported, sorry... " + solidType;
982 G4Exception("G4tgbGeometryDumpe::DumpSolidParams()",
983 "NotImplemented", FatalException, ErrMessage);
984 }
985
986 return params;
987}
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
G4double GetOuterRadiusPlusZ() const
G4double GetStartPhiAngle() const
G4double GetDeltaPhiAngle() const
G4double GetInnerRadiusMinusZ() const
G4double GetInnerRadiusPlusZ() const
G4double GetOuterRadiusMinusZ() const
G4double GetZHalfLength() const
G4double GetSemiAxisMax(G4int i) const
G4double GetZTopCut() const
G4double GetZBottomCut() const
G4double GetDy() const
G4double GetDx() const
G4double GetDz() const
G4double GetInnerStereo() const
G4double GetZHalfLength() const
G4double GetOuterStereo() const
G4double GetOuterRadius() const
G4double GetInnerRadius() const
G4double GetRadius() const
G4double GetTanAlpha() const
G4ThreeVector GetSymAxis() const
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
G4double Opening_angle
Definition: G4Polycone.hh:78
G4double GetStartPhi() const
G4PolyconeHistorical * GetOriginalParameters() const
G4int GetNumRZCorner() const
G4PolyconeSideRZ GetCorner(G4int index) const
G4int GetNumRZCorner() const
G4int GetNumSide() const
G4PolyhedraHistorical * GetOriginalParameters() const
G4PolyhedraSideRZ GetCorner(const G4int index) const
G4double GetStartPhi() const
G4double GetStartPhiAngle() const
G4double GetDeltaPhiAngle() const
G4double GetInnerRadius() const
G4double GetOuterRadius() const
G4double GetDeltaThetaAngle() const
G4double GetStartThetaAngle() const
G4double GetDPhi() const
G4double GetRmin() const
G4double GetRtor() const
G4double GetRmax() const
G4double GetSPhi() const
G4double GetYHalfLength1() const
G4double GetTanAlpha2() const
G4double GetXHalfLength2() const
G4ThreeVector GetSymAxis() const
G4double GetXHalfLength4() const
G4double GetZHalfLength() const
G4double GetYHalfLength2() const
G4double GetTanAlpha1() const
G4double GetXHalfLength3() const
G4double GetXHalfLength1() const
G4double GetXHalfLength2() const
G4double GetYHalfLength2() const
G4double GetXHalfLength1() const
G4double GetYHalfLength1() const
G4double GetZHalfLength() const
G4double GetZHalfLength() const
G4double GetInnerRadius() const
G4double GetOuterRadius() const
G4double GetStartPhiAngle() const
G4double GetDeltaPhiAngle() const
G4double GetPhiTwist() const
Definition: G4TwistedBox.hh:76
G4double GetXHalfLength() const
Definition: G4TwistedBox.hh:73
G4double GetZHalfLength() const
Definition: G4TwistedBox.hh:75
G4double GetYHalfLength() const
Definition: G4TwistedBox.hh:74
G4double GetPolarAngleTheta() const
G4double GetAzimuthalAnglePhi() const
G4double GetTiltAngleAlpha() const
G4double GetZHalfLength() const
G4double GetX1HalfLength() const
G4double GetX2HalfLength() const
G4double GetX3HalfLength() const
G4double GetX4HalfLength() const
G4double GetY2HalfLength() const
G4double GetPhiTwist() const
G4double GetY1HalfLength() const
G4double GetX2HalfLength() const
Definition: G4TwistedTrd.hh:78
G4double GetY2HalfLength() const
Definition: G4TwistedTrd.hh:80
G4double GetY1HalfLength() const
Definition: G4TwistedTrd.hh:79
G4double GetZHalfLength() const
Definition: G4TwistedTrd.hh:81
G4double GetPhiTwist() const
Definition: G4TwistedTrd.hh:82
G4double GetX1HalfLength() const
Definition: G4TwistedTrd.hh:77
G4double GetOuterRadius() const
G4double GetZHalfLength() const
G4double GetPhiTwist() const
G4double GetInnerRadius() const
G4double GetDPhi() const

Referenced by DumpPVParameterised(), and DumpSolidParams().

◆ GetTopPhysVol()

G4VPhysicalVolume * G4tgbGeometryDumper::GetTopPhysVol ( )

Definition at line 109 of file G4tgbGeometryDumper.cc.

110{
112 G4PhysicalVolumeStore::const_iterator ite;
113 G4VPhysicalVolume* pv = *(pvstore->begin());
114 for( ;; )
115 {
117 if( lv == 0 ) { break; }
118
119 //----- look for one PV of this LV
120 for( ite = pvstore->begin(); ite != pvstore->end(); ite++ )
121 {
122 pv = (*ite);
123 if( pv->GetLogicalVolume() == lv )
124 {
125 break;
126 }
127 }
128 }
129
130 return pv;
131}
static G4PhysicalVolumeStore * GetInstance()

Referenced by DumpGeometry().


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