G4cout << "<== Flugg FGeometryInit::FGeometryInit()" << G4endl;
}
-
+void FGeometryInit::Init() {
+// Build and initialize G4 geometry
+ setDetector();
+ setMotherVolume();
+ closeGeometry();
+ InitHistories();
+ InitJrLtGeantArray();
+ InitHistArray();
+ createFlukaMatFile();
+}
+
+
void FGeometryInit::closeGeometry() {
#ifdef G4GEOMETRY_DEBUG
G4cout << "==> Flugg FGeometryInit::closeGeometry()" << G4endl;
//Regions map
BuildRegionsMap();
- G4std::ofstream vos("Volumes_index.inp");
+ std::ofstream vos("Volumes_index.inp");
PrintRegionsMap(vos);
vos.close();
//Materials and compounds
BuildMaterialTables();
- G4std::ofstream fos("flukaMat.inp");
+ std::ofstream fos("flukaMat.inp");
PrintMaterialTables(fos);
PrintAssignmat(fos);
PrintMagneticField(fos);
#endif
}
-void FGeometryInit::PrintRegionsMap(G4std::ostream& os) {
+void FGeometryInit::PrintRegionsMap(std::ostream& os) {
#ifdef G4GEOMETRY_DEBUG
G4cout << "==> Flugg FGeometryInit::PrintRegionsMap()" << G4endl;
#endif
int index = (*i).second;
//Print index and region name in some fixed format
- os.setf(G4std::ios::left, G4std::ios::adjustfield);
+ os.setf(std::ios::left, std::ios::adjustfield);
os << setw10 << index;
- os << G4std::setw(20) << ptrVol->GetName() << G4std::setw(20) << "";
+ os << std::setw(20) << ptrVol->GetName() << std::setw(20) << "";
//If volume is a replica... print some more stuff
if(ptrVol->IsReplicated()) {
G4double offset = -1;
G4bool consum = false;
ptrVol->GetReplicationData(axis, nRep, width, offset, consum);
- os.setf(G4std::ios::left, G4std::ios::adjustfield);
- os << setw10 << "Repetion Nb: " << G4std::setw(3) << nRep;
+ os.setf(std::ios::left, std::ios::adjustfield);
+ os << setw10 << "Repetion Nb: " << std::setw(3) << nRep;
}
os << G4endl;
#endif
}
-void FGeometryInit::PrintMaterialTables(G4std::ostream& os) {
+void FGeometryInit::PrintMaterialTables(std::ostream& os) {
#ifdef G4GEOMETRY_DEBUG
G4cout << "==> Flugg FGeometryInit::PrintMaterialTables()" << G4endl;
#endif
////////////////////////////////////////////////////////////////////////
//
-void FGeometryInit::PrintAssignmat(G4std::ostream& os) {
+void FGeometryInit::PrintAssignmat(std::ostream& os) {
#ifdef G4GEOMETRY_DEBUG
G4cout << "==> Flugg FGeometryInit::PrintAssignmat()" << G4endl;
#endif
//Print card
os << setw10 << "ASSIGNMAT ";
- os.setf(static_cast<G4std::ios::fmtflags>(0),G4std::ios::floatfield);
+ os.setf(static_cast<std::ios::fmtflags>(0),std::ios::floatfield);
os << setw10 << setfixed << G4double(matIndex);
os << setw10 << setfixed << G4double(iFlukaRegion);
os << setw10 << "0.0";
}
-void FGeometryInit::PrintMagneticField(G4std::ostream& os) {
+void FGeometryInit::PrintMagneticField(std::ostream& os) {
#ifdef G4GEOMETRY_DEBUG
G4cout << "==> Flugg FGeometryInit::PrintMagneticField()" << G4endl;
#endif
os << setw10 << "";
os << setw10 << "";
os << setw10 << "";
- os.setf(static_cast<G4std::ios::fmtflags>(0),G4std::ios::floatfield);
+ os.setf(static_cast<std::ios::fmtflags>(0),std::ios::floatfield);
os << setw10 << setfixed
- << G4std::setprecision(4) << B[0]
+ << std::setprecision(4) << B[0]
<< setw10 << B[1]
<< setw10 << B[2]
<< G4endl;
G4VPhysicalVolume* physicalvol = (*pVolStore)[ir- 1];
G4VPhysicalVolume* mother = physicalvol;
- int level = off;
- while (level > 0) {
- if (mother) mother = mother->GetMother();
- level--;
- }
+ int index;
+//============================================================================
+ if (mother) {
+ // Check touchable depth
+ //
+ if (ptrTouchHist->GetHistoryDepth() < off) {
+ mother = 0;
+ } else {
+ // Get the off-th mother
+ index = ptrTouchHist->GetHistoryDepth() - off;
+ // in the touchable history volumes are ordered
+ // from top volume up to mother volume;
+ // the touchable volume is not in the history
+ mother = ptrTouchHist->GetHistory()->GetVolume(index);
+ }
+ }
+//============================================================================
int id;
if (iflag == 1) {
pGlob *= 10.0; // in mm
- pLoc =
- ptrNavig->ComputeLocalPoint(pGlob);
+// change because of geant 4 6.0
+// pLoc = ptrNavig->ComputeLocalPoint(pGlob);
+ pLoc = ptrNavig->GetGlobalToLocalTransform().TransformPoint(pGlob);
+
pLoc /= 10.0; // in cm
} else if (iflag == 2) {
pLoc =
inline G4int GetLttcFlagGeant();
void SetLttcFlagGeant(G4int);
void PrintJrLtGeant();
+ void Init();
//Map access methods
void BuildMediaMap();
protected:
void BuildRegionsMap();
- void PrintRegionsMap(G4std::ostream& os);
+ void PrintRegionsMap(std::ostream& os);
void BuildMaterialTables();
FlukaMaterial* BuildFlukaMaterialFromElement(const G4Element* element,
G4double matDensity);
FlukaCompound* BuildFlukaCompoundFromMaterial(const G4Material* material);
FlukaCompound* BuildFlukaCompoundFromElement(const G4Element* element,
G4double matDensity);
- void PrintMaterialTables(G4std::ostream& os);
- void PrintAssignmat(G4std::ostream& os);
- void PrintMagneticField(G4std::ostream& os);
+ void PrintMaterialTables(std::ostream& os);
+ void PrintAssignmat(std::ostream& os);
+ void PrintMagneticField(std::ostream& os);
private:
FGeometryInit(); //costructor
G4int fNRegions;
int* fRegionMediumMap;
- G4std::map<G4VPhysicalVolume*, int, G4std::less<G4VPhysicalVolume*> > fRegionVolumeMap;
- G4std::map<G4VPhysicalVolume*, int, G4std::less<G4VPhysicalVolume*> > fMediumVolumeMap;
- G4std::map<G4VPhysicalVolume*, int, G4std::less<G4VPhysicalVolume*> > fVolIdVolumeMap;
+ std::map<G4VPhysicalVolume*, int, std::less<G4VPhysicalVolume*> > fRegionVolumeMap;
+ std::map<G4VPhysicalVolume*, int, std::less<G4VPhysicalVolume*> > fMediumVolumeMap;
+ std::map<G4VPhysicalVolume*, int, std::less<G4VPhysicalVolume*> > fVolIdVolumeMap;
- G4std::map<G4Material*, FlukaMaterial*, G4std::less<G4Material*> > G4FlukaMaterialMap;
- G4std::map<G4Material*, FlukaCompound*, G4std::less<G4Material*> > G4FlukaCompoundMap;
+ std::map<G4Material*, FlukaMaterial*, std::less<G4Material*> > G4FlukaMaterialMap;
+ std::map<G4Material*, FlukaCompound*, std::less<G4Material*> > G4FlukaCompoundMap;
//G4int NOfMaterials;
};
-typedef G4std::map<G4VPhysicalVolume*, int, G4std::less<G4VPhysicalVolume*> >::const_iterator RegionIterator;
-typedef G4std::vector<G4Material*>::const_iterator MatTableIterator;
+typedef std::map<G4VPhysicalVolume*, int, std::less<G4VPhysicalVolume*> >::const_iterator RegionIterator;
+typedef std::vector<G4Material*>::const_iterator MatTableIterator;
//Include the file with the inline methods
#include "FluggNavigator.hh"
#include "G4ios.hh"
-#include "g4std/iomanip"
+#include <iomanip.h>
#ifdef G4GEOMETRY_DEBUG
# define G4DEBUG_NAVIGATION 1
{
public:
- friend G4std::ostream& operator << (G4std::ostream &os, const FluggNavigator &n);
+ friend std::ostream& operator << (std::ostream &os, const FluggNavigator &n);
FluggNavigator();
// Constructor - initialisers and setup.
}
}
-G4std::ostream& FlukaCompound::PrintCompounds(G4std::ostream& os) {
+std::ostream& FlukaCompound::PrintCompounds(std::ostream& os) {
PrintHeader(os, "COMPOUNDS");
for (FlukaCompoundsIterator i = fFlukaCompounds.begin();
return os;
}
-G4std::ostream& operator<<(G4std::ostream& os, const FlukaCompound& flucomp) {
+std::ostream& operator<<(std::ostream& os, const FlukaCompound& flucomp) {
G4int nmats = flucomp.GetNMaterials();
G4String matName = flucomp.GetName();
G4String matRealName = flucomp.GetRealName().substr(0,8);
G4int counttothree = 0;
os << setw10 <<"COMPOUND ";
for (G4int i = 0; i < nmats; i++) {
- os.setf(static_cast<G4std::ios::fmtflags>(0),G4std::ios::floatfield);
+ os.setf(static_cast<std::ios::fmtflags>(0),std::ios::floatfield);
os << setw10
<< setfixed
- << G4std::setprecision(6)
+ << std::setprecision(6)
<< flucomp.GetMaterialFraction(i);
- os.setf(static_cast<G4std::ios::fmtflags>(0),G4std::ios::floatfield);
+ os.setf(static_cast<std::ios::fmtflags>(0),std::ios::floatfield);
os << setw10
<< setfixed
- << G4std::setprecision(1)
+ << std::setprecision(1)
<< G4double(flucomp.GetMaterialIndex(i));
counttothree++;
if (counttothree == 3 ) {
#include <map>
class FlukaCompound;
-typedef G4std::map<G4String, FlukaCompound*, G4std::less<G4String> > FlukaCompoundsTable;
-typedef G4std::map<G4String, FlukaCompound*, G4std::less<G4String> >::const_iterator FlukaCompoundsIterator;
+typedef std::map<G4String, FlukaCompound*, std::less<G4String> > FlukaCompoundsTable;
+typedef std::map<G4String, FlukaCompound*, std::less<G4String> >::const_iterator FlukaCompoundsIterator;
class FlukaCompound {
public:
//Static
static inline const FlukaCompoundsTable* GetCompoundTable();
static inline const FlukaCompound* GetFlukaCompound(const G4String& name);
- static G4std::ostream& PrintCompounds(G4std::ostream& os);
+ static std::ostream& PrintCompounds(std::ostream& os);
public:
G4int fNMaterials; //Number of elements in total
//Ostream operator
-G4std::ostream& operator<<(G4std::ostream& os, const FlukaCompound& flucomp);
+std::ostream& operator<<(std::ostream& os, const FlukaCompound& flucomp);
#endif
fFlukaMaterial(fmat){
}
-G4std::ostream& operator<<(G4std::ostream& os, const FlukaLowMat& flowmat){
+std::ostream& operator<<(std::ostream& os, const FlukaLowMat& flowmat){
os << setw10 << "LOW-MAT ";
- os.setf(static_cast<G4std::ios::fmtflags>(0),G4std::ios::floatfield);
- os << setw10 << setfixed << G4std::setprecision(1)
+ os.setf(static_cast<std::ios::fmtflags>(0),std::ios::floatfield);
+ os << setw10 << setfixed << std::setprecision(1)
<< G4double(flowmat.GetIndex());
os << setw10 << " "
<< setw10 << " "
inline G4int FlukaLowMat::GetIndex() const {return fFlukaMaterial->GetIndex();}
-G4std::ostream& operator<<(G4std::ostream& os, const FlukaLowMat& flowmat);
+std::ostream& operator<<(std::ostream& os, const FlukaLowMat& flowmat);
#endif
return GetName();
}
-G4std::ostream& FlukaMaterial::PrintMaterialsByName(G4std::ostream& os) {
+std::ostream& FlukaMaterial::PrintMaterialsByName(std::ostream& os) {
PrintHeader(os, "MATERIALS");
for (FlukaMaterialsIterator i = fFlukaMaterials.begin();
i != fFlukaMaterials.end();
return os;
}
-G4std::ostream& FlukaMaterial::PrintMaterialsByIndex(G4std::ostream& os) {
+std::ostream& FlukaMaterial::PrintMaterialsByIndex(std::ostream& os) {
PrintHeader(os, "MATERIALS");
for (FlukaMaterialsIndexIterator i = fFlukaIndexMaterials.begin();
i != fFlukaIndexMaterials.end();
return os;
}
-G4std::ostream& operator<<(G4std::ostream& os, const FlukaMaterial& material){
+std::ostream& operator<<(std::ostream& os, const FlukaMaterial& material){
os << setw10 << "MATERIAL ";
- os.setf(static_cast<G4std::ios::fmtflags>(0),G4std::ios::floatfield);
+ os.setf(static_cast<std::ios::fmtflags>(0),std::ios::floatfield);
G4double Z = G4double(material.GetZ());
if (Z <= 0)
os << setw10 << " ";
else
os << setw10
<< setfixed
- << G4std::setprecision(1)
+ << std::setprecision(1)
<< Z;
G4double A = material.GetA();
if (A <= 0)
os << setw10 << " ";
else
- os << setw10 << G4std::setprecision(3)
+ os << setw10 << std::setprecision(3)
<< A;
G4double density = material.GetDensity();
if (density <=0)
density = 0.999;
- os.setf(static_cast<G4std::ios::fmtflags>(0),G4std::ios::floatfield);
+ os.setf(static_cast<std::ios::fmtflags>(0),std::ios::floatfield);
os << setw10
<< setscientific
- << G4std::setprecision(3)
+ << std::setprecision(3)
<< density;
- os.setf(static_cast<G4std::ios::fmtflags>(0),G4std::ios::floatfield);
+ os.setf(static_cast<std::ios::fmtflags>(0),std::ios::floatfield);
os << setw10
<< setfixed
- << G4std::setprecision(1)
+ << std::setprecision(1)
<< G4double(material.GetIndex());
os << setw10 << " ";
#include <map>
class FlukaMaterial;
-typedef G4std::map<G4String, FlukaMaterial*, G4std::less<G4String> > FlukaMaterialsTable;
-typedef G4std::map<G4String, FlukaMaterial*, G4std::less<G4String> >::const_iterator FlukaMaterialsIterator;
-typedef G4std::map<G4int, FlukaMaterial*, G4std::less<G4int> > FlukaMaterialsIndexTable;
-typedef G4std::map<G4int, FlukaMaterial*, G4std::less<G4int> >::const_iterator FlukaMaterialsIndexIterator;
+typedef std::map<G4String, FlukaMaterial*, std::less<G4String> > FlukaMaterialsTable;
+typedef std::map<G4String, FlukaMaterial*, std::less<G4String> >::const_iterator FlukaMaterialsIterator;
+typedef std::map<G4int, FlukaMaterial*, std::less<G4int> > FlukaMaterialsIndexTable;
+typedef std::map<G4int, FlukaMaterial*, std::less<G4int> >::const_iterator FlukaMaterialsIndexIterator;
class FlukaMaterial {
public:
return &fFlukaMaterials;}
static FlukaMaterial* GetFlukaMaterial(const G4String& name) {
return fFlukaMaterials[name];}
- static G4std::ostream& PrintMaterialsByName(G4std::ostream& os);
- static G4std::ostream& PrintMaterialsByIndex(G4std::ostream& os);
+ static std::ostream& PrintMaterialsByName(std::ostream& os);
+ static std::ostream& PrintMaterialsByIndex(std::ostream& os);
protected:
//Other
};
-G4std::ostream& operator<<(G4std::ostream& os, const FlukaMaterial& material);
+std::ostream& operator<<(std::ostream& os, const FlukaMaterial& material);
#endif
G4ThreeVector partLoc(pSx,pSy,pSz);
partLoc *= 10.0; // in millimeters!
static G4ThreeVector partLocOld = partLoc;
- static G4ThreeVector oldLocalPoint =
- ptrNavig->ComputeLocalPoint(partLocOld);
+
+// change because of geant4 6.0
+//static G4ThreeVector oldLocalPoint =
+// ptrNavig->ComputeLocalPoint(partLocOld);
+ static G4ThreeVector oldLocalPoint =
+ ptrNavig->GetGlobalToLocalTransform().TransformPoint(partLocOld);
G4ThreeVector pVec(pV[0],pV[1],pV[2]);
const G4double physStep=G4double(propStep*10.);
//changed from last located point (otherwise troubles come
//when fluka changes location or particle because G4 computes
//from last located point).
- G4ThreeVector newLocalPoint = ptrNavig->ComputeLocalPoint(partLoc);
+
+// change because of geant4 6.0
+//G4ThreeVector newLocalPoint = ptrNavig->ComputeLocalPoint(partLoc);
+ G4ThreeVector newLocalPoint =
+ ptrNavig->GetGlobalToLocalTransform().TransformPoint(partLoc);
+
+
+
G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
if(moveLenSq>=kCarTolerance*kCarTolerance)
ptrNavig->LocateGlobalPointWithinVolume(partLoc);
}
else if(newRegErr<0)
newReg=newRegErr;
-
+//======================= Endre print ===================
+printf("\nWrapG1 mreg=%d",newReg);
+//======================= Endre print ===================
//compute output variables (in cm.!)
//final step
ptrGeoInit->SetLttcFlagGeant(LttcFlagGeant);
partLocOld=partLoc;
- oldLocalPoint = ptrNavig->ComputeLocalPoint(partLocOld);
+
+// change because of geant4 6.0
+//oldLocalPoint = ptrNavig->ComputeLocalPoint(partLocOld);
+ oldLocalPoint =
+ ptrNavig->GetGlobalToLocalTransform().TransformPoint(partLocOld);
//compute new position
G4ThreeVector oldPos = G4ThreeVector(pSx,pSy,pSz);
G4ThreeVector normalGlob;
//normal computing
- if(ptrNavig->IsExitNormalValid()) {
- normalLoc=ptrNavig->GetLocalExitNormal();
+ G4bool* valid;
+ normalLoc=ptrNavig->GetLocalExitNormal(valid);
+ if(valid) {
normalLoc *= -1;
//global cooordinates normal
////////////////////////////////////////////////////////////////////////
// PrintHeader
////////////////////////////////////////////////////////////////////////
-G4std::ostream& PrintHeader(G4std::ostream& os, const char* title) {
+std::ostream& PrintHeader(std::ostream& os, const char* title) {
os << "*\n" << "*\n" << "*\n";
os << "********************* " << title << " *********************\n"
<< "*\n";
const G4NavigationHistory*);
// Common print utilities used in FGeometryInit.cc
-inline G4std::ostream& setw10(G4std::ostream& os) { return os << G4std::setw(10);}
-inline G4std::ostream& setscientific(G4std::ostream& os) { return os << G4std::setiosflags(G4std::ios::scientific);}
-inline G4std::ostream& setfixed(G4std::ostream& os) { return os << G4std::setiosflags(G4std::ios::fixed);}
-G4std::ostream& PrintHeader(G4std::ostream& os, const char* title);
+inline std::ostream& setw10(std::ostream& os) { return os << std::setw(10);}
+inline std::ostream& setscientific(std::ostream& os) { return os << std::setiosflags(std::ios::scientific);}
+inline std::ostream& setfixed(std::ostream& os) { return os << std::setiosflags(std::ios::fixed);}
+std::ostream& PrintHeader(std::ostream& os, const char* title);
G4String ToFlukaString(G4String str);
#endif