#include "TG4GeometryManager.h"
#include "TG4GeometryOutputManager.h"
#include "TG4GeometryServices.h"
-#include "TG4PhysicsManager.h"
-#include "TG4VSensitiveDetector.h"
-#include "TG4Limits.h"
+#include "TG4G3Units.h"
#include "TG4Globals.h"
-#include "TG3Units.h"
#include <G3toG4.hh>
#include <G3toG4BuildTree.hh>
#include <G3MedTable.hh>
#include <G3SensVolVector.hh>
-#include <G4VSensitiveDetector.hh>
#include <G4LogicalVolumeStore.hh>
#include <G4PVPlacement.hh>
#include <G4Material.hh>
TG4GeometryManager* TG4GeometryManager::fgInstance = 0;
+//_____________________________________________________________________________
TG4GeometryManager::TG4GeometryManager()
: fMediumCounter(0),
fMaterialCounter(0),
//TG4ElementTable::Instance();
}
+//_____________________________________________________________________________
TG4GeometryManager::TG4GeometryManager(const TG4GeometryManager& right) {
//
TG4Globals::Exception(
}
+//_____________________________________________________________________________
TG4GeometryManager::~TG4GeometryManager() {
//
delete fOutputManager;
delete fGeometryServices;
}
-//==================================================================== =========
+//=============================================================================
//
// operators
//
-//==================================================================== =========
+//=============================================================================
+
+//_____________________________________________________________________________
TG4GeometryManager&
TG4GeometryManager::operator=(const TG4GeometryManager& right)
{
// private methods
//
//=============================================================================
-
-
-void TG4GeometryManager::GstparCut(G4int itmed, TG3Cut par, G4double parval)
-{
-// Sets special tracking medium parameter.
-// It is applied to all logical volumes that use the specified
-// tracking medium.
-// ---
-
- // get medium from table
- G3MedTableEntry* medium = G3Med.get(itmed);
- if (!medium) {
- G4String text = "TG4GeometryManager::GstparCut: \n";
- text = text + " Medium not found.";
- G4Exception(text);
- }
-
- // get/create user limits
- G4UserLimits* limits = medium->GetLimits();
- TG4Limits* tg4Limits;
- if (limits) {
- tg4Limits = dynamic_cast<TG4Limits*> (limits);
- if (!tg4Limits)
- G4Exception("TG4GeometryManager::GstparCut: Wrong limits type.");
- }
- else {
- tg4Limits = new TG4Limits();
- medium->SetLimits(tg4Limits);
-
- // add verbose
- G4cout << "TG4GeometryManager::GstparCut: new TG4Limits() for medium "
- << itmed << " has been created." << G4endl;
- }
- // set parameter
- tg4Limits->SetG3Cut(par, parval*GeV);
-}
-
-
-void TG4GeometryManager::GstparFlag(G4int itmed, TG3Flag par, G4double parval)
-{
-// Sets special tracking medium parameter.
-// It is applied to all logical volumes that use the specified
-// tracking medium.
-// ---
-
- // get medium from table
- G3MedTableEntry* medium = G3Med.get(itmed);
- if (!medium) {
- G4String text = "TG4GeometryManager::GstparFlag: \n";
- text = text + " Medium not found.";
- G4Exception(text);
- }
-
- // get/create user limits
- G4UserLimits* limits = medium->GetLimits();
- TG4Limits* tg4Limits;
- if (limits) {
- tg4Limits = dynamic_cast<TG4Limits*> (limits);
- if (!tg4Limits)
- G4Exception("TG4GeometryManager::GstparFlag: Wrong limits type.");
- }
- else {
- tg4Limits = new TG4Limits();
- medium->SetLimits(tg4Limits);
-
- // add verbose
- G4cout << "TG4GeometryManager::GstparFlag: new TG4Limits() for medium "
- << itmed << " has been created." << G4endl;
- }
- // set parameter
- tg4Limits->SetG3Flag(par, parval);
-}
-
+//_____________________________________________________________________________
void TG4GeometryManager::FillMediumIdVector()
{
// The second index for materials (having its origin in
-// G4 tracking media concept) is stored in a vector of G4int
+// G3 tracking media concept) is stored in a vector of G4int
// parallel to G4MaterialTable.
// ---
G4cout << "Total nof tracking medias: " << fMediumCounter << G4endl;
}
+//_____________________________________________________________________________
+void TG4GeometryManager::SetUserLimits()
+{
+// Sets user limits defined in G3MedTable for all logical volumes.
+// ---
+
+ G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
+
+ for (G4int i=0; i<lvStore->size(); i++) {
+ G4LogicalVolume* lv = (*lvStore)[i];
+
+ // get limits from G3Med
+ G4int materialIndex = lv->GetMaterial()->GetIndex();
+ G4int mediumIndex = fMediumIdVector[materialIndex];
+ G4UserLimits* limits = G3Med.get(mediumIndex)->GetLimits();
+
+ lv->SetUserLimits(limits);
+ }
+}
//=============================================================================
//
//=============================================================================
+//_____________________________________________________________________________
void TG4GeometryManager::Material(Int_t& kmat, const char* name, Float_t a,
Float_t z, Float_t dens, Float_t radl, Float_t absl, Float_t* buf,
Int_t nwbuf)
}
+//_____________________________________________________________________________
void TG4GeometryManager::Mixture(Int_t& kmat, const char *name, Float_t *a,
Float_t *z, Float_t dens, Int_t nlmat, Float_t *wmat)
{
delete [] wmatin;
}
+//_____________________________________________________________________________
void TG4GeometryManager::Medium(Int_t& kmed, const char *name, Int_t nmat,
Int_t isvol, Int_t ifield, Float_t fieldm, Float_t tmaxfd,
Float_t stemax, Float_t deemax, Float_t epsil,
// Creates a temporary "medium" that is used for
// assigning corresponding parameters to G4 objects:
// NTMED is stored as a second material index;
-// ISVOL is used for builing TG3SensVolVector;
+// ISVOL is used for builing G3SensVolVector;
// STEMAX is passed in TG4Limits (if fUseG3TMLimits is set true);
// !! The other parameters (IFIELD, FIELDM, TMAXFD, DEEMAX, EPSIL, STMIN)
// are ignored by Geant4.
}
-void TG4GeometryManager::Matrix(Int_t& krot, Float_t thetaX, Float_t phiX,
- Float_t thetaY, Float_t phiY, Float_t thetaZ, Float_t phiZ)
+//_____________________________________________________________________________
+void TG4GeometryManager::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX,
+ Double_t thetaY, Double_t phiY, Double_t thetaZ, Double_t phiZ)
{
// Creates G4RotationMatrix.
// ---
}
+//_____________________________________________________________________________
+void TG4GeometryManager::Matrix(Int_t& krot, Float_t thetaX, Float_t phiX,
+ Float_t thetaY, Float_t phiY, Float_t thetaZ, Float_t phiZ)
+{
+// Single precision interface.
+// ---
+
+ //TG4Globals::Warning("TG4GeometryManager::Matrix in single precision.");
+
+ Double_t dthetaX = thetaX;
+ Double_t dphiX = phiX;
+ Double_t dthetaY = thetaY;
+ Double_t dphiY = phiY;
+ Double_t dthetaZ = thetaZ;
+ Double_t dphiZ = phiZ;
+
+ Matrix(krot, dthetaX, dphiX, dthetaY, dphiY, dthetaZ, dphiZ);
+}
+
+
+//_____________________________________________________________________________
void TG4GeometryManager::Ggclos()
-{
+{
// Sets the top VTE in temporary G3 volume table.
// Close geometry output file (if fWriteGeometry is set true).
//
}
+//_____________________________________________________________________________
void TG4GeometryManager::Gfmate(Int_t imat, char *name, Float_t &a,
Float_t &z, Float_t &dens, Float_t &radl, Float_t &absl,
Float_t* ubuf, Int_t& nbuf)
z = fGeometryServices->GetEffZ(material);
dens = material->GetDensity();
- dens /= TG3Units::MassDensity();
+ dens /= TG4G3Units::MassDensity();
radl = material->GetRadlen();
- radl /= TG3Units::Length();
+ radl /= TG4G3Units::Length();
// the following parameters are not defined in Geant4
absl = 0.;
}
+//_____________________________________________________________________________
void TG4GeometryManager::Gstpar(Int_t itmed, const char *param,
Float_t parval)
{
-// Passes the tracking medium parameter to TG4Limits.
-// The tracking medium parameter is set only in case
-// its value is different from the "global" physics setup.
-// (If: CheckCut/FlagWithG3Defaults is used checking
-// is performed with respect to G3 default values.)
-// When any cut/flag parameter is set in limits
-// the physics manager is locked and the physics setup
-// cannot be changed.
-// Applying this TG4Limits to particles and physical
-// processes is still in development.
-//
-// Geant3 desription:
-// ==================
-// To change the value of cut or mechanism "CHPAR"
-// to a new value PARVAL for tracking medium ITMED
-// The data structure JTMED contains the standard tracking
-// parameters (CUTS and flags to control the physics processes) which
-// are used by default for all tracking media. It is possible to
-// redefine individually with GSTPAR any of these parameters for a
-// given tracking medium.
-// ITMED tracking medium number
-// CHPAR is a character string (variable name)
-// PARVAL must be given as a floating point.
+// Write token to the output file only,
+// the method is performed by TG4PhysicsManager.
// ---
- // write token to the output file
if (fWriteGeometry)
fOutputManager->WriteGstpar(itmed, param, parval);
-
- // get physics setup
- TG4PhysicsManager* physicsManager = TG4PhysicsManager::Instance();
- //TG4CutVector* cutVector = physicsManager->GetCutVector();
- //TG4FlagVector* flagVector = physicsManager->GetFlagVector();
-
- G4String name = fGeometryServices->CutName(param);
- TG3Cut g3Cut;
- if (physicsManager->CheckCutWithCutVector(name, parval, g3Cut)) {
- GstparCut(itmed, g3Cut, parval);
- physicsManager->Lock();
- }
- else {
- TG3Flag g3Flag;
- if (physicsManager->CheckFlagWithFlagVector(name, parval, g3Flag)) {
- GstparFlag(itmed, g3Flag, parval);
- physicsManager->Lock();
- }
- else if (g3Cut==kNoG3Cuts && g3Flag==kNoG3Flags) {
- G4String text = "TG4GeometryManager::Gstpar:";
- text = text + name;
- text = text + " parameter is not yet implemented.";
- TG4Globals::Warning(text);
- }
- }
}
+//_____________________________________________________________________________
void TG4GeometryManager::SetCerenkov(Int_t itmed, Int_t npckov,
Float_t* ppckov, Float_t* absco, Float_t* effic,
Float_t* rindex)
// add units
G4int i;
for (i=0; i<npckov; i++) {
- ppckovDbl[i] = ppckovDbl[i]*TG3Units::Energy();
- abscoDbl[i] = abscoDbl[i]*TG3Units::Length();
+ ppckovDbl[i] = ppckovDbl[i]*TG4G3Units::Energy();
+ abscoDbl[i] = abscoDbl[i]*TG4G3Units::Length();
}
// create material properties table
}
+//_____________________________________________________________________________
void TG4GeometryManager::Gsdvn(const char *name, const char *mother,
Int_t ndiv, Int_t iaxis)
{
}
+//_____________________________________________________________________________
void TG4GeometryManager::Gsdvn2(const char *name, const char *mother,
- Int_t ndiv, Int_t iaxis, Float_t c0i, Int_t numed)
+ Int_t ndiv, Int_t iaxis, Double_t c0i, Int_t numed)
{
// Geant3 desription:
// ==================
}
+//_____________________________________________________________________________
+void TG4GeometryManager::Gsdvn2(const char *name, const char *mother,
+ Int_t ndiv, Int_t iaxis, Float_t c0i, Int_t numed)
+{
+// Single precision interface.
+// ---
+
+ //TG4Globals::Warning("TG4GeometryManager::Gsdvn2 in single precision.");
+
+ G4double dc0i = c0i;
+
+ Gsdvn2(name, mother, ndiv, iaxis, dc0i, numed);
+}
+
+
+//_____________________________________________________________________________
void TG4GeometryManager::Gsdvt(const char *name, const char *mother,
- Float_t step, Int_t iaxis, Int_t numed, Int_t ndvmx)
+ Double_t step, Int_t iaxis, Int_t numed, Int_t ndvmx)
{
// Geant3 desription:
// ==================
}
+//_____________________________________________________________________________
+void TG4GeometryManager::Gsdvt(const char *name, const char *mother,
+ Float_t step, Int_t iaxis, Int_t numed, Int_t ndvmx)
+{
+// Single precision interface.
+// ---
+
+ //TG4Globals::Warning("TG4GeometryManager::Gsdvt in single precision.");
+
+ G4double dstep = step;
+
+ Gsdvt(name, mother, dstep, iaxis, numed, ndvmx);
+}
+
+
+//_____________________________________________________________________________
void TG4GeometryManager::Gsdvt2(const char *name, const char *mother,
- Float_t step, Int_t iaxis, Float_t c0, Int_t numed, Int_t ndvmx)
+ Double_t step, Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx)
{
// Geant3 desription:
// ==================
}
+//_____________________________________________________________________________
+void TG4GeometryManager::Gsdvt2(const char *name, const char *mother,
+ Float_t step, Int_t iaxis, Float_t c0, Int_t numed, Int_t ndvmx)
+{
+// Single precision interface.
+// ---
+
+ //TG4Globals::Warning("TG4GeometryManager::Gsdvt2 in single precision.");
+
+ G4double dstep = step;
+ G4double dc0 = c0;
+
+ Gsdvt2(name, mother, dstep, iaxis, dc0, numed, ndvmx);
+}
+
+
+//_____________________________________________________________________________
void TG4GeometryManager::Gsord(const char *name, Int_t iax)
{
// No corresponding action in G4.
}
+//_____________________________________________________________________________
void TG4GeometryManager::Gspos(const char *vname, Int_t num,
- const char *vmoth, Float_t x, Float_t y, Float_t z, Int_t irot,
+ const char *vmoth, Double_t x, Double_t y, Double_t z, Int_t irot,
const char *vonly)
{
// Geant3 desription:
}
+//_____________________________________________________________________________
+void TG4GeometryManager::Gspos(const char *vname, Int_t num,
+ const char *vmoth, Float_t x, Float_t y, Float_t z, Int_t irot,
+ const char *vonly)
+{
+// Single precision interface.
+// ---
+
+ //TG4Globals::Warning("TG4GeometryManager::Gspos in single precision.");
+
+ G4double dx = x;
+ G4double dy = y;
+ G4double dz = z;
+
+ Gspos(vname, num, vmoth, dx, dy, dz, irot, vonly);
+}
+
+
+//_____________________________________________________________________________
void TG4GeometryManager::Gsposp(const char *name, Int_t nr,
- const char *mother, Float_t x, Float_t y, Float_t z, Int_t irot,
- const char *konly, Float_t *upar, Int_t np )
+ const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot,
+ const char *konly, Double_t *upar, Int_t np )
{
// Geant3 desription:
// ==================
// NR inside MOTHER, with its parameters UPAR(1..NP)
// ---
- G4double* parin = fGeometryServices->CreateG4doubleArray(upar, np);
-
// write token to the output file
if (fWriteGeometry)
- fOutputManager->WriteGsposp(name, nr, mother, x, y, z, irot, konly, parin, np);
+ fOutputManager->WriteGsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
G4gsposp(fGeometryServices->CutName(name), nr,
fGeometryServices->CutName(mother), x, y, z, irot, konly,
- parin, np);
-
- delete [] parin;
+ upar, np);
// register name in name map
fNameMap.AddName(fGeometryServices->CutName(name));
}
+//_____________________________________________________________________________
+void TG4GeometryManager::Gsposp(const char *name, Int_t nr,
+ const char *mother, Float_t x, Float_t y, Float_t z, Int_t irot,
+ const char *konly, Float_t *upar, Int_t np )
+{
+// Single precision interface.
+// ---
+
+ //TG4Globals::Warning("TG4GeometryManager::Gsposp in single precision.");
+
+ G4double dx = x;
+ G4double dy = y;
+ G4double dz = z;
+ G4double* parin = fGeometryServices->CreateG4doubleArray(upar, np);
+
+ Gsposp(name, nr, mother, dx, dy, dz, irot, konly, parin, np);
+
+ delete [] parin;
+}
+
+
+//_____________________________________________________________________________
Int_t TG4GeometryManager::Gsvolu(const char *name, const char *shape,
- Int_t nmed, Float_t *upar, Int_t npar)
+ Int_t nmed, Double_t *upar, Int_t npar)
{
// Geant3 desription:
// ==================
// It creates a new volume in the JVOLUM data structure.
// ---
- G4double* parin = fGeometryServices->CreateG4doubleArray(upar, npar);
-
// write token to the output file
if (fWriteGeometry)
- fOutputManager->WriteGsvolu(name, shape, nmed, parin, npar);
+ fOutputManager->WriteGsvolu(name, shape, nmed, upar, npar);
G4gsvolu(fGeometryServices->CutName(name),
- fGeometryServices->CutName(shape), nmed, parin, npar);
-
- delete [] parin;
+ fGeometryServices->CutName(shape), nmed, upar, npar);
// register name in name map
fNameMap.AddName(fGeometryServices->CutName(name));
}
+//_____________________________________________________________________________
+Int_t TG4GeometryManager::Gsvolu(const char *name, const char *shape,
+ Int_t nmed, Float_t *upar, Int_t npar)
+{
+// Single precision interface.
+// ---
+
+ //TG4Globals::Warning("TG4GeometryManager::Gsvolu in single precision.");
+
+ G4double* parin = fGeometryServices->CreateG4doubleArray(upar, npar);
+
+ G4int result
+ = Gsvolu(name, shape, nmed, parin, npar);
+
+ delete [] parin;
+
+ return result;
+}
+
+
+//_____________________________________________________________________________
void TG4GeometryManager::WriteEuclid(const char* fileName,
const char* topVolName, Int_t number, Int_t nlevel)
{
}
-Int_t TG4GeometryManager::VolId(const Text_t* volName) const
-{
-// Returns the sensitive detector identifier.
-// ---
-
- return fGeometryServices->GetVolumeID(volName);
-}
-
-
-const char* TG4GeometryManager::VolName(Int_t id) const
-{
-// Returns the name of the sensitive detector with the given identifier.
-// ---
-
- return fGeometryServices->GetVolumeName(id);
-}
-
-
-Int_t TG4GeometryManager::NofVolumes() const
-{
-// Returns the total number of sensitive detectors.
-// ---
-
- return fGeometryServices->NofSensitiveDetectors();
-}
-
-
-Int_t TG4GeometryManager::VolId2Mate(Int_t volumeId) const
-{
-// Return the material number for a given volume id
-// ---
-
- return fGeometryServices->GetMediumId(volumeId);
-}
-
-
//=============================================================================
//
// public methods - Geant4 only
//=============================================================================
+//_____________________________________________________________________________
G4VPhysicalVolume* TG4GeometryManager::CreateG4Geometry()
{
// Creates G4 geometry objects according to the G3VolTable
}
+//_____________________________________________________________________________
void TG4GeometryManager::ReadG3Geometry(G4String filePath)
{
// Processes g3calls.dat file and fills G3 tables.
}
+//_____________________________________________________________________________
void TG4GeometryManager::UseG3TrackingMediaLimits()
{
// Sets fUseG3TMLimits option.
}
+//_____________________________________________________________________________
void TG4GeometryManager::ClearG3Tables()
{
// Clears G3 volumes, materials, rotations(?) tables
}
+//_____________________________________________________________________________
void TG4GeometryManager::ClearG3TablesFinal()
{
// Clears G3 medias and volumes tables
// (the top volume is removed from the vol table)
// ---
+ SetUserLimits();
+
G3Med.Clear();
G3Vol.Clear();
}
+//_____________________________________________________________________________
void TG4GeometryManager::OpenOutFile(G4String filePath)
{
// Opens output file.
}
+//_____________________________________________________________________________
void TG4GeometryManager::CloseOutFile()
{
// Closes output file.
}
+//_____________________________________________________________________________
void TG4GeometryManager::PrintNameMap()
{
// Prints the map of volumes names to second names.
}
+//_____________________________________________________________________________
void TG4GeometryManager::SetWriteGeometry(G4bool writeGeometry)
{
// Controls geometry output.
}
+//_____________________________________________________________________________
void TG4GeometryManager::SetMapSecond(const G4String& name)
{
// Sets the second name for the map of volumes names.