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