]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliReconstruction.cxx
Assigns GRPRecoParam to the Global QADatamaker
[u/mrichter/AliRoot.git] / STEER / AliReconstruction.cxx
index e88e5c0ac558707380be40ab387d2b98e3aa85ee..565b8589b8fc9a71b28a9320180527c9c5e1c7cf 100644 (file)
 #include "AliVertexerTracks.h"
 #include "AliTriggerRunScalers.h"
 #include "AliCTPTimeParams.h" 
+#include "AliESDHLTDecision.h"
 
 ClassImp(AliReconstruction)
 
@@ -206,7 +207,7 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fRunMuonTracking(kFALSE),
   fRunV0Finder(kTRUE),
   fRunCascadeFinder(kTRUE),
-  fStopOnError(kFALSE),
+  fStopOnError(kTRUE),
   fWriteAlignmentData(kFALSE),
   fWriteESDfriend(kFALSE),
   fFillTriggerESD(kTRUE),
@@ -1147,6 +1148,13 @@ Bool_t AliReconstruction::LoadCDB()
     if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
     AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",fgkDetectorName[iDet]));
   }
+
+  // Temporary fix - one has to define the correct policy in order
+  // to load the trigger OCDB entries only for the detectors that
+  // in the trigger or that are needed in order to put correct
+  // information in ESD
+  AliCDBManager::Instance()->GetAll("TRIGGER/*/*");
+
   return kTRUE;
 }
 //_____________________________________________________________________________
@@ -1250,8 +1258,14 @@ void AliReconstruction::InitRawReader(const char* input)
   // set the input in case of raw data
   if (input) fRawInput = input;
   fRawReader = AliRawReader::Create(fRawInput.Data());
-  if (!fRawReader)
-    AliInfo("Reconstruction will run over digits");
+  if (!fRawReader) {
+    if (fRawInput.IsNull()) {
+      AliInfo("Reconstruction will run over digits");
+    }
+    else {
+      AliFatal("Can not create raw-data reader ! Exiting..."); 
+    }
+  }
 
   if (!fEquipIdMap.IsNull() && fRawReader)
     fRawReader->LoadEquipmentIdsMap(fEquipIdMap);
@@ -1484,6 +1498,10 @@ void AliReconstruction::SlaveBegin(TTree*)
   fesd = new AliESDEvent();
   fesd->CreateStdContent();
 
+  // add a so far non-std object to the ESD, this will
+  // become part of the std content
+  fesd->AddObject(new AliESDHLTDecision);
+
   fesd->WriteToTree(ftree);
   if (fWriteESDfriend) {
     // careful:
@@ -1623,13 +1641,16 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
       if (reconstructor && fRecoParam.GetDetRecoParamArray(iDet)) {
         const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
         reconstructor->SetRecoParam(par);
-       reconstructor->SetEventInfo(&fEventInfo);
+        reconstructor->SetEventInfo(&fEventInfo);
         if (fRunQA) {
           AliQAManager::QAManager()->SetRecoParam(iDet, par) ; 
           AliQAManager::QAManager()->SetEventSpecie(AliRecoParam::Convert(par->GetEventSpecie())) ;
         }
       }
     }
+    const AliDetectorRecoParam *grppar = fRecoParam.GetDetRecoParam(kNDetectors);
+    AliQAManager::QAManager()->SetRecoParam(AliQAv1::kGLOBAL, grppar) ; 
+    AliQAManager::QAManager()->SetEventSpecie(AliRecoParam::Convert(grppar->GetEventSpecie())) ;
   }
 
     // QA on single raw 
@@ -1649,7 +1670,10 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
       detectors=fRunLocalReconstruction;
       detectors.ReplaceAll("HLT", "");
       if (!RunLocalEventReconstruction(detectors)) {
-       if (fStopOnError) {CleanUp(); return kFALSE;}
+        if (fStopOnError) {
+          CleanUp(); 
+          return kFALSE;
+        }
       }
     }
 
@@ -1657,6 +1681,9 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
     fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
     fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
+
+    fesd->SetEventSpecie(fRecoParam.GetEventSpecie());
+    fhltesd->SetEventSpecie(fRecoParam.GetEventSpecie());
     
     // Set magnetic field from the tracker
     fesd->SetMagneticField(AliTracker::GetBz());
@@ -1837,6 +1864,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
                  t->RelateToVertexBxByBz(pvtx, b, kVeryBig);
              } 
           }
+         delete pvtx; pvtx=NULL;
        }
 
        // TPC-only primary vertex
@@ -1863,6 +1891,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
                  t->RelateToVertexTPCBxByBz(pvtx, b, kVeryBig);
              } 
           }
+         delete pvtx; pvtx=NULL;
        }
 
     }
@@ -1888,7 +1917,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
 
   if (fRunQA && IsInTasks(AliQAv1::kESDS)) {
     AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
-    AliQAManager::QAManager()->RunOneEvent(fesd) ; 
+    AliQAManager::QAManager()->RunOneEvent(fesd, fhltesd) ; 
   }
   if (fRunGlobalQA) {
     AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
@@ -1897,6 +1926,15 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
       qadm->Exec(AliQAv1::kESDS, fesd);
   }
 
+  // copy HLT decision from HLTesd to esd
+  // the most relevant information is stored in a reduced container in the esd,
+  // while the full information can be found in the HLTesd
+  TObject* pHLTSrc=fhltesd->FindListObject(AliESDHLTDecision::Name());
+  TObject* pHLTTgt=fesd->FindListObject(AliESDHLTDecision::Name());
+  if (pHLTSrc && pHLTTgt) {
+    pHLTSrc->Copy(*pHLTTgt);
+  }
+
     if (fWriteESDfriend) {
       //      fesdf->~AliESDfriend();
       //  new (fesdf) AliESDfriend(); // Reset...
@@ -2001,21 +2039,9 @@ void AliReconstruction::SlaveTerminate()
   }
 
   // End of cycle for the in-loop  
-  if (fRunQA) 
-    AliQAManager::QAManager()->EndOfCycle() ;
-  
-  if (fRunGlobalQA) {
-    AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
-    if (qadm) {
-      if (IsInTasks(AliQAv1::kRECPOINTS)) 
-        qadm->EndOfCycle(AliQAv1::kRECPOINTS);
-      if (IsInTasks(AliQAv1::kESDS)) 
-        qadm->EndOfCycle(AliQAv1::kESDS);
-      qadm->Finish();
-    }
-  }
 
   if (fRunQA || fRunGlobalQA) {
+    AliQAManager::QAManager()->EndOfCycle() ;
     if (fInput &&
        !fProofOutputLocation.IsNull() &&
        fProofOutputArchive.IsNull() &&
@@ -2073,6 +2099,7 @@ void AliReconstruction::Terminate()
   if (!fInput) {
     AliESDTagCreator *esdtagCreator = new AliESDTagCreator();
     esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData, AliQAv1::Instance()->GetQA(), AliQAv1::Instance()->GetEventSpecies(), AliQAv1::kNDET, AliRecoParam::kNSpecies);
+    delete esdtagCreator;
   }
 
   // Cleanup of CDB manager: cache and active storages!
@@ -2136,7 +2163,8 @@ Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
       TTree* digitsTree = loader->TreeD();
       if (!digitsTree) {
         AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet]));
-        if (fStopOnError) return kFALSE;
+        if (fStopOnError) 
+          return kFALSE;
       } else {
         reconstructor->Reconstruct(digitsTree, clustersTree);
         if (fRunQA && IsInTasks(AliQAv1::kDIGITSR)) {
@@ -2154,10 +2182,12 @@ Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
     loader->UnloadRecPoints();
     AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
   }
+  IsSelected("CTP", detStr);
   if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
     AliError(Form("the following detectors were not found: %s",
                   detStr.Data()));
-    if (fStopOnError) return kFALSE;
+    if (fStopOnError) 
+      return kFALSE;
   }
   eventNr++;
   return kTRUE;
@@ -2365,18 +2395,18 @@ Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
   
   Int_t rv = tracker->Clusters2Tracks(esd);
   
-  if ( rv )
-  {
-    AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
-    return kFALSE;
-  }
-  
   fLoader[iDet]->UnloadRecPoints();
 
   tracker->UnloadClusters();
   
   delete tracker;
   
+  if ( rv )
+  {
+    AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
+    return kFALSE;
+  }
+  
   return kTRUE;
 }
 
@@ -2610,7 +2640,8 @@ Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
       fLoader[iDet]->UnloadRecPoints();
     }
   }
-
+  
+  IsSelected("CTP", detStr);
   if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
     AliError(Form("the following detectors were not found: %s", 
                   detStr.Data()));
@@ -2671,7 +2702,7 @@ Bool_t AliReconstruction::FillTriggerScalers(AliESDEvent*& esd)
      //AliTimeStamp* timestamp = new AliTimeStamp(10308000, 0, (ULong64_t)486238);
      AliESDHeader* esdheader = fesd->GetHeader();
      for(Int_t i=0;i<50;i++){
-          if((1<<i) & esd->GetTriggerMask()){
+          if((1ull<<i) & esd->GetTriggerMask()){
           AliTriggerScalersESD* scalesd = fRunScalers->GetScalersForEventClass( timestamp, i+1);
           if(scalesd)esdheader->SetTriggerScalersRecord(scalesd);
         }
@@ -2998,9 +3029,9 @@ void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
       Int_t idx[200];
       for (Int_t i=0; i<200; ++i) idx[i] = -1; //PH avoid uninitialized values
       for (Int_t iDet = 5; iDet >= 0; iDet--) {// TOF, TRD, TPC, ITS clusters
-          nsp += track->GetNcls(iDet);
+          nsp += (iDet==GetDetIndex("TRD")) ? track->GetTRDntracklets():track->GetNcls(iDet);
 
-          if (iDet==0) { // ITS "extra" clusters
+          if (iDet==GetDetIndex("ITS")) { // ITS "extra" clusters
              track->GetClusters(iDet,idx);
              for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nsp++;
           }  
@@ -3013,9 +3044,9 @@ void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
        for (Int_t iDet = 5; iDet >= 0; iDet--) {
          AliTracker *tracker = fTracker[iDet];
          if (!tracker) continue;
-         Int_t nspdet = track->GetClusters(iDet,idx);
+         Int_t nspdet = (iDet==GetDetIndex("TRD")) ? track->GetTRDtracklets(idx):track->GetClusters(iDet,idx);
 
-         if (iDet==0) // ITS "extra" clusters             
+         if (iDet==GetDetIndex("ITS")) // ITS "extra" clusters             
              for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nspdet++;
 
          if (nspdet <= 0) continue;
@@ -3039,7 +3070,7 @@ void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
            } 
            isp2++;
            if (!isvalid) continue;
-           if (iDet==0 && (isp-1)>=6) p.SetExtra();
+           if (iDet==GetDetIndex("ITS") && (isp-1)>=6) p.SetExtra();
            sp->AddPoint(isptrack,&p); isptrack++;
          }
        }       
@@ -3133,9 +3164,10 @@ Bool_t AliReconstruction::FinishPlaneEff() {
  //  Return: kTRUE if all operations have been done properly, kFALSE otherwise
  //
  Bool_t ret=kFALSE;
+ TString detStr = fLoadCDB;
  //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
  for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS
-   //if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
+   if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
    if(fTracker[iDet] && fTracker[iDet]->GetPlaneEff()) {
       AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff();
       TString name=planeeff->GetName();
@@ -3178,14 +3210,16 @@ Bool_t AliReconstruction::InitPlaneEff() {
  AliWarning(Form("Implementation of this method not yet completed !! Method return kTRUE"));
 
   fSPDTrackleter = NULL;
-  AliReconstructor* itsReconstructor = GetReconstructor(0);
-  if (itsReconstructor) {
-    fSPDTrackleter = itsReconstructor->CreateTrackleter(); // this is NULL unless required in RecoParam
-  }
-  if (fSPDTrackleter) { 
-    AliInfo("Trackleter for SPD has been created");
+  TString detStr = fLoadCDB;
+  if (IsSelected(fgkDetectorName[0], detStr)) {
+    AliReconstructor* itsReconstructor = GetReconstructor(0);
+    if (itsReconstructor) {
+      fSPDTrackleter = itsReconstructor->CreateTrackleter(); // this is NULL unless required in RecoParam
+    }
+    if (fSPDTrackleter) {
+      AliInfo("Trackleter for SPD has been created");
+    }
   }
-
  return kTRUE;
 }
 
@@ -3239,9 +3273,7 @@ Bool_t AliReconstruction::SetRunQA(TString detAndAction)
        }
        Int_t colon = detAndAction.Index(":") ; 
        fQADetectors = detAndAction(0, colon) ; 
-       if (fQADetectors.Contains("ALL") )
-               fQADetectors = fFillESD ; 
-               fQATasks   = detAndAction(colon+1, detAndAction.Sizeof() ) ; 
+       fQATasks   = detAndAction(colon+1, detAndAction.Sizeof() ) ; 
        if (fQATasks.Contains("ALL") ) {
                fQATasks = Form("%d %d %d %d", AliQAv1::kRAWS, AliQAv1::kDIGITSR, AliQAv1::kRECPOINTS, AliQAv1::kESDS) ; 
        } else {