}
-void FGeometryInit::SetMediumFromName(const char* volName, int medium)
+void FGeometryInit::SetMediumFromName(const char* volName, int medium, int volid)
{
char name4[5];
char tmp[5];
break;
}
}
- if (! strncmp(name4, tmp, 4)) fMediumVolumeMap[ptrVol] = medium;
+ if (! strncmp(name4, tmp, 4)) {
+ fMediumVolumeMap[ptrVol] = medium;
+ fVolIdVolumeMap[ptrVol] = volid;
+ }
}
}
G4cout << "<== Flugg FGeometryInit::PrintMagneticField()" << G4endl;
#endif
}
+
+int FGeometryInit::CurrentVolID(int ir, int& copyNo)
+{
+ G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
+ G4VPhysicalVolume * physicalvol = (*pVolStore)[ir- 1];
+ copyNo = physicalvol->GetCopyNo();
+ int id = fVolIdVolumeMap[physicalvol];
+ return id;
+}
+
+int FGeometryInit::CurrentVolOffID(int ir, int off, int& copyNo)
+{
+ if (off == 0) return CurrentVolID(ir, copyNo);
+
+ G4PhysicalVolumeStore* pVolStore = G4PhysicalVolumeStore::GetInstance();
+ G4VPhysicalVolume* physicalvol = (*pVolStore)[ir- 1];
+ G4VPhysicalVolume* mother = physicalvol;
+
+ int level = off;
+ while (level > 0) {
+ if (mother) mother = mother->GetMother();
+ level--;
+ }
+
+ int id;
+
+ if (!mother) {
+ G4cout << "Flugg FGeometryInit::CurrentVolOffID mother not found" << G4endl;
+ id = -1;
+ copyNo = -1;
+ } else {
+ copyNo = mother ->GetCopyNo();
+ id = fVolIdVolumeMap[mother];
+ }
+ return id;
+}