25#include <G4Element.hh>
26#include <G4LogicalVolume.hh>
27#include <G4LogicalVolumeStore.hh>
28#include <G4Material.hh>
29#include <G4MaterialPropertiesTable.hh>
30#include <G4MaterialPropertyVector.hh>
31#include <G4PhysicalVolumeStore.hh>
32#include <G4UserLimits.hh>
33#include <G4VPhysicalVolume.hh>
35#include <G3EleTable.hh>
40#include <TGeoMatrix.h>
44#include <G4SystemOfUnits.hh>
67 "Cannot create two instances of singleton.");
98 if (G4StrUtil::contains(lvName, gSeparator))
106 G4double , G4double z,
const G4Element* element)
const
112 G4double ze = element->GetZ();
118 ax = 1.01 * g / mole;
141 G4double , G4double ,
const G4Element* )
const
152 G4int nofElements, G4double density,
const G4Material* material)
const
158 G4int ne = material->GetNumberOfElements();
161 G4double diff = std::abs(density - dm) / (density + dm) * 2.;
171 G4int nmat, G4double* a, G4double* wmat)
const
177 G4double* weight =
new G4double[abs(nmat)];
182 for (i = 0; i < abs(nmat); i++) {
184 aMol += wmat[i] * a[i];
188 "Total molecular weight = 0.");
190 for (i = 0; i < abs(nmat); i++) {
192 weight[i] = wmat[i] * a[i] / aMol;
196 for (G4int j = 0; j < nmat; j++) weight[j] = wmat[j];
207 Float_t* array, G4int size, G4bool copyValues)
const
212 G4double* doubleArray;
214 doubleArray =
new G4double[size];
216 for (G4int i = 0; i < size; i++) doubleArray[i] = array[i];
227 Double_t* array, G4int size, G4bool copyValues)
const
232 G4double* doubleArray;
234 doubleArray =
new G4double[size];
236 for (G4int i = 0; i < size; i++) doubleArray[i] = array[i];
250 G4String cutName = name;
251 G4int i = cutName.length();
252 while (cutName[--i] ==
' ') cutName = cutName.substr(0, i);
262 G4String cutName = name;
263 cutName = cutName.substr(0, cutName.find(
'$'));
270 const G4String& volumePath, G4String& volName, G4int& copyNo)
const
274 G4String path(volumePath);
276 G4int npos1 = path.find(
'/');
277 G4int npos2 = path.find(
'_');
278 G4int npos3 = path.find(
'/', 2);
279 if (npos3 < 0) npos3 = path.length();
281 volName = path.substr(npos1 + 1, npos2 - npos1 - 1);
282 G4String copyNoStr = path.substr(npos2 + 1, npos3 - npos2);
283 std::istringstream in(copyNoStr);
286 return path.substr(npos3, path.length() - npos3);
296 if (
fIsG3toG4 && G4StrUtil::contains(name, gSeparator)) {
297 fgBuffer = name.substr(0, name.find(gSeparator));
310 EMCOpSurfaceModel model)
const
316 case kGlisur:
return glisur;
317 case kUnified:
return unified;
318 case kLUT:
return LUT;
319 case kDAVIS:
return DAVIS;
320 case kdichroic:
return dichroic;
324 "Unknown optical surface model, return Glisur.");
336 case kDielectric_metal:
return dielectric_metal;
337 case kDielectric_dielectric:
return dielectric_dielectric;
338 case kDielectric_LUT:
return dielectric_LUT;
339 case kDielectric_LUTDAVIS:
return dielectric_LUTDAVIS;
340 case kDielectric_dichroic:
return dielectric_dichroic;
341 case kFirsov:
return firsov;
342 case kXray:
return x_ray;
346 "Unknown optical surface type, return dielectric_metal.");
347 return dielectric_metal;
353 EMCOpSurfaceFinish finish)
const
359 case kPolished:
return polished;
360 case kPolishedfrontpainted:
return polishedfrontpainted;
361 case kPolishedbackpainted:
return polishedbackpainted;
363 case kGround:
return ground;
364 case kGroundfrontpainted:
return groundfrontpainted;
365 case kGroundbackpainted:
return groundbackpainted;
367 case kPolishedlumirrorair:
return polishedlumirrorair;
368 case kPolishedlumirrorglue:
return polishedlumirrorglue;
370 case kPolishedair:
return polishedair;
371 case kPolishedteflonair:
return polishedteflonair;
372 case kPolishedtioair:
return polishedtioair;
373 case kPolishedtyvekair:
return polishedtyvekair;
374 case kPolishedvm2000air:
return polishedvm2000air;
375 case kPolishedvm2000glue:
return polishedvm2000glue;
377 case kEtchedlumirrorair:
return etchedlumirrorair;
378 case kEtchedlumirrorglue:
return etchedlumirrorglue;
379 case kEtchedair:
return etchedair;
380 case kEtchedteflonair:
return etchedteflonair;
381 case kEtchedtioair:
return etchedtioair;
382 case kEtchedtyvekair:
return etchedtyvekair;
383 case kEtchedvm2000air:
return etchedvm2000air;
384 case kEtchedvm2000glue:
return etchedvm2000glue;
385 case kGroundlumirrorair:
return groundlumirrorair;
386 case kGroundlumirrorglue:
return groundlumirrorglue;
387 case kGroundair:
return groundair;
388 case kGroundteflonair:
return groundteflonair;
389 case kGroundtioair:
return groundtioair;
390 case kGroundtyvekair:
return groundtyvekair;
391 case kGroundvm2000air:
return groundvm2000air;
392 case kGroundvm2000glue:
return groundvm2000glue;
394 case kRough_LUT:
return Rough_LUT;
395 case kRoughTeflon_LUT:
return RoughTeflon_LUT;
396 case kRoughESR_LUT:
return RoughESR_LUT;
397 case kRoughESRGrease_LUT:
return RoughESRGrease_LUT;
399 case kPolished_LUT:
return Polished_LUT;
400 case kPolishedTeflon_LUT:
return PolishedTeflon_LUT;
401 case kPolishedESR_LUT:
return PolishedESR_LUT;
402 case kPolishedESRGrease_LUT:
return PolishedESRGrease_LUT;
404 case kDetector_LUT:
return Detector_LUT;
408 "Unknown optical surface finish, return polished.");
415 const G4Transform3D& transform, TGeoHMatrix& matrix)
const
419 Double_t* translation =
new Double_t[3];
420 Double_t* rotation =
new Double_t[9];
421 for (G4int i = 0; i < 3; i++)
422 for (G4int j = 0; j < 3; j++) {
423 rotation[i * 3 + j] = transform(i, j);
424 translation[i] = transform(i, 3) / cm;
426 matrix.SetTranslation(translation);
427 matrix.SetRotation(rotation);
428 delete[] translation;
439 G4int nofMaterials = matNames.size();
440 if (nofMaterials != G4int(matWeights.size())) {
442 "Different number of material names and weigths.");
446 G4cout <<
"Nof of materials to be mixed: " << nofMaterials << G4endl;
450 std::vector<G4Material*> matVector;
452 for (im = 0; im < nofMaterials; im++) {
454 G4Material* material = G4Material::GetMaterial(matNames[im]);
455 matVector.push_back(material);
459 G4Material* mixture =
new G4Material(name, density, nofMaterials);
460 for (im = 0; im < nofMaterials; im++) {
461 G4Material* material = matVector[im];
462 G4double fraction = matWeights[im];
463 mixture->AddMaterial(material, fraction);
476 if (limits) limits->
Print();
489 G4cout << volumeName <<
" ";
493 G4cout <<
"has not the limits set." << G4endl;
504 G4cout <<
" GEANT4 Geometry statistics: " << G4endl <<
" "
507 <<
" physical volumes" << G4endl <<
" " << std::setw(5)
508 << G4Material::GetNumberOfMaterials() <<
" materials" << G4endl
510 <<
" user limits" << G4endl;
520 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
522 G4cout <<
"Logical volume store: " << G4endl;
524 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
526 G4LogicalVolume* lv = (*lvStore)[i];
528 void* address = lv->GetMaterial();
529 G4cout <<
"Logical volume: " << G4endl;
530 G4cout <<
" " << std::setw(5) << i <<
" " << lv <<
" " << lv->GetName()
531 <<
" " << std::setw(5) << lv->GetNoDaughters() <<
" daughters"
532 <<
" limits: " << lv->GetUserLimits()
533 <<
" material: " << lv->GetMaterial()->GetName() <<
" " << address
536 for (
size_t j = 0; j < lv->GetNoDaughters(); j++) {
537 void* addressd = lv->GetDaughter(j)->GetLogicalVolume()->GetMaterial();
538 G4cout <<
" Daughter: " << std::setw(5) << j <<
" "
539 << lv->GetDaughter(j) <<
" " << lv->GetDaughter(j)->GetName()
540 <<
" of LV: " << lv->GetDaughter(j)->GetLogicalVolume() <<
" "
541 << lv->GetDaughter(j)->GetLogicalVolume()->GetName()
542 <<
" copy no: " << lv->GetDaughter(j)->GetCopyNo()
544 << lv->GetDaughter(j)->GetLogicalVolume()->GetMaterial()->GetName()
545 <<
" " << addressd << G4endl;
555 G4PhysicalVolumeStore* pvStore = G4PhysicalVolumeStore::GetInstance();
557 for (G4int i = 0; i < G4int(pvStore->size()); i++) {
558 G4VPhysicalVolume* pv = (*pvStore)[i];
559 G4cout << i <<
"th volume name=" << pv->GetName()
561 <<
" copyNo=" << pv->GetCopyNo() << G4endl;
570 const G4ElementTable* elementTable = G4Element::GetElementTable();
572 G4cout <<
"Element table: " << G4endl;
574 for (G4int i = 0; i < G4int(elementTable->size()); i++) {
576 G4Element* element = (*elementTable)[i];
577 G4cout <<
" " << std::setw(5) << i <<
"th element:"
578 <<
" " << element << G4endl;
588 const G4MaterialTable* matTable = G4Material::GetMaterialTable();
599 const G4MaterialTable* matTable = G4Material::GetMaterialTable();
600 for (G4int i = 0; i < G4int(matTable->size()); i++) {
601 if ((*matTable)[i] && (*matTable)[i]->GetMaterialPropertiesTable()) {
603 G4cout << (*matTable)[i]->GetName()
604 <<
" material properties table: " << G4endl;
605 (*matTable)[i]->GetMaterialPropertiesTable()->DumpTable();
611 TG4OpSurfaceMap::const_iterator it;
613 if (it->second && it->second->GetMaterialPropertiesTable()) {
616 <<
" optical surface material properties table: " << G4endl;
617 it->second->GetMaterialPropertiesTable()->DumpTable();
639 TString(cutName.c_str()) +
" not defined.");
643 G4cout <<
"Cut " << cutName << G4endl;
644 G4cout <<
"Medium ID"
646 <<
"cutValue(MeV)" << G4endl;
652 G4cout << i + 1 <<
" " << cutValue << G4endl;
670 TString(controlName.c_str()) +
" not defined.");
674 G4cout <<
"Control " << controlName << G4endl;
675 G4cout <<
"Medium ID"
677 <<
"controlValue" << G4endl;
684 G4cout << i + 1 <<
" " << controlValue << G4endl;
695 gSeparator = separator;
714 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
717 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
718 G4LogicalVolume* lv = (*lvStore)[i];
730 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
731 return lvStore->size();
739 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
742 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
743 counter += ((*lvStore)[i])->GetNoDaughters();
754 if (!limits)
return 0;
759 "TG4GeometryServices",
"GetLimits(.)",
"Wrong limits type");
773 if (!limits)
return 0;
777 if (tg4Limits)
return tg4Limits;
782 tg4Limits =
new TG4Limits(*limits, cuts, controls);
788 "TG4GeometryServices",
"GetLimits(..)",
"Wrong limits type.");
794 const G4String& name, G4bool silent)
const
798 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
800 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
801 G4LogicalVolume* lv = (*lvStore)[i];
802 if (lv->GetName() == name)
return lv;
807 "Logical volume " + TString(name) +
" not found.");
814 const G4String& name, G4int copyNo, G4bool silent)
const
819 G4PhysicalVolumeStore* pvStore = G4PhysicalVolumeStore::GetInstance();
821 for (G4int i = 0; i < G4int(pvStore->size()); i++) {
822 G4VPhysicalVolume* pv = (*pvStore)[i];
828 if (
UserVolumeName(pv->GetName()) == name && pv->GetCopyNo() == copyNo)
834 "Physical volume " + TString(name) +
" not found.");
841 const G4String& name, G4int copyNo, G4LogicalVolume* mlv, G4bool silent)
const
846 for (
size_t i = 0; i < mlv->GetNoDaughters(); i++) {
847 G4VPhysicalVolume* dpv = mlv->GetDaughter(i);
848 if (
UserVolumeName(dpv->GetName()) == name && dpv->GetCopyNo() == copyNo)
854 "Physical volume " + TString(name) +
" not found.");
861 const G4String& name, G4bool silent)
const
865 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
867 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
868 G4LogicalVolume* lv = (*lvStore)[i];
870 if (limits && limits->
GetName() == name)
return limits;
875 "Limits " + TString(name) +
" not found.");
882 const G4String& name, G4bool silent)
const
887 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
889 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
890 G4LogicalVolume* lv = (*lvStore)[i];
891 if (!
dynamic_cast<TG4Limits*
>(lv->GetUserLimits())) {
895 if (limits && limits->
GetName() == name)
return limits;
900 "Limits " + TString(name) +
" not found.");
907 const G4Material* material, G4bool silent)
const
913 if (!medium)
return 0;
926 if (!medium)
return 0;
928 return medium->
GetID();
938 G4int nofElements = material->GetNumberOfElements();
939 if (nofElements > 1) {
945 for (G4int i = 0; i < nofElements; i++) {
946 G4double aOfElement = material->GetElement(i)->GetA();
947 G4double massFraction = material->GetFractionVector()[i];
952 a = material->GetA();
965 G4int nofElements = material->GetNumberOfElements();
966 if (nofElements > 1) {
972 for (G4int i = 0; i < nofElements; i++) {
973 G4double zOfElement = material->GetElement(i)->GetZ();
974 G4double massFraction = material->GetFractionVector()[i];
975 z += zOfElement * massFraction;
979 z = material->GetZ();
986 G4double a, G4double z, G4double density)
const
991 const G4MaterialTable* kpMatTable = G4Material::GetMaterialTable();
993 for (G4int i = 0; i < G4int(G4Material::GetNumberOfMaterials()); i++) {
995 G4Material* material = (*kpMatTable)[i];
1008 G4double* a, G4double* z, G4double density, G4int nmat, G4double* wmat)
const
1016 G4Material* found = 0;
1017 for (G4int i = 0; i < G4int(G4Material::GetNumberOfMaterials()); i++) {
1019 G4Material* material = (*G4Material::GetMaterialTable())[i];
1020 G4int nofElements = material->GetNumberOfElements();
1025 G4bool equal =
true;
1026 for (G4int ie = 0; ie < nofElements; ie++) {
1028 G4double we = (material->GetFractionVector())[ie];
Definition of the TG4G3ControlVector class.
Definition of the TG4G3Units class.
Definition of the TG4GeometryServices class.
Definition of the TG4Globals class and basic container types.
Definition of the TG4IntMap class.
Definition of the TG4Limits class.
Definition of the TG4MediumMap class.
Definition of the TG4Medium class.
Definition of the TG4NameMap class.
Vector of control process values with convenient set/get methods.
static TG4G3Control GetControl(const G4String &controlName)
Vector of kinetic energy cut values with convenient set/get methods.
static TG4G3Cut GetCut(const G4String &cutName)
static G4double AtomicWeight()
static G4double InverseMassDensity()
static G4double InverseAtomicWeight()
Services for accessing to Geant4 geometry.
void PrintControls(const G4String &controlName) const
G4String CutVolumePath(const G4String &volumePath, G4String &volName, G4int ©No) const
void PrintLogicalVolumeStore() const
static const G4double fgkDensityTolerance
density tolerance (percentual)
static TG4GeometryServices * fgInstance
this instance
TG4OpSurfaceMap * fOpSurfaceMap
map of optical surfaces names to their objects
void PrintPhysicalVolumeStore() const
TG4MediumMap * fMediumMap
map of madia
TG4Limits * FindLimits(const G4String &name, G4bool silent=false) const
G4Material * FindMaterial(G4double a, G4double z, G4double density) const
virtual ~TG4GeometryServices()
G4OpticalSurfaceFinish SurfaceFinish(EMCOpSurfaceFinish finish) const
G4double * ConvertAtomWeight(G4int nmat, G4double *a, G4double *wmat) const
G4int GetMediumId(G4LogicalVolume *lv) const
Int_t NofG4PhysicalVolumes() const
G4Material * MixMaterials(G4String name, G4double density, const TG4StringVector &matNames, const TG4doubleVector &matWeights)
G4bool IsG3Volume(const G4String &lvName) const
G4double * CreateG4doubleArray(Float_t *array, G4int size, G4bool copyValues=true) const
void PrintStatistics(G4bool open, G4bool close) const
void PrintElementTable() const
G4LogicalVolume * FindLogicalVolume(const G4String &name, G4bool silent=false) const
const G4String & UserVolumeName(const G4String &name) const
G4String CutName(const char *name) const
G4SurfaceType SurfaceType(EMCOpSurfaceType surfType) const
TG4Limits * FindLimits2(const G4String &name, G4bool silent=false) const
Int_t NofG3Volumes() const
Int_t NofG4LogicalVolumes() const
void PrintMaterials() const
G4bool CompareElement(G4double a, G4double z, const G4Element *elem) const
void PrintLimits(const G4String &name) const
void PrintMaterialsProperties() const
G4VPhysicalVolume * FindPhysicalVolume(const G4String &name, G4int copyNo, G4bool silent=false) const
TG4Limits * GetLimits(G4UserLimits *limits) const
G4bool fIsG3toG4
info if user geometry is defined via G3toG4
G4VPhysicalVolume * FindDaughter(const G4String &name, G4int copyNo, G4LogicalVolume *mlv, G4bool silent=false) const
void SetG3toG4Separator(char separator)
static const G4double fgkAZTolerance
A,Z tolerance.
G4double GetEffA(G4Material *material) const
G4bool CompareMaterial(G4int nofElements, G4double density, const G4Material *material) const
G4String CutMaterialName(const char *name) const
void PrintVolumeLimits(const G4String &volumeName) const
G4OpticalSurfaceModel SurfaceModel(EMCOpSurfaceModel model) const
void PrintCuts(const G4String &cutName) const
void Convert(const G4Transform3D &transform, TGeoHMatrix &matrix) const
G4double GetEffZ(G4Material *material) const
static G4String fgBuffer
string buffer
static void PrintStars(G4bool emptyLineFirst)
static void Warning(const TString &className, const TString &methodName, const TString &text)
static void Exception(const TString &className, const TString &methodName, const TString &text)
Extended G4UserLimits class.
const TG4G3CutVector * GetCutVector() const
static G4int GetNofLimits()
const TG4G3ControlVector * GetControlVector() const
The map of media to logical volumes.
G4int GetNofMedia() const
TG4Medium * GetMedium(G4int mediumID, G4bool warn=true) const
Helper class to keep medium data.
G4UserLimits * GetLimits() const
Base class for defining the verbose level and a common messenger.
virtual G4int VerboseLevel() const
std::map< G4String, G4OpticalSurface * > TG4OpSurfaceMap
The map between optical surfaces names and their objects.
std::vector< G4String > TG4StringVector
std::vector< G4double > TG4doubleVector
TG4G3Cut
Enumeration for G3 types of kinetic energy cuts.
TG4G3Control
Enumeration for G3 types of physics processes controls.
@ kNoG3Cuts
Invalid value.
@ kNoG3Controls
No process control.