]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
GetRegionList and GetMaterialList added.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 14 Apr 2004 14:55:22 +0000 (14:55 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 14 Apr 2004 14:55:22 +0000 (14:55 +0000)
TFluka/TFlukaMCGeometry.cxx
TFluka/TFlukaMCGeometry.h

index 0fe69f803c7db7583db8a2b87f51048c839c0af3..622bf10c93f8ac7d8be2f436769a4d23946771c5 100644 (file)
@@ -103,8 +103,9 @@ TFlukaMCGeometry::TFlukaMCGeometry(const char *name, const char *title)
   // Standard constructor
   //
   fLastMaterial = 0;
-  fNextRegion = 0;
-  fNextLattice = 0;
+  fNextRegion   = 0;
+  fNextLattice  = 0;
+  fRegionList   = 0;
   fluka = (TFluka*)gMC;
   mcgeom = this;
 }
@@ -117,8 +118,9 @@ TFlukaMCGeometry::TFlukaMCGeometry()
   // Default constructor
   //
   fLastMaterial = 0;
-  fNextRegion = 0;
-  fNextLattice = 0;
+  fNextRegion   = 0;
+  fNextLattice  = 0;
+  fRegionList   = 0;
   fluka = (TFluka*)gMC;
   mcgeom = this;
 }
@@ -130,6 +132,7 @@ TFlukaMCGeometry::~TFlukaMCGeometry()
   // Destructor
   //
   fgInstance=0;
+  if (fRegionList) delete [] fRegionList;
   if (gGeoManager) delete gGeoManager;
 }
 
@@ -358,6 +361,43 @@ Int_t TFlukaMCGeometry::GetFlukaMaterial(Int_t imed) const
    return imatfl;   
 }
 
+//_____________________________________________________________________________
+Int_t *TFlukaMCGeometry::GetRegionList(Int_t imed, Int_t &nreg)
+{
+// Get an ordered list of regions matching a given medium number
+   nreg = 0;
+   if (!fRegionList) fRegionList = new Int_t[NofVolumes()+1];
+   TIter next(gGeoManager->GetListOfUVolumes());
+   TGeoVolume *vol;
+   Int_t imedium, ireg;
+   while ((vol = (TGeoVolume*)next())) {
+      imedium = vol->GetMedium()->GetId();
+      if (imedium == imed) {
+         ireg = vol->GetNumber();
+         fRegionList[nreg++] = ireg;
+      }
+   }
+   return fRegionList;
+}         
+
+//_____________________________________________________________________________
+Int_t *TFlukaMCGeometry::GetMaterialList(Int_t imat, Int_t &nreg)
+{
+// Get an ordered list of regions matching a given medium number
+   nreg = 0;
+   if (!fRegionList) fRegionList = new Int_t[NofVolumes()+1];
+   TIter next(gGeoManager->GetListOfUVolumes());
+   TGeoVolume *vol;
+   Int_t imaterial, ireg;
+   while ((vol = (TGeoVolume*)next())) {
+      imaterial = vol->GetMedium()->GetMaterial()->GetIndex();
+      if (imaterial == imat) {
+         ireg = vol->GetNumber();
+         fRegionList[nreg++] = ireg;
+      }
+   }
+   return fRegionList;
+}         
 //_____________________________________________________________________________
 void TFlukaMCGeometry::Medium(Int_t& kmed, const char* name, Int_t nmat, Int_t isvol,
                     Int_t ifield, Double_t fieldm, Double_t tmaxfd,
index b390a6251934e354694eec397b475c941ab46dd1..39e909bee2a6fa21ee7f823682bec7a65eb6f72c 100644 (file)
@@ -109,6 +109,8 @@ class TFlukaMCGeometry : public TVirtualMCGeometry {
     const char*   CurrentVolName() const;
     const char*   CurrentVolOffName(Int_t off) const;
     Int_t         GetMedium() const;
+    Int_t        *GetRegionList(Int_t imed, Int_t &nreg);
+    Int_t        *GetMaterialList(Int_t imat, Int_t &nreg);
     Int_t         GetFlukaMaterial(Int_t imed) const;
     Int_t         GetLastMaterialIndex() const {return fLastMaterial;}
     virtual Int_t VolId(const Text_t* volName) const;
@@ -135,6 +137,7 @@ class TFlukaMCGeometry : public TVirtualMCGeometry {
     Int_t        fLastMaterial;           // last FLUKA material index
     Int_t        fNextRegion;             // next region number
     Int_t        fNextLattice;            // next lattice history
+    Int_t       *fRegionList;             //! region list matching a given medium number
   ClassDef(TFlukaMCGeometry,1)  //Virtual MonteCarlo Interface
 };