3 //**************************************************************************
4 //* This file is property of and copyright by the *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************/
19 /// @file AliHLTOfflineInterface.cxx
20 /// @author Matthias Richter
22 /// @brief the HLT interface to AliRoot
25 #include "AliHLTOfflineInterface.h"
26 #include "AliHLTLogging.h"
28 /** ROOT macro for the implementation of ROOT specific class methods */
29 ClassImp(AliHLTOfflineInterface)
31 AliHLTOfflineInterface::AliHLTOfflineInterface()
38 // The class implements the basic interface to the AliRoot objects during
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.
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;
54 AliHLTOfflineInterface::AliHLTOfflineInterface(AliRunLoader* pRunLoader, AliRawReader* pRawReader)
56 fpRunLoader(pRunLoader),
57 fpRawReader(pRawReader),
64 AliHLTOfflineInterface::~AliHLTOfflineInterface()
69 AliRunLoader* AliHLTOfflineInterface::GetRunLoader() const
71 // set RawReader pointer
72 return fpRunLoader!=NULL?fpRunLoader:fgpRunLoader;
75 AliRawReader* AliHLTOfflineInterface::GetRawReader() const
77 // get RawReader pointer
78 return fpRawReader!=NULL?fpRawReader:fgpRawReader;
81 int AliHLTOfflineInterface::SetESD(Int_t /*eventNo*/, AliESDEvent* pESD)
88 AliESDEvent* AliHLTOfflineInterface::GetESD() const
94 int AliHLTOfflineInterface::SetParams(AliRunLoader* runLoader, AliRawReader* rawReader)
96 // set parameters of the interface
98 if (fpRunLoader!=NULL && fpRunLoader!=runLoader) {
99 //HLTWarning("overriding previous instance of Run Loader %p with %p", fpRunLoader, runLoader);
101 fpRunLoader=runLoader;
102 if (fpRawReader!=NULL && fpRawReader!=rawReader) {
103 //HLTWarning("overriding previous instance of RawReader %p with %p", fpRawReader, rawReader);
105 fpRawReader=rawReader;
109 int AliHLTOfflineInterface::Reset()
111 // see header file for class documentation
119 int AliHLTOfflineInterface::SetParamsToComponents(AliRunLoader* runLoader, AliRawReader* rawReader)
121 // pass parameters to registered components
125 fgpRunLoader=runLoader;
126 fgpRawReader=rawReader;
127 AliHLTOfflineInterface* pCurrent=fgAnchor;
128 while (pCurrent!=NULL) {
130 if (pCurrent) iLocal=pCurrent->SetParams(runLoader, rawReader);
132 log.LoggingVarargs(kHLTLogWarning, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
133 "parameter initialization failed for component %p with result %d", pCurrent, iLocal);
134 if (iResult>=0) iResult=iLocal;
137 pCurrent=pCurrent->fpNext;
140 // log.LoggingVarargs(kHLTLogInfo, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
141 // "parameters set to %d offline interface component(s)", count);
146 int AliHLTOfflineInterface::ResetComponents()
148 // loop over registered components and call Reset
150 AliHLTOfflineInterface* pCurrent=fgAnchor;
151 while (pCurrent!=NULL) {
153 if (pCurrent) iLocal=pCurrent->Reset();
155 if (iResult>=0) iResult=iLocal;
157 pCurrent=pCurrent->fpNext;
162 int AliHLTOfflineInterface::FillComponentESDs(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd)
164 // loop ove registered components and call FillESD function
166 AliHLTOfflineInterface* pCurrent=fgAnchor;
167 while (pCurrent!=NULL) {
170 pCurrent->SetESD(eventNo, esd);
171 if (pCurrent->GetRunLoader()!=runLoader) {
172 //HLTWarning("runLoader mismatch: component %p was reconstructed with runLoader %p, but got %p now", pCurrent, pCurrent->GetRunLoader(), runLoader);
174 iLocal=pCurrent->FillESD(eventNo, runLoader, esd);
177 if (iResult>=0) iResult=iLocal;
179 pCurrent=pCurrent->fpNext;
184 int AliHLTOfflineInterface::Register(AliHLTOfflineInterface* me)
186 // register a component in the list of offline interface components
188 if (fgAnchor==NULL) {
198 int AliHLTOfflineInterface::Unregister(AliHLTOfflineInterface* me)
200 // remove a component from the list
203 AliHLTOfflineInterface* prev=NULL;
204 AliHLTOfflineInterface* handler=fgAnchor;
205 while (handler!=NULL && handler!=me) {
207 handler=handler->fpNext;
211 fgAnchor=handler->fpNext;
213 prev->fpNext=handler->fpNext;