]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTOfflineInterface.cxx
Changes needed for new HLT output DDLs.
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTOfflineInterface.cxx
1 // $Id$
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
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 ClassImp(AliHLTOfflineInterface)
30
31 AliHLTOfflineInterface::AliHLTOfflineInterface()
32   :
33   fpRunLoader(NULL),
34   fpRawReader(NULL),
35   fpESD(NULL),
36   fpNext(NULL)
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
45 AliHLTOfflineInterface* AliHLTOfflineInterface::fAnchor=NULL;
46 AliHLTOfflineInterface* AliHLTOfflineInterface::fCurrent=NULL;
47 int AliHLTOfflineInterface::fCount=0;
48 AliRunLoader* AliHLTOfflineInterface::fgpRunLoader=NULL;
49 AliRawReader* AliHLTOfflineInterface::fgpRawReader=NULL;
50
51 AliHLTOfflineInterface::AliHLTOfflineInterface(AliRunLoader* pRunLoader, AliRawReader* pRawReader)
52   :
53   fpRunLoader(pRunLoader),
54   fpRawReader(pRawReader),
55   fpESD(NULL),
56   fpNext(NULL)
57 {
58 }
59
60 AliHLTOfflineInterface::~AliHLTOfflineInterface()
61 {
62 }
63
64 AliRunLoader* AliHLTOfflineInterface::GetRunLoader() const
65 {
66   return fpRunLoader!=NULL?fpRunLoader:fgpRunLoader;
67 }
68
69 AliRawReader* AliHLTOfflineInterface::GetRawReader() const
70 {
71   return fpRawReader!=NULL?fpRawReader:fgpRawReader;
72 }
73
74 int AliHLTOfflineInterface::SetESD(Int_t /*eventNo*/, AliESDEvent* pESD)
75 {
76   fpESD=pESD;
77   return 0;
78 }
79
80 AliESDEvent* AliHLTOfflineInterface::GetESD() const
81 {
82   return fpESD;
83 }
84
85 int 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
100 int 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
110 int AliHLTOfflineInterface::SetParamsToComponents(AliRunLoader* runLoader, AliRawReader* rawReader)
111 {
112   // see header file for class documentation
113   AliHLTLogging log;
114   int iResult=0;
115   int count=0;
116   fgpRunLoader=runLoader;
117   fgpRawReader=rawReader;
118   AliHLTOfflineInterface* pCurrent=fAnchor;
119   while (pCurrent!=NULL) {
120     int iLocal=0;
121     if (pCurrent) iLocal=pCurrent->SetParams(runLoader, rawReader);
122     if (iLocal<0) {
123       log.LoggingVarargs(kHLTLogWarning, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
124                         "parameter initialization failed for component %p with result %d", pCurrent, iLocal);
125       if (iResult>=0) iResult=iLocal;
126     }
127     count++;
128     pCurrent=pCurrent->fpNext;
129   }
130   if (iResult>=0) {
131 //       log.LoggingVarargs(kHLTLogInfo, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
132 //                      "parameters set to %d offline interface component(s)", count);
133   }
134   return iResult;
135 }
136
137 int AliHLTOfflineInterface::ResetComponents()
138 {
139   // see header file for class documentation
140   int iResult=0;
141   AliHLTOfflineInterface* pCurrent=fAnchor;
142   while (pCurrent!=NULL) {
143     int iLocal=0;
144     if (pCurrent) iLocal=pCurrent->Reset();
145     if (iLocal<0) {
146       if (iResult>=0) iResult=iLocal;
147     }
148     pCurrent=pCurrent->fpNext;
149   }
150   return iResult;
151 }
152
153 int AliHLTOfflineInterface::FillComponentESDs(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd)
154 {
155   // see header file for class documentation
156   int iResult=0;
157   AliHLTOfflineInterface* pCurrent=fAnchor;
158   while (pCurrent!=NULL) {
159     int iLocal=0;
160     if (pCurrent) {
161       pCurrent->SetESD(eventNo, esd);
162       if (pCurrent->GetRunLoader()!=runLoader) {
163         //HLTWarning("runLoader mismatch: component %p was reconstructed with runLoader %p, but got %p now", pCurrent, pCurrent->GetRunLoader(), runLoader);
164       }
165       iLocal=pCurrent->FillESD(eventNo, runLoader, esd);
166     }
167     if (iLocal<0) {
168       if (iResult>=0) iResult=iLocal;
169     }
170     pCurrent=pCurrent->fpNext;
171   }
172   return iResult;
173 }
174
175 int AliHLTOfflineInterface::Register(AliHLTOfflineInterface* me)
176 {
177   // see header file for function documentation
178   int iResult=0;
179   if (fAnchor==NULL) {
180     fAnchor=me;
181   } else {
182     me->fpNext=fAnchor;
183     fAnchor=me;
184   }
185   fCount++;
186   return iResult;
187 }
188
189 int AliHLTOfflineInterface::Unregister(AliHLTOfflineInterface* me)
190 {
191   // see header file for function documentation
192   int iResult=0;
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--;
207   }
208   return iResult;
209 }