LCOV - code coverage report
Current view: top level - HLT/BASE - AliHLTOfflineInterface.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 28 80 35.0 %
Date: 2016-06-14 17:26:59 Functions: 5 17 29.4 %

          Line data    Source code
       1             : // $Id$
       2             : 
       3             : //**************************************************************************
       4             : //* This file is property of and copyright by the                          * 
       5             : //* ALICE Experiment at CERN, All rights reserved.                         *
       6             : //*                                                                        *
       7             : //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
       8             : //*                  for The ALICE HLT Project.                            *
       9             : //*                                                                        *
      10             : //* Permission to use, copy, modify and distribute this software and its   *
      11             : //* documentation strictly for non-commercial purposes is hereby granted   *
      12             : //* without fee, provided that the above copyright notice appears in all   *
      13             : //* copies and that both the copyright notice and this permission notice   *
      14             : //* appear in the supporting documentation. The authors make no claims     *
      15             : //* about the suitability of this software for any purpose. It is          *
      16             : //* provided "as is" without express or implied warranty.                  *
      17             : //**************************************************************************/
      18             : 
      19             : /// @file   AliHLTOfflineInterface.cxx
      20             : /// @author Matthias Richter
      21             : /// @date   
      22             : /// @brief  the HLT interface to AliRoot
      23             : ///
      24             : 
      25             : #include "AliHLTOfflineInterface.h"
      26             : #include "AliHLTLogging.h"
      27             : 
      28             : /** ROOT macro for the implementation of ROOT specific class methods */
      29         126 : ClassImp(AliHLTOfflineInterface)
      30             : 
      31          30 : AliHLTOfflineInterface::AliHLTOfflineInterface()
      32             :   :
      33          30 :   fpRunLoader(NULL),
      34          30 :   fpRawReader(NULL),
      35          30 :   fpESD(NULL),
      36          30 :   fpNext(NULL)
      37          90 : {
      38             :   // The class implements the basic interface to the AliRoot objects during
      39             :   // reconstructions.
      40             :   // It serves as a base class for offline source and sink interface components
      41             :   // and provides access methods for the AliRunLoader, AliRawReader and AliESDEvent
      42             :   // objects. The AliRunLoader and the AliRawReader are fixed during one run,
      43             :   // while the AliESDEvent object will be changed from event to event.<br>
      44             :   // \em Note: The digits and clusters trees are not available through this
      45             :   // interface class as they are completetly detector (AliLoader) dependend.
      46          30 : }
      47             : 
      48             : AliHLTOfflineInterface* AliHLTOfflineInterface::fgAnchor=NULL;
      49             : AliHLTOfflineInterface* AliHLTOfflineInterface::fgCurrent=NULL;
      50             : int AliHLTOfflineInterface::fgCount=0;
      51             : AliRunLoader* AliHLTOfflineInterface::fgpRunLoader=NULL;
      52             : AliRawReader* AliHLTOfflineInterface::fgpRawReader=NULL;
      53             : 
      54           0 : AliHLTOfflineInterface::AliHLTOfflineInterface(AliRunLoader* pRunLoader, AliRawReader* pRawReader)
      55             :   :
      56           0 :   fpRunLoader(pRunLoader),
      57           0 :   fpRawReader(pRawReader),
      58           0 :   fpESD(NULL),
      59           0 :   fpNext(NULL)
      60           0 : {
      61             :   // constructor
      62           0 : }
      63             : 
      64             : AliHLTOfflineInterface::~AliHLTOfflineInterface()
      65           0 : {
      66             :   // destructor
      67          60 : }
      68             : 
      69             : AliRunLoader* AliHLTOfflineInterface::GetRunLoader() const
      70             : {
      71             :   // set RawReader pointer
      72           0 :   return fpRunLoader!=NULL?fpRunLoader:fgpRunLoader;
      73             : }
      74             : 
      75             : AliRawReader* AliHLTOfflineInterface::GetRawReader() const
      76             : {
      77             :   // get RawReader pointer
      78           0 :   return fpRawReader!=NULL?fpRawReader:fgpRawReader;
      79             : }
      80             : 
      81             : int AliHLTOfflineInterface::SetESD(Int_t /*eventNo*/, AliESDEvent* pESD)
      82             : {
      83             :   // set ESD pointer
      84           0 :   fpESD=pESD;
      85           0 :   return 0;
      86             : }
      87             : 
      88             : AliESDEvent* AliHLTOfflineInterface::GetESD() const
      89             : {
      90             :   // get ESD pointer
      91           0 :   return fpESD;
      92             : }
      93             : 
      94             : int AliHLTOfflineInterface::SetParams(AliRunLoader* runLoader, AliRawReader* rawReader)
      95             : {
      96             :   // set parameters of the interface
      97             :   int iResult=0;
      98           0 :   if (fpRunLoader!=NULL && fpRunLoader!=runLoader) {
      99             :     //HLTWarning("overriding previous instance of Run Loader %p with %p", fpRunLoader, runLoader);
     100             :   }
     101           0 :   fpRunLoader=runLoader;
     102           0 :   if (fpRawReader!=NULL && fpRawReader!=rawReader) {
     103             :     //HLTWarning("overriding previous instance of RawReader %p with %p", fpRawReader, rawReader);
     104             :   }
     105           0 :   fpRawReader=rawReader;
     106           0 :   return iResult;
     107             : }
     108             : 
     109             : int AliHLTOfflineInterface::Reset()
     110             : {
     111             :   // see header file for class documentation
     112             :   int iResult=0;
     113           0 :   fpRunLoader=NULL;
     114           0 :   fpRawReader=NULL;
     115           0 :   fpESD=NULL;
     116           0 :   return iResult;
     117             : }
     118             : 
     119             : int AliHLTOfflineInterface::SetParamsToComponents(AliRunLoader* runLoader, AliRawReader* rawReader)
     120             : {
     121             :   // pass parameters to registered components
     122           0 :   AliHLTLogging log;
     123             :   int iResult=0;
     124             :   int count=0;
     125           0 :   fgpRunLoader=runLoader;
     126           0 :   fgpRawReader=rawReader;
     127           0 :   AliHLTOfflineInterface* pCurrent=fgAnchor;
     128           0 :   while (pCurrent!=NULL) {
     129             :     int iLocal=0;
     130           0 :     if (pCurrent) iLocal=pCurrent->SetParams(runLoader, rawReader);
     131           0 :     if (iLocal<0) {
     132           0 :       log.LoggingVarargs(kHLTLogWarning, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
     133             :                         "parameter initialization failed for component %p with result %d", pCurrent, iLocal);
     134           0 :       if (iResult>=0) iResult=iLocal;
     135             :     }
     136           0 :     count++;
     137           0 :     pCurrent=pCurrent->fpNext;
     138             :   }
     139             :   if (iResult>=0) {
     140             : //       log.LoggingVarargs(kHLTLogInfo, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
     141             : //                      "parameters set to %d offline interface component(s)", count);
     142             :   }
     143             :   return iResult;
     144           0 : }
     145             : 
     146             : int AliHLTOfflineInterface::ResetComponents()
     147             : {
     148             :   // loop over registered components and call Reset
     149             :   int iResult=0;
     150           0 :   AliHLTOfflineInterface* pCurrent=fgAnchor;
     151           0 :   while (pCurrent!=NULL) {
     152             :     int iLocal=0;
     153           0 :     if (pCurrent) iLocal=pCurrent->Reset();
     154           0 :     if (iLocal<0) {
     155           0 :       if (iResult>=0) iResult=iLocal;
     156             :     }
     157           0 :     pCurrent=pCurrent->fpNext;
     158             :   }
     159           0 :   return iResult;
     160             : }
     161             : 
     162             : int AliHLTOfflineInterface::FillComponentESDs(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd)
     163             : {
     164             :   // loop ove registered components and call FillESD function
     165             :   int iResult=0;
     166           0 :   AliHLTOfflineInterface* pCurrent=fgAnchor;
     167           0 :   while (pCurrent!=NULL) {
     168             :     int iLocal=0;
     169           0 :     if (pCurrent) {
     170           0 :       pCurrent->SetESD(eventNo, esd);
     171           0 :       if (pCurrent->GetRunLoader()!=runLoader) {
     172             :         //HLTWarning("runLoader mismatch: component %p was reconstructed with runLoader %p, but got %p now", pCurrent, pCurrent->GetRunLoader(), runLoader);
     173             :       }
     174           0 :       iLocal=pCurrent->FillESD(eventNo, runLoader, esd);
     175           0 :     }
     176           0 :     if (iLocal<0) {
     177           0 :       if (iResult>=0) iResult=iLocal;
     178             :     }
     179           0 :     pCurrent=pCurrent->fpNext;
     180             :   }
     181           0 :   return iResult;
     182             : }
     183             : 
     184             : int AliHLTOfflineInterface::Register(AliHLTOfflineInterface* me)
     185             : {
     186             :   // register a component in the list of offline interface components
     187             :   int iResult=0;
     188          60 :   if (fgAnchor==NULL) {
     189           3 :     fgAnchor=me;
     190           3 :   } else {
     191          27 :     me->fpNext=fgAnchor;
     192          27 :     fgAnchor=me;
     193             :   }
     194          30 :   fgCount++;
     195          30 :   return iResult;
     196             : }
     197             : 
     198             : int AliHLTOfflineInterface::Unregister(AliHLTOfflineInterface* me)
     199             : {
     200             :   // remove a component from the list
     201             :   int iResult=0;
     202          60 :   fgCurrent=NULL;
     203             :   AliHLTOfflineInterface* prev=NULL;
     204          30 :   AliHLTOfflineInterface* handler=fgAnchor;
     205         612 :   while (handler!=NULL && handler!=me) {
     206             :     prev=handler;
     207         123 :     handler=handler->fpNext;
     208             :   }
     209          30 :   if (handler) {
     210          60 :     if (prev==NULL) {
     211          36 :       fgAnchor=handler->fpNext;
     212           6 :     } else {
     213          24 :       prev->fpNext=handler->fpNext;
     214             :     }
     215          30 :     fgCount--;
     216          30 :   }
     217          30 :   return iResult;
     218             : }

Generated by: LCOV version 1.11