]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTOfflineInterface.cxx
changed from usage of TList to private list due to crashes in TList when instantiated...
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTOfflineInterface.cxx
1 // $Id$
2
3 /**************************************************************************
4  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  *                                                                        *
6  * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
7  *          for The ALICE Off-line Project.                               *
8  *                                                                        *
9  * Permission to use, copy, modify and distribute this software and its   *
10  * documentation strictly for non-commercial purposes is hereby granted   *
11  * without fee, provided that the above copyright notice appears in all   *
12  * copies and that both the copyright notice and this permission notice   *
13  * appear in the supporting documentation. The authors make no claims     *
14  * about the suitability of this software for any purpose. It is          *
15  * provided "as is" without express or implied warranty.                  *
16  **************************************************************************/
17
18 /** @file   AliHLTOfflineInterface.cxx
19     @author Matthias Richter
20     @date   
21     @brief  the HLT interface to AliRoot
22 */
23
24 #include "AliHLTOfflineInterface.h"
25 #include "AliHLTLogging.h"
26
27 /** ROOT macro for the implementation of ROOT specific class methods */
28 ClassImp(AliHLTOfflineInterface)
29
30 AliHLTOfflineInterface::AliHLTOfflineInterface()
31   :
32   fpRunLoader(NULL),
33   fpRawReader(NULL),
34   fpESD(NULL)
35 {
36   // see header file for class documentation
37   // or
38   // refer to README to build package
39   // or
40   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
41 }
42
43 AliHLTOfflineInterface* AliHLTOfflineInterface::fAnchor=NULL;
44 AliHLTOfflineInterface* AliHLTOfflineInterface::fCurrent=NULL;
45 int AliHLTOfflineInterface::fCount=0;
46 AliRunLoader* AliHLTOfflineInterface::fgpRunLoader=NULL;
47 AliRawReader* AliHLTOfflineInterface::fgpRawReader=NULL;
48
49 AliHLTOfflineInterface::AliHLTOfflineInterface(AliRunLoader* pRunLoader, AliRawReader* pRawReader)
50   :
51   fpRunLoader(pRunLoader),
52   fpRawReader(pRawReader),
53   fpESD(NULL)
54 {
55 }
56
57 AliHLTOfflineInterface::AliHLTOfflineInterface(const AliHLTOfflineInterface&)
58   :
59   TObject(),
60   fpRunLoader(NULL),
61   fpRawReader(NULL),
62   fpESD(NULL)
63 {
64   // see header file for class documentation
65   //HLTFatal("copy constructor untested");
66 }
67
68 AliHLTOfflineInterface& AliHLTOfflineInterface::operator=(const AliHLTOfflineInterface&)
69
70   // see header file for class documentation
71   //HLTFatal("assignment operator untested");
72   return *this;
73 }
74
75 AliHLTOfflineInterface::~AliHLTOfflineInterface()
76 {
77 }
78
79 AliRunLoader* AliHLTOfflineInterface::GetRunLoader() const
80 {
81   return fpRunLoader!=NULL?fpRunLoader:fgpRunLoader;
82 }
83
84 AliRawReader* AliHLTOfflineInterface::GetRawReader() const
85 {
86   return fpRawReader!=NULL?fpRawReader:fgpRawReader;
87 }
88
89 int AliHLTOfflineInterface::SetESD(Int_t eventNo, AliESD* pESD)
90 {
91   fpESD=pESD;
92   return 0;
93 }
94
95 AliESD* AliHLTOfflineInterface::GetESD() const
96 {
97   return fpESD;
98 }
99
100 int AliHLTOfflineInterface::SetParams(AliRunLoader* runLoader, AliRawReader* rawReader)
101 {
102   // see header file for class documentation
103   int iResult=0;
104   if (fpRunLoader!=NULL && fpRunLoader!=runLoader) {
105     //HLTWarning("overriding previous instance of Run Loader %p with %p", fpRunLoader, runLoader);
106   }
107   fpRunLoader=runLoader;
108   if (fpRawReader!=NULL && fpRawReader!=rawReader) {
109     //HLTWarning("overriding previous instance of RawReader %p with %p", fpRawReader, rawReader);
110   }
111   fpRawReader=rawReader;
112   return iResult;
113 }
114
115 int AliHLTOfflineInterface::Reset()
116 {
117   // see header file for class documentation
118   int iResult=0;
119   fpRunLoader=NULL;
120   fpRawReader=NULL;
121   fpESD=NULL;
122   return iResult;
123 }
124
125 int AliHLTOfflineInterface::SetParamsToComponents(AliRunLoader* runLoader, AliRawReader* rawReader)
126 {
127   // see header file for class documentation
128   AliHLTLogging log;
129   int iResult=0;
130   int count=0;
131   fgpRunLoader=runLoader;
132   fgpRawReader=rawReader;
133   AliHLTOfflineInterface* pCurrent=fAnchor;
134   while (pCurrent!=NULL) {
135     int iLocal=0;
136     if (pCurrent) iLocal=pCurrent->SetParams(runLoader, rawReader);
137     if (iLocal<0) {
138       log.LoggingVarargs(kHLTLogWarning, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
139                         "parameter initialization failed for component %p with result %d", pCurrent, iLocal);
140       if (iResult>=0) iResult=iLocal;
141     }
142     count++;
143     pCurrent=pCurrent->fpNext;
144   }
145   if (iResult>=0) {
146 //       log.LoggingVarargs(kHLTLogInfo, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
147 //                      "parameters set to %d offline interface component(s)", count);
148   }
149   return iResult;
150 }
151
152 int AliHLTOfflineInterface::ResetComponents()
153 {
154   // see header file for class documentation
155   int iResult=0;
156   AliHLTOfflineInterface* pCurrent=fAnchor;
157   while (pCurrent!=NULL) {
158     int iLocal=0;
159     if (pCurrent) iLocal=pCurrent->Reset();
160     if (iLocal<0) {
161       if (iResult>=0) iResult=iLocal;
162     }
163     pCurrent=pCurrent->fpNext;
164   }
165   return iResult;
166 }
167
168 int AliHLTOfflineInterface::FillComponentESDs(int eventNo, AliRunLoader* runLoader, AliESD* esd)
169 {
170   // see header file for class documentation
171   int iResult=0;
172   AliHLTOfflineInterface* pCurrent=fAnchor;
173   while (pCurrent!=NULL) {
174     int iLocal=0;
175     if (pCurrent) {
176       pCurrent->SetESD(eventNo, esd);
177       if (pCurrent->GetRunLoader()!=runLoader) {
178         //HLTWarning("runLoader missmatch: component %p was reconstructed with runLoader %p, but got %p now", pCurrent, pCurrent->GetRunLoader(), runLoader);
179       }
180       iLocal=pCurrent->FillESD(eventNo, runLoader, esd);
181     }
182     if (iLocal<0) {
183       if (iResult>=0) iResult=iLocal;
184     }
185     pCurrent=pCurrent->fpNext;
186   }
187   return iResult;
188 }
189
190 int AliHLTOfflineInterface::Register(AliHLTOfflineInterface* me)
191 {
192   // see header file for function documentation
193   int iResult=0;
194   if (fAnchor==NULL) {
195     fAnchor=me;
196   } else {
197     me->fpNext=fAnchor;
198     fAnchor=me;
199   }
200   fCount++;
201   return iResult;
202 }
203
204 int AliHLTOfflineInterface::Unregister(AliHLTOfflineInterface* me)
205 {
206   // see header file for function documentation
207   int iResult=0;
208   fCurrent=NULL;
209   AliHLTOfflineInterface* prev=NULL;
210   AliHLTOfflineInterface* handler=fAnchor;
211   while (handler!=NULL && handler!=me) {
212     prev=handler;
213     handler=handler->fpNext;
214   }
215   if (handler) {
216     if (prev==NULL) {
217       fAnchor=handler->fpNext;
218     } else {
219       prev->fpNext=handler->fpNext;
220     }
221     fCount--;
222   }
223   return iResult;
224 }