]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTOfflineInterface.cxx
- singleton functionality added for component and configuration handler
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTOfflineInterface.cxx
CommitLineData
242bb794 1// $Id$
2
3/**************************************************************************
9be2600f 4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
242bb794 6 * *
9be2600f 7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
242bb794 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"
8451168b 26#include "AliHLTLogging.h"
242bb794 27
28/** ROOT macro for the implementation of ROOT specific class methods */
29ClassImp(AliHLTOfflineInterface)
30
31AliHLTOfflineInterface::AliHLTOfflineInterface()
32 :
33 fpRunLoader(NULL),
34 fpRawReader(NULL),
79c114b5 35 fpESD(NULL),
36 fpNext(NULL)
242bb794 37{
38 // see header file for class documentation
39 // or
40 // refer to README to build package
41 // or
42 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
43}
44
7617ca1e 45AliHLTOfflineInterface* AliHLTOfflineInterface::fAnchor=NULL;
46AliHLTOfflineInterface* AliHLTOfflineInterface::fCurrent=NULL;
47int AliHLTOfflineInterface::fCount=0;
8451168b 48AliRunLoader* AliHLTOfflineInterface::fgpRunLoader=NULL;
49AliRawReader* AliHLTOfflineInterface::fgpRawReader=NULL;
242bb794 50
51AliHLTOfflineInterface::AliHLTOfflineInterface(AliRunLoader* pRunLoader, AliRawReader* pRawReader)
52 :
53 fpRunLoader(pRunLoader),
54 fpRawReader(pRawReader),
79c114b5 55 fpESD(NULL),
56 fpNext(NULL)
242bb794 57{
58}
59
242bb794 60AliHLTOfflineInterface::~AliHLTOfflineInterface()
61{
62}
63
8451168b 64AliRunLoader* AliHLTOfflineInterface::GetRunLoader() const
242bb794 65{
8451168b 66 return fpRunLoader!=NULL?fpRunLoader:fgpRunLoader;
242bb794 67}
68
8451168b 69AliRawReader* AliHLTOfflineInterface::GetRawReader() const
242bb794 70{
8451168b 71 return fpRawReader!=NULL?fpRawReader:fgpRawReader;
242bb794 72}
73
298ef463 74int AliHLTOfflineInterface::SetESD(Int_t /*eventNo*/, AliESDEvent* pESD)
242bb794 75{
76 fpESD=pESD;
77 return 0;
78}
79
af885e0f 80AliESDEvent* AliHLTOfflineInterface::GetESD() const
242bb794 81{
82 return fpESD;
83}
84
85int AliHLTOfflineInterface::SetParams(AliRunLoader* runLoader, AliRawReader* rawReader)
86{
87 // see header file for class documentation
88 int iResult=0;
89 if (fpRunLoader!=NULL && fpRunLoader!=runLoader) {
90 //HLTWarning("overriding previous instance of Run Loader %p with %p", fpRunLoader, runLoader);
91 }
92 fpRunLoader=runLoader;
93 if (fpRawReader!=NULL && fpRawReader!=rawReader) {
94 //HLTWarning("overriding previous instance of RawReader %p with %p", fpRawReader, rawReader);
95 }
96 fpRawReader=rawReader;
97 return iResult;
98}
99
100int AliHLTOfflineInterface::Reset()
101{
102 // see header file for class documentation
103 int iResult=0;
104 fpRunLoader=NULL;
105 fpRawReader=NULL;
106 fpESD=NULL;
107 return iResult;
108}
109
110int AliHLTOfflineInterface::SetParamsToComponents(AliRunLoader* runLoader, AliRawReader* rawReader)
111{
112 // see header file for class documentation
8451168b 113 AliHLTLogging log;
242bb794 114 int iResult=0;
8451168b 115 int count=0;
116 fgpRunLoader=runLoader;
117 fgpRawReader=rawReader;
7617ca1e 118 AliHLTOfflineInterface* pCurrent=fAnchor;
119 while (pCurrent!=NULL) {
242bb794 120 int iLocal=0;
7617ca1e 121 if (pCurrent) iLocal=pCurrent->SetParams(runLoader, rawReader);
242bb794 122 if (iLocal<0) {
8451168b 123 log.LoggingVarargs(kHLTLogWarning, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
7617ca1e 124 "parameter initialization failed for component %p with result %d", pCurrent, iLocal);
242bb794 125 if (iResult>=0) iResult=iLocal;
126 }
8451168b 127 count++;
7617ca1e 128 pCurrent=pCurrent->fpNext;
242bb794 129 }
8451168b 130 if (iResult>=0) {
90ebac25 131// log.LoggingVarargs(kHLTLogInfo, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
132// "parameters set to %d offline interface component(s)", count);
8451168b 133 }
242bb794 134 return iResult;
135}
136
137int AliHLTOfflineInterface::ResetComponents()
138{
139 // see header file for class documentation
140 int iResult=0;
7617ca1e 141 AliHLTOfflineInterface* pCurrent=fAnchor;
142 while (pCurrent!=NULL) {
242bb794 143 int iLocal=0;
7617ca1e 144 if (pCurrent) iLocal=pCurrent->Reset();
242bb794 145 if (iLocal<0) {
146 if (iResult>=0) iResult=iLocal;
147 }
7617ca1e 148 pCurrent=pCurrent->fpNext;
242bb794 149 }
150 return iResult;
151}
152
af885e0f 153int AliHLTOfflineInterface::FillComponentESDs(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd)
242bb794 154{
155 // see header file for class documentation
156 int iResult=0;
7617ca1e 157 AliHLTOfflineInterface* pCurrent=fAnchor;
158 while (pCurrent!=NULL) {
242bb794 159 int iLocal=0;
7617ca1e 160 if (pCurrent) {
161 pCurrent->SetESD(eventNo, esd);
162 if (pCurrent->GetRunLoader()!=runLoader) {
c5123824 163 //HLTWarning("runLoader mismatch: component %p was reconstructed with runLoader %p, but got %p now", pCurrent, pCurrent->GetRunLoader(), runLoader);
8451168b 164 }
7617ca1e 165 iLocal=pCurrent->FillESD(eventNo, runLoader, esd);
8451168b 166 }
242bb794 167 if (iLocal<0) {
168 if (iResult>=0) iResult=iLocal;
169 }
7617ca1e 170 pCurrent=pCurrent->fpNext;
242bb794 171 }
172 return iResult;
173}
174
175int AliHLTOfflineInterface::Register(AliHLTOfflineInterface* me)
176{
177 // see header file for function documentation
178 int iResult=0;
7617ca1e 179 if (fAnchor==NULL) {
180 fAnchor=me;
242bb794 181 } else {
7617ca1e 182 me->fpNext=fAnchor;
183 fAnchor=me;
242bb794 184 }
7617ca1e 185 fCount++;
242bb794 186 return iResult;
187}
188
189int AliHLTOfflineInterface::Unregister(AliHLTOfflineInterface* me)
190{
191 // see header file for function documentation
192 int iResult=0;
7617ca1e 193 fCurrent=NULL;
194 AliHLTOfflineInterface* prev=NULL;
195 AliHLTOfflineInterface* handler=fAnchor;
196 while (handler!=NULL && handler!=me) {
197 prev=handler;
198 handler=handler->fpNext;
199 }
200 if (handler) {
201 if (prev==NULL) {
202 fAnchor=handler->fpNext;
203 } else {
204 prev->fpNext=handler->fpNext;
205 }
206 fCount--;
242bb794 207 }
208 return iResult;
209}