]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliRun.cxx
added new files to build system
[u/mrichter/AliRoot.git] / STEER / AliRun.cxx
index a92be230e4d0bd243db29c5a1e43bea705bebe6f..1be79528eef8b93cf360785471204a93640288a5 100644 (file)
@@ -49,6 +49,7 @@
 #include <TRandom3.h>
 #include <TSystem.h>
 #include <TVirtualMC.h>
+#include <TGeoManager.h>
 // 
 #include "AliLog.h"
 #include "AliDetector.h"
@@ -63,6 +64,7 @@
 #include "AliPDG.h"
 #include "AliRun.h"
 #include "AliStack.h"
+#include "AliCDBManager.h"
 #include "AliAlignObj.h"
 
 AliRun *gAlice;
@@ -84,9 +86,13 @@ AliRun::AliRun():
   fInitDone(kFALSE),
   fLego(0),
   fPDGDB(0),  //Particle factory object
-  fConfigFunction("\0"),
+  fConfigFunction(""),
   fRandom(0),
+  fBaseFileName(""),
   fIsRootGeometry(kFALSE),
+  fGeometryFromCDB(kFALSE),
+  fGeometryFileName(""),
+  fTriggerDescriptor(""),
   fRunLoader(0x0)
 {
   //
@@ -114,7 +120,11 @@ AliRun::AliRun(const AliRun& arun):
   fPDGDB(0),  //Particle factory object
   fConfigFunction("\0"),
   fRandom(0),
+  fBaseFileName(""),
   fIsRootGeometry(kFALSE),
+  fGeometryFromCDB(kFALSE),
+  fGeometryFileName(""),
+  fTriggerDescriptor(""),
   fRunLoader(0x0)
 {
   //
@@ -141,7 +151,11 @@ AliRun::AliRun(const char *name, const char *title):
   fPDGDB(TDatabasePDG::Instance()),        //Particle factory object!
   fConfigFunction("Config();"),
   fRandom(new TRandom3()),
+  fBaseFileName(""),
   fIsRootGeometry(kFALSE),
+  fGeometryFromCDB(kFALSE),
+  fGeometryFileName(""),
+  fTriggerDescriptor(""),
   fRunLoader(0x0)
 {
   //
@@ -162,8 +176,6 @@ AliRun::AliRun(const char *name, const char *title):
 
   // Add to list of browsable  
   gROOT->GetListOfBrowsables()->Add(this,name);
-  // Create the TNode geometry for the event display
-  BuildSimpleGeometry();
   
   // Create default mag field
   SetField();
@@ -275,8 +287,24 @@ 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();
+   if (flag && gMC) gMC->SetRootGeometry();
 }
+
+//_______________________________________________________________________
+void AliRun::SetGeometryFromCDB()
+{
+  // Set the loading of geometry from cdb instead of creating it
+  // A default CDB storage needs to be set before this method is called
+  if(AliCDBManager::Instance()->IsDefaultStorageSet()){
+    SetRootGeometry();
+    fGeometryFromCDB = kTRUE;
+  }else{
+    AliError("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+    AliError("Loading of geometry from CDB ignored. First set a default CDB storage!");
+    AliError("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+  }
+}
+
 //_______________________________________________________________________
 void AliRun::SetField(Int_t type, Int_t version, Float_t scale,
                      Float_t maxField, const char* filename)
@@ -460,27 +488,27 @@ Int_t AliRun::GetEvent(Int_t event)
 //_______________________________________________________________________
 TGeometry *AliRun::GetGeometry()
 {
-  //
-  // Import Alice geometry from current file
-  // Return pointer to geometry object
-  //
-  if (!fGeometry) fGeometry = dynamic_cast<TGeometry*>(gDirectory->Get("AliceGeom"));
-  //
-  // Unlink and relink nodes in detectors
-  // This is bad and there must be a better way...
-  //
+  // Create the TNode geometry for the event display
+  if (!fGeometry) { 
+    BuildSimpleGeometry();
+    //
+    // Unlink and relink nodes in detectors
+    // This is bad and there must be a better way...
+    //
   
-  TIter next(fModules);
-  AliModule *detector;
-  while((detector = dynamic_cast<AliModule*>(next()))) {
-    TList *dnodes=detector->Nodes();
-    Int_t j;
-    TNode *node, *node1;
-    for ( j=0; j<dnodes->GetSize(); j++) {
-      node = dynamic_cast<TNode*>(dnodes->At(j));
-      node1 = fGeometry->GetNode(node->GetName());
-      dnodes->Remove(node);
-      dnodes->AddAt(node1,j);
+    TIter next(fModules);
+    AliModule *detector;
+    while((detector = dynamic_cast<AliModule*>(next()))) {
+      detector->BuildGeometry();
+      TList *dnodes=detector->Nodes();
+      Int_t j;
+      TNode *node, *node1;
+      for ( j=0; j<dnodes->GetSize(); j++) {
+       node = dynamic_cast<TNode*>(dnodes->At(j));
+       node1 = fGeometry->GetNode(node->GetName());
+       dnodes->Remove(node);
+       dnodes->AddAt(node1,j);
+      }
     }
   }
   return fGeometry;
@@ -552,6 +580,10 @@ void AliRun::InitMC(const char *setup)
   gROOT->LoadMacro(setup);
   gInterpreter->ProcessLine(fConfigFunction.Data());
 
+  // Set the run number in the CDB manager as assigned from
+  // constructor or from config file 
+  AliCDBManager::Instance()->SetRun(GetRunNumber());
+  
   fRunLoader->CdGAFile();
 
   AliPDG::AddParticlesToPdgDataBase();  
@@ -727,7 +759,7 @@ void AliRun::Tree2Tree(Option_t *option, const char *selected)
 //_______________________________________________________________________
 void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min,
                     Float_t c1max,Int_t nc2,Float_t c2min,Float_t c2max,
-                    Float_t rmin,Float_t rmax,Float_t zmax, AliLegoGenerator* gener)
+                    Float_t rmin,Float_t rmax,Float_t zmax, AliLegoGenerator* gener, Int_t nev)
 {
   //
   // Generates lego plots of:
@@ -766,10 +798,12 @@ void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min,
   */
   //End_Html
   //
-
+  // Number of events 
+    if (nev == -1) nev  = nc1 * nc2;
+    
   // check if initialisation has been done
   // If runloader has been initialized, set the number of events per file to nc1 * nc2
-
+    
   // Set new generator
   if (!gener) gener  = new AliLegoGenerator();
   //
@@ -793,9 +827,9 @@ void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min,
   
   //Run Lego Object
 
-  if (fRunLoader) fRunLoader->SetNumberOfEventsPerFile(nc1 * nc2);
+  if (fRunLoader) fRunLoader->SetNumberOfEventsPerFile(nev);
   //gMC->ProcessRun(nc1*nc2+1);
-  gMC->ProcessRun(nc1*nc2);
+  gMC->ProcessRun(nev);
   
   // End of this run, close files
   FinishRun();
@@ -957,24 +991,3 @@ void AliRun::AddModule(AliModule* mod)
   TString str = name; gSystem->ExpandPathName(str);
   return !gSystem->AccessPathName(str.Data(),mode);
 }
-
-//_____________________________________________________________________________
-Bool_t AliRun::ApplyDisplacements(TClonesArray* AlObjArray)
-{
-  // Read collection of alignment objects (AliAlignObj derived) saved
-  // in the TClonesArray ClArrayName and apply them to the geometry
-  // manager singleton.
-  //
-  Int_t nvols = AlObjArray->GetEntriesFast();
-
-  for(Int_t j=0; j<nvols; j++)
-    {
-      AliAlignObj* alobj = (AliAlignObj*) AlObjArray->UncheckedAt(j);
-      if (alobj->ApplyToGeometry() == kFALSE)
-       return kFALSE;
-    }
-
-  return kTRUE;
-
-}
-