]> 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 45b04944aa714eac19abc21cb4e8a3d14198930a..c469adefad9b581dda48a4d5bcb73b9c280ad2aa 100644 (file)
@@ -384,6 +384,63 @@ void FGeometryInit::PrintRegionsMap(G4std::ostream& os) {
 #endif
 }
 
+////////////////////////////////////////////////////////////////////////
+//
+void    FGeometryInit::BuildMediaMap()
+{
+    fRegionMediumMap = new int[fNRegions+1];
+    for (RegionIterator i = fRegionVolumeMap.begin(); 
+        i != fRegionVolumeMap.end(); 
+        i++) {
+       //Get info in the map
+       G4VPhysicalVolume* ptrVol = (*i).first;
+       int region = (*i).second;
+       G4int imed = fMediumVolumeMap[ptrVol];
+       fRegionMediumMap[region] = imed;
+       printf("BuildMediaMap %s %d %d\n",(ptrVol->GetName()).data(), region, imed);
+       
+    }
+}
+
+G4int FGeometryInit::GetMedium(int region) const
+{
+    return fRegionMediumMap[region];
+}
+
+
+void  FGeometryInit::SetMediumFromName(const char* volName, int medium, int volid) 
+ {
+  char name4[5];
+  char tmp[5];
+  strncpy(tmp, volName, 4);
+  tmp[4]='\0';
+  fNRegions = 0;
+  
+  for (RegionIterator i = fRegionVolumeMap.begin(); 
+       i != fRegionVolumeMap.end(); 
+       i++) {
+    fNRegions++;
+    //Get info in the map
+    G4VPhysicalVolume* ptrVol = (*i).first;
+    strncpy(name4, (ptrVol->GetName()).data(), 4);
+    name4[4]='\0';
+    for (int j = 0; j < 4; j++) {
+       if (name4[j] == '\0') {
+           for (int k = j; k < 4; k++) {
+               name4[k] = ' ';
+           }
+           break;
+       }
+    }
+    if (! strncmp(name4, tmp, 4)) {
+       fMediumVolumeMap[ptrVol] = medium;
+       fVolIdVolumeMap[ptrVol]  = volid;
+    }
+  }
+}
+
+
+
 ////////////////////////////////////////////////////////////////////////
 // 
 void FGeometryInit::BuildMaterialTables() {
@@ -607,9 +664,9 @@ void FGeometryInit::PrintMaterialTables(G4std::ostream& os) {
   size_t nElements = G4Element::GetNumberOfElements();
   size_t nMaterials = G4Material::GetNumberOfMaterials();
 
-  os << "* In Geant4 there are " << nMaterials << " materials" << endl;
-  os << "* In Geant4 there are " << nElements  << " elements"  << endl;
-  os << "* In Geant4 there are " << nIsotopes  << " isotopes"  << endl;
+  os << "* In Geant4 there are " << nMaterials << " materials" << G4endl;
+  os << "* In Geant4 there are " << nElements  << " elements"  << G4endl;
+  os << "* In Geant4 there are " << nIsotopes  << " isotopes"  << G4endl;
 
   //Materials
   G4cout << "\t* Printing FLUKA materials..." << G4endl;
@@ -736,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;
+}