]>
Commit | Line | Data |
---|---|---|
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 */ | |
29 | ClassImp(AliHLTOfflineInterface) | |
30 | ||
31 | AliHLTOfflineInterface::AliHLTOfflineInterface() | |
32 | : | |
33 | fpRunLoader(NULL), | |
34 | fpRawReader(NULL), | |
35 | fpESD(NULL) | |
36 | { | |
37 | // see header file for class documentation | |
38 | // or | |
39 | // refer to README to build package | |
40 | // or | |
41 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
42 | } | |
43 | ||
7617ca1e | 44 | AliHLTOfflineInterface* AliHLTOfflineInterface::fAnchor=NULL; |
45 | AliHLTOfflineInterface* AliHLTOfflineInterface::fCurrent=NULL; | |
46 | int AliHLTOfflineInterface::fCount=0; | |
8451168b | 47 | AliRunLoader* AliHLTOfflineInterface::fgpRunLoader=NULL; |
48 | AliRawReader* AliHLTOfflineInterface::fgpRawReader=NULL; | |
242bb794 | 49 | |
50 | AliHLTOfflineInterface::AliHLTOfflineInterface(AliRunLoader* pRunLoader, AliRawReader* pRawReader) | |
51 | : | |
52 | fpRunLoader(pRunLoader), | |
53 | fpRawReader(pRawReader), | |
54 | fpESD(NULL) | |
55 | { | |
56 | } | |
57 | ||
58 | AliHLTOfflineInterface::AliHLTOfflineInterface(const AliHLTOfflineInterface&) | |
59 | : | |
60 | TObject(), | |
61 | fpRunLoader(NULL), | |
62 | fpRawReader(NULL), | |
63 | fpESD(NULL) | |
64 | { | |
65 | // see header file for class documentation | |
66 | //HLTFatal("copy constructor untested"); | |
67 | } | |
68 | ||
69 | AliHLTOfflineInterface& AliHLTOfflineInterface::operator=(const AliHLTOfflineInterface&) | |
70 | { | |
71 | // see header file for class documentation | |
72 | //HLTFatal("assignment operator untested"); | |
73 | return *this; | |
74 | } | |
75 | ||
76 | AliHLTOfflineInterface::~AliHLTOfflineInterface() | |
77 | { | |
78 | } | |
79 | ||
8451168b | 80 | AliRunLoader* AliHLTOfflineInterface::GetRunLoader() const |
242bb794 | 81 | { |
8451168b | 82 | return fpRunLoader!=NULL?fpRunLoader:fgpRunLoader; |
242bb794 | 83 | } |
84 | ||
8451168b | 85 | AliRawReader* AliHLTOfflineInterface::GetRawReader() const |
242bb794 | 86 | { |
8451168b | 87 | return fpRawReader!=NULL?fpRawReader:fgpRawReader; |
242bb794 | 88 | } |
89 | ||
90 | int AliHLTOfflineInterface::SetESD(Int_t eventNo, AliESD* pESD) | |
91 | { | |
92 | fpESD=pESD; | |
93 | return 0; | |
94 | } | |
95 | ||
96 | AliESD* AliHLTOfflineInterface::GetESD() const | |
97 | { | |
98 | return fpESD; | |
99 | } | |
100 | ||
101 | int AliHLTOfflineInterface::SetParams(AliRunLoader* runLoader, AliRawReader* rawReader) | |
102 | { | |
103 | // see header file for class documentation | |
104 | int iResult=0; | |
105 | if (fpRunLoader!=NULL && fpRunLoader!=runLoader) { | |
106 | //HLTWarning("overriding previous instance of Run Loader %p with %p", fpRunLoader, runLoader); | |
107 | } | |
108 | fpRunLoader=runLoader; | |
109 | if (fpRawReader!=NULL && fpRawReader!=rawReader) { | |
110 | //HLTWarning("overriding previous instance of RawReader %p with %p", fpRawReader, rawReader); | |
111 | } | |
112 | fpRawReader=rawReader; | |
113 | return iResult; | |
114 | } | |
115 | ||
116 | int AliHLTOfflineInterface::Reset() | |
117 | { | |
118 | // see header file for class documentation | |
119 | int iResult=0; | |
120 | fpRunLoader=NULL; | |
121 | fpRawReader=NULL; | |
122 | fpESD=NULL; | |
123 | return iResult; | |
124 | } | |
125 | ||
126 | int AliHLTOfflineInterface::SetParamsToComponents(AliRunLoader* runLoader, AliRawReader* rawReader) | |
127 | { | |
128 | // see header file for class documentation | |
8451168b | 129 | AliHLTLogging log; |
242bb794 | 130 | int iResult=0; |
8451168b | 131 | int count=0; |
132 | fgpRunLoader=runLoader; | |
133 | fgpRawReader=rawReader; | |
7617ca1e | 134 | AliHLTOfflineInterface* pCurrent=fAnchor; |
135 | while (pCurrent!=NULL) { | |
242bb794 | 136 | int iLocal=0; |
7617ca1e | 137 | if (pCurrent) iLocal=pCurrent->SetParams(runLoader, rawReader); |
242bb794 | 138 | if (iLocal<0) { |
8451168b | 139 | log.LoggingVarargs(kHLTLogWarning, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__, |
7617ca1e | 140 | "parameter initialization failed for component %p with result %d", pCurrent, iLocal); |
242bb794 | 141 | if (iResult>=0) iResult=iLocal; |
142 | } | |
8451168b | 143 | count++; |
7617ca1e | 144 | pCurrent=pCurrent->fpNext; |
242bb794 | 145 | } |
8451168b | 146 | if (iResult>=0) { |
90ebac25 | 147 | // log.LoggingVarargs(kHLTLogInfo, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__, |
148 | // "parameters set to %d offline interface component(s)", count); | |
8451168b | 149 | } |
242bb794 | 150 | return iResult; |
151 | } | |
152 | ||
153 | int AliHLTOfflineInterface::ResetComponents() | |
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) iLocal=pCurrent->Reset(); |
242bb794 | 161 | if (iLocal<0) { |
162 | if (iResult>=0) iResult=iLocal; | |
163 | } | |
7617ca1e | 164 | pCurrent=pCurrent->fpNext; |
242bb794 | 165 | } |
166 | return iResult; | |
167 | } | |
168 | ||
8451168b | 169 | int AliHLTOfflineInterface::FillComponentESDs(int eventNo, AliRunLoader* runLoader, AliESD* esd) |
242bb794 | 170 | { |
171 | // see header file for class documentation | |
172 | int iResult=0; | |
7617ca1e | 173 | AliHLTOfflineInterface* pCurrent=fAnchor; |
174 | while (pCurrent!=NULL) { | |
242bb794 | 175 | int iLocal=0; |
7617ca1e | 176 | if (pCurrent) { |
177 | pCurrent->SetESD(eventNo, esd); | |
178 | if (pCurrent->GetRunLoader()!=runLoader) { | |
179 | //HLTWarning("runLoader missmatch: component %p was reconstructed with runLoader %p, but got %p now", pCurrent, pCurrent->GetRunLoader(), runLoader); | |
8451168b | 180 | } |
7617ca1e | 181 | iLocal=pCurrent->FillESD(eventNo, runLoader, esd); |
8451168b | 182 | } |
242bb794 | 183 | if (iLocal<0) { |
184 | if (iResult>=0) iResult=iLocal; | |
185 | } | |
7617ca1e | 186 | pCurrent=pCurrent->fpNext; |
242bb794 | 187 | } |
188 | return iResult; | |
189 | } | |
190 | ||
191 | int AliHLTOfflineInterface::Register(AliHLTOfflineInterface* me) | |
192 | { | |
193 | // see header file for function documentation | |
194 | int iResult=0; | |
7617ca1e | 195 | if (fAnchor==NULL) { |
196 | fAnchor=me; | |
242bb794 | 197 | } else { |
7617ca1e | 198 | me->fpNext=fAnchor; |
199 | fAnchor=me; | |
242bb794 | 200 | } |
7617ca1e | 201 | fCount++; |
242bb794 | 202 | return iResult; |
203 | } | |
204 | ||
205 | int AliHLTOfflineInterface::Unregister(AliHLTOfflineInterface* me) | |
206 | { | |
207 | // see header file for function documentation | |
208 | int iResult=0; | |
7617ca1e | 209 | fCurrent=NULL; |
210 | AliHLTOfflineInterface* prev=NULL; | |
211 | AliHLTOfflineInterface* handler=fAnchor; | |
212 | while (handler!=NULL && handler!=me) { | |
213 | prev=handler; | |
214 | handler=handler->fpNext; | |
215 | } | |
216 | if (handler) { | |
217 | if (prev==NULL) { | |
218 | fAnchor=handler->fpNext; | |
219 | } else { | |
220 | prev->fpNext=handler->fpNext; | |
221 | } | |
222 | fCount--; | |
242bb794 | 223 | } |
224 | return iResult; | |
225 | } |