]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Changes to store and retrieve the TGeo geometry (R.Grosso)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 26 May 2005 03:37:45 +0000 (03:37 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 26 May 2005 03:37:45 +0000 (03:37 +0000)
FMD/AliFMDGeoSimulator.cxx
FMD/AliFMDSimulator.cxx
STEER/AliMC.cxx
STEER/AliModule.cxx
STEER/AliRun.cxx
STEER/AliRun.h

index 6ace35b47666979e0f84e33000078a1319dbf5a2..3799dd52c6e7c03aabe2be26e6d7f8afb7a7483d 100644 (file)
@@ -157,13 +157,13 @@ AliFMDGeoSimulator::DefineMaterials()
     return;
   }
   AliFMDSimulator::DefineMaterials();
-  fSi      = gGeoManager->GetMedium("FMD Si$");
-  fC       = gGeoManager->GetMedium("FMD Carbon$");
-  fAl      = gGeoManager->GetMedium("FMD Aluminum$");
-  fChip    = gGeoManager->GetMedium("FMD Chip$");
-  fAir     = gGeoManager->GetMedium("FMD Air$");
-  fPCB     = gGeoManager->GetMedium("FMD PCB$");
-  fPlastic = gGeoManager->GetMedium("FMD Plastic$");
+  fSi      = gGeoManager->GetMedium("FMDSi$");
+  fC       = gGeoManager->GetMedium("FMDCarbon$");
+  fAl      = gGeoManager->GetMedium("FMDAluminum$");
+  fChip    = gGeoManager->GetMedium("FMDChip$");
+  fAir     = gGeoManager->GetMedium("FMDAir$");
+  fPCB     = gGeoManager->GetMedium("FMDPCB$");
+  fPlastic = gGeoManager->GetMedium("FMDPlastic$");
 }
 
 //____________________________________________________________________
index d70ac4591c6a9c064ce99b9e7db664eb8e3ad23a..bdba7b8342654fd68a0cb55027ea9fd42a665744 100644 (file)
@@ -196,9 +196,9 @@ AliFMDSimulator::DefineMaterials()
   precision        = .001;
   minStepSize      = .001;
   id               = kSiId;
-  fFMD->AliMaterial(id, "FMD Si$", 
+  fFMD->AliMaterial(id, "Si$", 
                      a, z, density, radiationLength, absorbtionLength);
-  fFMD->AliMedium(kSiId, "FMD Si$",
+  fFMD->AliMedium(kSiId, "Si$",
                    id,1,fieldType,maxField,maxBending,
                    maxStepSize,maxEnergyLoss,precision,minStepSize);
   
@@ -213,9 +213,9 @@ AliFMDSimulator::DefineMaterials()
   precision        = .003;
   minStepSize      = .003;
   id               = kCarbonId;
-  fFMD->AliMaterial(id, "FMD Carbon$", 
+  fFMD->AliMaterial(id, "Carbon$", 
                      a, z, density, radiationLength, absorbtionLength);
-  fFMD->AliMedium(kCarbonId, "FMD Carbon$",
+  fFMD->AliMedium(kCarbonId, "Carbon$",
                    id,0,fieldType,maxField,maxBending,
                    maxStepSize,maxEnergyLoss,precision,minStepSize);
 
@@ -225,9 +225,9 @@ AliFMDSimulator::DefineMaterials()
   density          = 2.7;
   radiationLength  = 8.9;
   id               = kAlId;
-  fFMD->AliMaterial(id, "FMD Aluminum$", 
+  fFMD->AliMaterial(id, "Aluminum$", 
                      a, z, density, radiationLength, absorbtionLength);
-  fFMD->AliMedium(kAlId, "FMD Aluminum$", 
+  fFMD->AliMedium(kAlId, "Aluminum$", 
                    id, 0, fieldType, maxField, maxBending,
                    maxStepSize, maxEnergyLoss, precision, minStepSize);
   
@@ -246,8 +246,8 @@ AliFMDSimulator::DefineMaterials()
     precision        = .003;
     minStepSize      = .003;
     id = kSiChipId;
-    fFMD->AliMixture(id, "FMD Si Chip$", as, zs, density, 6, ws);
-    fFMD->AliMedium(kSiChipId, "FMD Si Chip$", 
+    fFMD->AliMixture(id, "Si Chip$", as, zs, density, 6, ws);
+    fFMD->AliMedium(kSiChipId, "Si Chip$", 
                      id, 0, fieldType, maxField, maxBending, 
                      maxStepSize, maxEnergyLoss, precision, minStepSize);
   }
@@ -264,8 +264,8 @@ AliFMDSimulator::DefineMaterials()
     precision        = .001;
     minStepSize      = .001;
     id               = KaptionId;
-    fFMD->AliMixture(id, "FMD Kaption$", as, zs, density, 4, ws);
-    fFMD->AliMedium(kAlId, "FMD Kaption$",
+    fFMD->AliMixture(id, "Kaption$", as, zs, density, 4, ws);
+    fFMD->AliMedium(kAlId, "Kaption$",
                      id,0,fieldType,maxField,maxBending,
                      maxStepSize,maxEnergyLoss,precision,minStepSize);
   }
@@ -282,8 +282,8 @@ AliFMDSimulator::DefineMaterials()
     precision    = .001;
     minStepSize  = .001;
     id           = kAirId;
-    fFMD->AliMixture(id, "FMD Air$", as, zs, density, 4, ws);
-    fFMD->AliMedium(kAirId, "FMD Air$", 
+    fFMD->AliMixture(id, "Air$", as, zs, density, 4, ws);
+    fFMD->AliMedium(kAirId, "Air$", 
                      id,0,fieldType,maxField,maxBending,
                      maxStepSize,maxEnergyLoss,precision,minStepSize);
   }
@@ -308,8 +308,8 @@ AliFMDSimulator::DefineMaterials()
     precision    = .001;
     minStepSize  = .001;
     id           = kPcbId;
-    fFMD->AliMixture(id, "FMD PCB$", as, zs, density, 14, ws);
-    fFMD->AliMedium(kPcbId, "FMD PCB$", 
+    fFMD->AliMixture(id, "PCB$", as, zs, density, 14, ws);
+    fFMD->AliMedium(kPcbId, "PCB$", 
                      id,0,fieldType,maxField,maxBending,
                      maxStepSize,maxEnergyLoss,precision,minStepSize);
   }
@@ -325,8 +325,8 @@ AliFMDSimulator::DefineMaterials()
     precision    = .003;
     minStepSize  = .003;
     id           = kPlasticId;
-    fFMD->AliMixture(id, "FMD Plastic$", as, zs, density, -2, ws);
-    fFMD->AliMedium(kPlasticId, "FMD Plastic$", 
+    fFMD->AliMixture(id, "Plastic$", as, zs, density, -2, ws);
+    fFMD->AliMedium(kPlasticId, "Plastic$", 
                      id,0,fieldType,maxField,maxBending,
                      maxStepSize,maxEnergyLoss,precision,minStepSize);
   }
index e1bde47e0167bf27dea9bf527f4a21961963adaa..099237fa341ed32ecde29cabbf830ca7456cc308 100644 (file)
@@ -26,9 +26,9 @@
 #include <TStopwatch.h>
 #include <TSystem.h>
 #include <TVirtualMC.h>
-#include "TGeant3.h"
+#include <TGeoManager.h>
+#include "TGeant3.h" 
 
 #include "AliLog.h"
 #include "AliDetector.h"
 #include "AliGenerator.h"
@@ -144,9 +144,26 @@ void AliMC::Copy(TObject &) const
 void  AliMC::ConstructGeometry() 
 {
   //
-  // Create modules, materials, geometry
+  // Either load geometry from file or create it through usual
+  // loop on detectors. In the first case the method
+  // AliModule::CreateMaterials() only builds fIdtmed and is postponed
+  // at InitGeometry().
   //
 
+  if(gAlice->IsRootGeometry()){
+    // Load geometry 
+    const char *geomfilename = gAlice->GetGeometryFileName();
+    if(gSystem->ExpandPathName(geomfilename)){
+      AliInfo(Form("Loading geometry from file:\n %40s\n\n",geomfilename));
+      TGeoManager::Import(geomfilename);
+    }else{
+      AliInfo(Form("Geometry file %40s not found!\n",geomfilename));
+      return;
+    }
+
+  }else{
+
+    // Create modules, materials, geometry
     TStopwatch stw;
     TIter next(gAlice->Modules());
     AliModule *detector;
@@ -159,6 +176,9 @@ void  AliMC::ConstructGeometry()
       AliInfo(Form("%10s R:%.2fs C:%.2fs",
                   detector->GetName(),stw.RealTime(),stw.CpuTime()));
     }
+
+  }
+  
 }
 
 //_______________________________________________________________________
@@ -175,6 +195,7 @@ void  AliMC::InitGeometry()
     while((detector = dynamic_cast<AliModule*>(next()))) {
       stw.Start();
       // Initialise detector and display geometry
+      if (gAlice->IsRootGeometry()) detector->CreateMaterials();
       detector->Init();
       detector->BuildGeometry();
       AliInfo(Form("%10s R:%.2fs C:%.2fs",
@@ -480,12 +501,12 @@ void AliMC::ResetHits()
 void AliMC::PostTrack()
 {
   // Posts tracks for each module
-     TObjArray &dets = *gAlice->Modules();
-     AliModule *module;
-
-     for(Int_t i=0; i<=gAlice->GetNdets(); i++)
-       if((module = dynamic_cast<AliModule*>(dets[i])))
-        module->PostTrack();
+  TObjArray &dets = *gAlice->Modules();
+  AliModule *module;
+  
+  for(Int_t i=0; i<=gAlice->GetNdets(); i++)
+    if((module = dynamic_cast<AliModule*>(dets[i])))
+      module->PostTrack();
 }
 
 //_______________________________________________________________________
index c59c983f1439a456417fccabae73e61da204a938..61fa6ae2e770c8b9e3bd95335f42a22c2e397ce7 100644 (file)
@@ -40,6 +40,7 @@
 #include <TSystem.h>
 #include <TDirectory.h>
 #include <TVirtualMC.h>
+#include <TGeoManager.h>
 
 #include "AliLog.h"
 #include "AliConfig.h"
@@ -245,10 +246,18 @@ void AliModule::AliMaterial(Int_t imat, const char* name, Float_t a,
   // nwbuf       number of user words
   //
   Int_t kmat;
-  gMC->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf);
-  (*fIdmate)[imat]=kmat;
+  TString uniquename = GetName();
+  uniquename.Append(name);
+  if(gAlice->IsRootGeometry()){
+    TGeoMaterial *mat = gGeoManager->GetMaterial(uniquename.Data());
+    kmat = mat->GetUniqueID();
+    (*fIdmate)[imat]=kmat;
+  }else{
+    gMC->Material(kmat, uniquename.Data(), a, z, dens, radl, absl, buf, nwbuf);
+    (*fIdmate)[imat]=kmat;
+  }
 }
-  
+
 //_______________________________________________________________________
 void AliModule::AliGetMaterial(Int_t imat, char* name, Float_t &a, 
                                Float_t &z, Float_t &dens, Float_t &radl,
@@ -273,7 +282,6 @@ void AliModule::AliGetMaterial(Int_t imat, char* name, Float_t &a,
   kmat=(*fIdmate)[imat];
   gMC->Gfmate(kmat, name, a, z, dens, radl, absl, buf, nwbuf);
 }
-  
 
 //_______________________________________________________________________
 void AliModule::AliMixture(Int_t imat, const char *name, Float_t *a,
@@ -300,10 +308,18 @@ void AliModule::AliMixture(Int_t imat, const char *name, Float_t *a,
   // wmat        array of concentrations
   //
   Int_t kmat;
-  gMC->Mixture(kmat, name, a, z, dens, nlmat, wmat);
-  (*fIdmate)[imat]=kmat;
+  TString uniquename = GetName();
+  uniquename.Append(name);
+  if(gAlice->IsRootGeometry()){
+    TGeoMaterial *mat = gGeoManager->GetMaterial(uniquename.Data());
+    kmat = mat->GetUniqueID();
+    (*fIdmate)[imat]=kmat;
+  }else{
+    gMC->Mixture(kmat, uniquename.Data(), a, z, dens, nlmat, wmat);
+    (*fIdmate)[imat]=kmat;
+  }
 } 
+
 //_______________________________________________________________________
 void AliModule::AliMedium(Int_t numed, const char *name, Int_t nmat,
                           Int_t isvol, Int_t ifield, Float_t fieldm,
@@ -333,11 +349,26 @@ void AliModule::AliMedium(Int_t numed, const char *name, Int_t nmat,
   //        =  3       constant magnetic field along z
   //  
   Int_t kmed;
-  gMC->Medium(kmed,name, (*fIdmate)[nmat], isvol, ifield, fieldm,
-                        tmaxfd, stemax, deemax, epsil, stmin, ubuf, nbuf); 
-  (*fIdtmed)[numed]=kmed;
+  TString uniquename = GetName();
+  uniquename.Append(name);
+  if(gAlice->IsRootGeometry()){
+    TList *medialist = gGeoManager->GetListOfMedia();
+    TIter next(medialist);
+    TGeoMedium *med = 0;
+    while((med = (TGeoMedium*) next())){
+      if(!strcmp(uniquename.Data(),med->GetName())){
+       kmed = med->GetId();
+       (*fIdtmed)[numed]=kmed;
+       break;
+      }
+    }
+  }else{
+    gMC->Medium(kmed, uniquename.Data(), (*fIdmate)[nmat], isvol, ifield,
+                fieldm, tmaxfd, stemax, deemax, epsil, stmin, ubuf, nbuf); 
+    (*fIdtmed)[numed]=kmed;
+  }
 } 
+
 //_______________________________________________________________________
 void AliModule::AliMatrix(Int_t &nmat, Float_t theta1, Float_t phi1,
                           Float_t theta2, Float_t phi2, Float_t theta3,
index 3f5d5ce63a21e44a408e500e0055f9321ae9fd15..e5975c2200671dba0c0299e1adca954e27554f5f 100644 (file)
@@ -49,6 +49,7 @@
 #include <TRandom3.h>
 #include <TSystem.h>
 #include <TVirtualMC.h>
+#include <TGeoManager.h>
 // 
 #include "AliLog.h"
 #include "AliDetector.h"
@@ -89,6 +90,7 @@ AliRun::AliRun():
   fPDGDB(0),  //Particle factory object
   fConfigFunction("\0"),
   fRandom(0),
+  fIsRootGeometry(kFALSE),
   fRunLoader(0x0)
 {
   //
@@ -117,6 +119,7 @@ AliRun::AliRun(const AliRun& arun):
   fPDGDB(0),  //Particle factory object
   fConfigFunction("\0"),
   fRandom(0),
+  fIsRootGeometry(kFALSE),
   fRunLoader(0x0)
 {
   //
@@ -144,7 +147,8 @@ AliRun::AliRun(const char *name, const char *title):
   fPDGDB(TDatabasePDG::Instance()),        //Particle factory object!
   fConfigFunction("Config();"),
   fRandom(new TRandom3()),
-  fRunLoader(0x0)
+  fIsRootGeometry(kFALSE),
+ fRunLoader(0x0)
 {
   //
   //  Constructor for the main processor.
@@ -280,6 +284,14 @@ void  AliRun::SetField(AliMagF* magField)
   fField->ReadField();
 }
 
+//_______________________________________________________________________
+void AliRun::SetRootGeometry(Bool_t flag)
+{
+// Instruct application that the geometry is to be retreived from a root file.
+   fIsRootGeometry = flag;
+   if (flag) gMC->SetRootGeometry();
+}   
+
 //_______________________________________________________________________
 void AliRun::SetField(Int_t type, Int_t version, Float_t scale,
                      Float_t maxField, const char* filename)
@@ -616,6 +628,7 @@ void AliRun::RunMC(Int_t nevent, const char *setup)
   //Hits moved to begin event -> now we are crating separate tree for each event
 
   gMC->ProcessRun(nevent);
+//   cout<<"\n***** "<<gGeoManager->GetMaterial("TPCEpoxy")->GetA()<<"  ****\n";
 
   // End of this run, close files
   if(nevent>0) FinishRun();
index f0baa7a06bc580ac1872162785a35885602703ee..81f0127925460cfe8146ffc12a36a8a83431de98 100644 (file)
@@ -79,6 +79,10 @@ public:
    virtual  void  InitMC(const char *setup="Config.C");
    virtual  void  Init(const char *setup="Config.C") {InitMC(setup);}
    Bool_t         IsFolder() const {return kTRUE;}
+   Bool_t         IsRootGeometry() const {return fIsRootGeometry;}
+   void           SetRootGeometry(Bool_t flag=kTRUE);
+   const char*    GetGeometryFileName() const {return fGeometryFileName.Data();}
+   void           SetGeometryFileName(const char *name) {fGeometryFileName = name;}
    virtual AliLego* Lego() const {return fLego;}
 
    virtual  void  ResetDigits();
@@ -158,6 +162,8 @@ protected:
   TString        fConfigFunction;    //  Configuration file to be executed
   TRandom       *fRandom;            //  Pointer to the random number generator
   TString        fBaseFileName;      //  Name of the base root file
+  Bool_t         fIsRootGeometry;    //! Flag telling if the geometry is loaded from file
+  TString        fGeometryFileName;  //! Name of the geometry file    
 
   AliRunLoader  *fRunLoader;         //!run getter - written as a separate object
 private: