]>
Commit | Line | Data |
---|---|---|
242bb794 | 1 | // $Id$ |
2 | ||
5ba46b3b | 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 | /// | |
242bb794 | 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), | |
79c114b5 | 35 | fpESD(NULL), |
36 | fpNext(NULL) | |
242bb794 | 37 | { |
5ba46b3b | 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. | |
242bb794 | 46 | } |
47 | ||
5ba46b3b | 48 | AliHLTOfflineInterface* AliHLTOfflineInterface::fgAnchor=NULL; |
49 | AliHLTOfflineInterface* AliHLTOfflineInterface::fgCurrent=NULL; | |
50 | int AliHLTOfflineInterface::fgCount=0; | |
8451168b | 51 | AliRunLoader* AliHLTOfflineInterface::fgpRunLoader=NULL; |
52 | AliRawReader* AliHLTOfflineInterface::fgpRawReader=NULL; | |
242bb794 | 53 | |
54 | AliHLTOfflineInterface::AliHLTOfflineInterface(AliRunLoader* pRunLoader, AliRawReader* pRawReader) | |
55 | : | |
56 | fpRunLoader(pRunLoader), | |
57 | fpRawReader(pRawReader), | |
79c114b5 | 58 | fpESD(NULL), |
59 | fpNext(NULL) | |
242bb794 | 60 | { |
5ba46b3b | 61 | // constructor |
242bb794 | 62 | } |
63 | ||
242bb794 | 64 | AliHLTOfflineInterface::~AliHLTOfflineInterface() |
65 | { | |
5ba46b3b | 66 | // destructor |
242bb794 | 67 | } |
68 | ||
8451168b | 69 | AliRunLoader* AliHLTOfflineInterface::GetRunLoader() const |
242bb794 | 70 | { |
5ba46b3b | 71 | // set RawReader pointer |
8451168b | 72 | return fpRunLoader!=NULL?fpRunLoader:fgpRunLoader; |
242bb794 | 73 | } |
74 | ||
8451168b | 75 | AliRawReader* AliHLTOfflineInterface::GetRawReader() const |
242bb794 | 76 | { |
5ba46b3b | 77 | // get RawReader pointer |
8451168b | 78 | return fpRawReader!=NULL?fpRawReader:fgpRawReader; |
242bb794 | 79 | } |
80 | ||
298ef463 | 81 | int AliHLTOfflineInterface::SetESD(Int_t /*eventNo*/, AliESDEvent* pESD) |
242bb794 | 82 | { |
5ba46b3b | 83 | // set ESD pointer |
242bb794 | 84 | fpESD=pESD; |
85 | return 0; | |
86 | } | |
87 | ||
af885e0f | 88 | AliESDEvent* AliHLTOfflineInterface::GetESD() const |
242bb794 | 89 | { |
5ba46b3b | 90 | // get ESD pointer |
242bb794 | 91 | return fpESD; |
92 | } | |
93 | ||
94 | int AliHLTOfflineInterface::SetParams(AliRunLoader* runLoader, AliRawReader* rawReader) | |
95 | { | |
5ba46b3b | 96 | // set parameters of the interface |
242bb794 | 97 | int iResult=0; |
98 | if (fpRunLoader!=NULL && fpRunLoader!=runLoader) { | |
99 | //HLTWarning("overriding previous instance of Run Loader %p with %p", fpRunLoader, runLoader); | |
100 | } | |
101 | fpRunLoader=runLoader; | |
102 | if (fpRawReader!=NULL && fpRawReader!=rawReader) { | |
103 | //HLTWarning("overriding previous instance of RawReader %p with %p", fpRawReader, rawReader); | |
104 | } | |
105 | fpRawReader=rawReader; | |
106 | return iResult; | |
107 | } | |
108 | ||
109 | int AliHLTOfflineInterface::Reset() | |
110 | { | |
111 | // see header file for class documentation | |
112 | int iResult=0; | |
113 | fpRunLoader=NULL; | |
114 | fpRawReader=NULL; | |
115 | fpESD=NULL; | |
116 | return iResult; | |
117 | } | |
118 | ||
119 | int AliHLTOfflineInterface::SetParamsToComponents(AliRunLoader* runLoader, AliRawReader* rawReader) | |
120 | { | |
5ba46b3b | 121 | // pass parameters to registered components |
8451168b | 122 | AliHLTLogging log; |
242bb794 | 123 | int iResult=0; |
8451168b | 124 | int count=0; |
125 | fgpRunLoader=runLoader; | |
126 | fgpRawReader=rawReader; | |
5ba46b3b | 127 | AliHLTOfflineInterface* pCurrent=fgAnchor; |
7617ca1e | 128 | while (pCurrent!=NULL) { |
242bb794 | 129 | int iLocal=0; |
7617ca1e | 130 | if (pCurrent) iLocal=pCurrent->SetParams(runLoader, rawReader); |
242bb794 | 131 | if (iLocal<0) { |
8451168b | 132 | log.LoggingVarargs(kHLTLogWarning, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__, |
7617ca1e | 133 | "parameter initialization failed for component %p with result %d", pCurrent, iLocal); |
242bb794 | 134 | if (iResult>=0) iResult=iLocal; |
135 | } | |
8451168b | 136 | count++; |
7617ca1e | 137 | pCurrent=pCurrent->fpNext; |
242bb794 | 138 | } |
8451168b | 139 | if (iResult>=0) { |
90ebac25 | 140 | // log.LoggingVarargs(kHLTLogInfo, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__, |
141 | // "parameters set to %d offline interface component(s)", count); | |
8451168b | 142 | } |
242bb794 | 143 | return iResult; |
144 | } | |
145 | ||
146 | int AliHLTOfflineInterface::ResetComponents() | |
147 | { | |
5ba46b3b | 148 | // loop over registered components and call Reset |
242bb794 | 149 | int iResult=0; |
5ba46b3b | 150 | AliHLTOfflineInterface* pCurrent=fgAnchor; |
7617ca1e | 151 | while (pCurrent!=NULL) { |
242bb794 | 152 | int iLocal=0; |
7617ca1e | 153 | if (pCurrent) iLocal=pCurrent->Reset(); |
242bb794 | 154 | if (iLocal<0) { |
155 | if (iResult>=0) iResult=iLocal; | |
156 | } | |
7617ca1e | 157 | pCurrent=pCurrent->fpNext; |
242bb794 | 158 | } |
159 | return iResult; | |
160 | } | |
161 | ||
af885e0f | 162 | int AliHLTOfflineInterface::FillComponentESDs(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd) |
242bb794 | 163 | { |
5ba46b3b | 164 | // loop ove registered components and call FillESD function |
242bb794 | 165 | int iResult=0; |
5ba46b3b | 166 | AliHLTOfflineInterface* pCurrent=fgAnchor; |
7617ca1e | 167 | while (pCurrent!=NULL) { |
242bb794 | 168 | int iLocal=0; |
7617ca1e | 169 | if (pCurrent) { |
170 | pCurrent->SetESD(eventNo, esd); | |
171 | if (pCurrent->GetRunLoader()!=runLoader) { | |
c5123824 | 172 | //HLTWarning("runLoader mismatch: component %p was reconstructed with runLoader %p, but got %p now", pCurrent, pCurrent->GetRunLoader(), runLoader); |
8451168b | 173 | } |
7617ca1e | 174 | iLocal=pCurrent->FillESD(eventNo, runLoader, esd); |
8451168b | 175 | } |
242bb794 | 176 | if (iLocal<0) { |
177 | if (iResult>=0) iResult=iLocal; | |
178 | } | |
7617ca1e | 179 | pCurrent=pCurrent->fpNext; |
242bb794 | 180 | } |
181 | return iResult; | |
182 | } | |
183 | ||
184 | int AliHLTOfflineInterface::Register(AliHLTOfflineInterface* me) | |
185 | { | |
5ba46b3b | 186 | // register a component in the list of offline interface components |
242bb794 | 187 | int iResult=0; |
5ba46b3b | 188 | if (fgAnchor==NULL) { |
189 | fgAnchor=me; | |
242bb794 | 190 | } else { |
5ba46b3b | 191 | me->fpNext=fgAnchor; |
192 | fgAnchor=me; | |
242bb794 | 193 | } |
5ba46b3b | 194 | fgCount++; |
242bb794 | 195 | return iResult; |
196 | } | |
197 | ||
198 | int AliHLTOfflineInterface::Unregister(AliHLTOfflineInterface* me) | |
199 | { | |
5ba46b3b | 200 | // remove a component from the list |
242bb794 | 201 | int iResult=0; |
5ba46b3b | 202 | fgCurrent=NULL; |
7617ca1e | 203 | AliHLTOfflineInterface* prev=NULL; |
5ba46b3b | 204 | AliHLTOfflineInterface* handler=fgAnchor; |
7617ca1e | 205 | while (handler!=NULL && handler!=me) { |
206 | prev=handler; | |
207 | handler=handler->fpNext; | |
208 | } | |
209 | if (handler) { | |
210 | if (prev==NULL) { | |
5ba46b3b | 211 | fgAnchor=handler->fpNext; |
7617ca1e | 212 | } else { |
213 | prev->fpNext=handler->fpNext; | |
214 | } | |
5ba46b3b | 215 | fgCount--; |
242bb794 | 216 | } |
217 | return iResult; | |
218 | } |