]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/STEER/AliReconstruction.cxx
.so cleanup: more gSystem->Load()
[u/mrichter/AliRoot.git] / STEER / STEER / AliReconstruction.cxx
index c1b8bbb6c27aac4b88a7b1a04a2cf035fa46a9b0..a27bef0062805bd6105899c2bdafc11c005401eb 100644 (file)
 #include "AliLHCData.h"
 #include "ARVersion.h"
 #include <RVersion.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <sys/resource.h>
 ClassImp(AliReconstruction)
@@ -333,7 +334,7 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fMaxVMEM(0)
 {
 // create reconstruction object with default parameters
-  gGeoManager = NULL;
+  AliGeomManager::Destroy();
   
   for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
     fReconstructor[iDet] = NULL;
@@ -1640,15 +1641,34 @@ void AliReconstruction::Begin(TTree *)
          snapshotFileOut="OCDB.root";
   }
 
-  if (!MisalignGeometry(fLoadAlignData)) {
-    Abort("MisalignGeometry", TSelector::kAbortProcess);
-    return;
+  TString detStr(fLoadAlignData);
+  if (!toCDBSnapshot) {
+    if (!MisalignGeometry(fLoadAlignData)) {
+      Abort("MisalignGeometry", TSelector::kAbortProcess);
+      return;
+    }
+  } else {
+    // when creating the snapshot, load the CDB alignment objects without applying them to the geometry
+    for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+      if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
+      if (!strcmp(fgkDetectorName[iDet],"HLT")) continue;
+      if (AliGeomManager::GetNalignable(fgkDetectorName[iDet]) != 0)
+      {
+        TString detAlignPath = fgkDetectorName[iDet];
+        detAlignPath += "/Align/Data";
+        AliCDBManager::Instance()->Get(detAlignPath);
+      }
+    } // end loop over detectors
+    if(AliGeomManager::GetNalignable("GRP") != 0)
+      AliCDBManager::Instance()->Get("GRP/Align/Data");
   }
 
   const TMap* cdbCache = AliCDBManager::Instance()->GetEntryCache();
-  if(cdbCache->Contains("GRP/Geometry/Data"))
-         AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
-  if(!toCDBSnapshot) AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
+  if(!toCDBSnapshot) {
+    if(cdbCache->Contains("GRP/Geometry/Data"))
+      AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
+    AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
+  }
   AliSysInfo::AddStamp("MisalignGeom");
 
   if (!InitGRP()) {
@@ -1695,9 +1715,7 @@ void AliReconstruction::Begin(TTree *)
   if(toCDBSnapshot)
   {
       AliCDBManager::Instance()->DumpToSnapshotFile(snapshotFileOut.Data(),kFALSE);
-      AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
-      if(cdbCache->Contains("GRP/Calib/CosmicTriggers"))
-         AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
+      exit(0);
   }
 
   if (fInput && gProof) {
@@ -1975,9 +1993,9 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
   static Long_t oldMres=0;
   static Long_t oldMvir=0;
   static Float_t oldCPU=0;
-  // static Long_t aveDMres=0;
-  // static Long_t aveDMvir=0;
-  // static Float_t aveDCPU=0;
+  static Long_t aveDMres=0;
+  static Long_t aveDMvir=0;
+  static Float_t aveDCPU=0;
 
   AliCodeTimerAuto("",0);
 
@@ -2490,6 +2508,19 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
                 nbf,fMemCountESDHLT,fhlttree->GetTotBytes(),fhlttree->GetZipBytes()));        
   }
     
+    gSystem->GetProcInfo(&procInfo);
+    Long_t dMres=(procInfo.fMemResident-oldMres)/1024;
+    Long_t dMvir=(procInfo.fMemVirtual-oldMvir)/1024;
+    Float_t dCPU=procInfo.fCpuUser+procInfo.fCpuSys-oldCPU;
+    aveDMres+=(dMres-aveDMres)/(iEvent-fFirstEvent+1);
+    aveDMvir+=(dMvir-aveDMvir)/(iEvent-fFirstEvent+1);
+    aveDCPU+=(dCPU-aveDCPU)/(iEvent-fFirstEvent+1);
+    AliInfo(Form("======================= End Event %d: Res %ld(%3ld <%3ld>) Vir %ld(%3ld <%3ld>) CPU %5.2f <%5.2f> ===================",
+                iEvent, procInfo.fMemResident/1024, dMres, aveDMres, procInfo.fMemVirtual/1024, dMvir, aveDMvir, dCPU, aveDCPU));
+    oldMres=procInfo.fMemResident;
+    oldMvir=procInfo.fMemVirtual;
+    oldCPU=procInfo.fCpuUser+procInfo.fCpuSys;
+  
     
   return kTRUE;
 }
@@ -3314,6 +3345,9 @@ Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
       if (esd->GetTriggerMask() != input.GetClassMask())
        AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx",
                      input.GetClassMask(),esd->GetTriggerMask()));
+      if (esd->GetTriggerMaskNext50() != input.GetClassMaskNext50())
+       AliError(Form("Invalid trigger pattern found in CTP raw-data Next50: %llx %llx",
+                     input.GetClassMaskNext50(),esd->GetTriggerMaskNext50()));
       if (esd->GetOrbitNumber() != input.GetOrbitID())
        AliError(Form("Invalid orbit id found in CTP raw-data: %x %x",
                      input.GetOrbitID(),esd->GetOrbitNumber()));
@@ -3355,6 +3389,12 @@ Bool_t AliReconstruction::FillTriggerScalers(AliESDEvent*& esd)
           if(scalesd)esdheader->SetTriggerScalersRecord(scalesd);
         }
      }
+     for(Int_t i=0;i<50;i++){
+          if((1ull<<i) & esd->GetTriggerMaskNext50()){
+          AliTriggerScalersESD* scalesd = fRunScalers->GetScalersForEventClass( timestamp, i+51);
+          if(scalesd)esdheader->SetTriggerScalersRecord(scalesd);
+        }
+     }
      const AliTriggerScalersRecordESD* scalrecEvent = fRunScalers->GetScalersDeltaForEvent( timestamp);
      const AliTriggerScalersRecordESD* scalrecRun = fRunScalers->GetScalersDeltaForRun();
      if (scalrecEvent) esdheader->SetTriggerScalersDeltaEvent(scalrecEvent);
@@ -3436,7 +3476,7 @@ Bool_t AliReconstruction::InitRunLoader()
     for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
       TString detName = fgkDetectorName[iDet];
       if (libs.Contains("lib" + detName + "base.so")) continue;
-      gSystem->Load("lib" + detName + "base.so");
+      gSystem->Load("lib" + detName + "base");
     }
     fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
     if (!fRunLoader) {
@@ -3509,7 +3549,7 @@ AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
     AliDebug(1, Form("defining plugin for %s", recName.Data()));
     TString libs = gSystem->GetLibraries();
     if (libs.Contains("lib" + detName + "base.so") ||
-       (gSystem->Load("lib" + detName + "base.so") >= 0)) {
+       (gSystem->Load("lib" + detName + "base") >= 0)) {
       pluginManager->AddHandler("AliReconstructor", detName, 
                                recName, detName + "rec", recName + "()");
     } else {
@@ -3665,6 +3705,7 @@ void AliReconstruction::CleanUp()
 {
 // delete trackers and the run loader and close and delete the file
   for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+    if (fReconstructor[iDet]) fReconstructor[iDet]->SetRecoParam(NULL);
     delete fReconstructor[iDet];
     fReconstructor[iDet] = NULL;
     fLoader[iDet] = NULL;
@@ -4099,7 +4140,9 @@ Bool_t AliReconstruction::GetEventInfo()
     fEventInfo.SetEventType(fRawReader->GetType());
 
     ULong64_t mask = fRawReader->GetClassMask();
+    ULong64_t maskNext50 = fRawReader->GetClassMaskNext50();
     fEventInfo.SetTriggerMask(mask);
+    fEventInfo.SetTriggerMaskNext50(maskNext50);
     UInt_t clmask = fRawReader->GetDetectorPattern()[0];
     fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
 
@@ -4127,6 +4170,7 @@ Bool_t AliReconstruction::GetEventInfo()
     if (fRunLoader && (!fRunLoader->LoadTrigger())) {
       aCTP = fRunLoader->GetTrigger();
       fEventInfo.SetTriggerMask(aCTP->GetClassMask());
+      fEventInfo.SetTriggerMaskNext50(aCTP->GetClassMaskNext50());
       // get inputs from actp - just get
       AliESDHeader* esdheader = fesd->GetHeader();
       esdheader->SetL0TriggerInputs(aCTP->GetL0TriggerInputs());
@@ -4177,6 +4221,7 @@ Bool_t AliReconstruction::GetEventInfo()
   UChar_t clustmask = 0;
   TString trclasses;
   ULong64_t trmask = fEventInfo.GetTriggerMask();
+  ULong64_t trmaskNext50 = fEventInfo.GetTriggerMaskNext50();
   const TObjArray& classesArray = config->GetClasses();
   Int_t nclasses = classesArray.GetEntriesFast();
   for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
@@ -4192,6 +4237,17 @@ Bool_t AliReconstruction::GetEventInfo()
        clustmask |= trclass->GetCluster()->GetClusterMask();
       }
     }
+    if (trclass && trclass->GetMaskNext50()>0) {
+      Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMaskNext50()))+50;
+      if (fesd) fesd->SetTriggerClass(trclass->GetName(),trindex);
+      if (fRawReader) fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
+      if (trmaskNext50 & (1ull << (trindex-50))) {
+       trclasses += " ";
+       trclasses += trclass->GetName();
+       trclasses += " ";
+       clustmask |= trclass->GetCluster()->GetClusterMask();
+      }
+    }
   }
   fEventInfo.SetTriggerClasses(trclasses);
   // Now put the declared trigger classes (not present in the run)
@@ -4226,6 +4282,7 @@ Bool_t AliReconstruction::GetEventInfo()
   // Set the information in ESD
   if (fesd) {
     fesd->SetTriggerMask(trmask);
+    fesd->SetTriggerMaskNext50(trmaskNext50);
     fesd->SetTriggerCluster(clustmask);
   }