]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - Flugg/FGeometryInit.cxx
Use TPDCCode.h instead of AliPDG.
[u/mrichter/AliRoot.git] / Flugg / FGeometryInit.cxx
index 6d44811bf3e42e7202ac501629b9a5013b4f14b9..c469adefad9b581dda48a4d5bcb73b9c280ad2aa 100644 (file)
@@ -408,7 +408,7 @@ G4int FGeometryInit::GetMedium(int region) const
 }
 
 
-void  FGeometryInit::SetMediumFromName(const char* volName, int medium) 
+void  FGeometryInit::SetMediumFromName(const char* volName, int medium, int volid
  {
   char name4[5];
   char tmp[5];
@@ -432,7 +432,10 @@ void  FGeometryInit::SetMediumFromName(const char* volName, int medium)
            break;
        }
     }
-    if (! strncmp(name4, tmp, 4)) fMediumVolumeMap[ptrVol] = medium;
+    if (! strncmp(name4, tmp, 4)) {
+       fMediumVolumeMap[ptrVol] = medium;
+       fVolIdVolumeMap[ptrVol]  = volid;
+    }
   }
 }
 
@@ -790,3 +793,39 @@ void FGeometryInit::PrintMagneticField(G4std::ostream& os) {
   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;
+}