]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/util/AliHLTLoaderPublisherComponent.cxx
corrected compilation warnings
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTLoaderPublisherComponent.cxx
CommitLineData
90ebac25 1// @(#) $Id$
2
9be2600f 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
90ebac25 19/** @file AliHLTLoaderPublisherComponent.cxx
20 @author Matthias Richter
21 @date
22 @brief A general tree publisher component for the AliLoader.
23*/
24
25#include "AliHLTLoaderPublisherComponent.h"
26#include "AliRunLoader.h"
27#include "AliLoader.h"
28#include "AliLog.h"
29#include "TTree.h"
30
31/** global instance for agent registration */
32AliHLTLoaderPublisherComponent gAliHLTLoaderPublisherComponent;
33
34/** ROOT macro for the implementation of ROOT specific class methods */
35ClassImp(AliHLTLoaderPublisherComponent)
36
37AliHLTLoaderPublisherComponent::AliHLTLoaderPublisherComponent()
38 :
39 fMaxSize(0),
40 fLoaderType(),
41 fTreeType("digits"),
42 fVerbose(kFALSE),
43 fDataType(kAliHLTAnyDataType),
44 fSpecification(0),
45 fpLoader(NULL)
46{
47 // see header file for class documentation
48 // or
49 // refer to README to build package
50 // or
51 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
52}
53
79c114b5 54AliHLTLoaderPublisherComponent::AliHLTLoaderPublisherComponent(const AliHLTLoaderPublisherComponent&)
55 :
56 fMaxSize(0),
57 fLoaderType(),
58 fTreeType("digits"),
59 fVerbose(kFALSE),
60 fDataType(kAliHLTAnyDataType),
61 fSpecification(0),
62 fpLoader(NULL)
63{
64 // see header file for class documentation
65}
66
67AliHLTLoaderPublisherComponent& AliHLTLoaderPublisherComponent::operator=(const AliHLTLoaderPublisherComponent&)
68{
69 // see header file for class documentation
70 return *this;
71}
72
90ebac25 73AliHLTLoaderPublisherComponent::~AliHLTLoaderPublisherComponent()
74{
75 // see header file for class documentation
76}
77
78const char* AliHLTLoaderPublisherComponent::GetComponentID()
79{
80 // see header file for class documentation
81 return "AliLoaderPublisher";
82}
83
84AliHLTComponentDataType AliHLTLoaderPublisherComponent::GetOutputDataType()
85{
86 return fDataType;
87}
88
89void AliHLTLoaderPublisherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
90{
91 constBase=fMaxSize;
92 inputMultiplier=1;
93}
94
95AliHLTComponent* AliHLTLoaderPublisherComponent::Spawn()
96{
97 // see header file for class documentation
98 return new AliHLTLoaderPublisherComponent;
99}
100
101int AliHLTLoaderPublisherComponent::DoInit( int argc, const char** argv )
102{
103 // see header file for class documentation
104 int iResult=0;
105
106 // scan arguments
107 TString argument="";
108 int bMissingParam=0;
109 for (int i=0; i<argc && iResult>=0; i++) {
110 argument=argv[i];
111 if (argument.IsNull()) continue;
112
113 // -loader
114 if (argument.CompareTo("-loader")==0) {
115 if ((bMissingParam=(++i>=argc))) break;
116 fLoaderType=argv[i];
117
118 // -tree
119 } else if (argument.CompareTo("-tree")==0) {
120 if ((bMissingParam=(++i>=argc))) break;
121 fTreeType=argv[i];
122
123 // -verbose
124 } else if (argument.CompareTo("-verbose")==0) {
125 fVerbose=kTRUE;
126
127 // -datatype
128 } else if (argument.CompareTo("-datatype")==0) {
129 if ((bMissingParam=(++i>=argc))) break;
130 memcpy(&fDataType.fID, argv[i], TMath::Min(kAliHLTComponentDataTypefIDsize, (Int_t)strlen(argv[i])));
131 if ((bMissingParam=(++i>=argc))) break;
132 memcpy(&fDataType.fOrigin, argv[i], TMath::Min(kAliHLTComponentDataTypefOriginSize, (Int_t)strlen(argv[i])));
133
134 // -dataspec
135 } else if (argument.CompareTo("-dataspec")==0) {
136 if ((bMissingParam=(++i>=argc))) break;
137 TString parameter(argv[i]);
138 parameter.Remove(TString::kLeading, ' '); // remove all blanks
139 if (parameter.IsDigit()) {
140 fSpecification=(AliHLTUInt32_t)parameter.Atoi();
141 } else if (parameter.BeginsWith("0x") &&
142 parameter.Replace(0,2,"",0).IsHex()) {
143 sscanf(parameter.Data(),"%x", &fSpecification);
144 } else {
145 HLTError("wrong parameter for argument %s, number expected", argument.Data());
146 iResult=-EINVAL;
147 }
148 } else {
149 HLTError("unknown argument %s", argument.Data());
150 iResult=-EINVAL;
151 }
152 }
153 if (bMissingParam) {
154 HLTError("missing parameter for argument %s", argument.Data());
155 iResult=-EINVAL;
156 }
157
158 if (iResult<0) return iResult;
159
160 if (fLoaderType.IsNull()) {
161 HLTError("loader type required, use \'-loader\' option");
162 return -EINVAL;
163 }
164
165 // fetch runLoader instance from interface
166 AliRunLoader* pRunLoader=GetRunLoader();
167 if (pRunLoader) {
168
169 // get the TPC loader
170 fpLoader=pRunLoader->GetLoader(fLoaderType.Data());
171 if (fpLoader) {
172 // prepare the loader
173 fpLoader->LoadDigits("read");
174
175 // scan trough all events and estimate the size of the digits
176 for (int i=0; i<pRunLoader->GetNumberOfEvents(); i++) {
177 pRunLoader->GetEvent(i);
178 TTree* pTree=GetTree();
179 if (pTree) {
180 int size=EstimateObjectSize(pTree);
181 if (size>fMaxSize) fMaxSize=size;
182 if (fVerbose) {
183 AliInfoStream() << "event " << i << " "
184 << fTreeType <<" size " << size
185 << " count " << pTree->GetEntries() << endl;
186 }
187 } else {
188 AliWarningStream() << "no " << fTreeType << " tree for event " << i << endl;
189 }
190 }
191 } else {
192 AliErrorStream() << "can not get loader of type " << fLoaderType << endl;
193 iResult=-EFAULT;
194 }
195 } else {
196 AliErrorStream() << "can not get runLoader" << endl;
197 iResult=-EFAULT;
198 }
199 return iResult;
200}
201
202int AliHLTLoaderPublisherComponent::DoDeinit()
203{
204 // see header file for class documentation
205 int iResult=0;
206 if (fpLoader) {
207 fpLoader->UnloadDigits();
208 }
209 fpLoader=NULL;
210 return iResult;
211}
212
298ef463 213int AliHLTLoaderPublisherComponent::GetEvent(const AliHLTComponentEventData& /*evtData*/,
214 AliHLTComponentTriggerData& /*trigData*/)
90ebac25 215{
216 // see header file for class documentation
217 int iResult=0;
218 // fetch runLoader instance from interface
219 AliRunLoader* pRunLoader=GetRunLoader();
220 if (pRunLoader && fpLoader) {
221 pRunLoader->GetEvent(GetEventCount());
222 TTree* pTree=GetTree();
223 if (pTree) {
224 PushBack(pTree, fDataType);
225 } else {
226 AliWarningStream() << "no " << fTreeType << " tree for event " << GetEventCount() << endl;
227 }
228 } else {
229 AliErrorStream() << "component not initialized" << endl;
56951e49 230 iResult=-EFAULT;
90ebac25 231 }
232 return iResult;
233}
234
235TTree* AliHLTLoaderPublisherComponent::GetTree()
236{
237 TTree* pTree=NULL;
238 if (fpLoader) {
239 if (fTreeType.CompareTo("digits")==0)
240 pTree=fpLoader->TreeD();
241 else if (fTreeType.CompareTo("clusters")==0) {
242 pTree=fpLoader->TreeR();
243 }
244 } else {
245 }
246 return pTree;
247}