]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/STEER/AliReconstruction.cxx
Clearer fatal message.
[u/mrichter/AliRoot.git] / STEER / STEER / AliReconstruction.cxx
index 9b71690d2ec25f7426129732e75eb9b864fdda5c..1fd335699b256028f113451e004a8f8481a3a235 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;
@@ -821,8 +822,9 @@ void AliReconstruction::InitCDB()
 
 //_____________________________________________________________________________
 void AliReconstruction::SetCDBSnapshotMode(const char* snapshotFileName) {
+    if (!AliCDBManager::Instance()->SetSnapshotMode(snapshotFileName))
+      AliFatal("Setting CDB snapshot mode failed.");
     fCDBSnapshotMode = kTRUE;
-    AliCDBManager::Instance()->SetSnapshotMode(snapshotFileName);
 }
 
 //_____________________________________________________________________________
@@ -1640,15 +1642,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 +1716,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) {
@@ -2490,6 +2509,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 +3346,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 +3390,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 +3477,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 +3550,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 +3706,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 +4141,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 +4171,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 +4222,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 +4238,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 +4283,7 @@ Bool_t AliReconstruction::GetEventInfo()
   // Set the information in ESD
   if (fesd) {
     fesd->SetTriggerMask(trmask);
+    fesd->SetTriggerMaskNext50(trmaskNext50);
     fesd->SetTriggerCluster(clustmask);
   }
 
@@ -4692,79 +4750,52 @@ void AliReconstruction::CheckRecoCDBvsSimuCDB()
     //
     AliInfo(Form("#%d Checking %s",i,cdbent->GetName()));
     //
-    // check in the simuCDB special params
+    // find cdbID used for sim
+    TString idSim="",storSim="";
+    TIter nextSim(cdbListSim);
+    while ((stro=(TObjString*)nextSim())) {
+      if (stro->GetString().Contains(cdbent->GetName())) {
+       idSim = stro->GetString();
+       break;
+      }
+    }    
+    // find the storage used for sim
+    // check in the simuCDB special paths
     pair = (TPair*)cdbMapSim->FindObject(cdbent->GetName());
-    TString idSimD = "";
-    TString idSimS = "";
     if (pair) { // specific path is used
-      idSimS = ((TObjString*)pair->Value())->GetString();
-      RectifyCDBurl(idSimS);
-    }
-    else { // check in default storage list
-      TIter nextSim(cdbListSim);
-      while ((stro=(TObjString*)nextSim())) {
-       if (stro->GetString().Contains(cdbent->GetName())) {
-         idSimD = stro->GetString();
-         break;
-       }
-      }
+      storSim = ((TObjString*)pair->Value())->GetString();
+      RectifyCDBurl(storSim);
     }
+    else storSim = defSimStore;  // default storage list is used
     //
-    // check in the recoCDB special params
+    if (!idSim.IsNull()) AliInfo(Form("Sim. used %s from %s",idSim.Data(), storSim.Data()));
+    else                 AliInfo("Sim. did not use this object");
+    //
+    // find cdbID used for rec
+    TString idRec="",storRec="";
+    TIter nextRec(cdbListRec);
+    AliCDBId* id=0;
+    while ((id=(AliCDBId*)nextRec())) {
+      idRec = id->ToString();
+      if (idRec.Contains(cdbent->GetName())) break;
+      idRec="";
+    }
+    //
+    // find storage used for the rec
     pair = (TPair*)cdbMapRec->FindObject(cdbent->GetName());
-    TString idRecD = "";
-    TString idRecS = "";
     if (pair) {  // specific path is used
-      idRecS = ((TObjString*)pair->Value())->GetString();
-      RectifyCDBurl(idRecS);
-    }
-    else { // check in default storage list
-      TIter nextRec(cdbListRec);
-      AliCDBId* id=0;
-      while ((id=(AliCDBId*)nextRec())) {
-       idRecD = id->ToString();
-       if (idRecD.Contains(cdbent->GetName())) break;
-       idRecD="";
-      }
+      storRec = ((TObjString*)pair->Value())->GetString();
+      RectifyCDBurl(storRec);
     }
-    //-----------------------------
-    Bool_t ok = kTRUE;
-    if (!idSimD.IsNull()) {  // simulation used object from default storage
-      AliInfo(Form("Simulation used default storage %s\nentry %s",defSimStore.Data(),idSimD.Data()));
-      if (!idRecD.IsNull()) { // reco also
-       AliInfo(Form("Reconstruction used default storage %s\nentry %s",defRecStore.Data(),idRecD.Data()));
-       if ( (idSimD!=idRecD) || (defSimStore!=defRecStore) ) ok = kFALSE;
-      }
-      else if (!idRecS.IsNull()) { // reco used specific storage, strict check of version is not possible
-       AliInfo(Form("Reconstruction used specific storage %s",idRecS.Data()));
-       if (defSimStore!=idRecS) ok = kFALSE;
-      }
-      else {
-       AliInfo("Did not find object used in reconstruction");
-       ok = kFALSE;
-      }
-    }
-    else if (!idSimS.IsNull()) { // simulation used object from specific storage
-      AliInfo(Form("Simulation used specific storage %s",idSimS.Data()));
-      if (!idRecS.IsNull()) { // reco also     
-       AliInfo(Form("Reconstruction used specific storage %s",idRecS.Data()));
-       if (idSimS!=idRecS) ok = kFALSE;
-      }
-      else if (!idRecD.IsNull()) {
-       AliInfo(Form("Reconstruction used default storage %s\nentry",idRecD.Data()));
-       if (idSimS!=defRecStore) ok = kFALSE;
-      }
-      else {
-       AliInfo("Did not find object used in reconstruction");
-       ok = kFALSE;
-      }      
-    }
-    else {
-      AliInfo("Did not find object used in simulation, assuming not needed and disabling the check");
-    }
-    if (!ok) AliFatal("Different objects were used in sim and rec");
+    else storRec = defRecStore; // default storage list is used
+    //
+    if (!idRec.IsNull()) AliInfo(Form("Rec. used %s from %s",idRec.Data(), storRec.Data()));
+    else                 AliInfo("Rec. did not use this object");
+    //
+    if (!idSim.IsNull() && !idRec.IsNull() && ((idSim!=idRec) || (storSim!=storRec)) ) 
+      AliFatal("Different objects were used in sim and rec");
   }
-  //
+  
 }
 
 //_________________________________________________________