]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliRun.cxx
- AliStack::FinishEvent() not called for lego run
[u/mrichter/AliRoot.git] / STEER / AliRun.cxx
index 8ee89faae3e7cd41b87dd756d017863662b61468..5bc0d80efb8f7a20dfc8599125c5dd9fbc99fb8a 100644 (file)
@@ -50,6 +50,7 @@
 #include <TSystem.h>
 #include <TVirtualMC.h>
 // 
+#include "AliLog.h"
 #include "AliDetector.h"
 #include "AliDisplay.h"
 #include "AliHeader.h"
 #include "AliPDG.h"
 #include "AliRun.h"
 #include "AliStack.h"
+#include "AliAlignObj.h"
+#ifdef __APPLE__
+//#include "AliTPCTrackHitsInterfaces.h"
+#endif
 
 AliRun *gAlice;
 
-
 ClassImp(AliRun)
 
 //_______________________________________________________________________
@@ -74,12 +78,10 @@ AliRun::AliRun():
   fEvent(0),
   fEventNrInRun(0),
   fEventsPerRun(0),
-  fDebug(0),
   fModules(0),
   fGeometry(0),
   fMCApp(0),
   fDisplay(0),
-  //  fTimer(),
   fField(0),
   fMC(0),
   fNdets(0),
@@ -88,6 +90,7 @@ AliRun::AliRun():
   fPDGDB(0),  //Particle factory object
   fConfigFunction("\0"),
   fRandom(0),
+  fIsRootGeometry(kFALSE),
   fRunLoader(0x0)
 {
   //
@@ -104,12 +107,10 @@ AliRun::AliRun(const AliRun& arun):
   fEvent(0),
   fEventNrInRun(0),
   fEventsPerRun(0),
-  fDebug(0),
   fModules(0),
   fGeometry(0),
   fMCApp(0),
   fDisplay(0),
-  //  fTimer(),
   fField(0),
   fMC(0),
   fNdets(0),
@@ -118,6 +119,7 @@ AliRun::AliRun(const AliRun& arun):
   fPDGDB(0),  //Particle factory object
   fConfigFunction("\0"),
   fRandom(0),
+  fIsRootGeometry(kFALSE),
   fRunLoader(0x0)
 {
   //
@@ -133,12 +135,10 @@ AliRun::AliRun(const char *name, const char *title):
   fEvent(0),
   fEventNrInRun(0),
   fEventsPerRun(0),
-  fDebug(0),
   fModules(new TObjArray(77)), // Support list for the Detectors
   fGeometry(0),
   fMCApp(0),
   fDisplay(0),
-  //  fTimer(),
   fField(0),
   fMC(gMC),
   fNdets(0),
@@ -147,6 +147,7 @@ AliRun::AliRun(const char *name, const char *title):
   fPDGDB(TDatabasePDG::Instance()),        //Particle factory object!
   fConfigFunction("Config();"),
   fRandom(new TRandom3()),
+  fIsRootGeometry(kFALSE),
   fRunLoader(0x0)
 {
   //
@@ -176,6 +177,14 @@ AliRun::AliRun(const char *name, const char *title):
   // Add particle list to configuration
   AliConfig::Instance()->Add(fPDGDB); 
 
+#ifdef __APPLE__
+  // Terrible hack to avoid problem with the initialisation of 
+  // static and globals on Mac OS X 
+  //  AliClassAliTrackHitsInfo p1=galiclass____AliClassAliTrackHitsInfo;
+  // AliClassAliTrackHitsParam p2=galiclass____AliTrackHitsParam;
+  //AliClassAliHitInfo p3=galiclass____AliHitInfo;
+#endif
+
 }
 
 
@@ -217,7 +226,7 @@ AliRun::~AliRun()
 //_______________________________________________________________________
 void AliRun::Copy(TObject &) const
 {
-  Fatal("Copy","Not implemented!\n");
+  AliFatal("Not implemented!");
 }
 
 //_______________________________________________________________________
@@ -275,6 +284,13 @@ 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)
@@ -298,7 +314,7 @@ void AliRun::SetField(Int_t type, Int_t version, Float_t scale,
     fField = new AliMagFDM("Map4",filename,type,scale,maxField);
     fField->ReadField();
   } else {
-    Warning("SetField","Invalid map %d\n",version);
+    AliWarning(Form("Invalid map %d",version));
   }
 }
 
@@ -307,7 +323,7 @@ void AliRun::SetField(Int_t type, Int_t version, Float_t scale,
 void AliRun::InitLoaders()
 {
   //creates list of getters
-  if (GetDebug()) Info("InitLoaders","");
+  AliDebug(1, "");
   TIter next(fModules);
   AliModule *mod;
   while((mod = (AliModule*)next()))
@@ -316,11 +332,11 @@ void AliRun::InitLoaders()
      AliDetector *det = dynamic_cast<AliDetector*>(mod);
      if (det) 
       {
-        if (GetDebug()) Info("InitLoaders"," Adding %s ",det->GetName());
+        AliDebug(2, Form("Adding %s", det->GetName()));
         fRunLoader->AddLoader(det);
       }
    }
-  if (GetDebug()) Info("InitLoaders","Done");
+  AliDebug(1, "Done");
 }
 //_____________________________________________________________________________
 
@@ -332,7 +348,7 @@ void AliRun::FinishRun()
   
   if(fLego) 
    {
-    if (GetDebug()) Info("FinishRun"," Finish Lego");
+    AliDebug(1, "Finish Lego");
     fRunLoader->CdGAFile();
     fLego->FinishRun();
    }
@@ -341,11 +357,11 @@ void AliRun::FinishRun()
   TIter next(fModules);
   AliModule *detector;
   while((detector = dynamic_cast<AliModule*>(next()))) {
-    if (GetDebug()) Info("FinishRun"," %s->FinishRun()",detector->GetName());
+    AliDebug(2, Form("%s->FinishRun()", detector->GetName()));
     detector->FinishRun();
   }
   
-  if (GetDebug()) Info("FinishRun"," fRunLoader->WriteHeader(OVERWRITE)");
+  AliDebug(1, "fRunLoader->WriteHeader(OVERWRITE)");
   fRunLoader->WriteHeader("OVERWRITE");
 
   // Write AliRun info and all detectors parameters
@@ -354,7 +370,7 @@ void AliRun::FinishRun()
   fRunLoader->Write(0,TObject::kOverwrite);//write RunLoader itself
   
   // Clean tree information
-  if (GetDebug()) Info("FinishRun"," fRunLoader->Stack()->FinishRun()");
+  AliDebug(1, "fRunLoader->Stack()->FinishRun()");
   fRunLoader->Stack()->FinishRun();
 
   if(fMCApp) fMCApp->FinishRun();
@@ -422,7 +438,7 @@ Int_t AliRun::GetEvent(Int_t event)
 //
   if (fRunLoader == 0x0)
    {
-     Error("GetEvent","RunLoader is not set. Can not load data.");
+     AliError("RunLoader is not set. Can not load data.");
      return -1;
    }
 /*****************************************/ 
@@ -540,11 +556,12 @@ void AliRun::InitMC(const char *setup)
   Announce();
 
   if(fInitDone) {
-    Warning("Init","Cannot initialise AliRun twice!\n");
+    AliWarning("Cannot initialise AliRun twice!");
     return;
   }
     
-  fMCApp=new AliMC(GetName(),GetTitle());
+  if (!fMCApp)  
+    fMCApp=new AliMC(GetName(),GetTitle());
     
   gROOT->LoadMacro(setup);
   gInterpreter->ProcessLine(fConfigFunction.Data());
@@ -555,9 +572,6 @@ void AliRun::InitMC(const char *setup)
 
   fNdets = fModules->GetLast()+1;
 
-  // Added also after in case of interactive initialisation of modules
-  fNdets = fModules->GetLast()+1;
-
   TIter next(fModules);
   for(Int_t i=0; i<fNdets; ++i)
    {
@@ -625,12 +639,12 @@ void AliRun::RunReco(const char *selected, Int_t first, Int_t last)
   // Main function to be called to reconstruct Alice event
   // 
    Int_t nev = fRunLoader->GetNumberOfEvents();
-   if (GetDebug()) Info("RunReco","Found %d events",nev);
+   AliDebug(1, Form("Found %d events", nev));
    Int_t nFirst = first;
    Int_t nLast  = (last < 0)? nev : last;
    
    for (Int_t nevent = nFirst; nevent <= nLast; nevent++) {
-     if (GetDebug()) Info("RunReco","Processing event %d",nevent);
+     AliDebug(1, Form("Processing event %d", nevent));
      GetEvent(nevent);
      Digits2Reco(selected);
    }
@@ -688,7 +702,7 @@ void AliRun::Tree2Tree(Option_t *option, const char *selected)
        
        if (oS) 
         {
-          if (GetDebug()) Info("Tree2Tree","Processing Hits2SDigits for %s ...",detector->GetName());
+          AliDebug(1, Form("Processing Hits2SDigits for %s ...", detector->GetName()));
           loader->LoadHits("read");
           if (loader->TreeS() == 0x0) loader->MakeTree("S");
           detector->MakeBranch(option);
@@ -699,7 +713,7 @@ void AliRun::Tree2Tree(Option_t *option, const char *selected)
         }  
        if (oD) 
         {
-          if (GetDebug()) Info("Tree2Tree","Processing SDigits2Digits for %s ...",detector->GetName());
+          AliDebug(1, Form("Processing SDigits2Digits for %s ...", detector->GetName()));
           loader->LoadSDigits("read");
           if (loader->TreeD() == 0x0) loader->MakeTree("D");
           detector->MakeBranch(option);
@@ -710,7 +724,7 @@ void AliRun::Tree2Tree(Option_t *option, const char *selected)
         } 
        if (oR) 
         {
-          if (GetDebug()) Info("Tree2Tree","Processing Digits2Reco for %s ...",detector->GetName());
+          AliDebug(1, Form("Processing Digits2Reco for %s ...", detector->GetName()));
           loader->LoadDigits("read");
           if (loader->TreeR() == 0x0) loader->MakeTree("R");
           detector->MakeBranch(option);
@@ -834,7 +848,7 @@ void AliRun::Field(const Double_t* x, Double_t *b) const
     for (Int_t j=0; j<3; j++) b[j] = bfloat[j]; 
   } 
   else {
-    printf("No mag field defined!\n");
+    AliError("No mag field defined!");
     b[0]=b[1]=b[2]=0.;
   }
 }      
@@ -871,7 +885,7 @@ Int_t AliRun::GetEvNumber() const
 //Returns number of current event  
   if (fRunLoader == 0x0)
    {
-     Error("GetEvent","RunLoader is not set. Can not load data.");
+     AliError("RunLoader is not set. Can not load data.");
      return -1;
    }
 
@@ -890,13 +904,13 @@ void AliRun::SetRunLoader(AliRunLoader* rloader)
   TString evfoldname;
   TFolder* evfold = fRunLoader->GetEventFolder();
   if (evfold) evfoldname = evfold->GetName();
-  else Warning("SetRunLoader","Did not get Event Folder from Run Loader");
+  else AliWarning("Did not get Event Folder from Run Loader");
   
   if ( fRunLoader->GetAliRun() )
    {//if alrun already exists in folder
     if (fRunLoader->GetAliRun() != this )
      {//and is different than this - crash
-       Fatal("AliRun","AliRun is already in Folder and it is not this object");
+       AliFatal("AliRun is already in Folder and it is not this object");
        return;//pro forma
      }//else do nothing
    }
@@ -917,11 +931,11 @@ void AliRun::SetRunLoader(AliRunLoader* rloader)
         AliLoader* loader = fRunLoader->GetLoader(detector);
         if (loader == 0x0)
          {
-           Error("SetRunLoader","Can not get loader for detector %s",detector->GetName());
+           AliError(Form("Can not get loader for detector %s", detector->GetName()));
          }
         else
          {
-           if (GetDebug()) Info("SetRunLoader","Setting loader for detector %s",detector->GetName());
+           AliDebug(1, Form("Setting loader for detector %s", detector->GetName()));
            detector->SetLoader(loader);
          }
       }
@@ -937,9 +951,44 @@ void AliRun::AddModule(AliModule* mod)
   if (strlen(mod->GetName()) == 0) return;
   if (GetModuleID(mod->GetName()) >= 0) return;
   
-  if (GetDebug()) Info("AddModule","%s",mod->GetName());
+  AliDebug(1, mod->GetName());
   if (fRunLoader == 0x0) AliConfig::Instance()->Add(mod);
   else AliConfig::Instance()->Add(mod,fRunLoader->GetEventFolder()->GetName());
 
   Modules()->Add(mod);
+  
+  fNdets++;
+}
+
+// added by Alberto Colla
+//_____________________________________________________________________________
+/*inline*/ Bool_t AliRun::IsFileAccessible(const char* fnam, EAccessMode mode)
+{ return !gSystem->AccessPathName(fnam,mode);}
+
+//______________________________________________________
+/*inline*/ Bool_t AliRun::IsFileAccessible(Char_t* name,EAccessMode mode)
+{
+  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;
+
 }
+