]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/AliHLTGlobalEsdToFlatConverterComponent.cxx
update on esd to flat converter component
[u/mrichter/AliRoot.git] / HLT / global / AliHLTGlobalEsdToFlatConverterComponent.cxx
CommitLineData
eb84342b 1//-*- Mode: C++ -*-
2// $Id: AliHLTGlobalEsdToFlatConverterComponent.cxx $
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: Steffen Weber *
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 AliHLTGlobalEsdToFlatConverterComponent.cxx
19 @author Steffen Weber
20 @brief Component to convert ESD objects to flatESD objects
21*/
22
23#include "TMap.h"
24#include "TSystem.h"
25#include "TTimeStamp.h"
26#include "TObjString.h"
27#include "TList.h"
28#include "AliESDEvent.h"
29#include "AliFlatESDEvent.h"
30#include "AliHLTErrorGuard.h"
31#include "AliHLTDataTypes.h"
32#include "AliHLTGlobalEsdToFlatConverterComponent.h"
33#include "AliHLTITSClusterDataFormat.h"
34#include "AliHLTTPCDefinitions.h"
35#include "TTree.h"
36#include "AliCDBEntry.h"
37#include "AliCDBManager.h"
38
39using namespace std;
40
41/** ROOT macro for the implementation of ROOT specific class methods */
42ClassImp(AliHLTGlobalEsdToFlatConverterComponent)
43
44/*
45 * ---------------------------------------------------------------------------------
46 * Constructor / Destructor
47 * ---------------------------------------------------------------------------------
48 */
49
50// #################################################################################
51AliHLTGlobalEsdToFlatConverterComponent::AliHLTGlobalEsdToFlatConverterComponent() :
52 AliHLTProcessor()
53 {
54 // an example component which implements the ALICE HLT processor
55 // interface and does some analysis on the input raw data
56 //
57 // see header file for class documentation
58 // or
59 // refer to README to build package
60 // or
61 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
62 //
63 // NOTE: all helper classes should be instantiated in DoInit()
64}
65
66// #################################################################################
67AliHLTGlobalEsdToFlatConverterComponent::~AliHLTGlobalEsdToFlatConverterComponent() {
68 // see header file for class documentation
69}
70
71/*
72 * ---------------------------------------------------------------------------------
73 * Public functions to implement AliHLTComponent's interface.
74 * These functions are required for the registration process
75 * ---------------------------------------------------------------------------------
76 */
77
78// #################################################################################
79const Char_t* AliHLTGlobalEsdToFlatConverterComponent::GetComponentID() {
80 // see header file for class documentation
81 return "GlobalEsdToFlatConverster";
82}
83
84// #################################################################################
85void AliHLTGlobalEsdToFlatConverterComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
86 // see header file for class documentation
87 list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginOut);
88 list.push_back( kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut );
89}
90
91// #################################################################################
92AliHLTComponentDataType AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataType() {
93 // see header file for class documentation
94 return kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
95}
96
97// #################################################################################
98void AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
99 // see header file for class documentation
100 constBase = 100000;
101 inputMultiplier = 1.0;
102}
103
104
105// #################################################################################
106AliHLTComponent* AliHLTGlobalEsdToFlatConverterComponent::Spawn() {
107 // see header file for class documentation
108 return new AliHLTGlobalEsdToFlatConverterComponent;
109}
110
111/*
112 * ---------------------------------------------------------------------------------
113 * Protected functions to implement AliHLTComponent's interface.
114 * These functions provide initialization as well as the actual processing
115 * capabilities of the component.
116 * ---------------------------------------------------------------------------------
117 */
118
119// #################################################################################
120Int_t AliHLTGlobalEsdToFlatConverterComponent::DoInit( Int_t argc, const Char_t** argv ) {
121 // see header file for class documentation
122 printf("AliHLTGlobalEsdToFlatConverterComponent::DoInit\n");
123 // see header file for class documentation
124 int iResult=0;
125 TString argument="";
126 int bMissingParam=0;
127
128 // default list of skiped ESD objects
129 TString skipObjects=
130 // "AliESDRun,"
131 // "AliESDHeader,"
132 // "AliESDZDC,"
133 "AliESDFMD,"
134 // "AliESDVZERO,"
135 // "AliESDTZERO,"
136 // "TPCVertex,"
137 // "SPDVertex,"
138 // "PrimaryVertex,"
139 // "AliMultiplicity,"
140 // "PHOSTrigger,"
141 // "EMCALTrigger,"
142 // "SPDPileupVertices,"
143 // "TrkPileupVertices,"
144 "Cascades,"
145 "Kinks,"
146 "AliRawDataErrorLogs,"
147 "AliESDACORDE";
148
149 iResult=Reconfigure(NULL, NULL);
150 TString allArgs = "";
151 for ( int i = 0; i < argc; i++ ) {
152 if ( !allArgs.IsNull() ) allArgs += " ";
153 allArgs += argv[i];
154 }
155
156 TObjArray* pTokens=allArgs.Tokenize(" ");
157 if (pTokens) {
158 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
159 argument=((TObjString*)pTokens->At(i))->String();
160 if (argument.IsNull()) continue;
161 if (argument.Contains("-skipobject=")) {
162 argument.ReplaceAll("-skipobject=", "");
163 skipObjects=argument;
164 } else {
165 HLTError("unknown argument %s", argument.Data());
166 iResult=-EINVAL;
167 break;
168 }
169 }
170 }
171 if (bMissingParam) {
172 HLTError("missing parameter for argument %s", argument.Data());
173 iResult=-EINVAL;
174 }
175
176
177 if (iResult>=0) {
178 SetupCTPData();
179 }
180
181 return iResult;
182}
183
184
185
186// #################################################################################
187Int_t AliHLTGlobalEsdToFlatConverterComponent::DoDeinit() {
188 // see header file for class documentation
189
190
191 return 0;
192}
193
194// #################################################################################
195Int_t AliHLTGlobalEsdToFlatConverterComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
196 const AliHLTComponentBlockData* /*blocks*/,
197 AliHLTComponentTriggerData& /*trigData*/,
198 AliHLTUInt8_t* outputPtr,
199 AliHLTUInt32_t& size,
200 AliHLTComponentBlockDataList& outputBlocks) {
201 // see header file for class documentation
202
203 printf("AliHLTGlobalEsdToFlatConverterComponent::DoEvent\n");
204 Int_t iResult=0;
205
206 // -- Only use data event
207 if (!IsDataEvent())
208 return 0;
209
210 const AliESDEvent *esd;
211
212 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {
213 cout<<"Found ESD in esd test component !!!"<<endl;
214 esd = dynamic_cast<const AliESDEvent*>(iter);
215 if( esd ){
216 cout<<"N ESD tracks: "<<esd->GetNumberOfTracks()<<endl;
217 iResult=1;
218 } else {
219 cout<<"ESD pointer is NULL "<<endl;
220 }
221 }
222
223 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDfriendObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {
224 //fBenchmark.AddInput(pBlock->fSize);
225 cout<<"Found ESD friend in esd test component !!!"<<endl;
226 const AliESDfriend *esdFriend = dynamic_cast<const AliESDfriend*>(iter);
227 if( esdFriend ){
228 cout<<"N friend tracks: "<<esdFriend->GetNumberOfTracks()<<endl;
229 } else {
230 cout<<"ESD friend pointer is NULL "<<endl;
231 }
232 }
233
234
235
236 if (iResult>=0) {
237
238
239 Bool_t useESDFriends = 0;
240 AliFlatESDEvent *flatEsd ;
241 Byte_t *mem = new Byte_t[AliFlatESDEvent::EstimateSize(const_cast<AliESDEvent*>(esd), useESDFriends)];
242
243 flatEsd = reinterpret_cast<AliFlatESDEvent*>(mem);
244 new (flatEsd) AliFlatESDEvent;
e2346810 245// flatEsd->Fill(esd,useESDFriends);
eb84342b 246
247
248
249
250
251
252 AliHLTComponentBlockData outBlock;
253 FillBlockData( outBlock );
254 outBlock.fOffset = size;
255 outBlock.fSize = flatEsd->GetSize();
256 outBlock.fDataType = kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
257 outBlock.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( 0, 35, 0, 5 );
258
259 outputBlocks.push_back( outBlock );
260
261 size += outBlock.fSize;
262 }
263
264
265
266
267 return iResult;
268}
269
270
271// #################################################################################
272Int_t AliHLTGlobalEsdToFlatConverterComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
273 // see header file for class documentation
274 ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
275 return 0;
276}
277
278
279int AliHLTGlobalEsdToFlatConverterComponent::Configure(const char* arguments)
280{
281 // see header file for class documentation
282 int iResult=0;
283 if (!arguments) return iResult;
284
285 TString allArgs=arguments;
286 TString argument;
287 int bMissingParam=0;
288
289 TObjArray* pTokens=allArgs.Tokenize(" ");
290 if (pTokens) {
291 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
292 argument=((TObjString*)pTokens->At(i))->String();
293 if (argument.IsNull()) continue;
294 HLTError("unknown argument %s", argument.Data());
295 iResult=-EINVAL;
296 break;
297 }
298 delete pTokens;
299 }
300 if (bMissingParam) {
301 HLTError("missing parameter for argument %s", argument.Data());
302 iResult=-EINVAL;
303 }
304
305 return iResult;
306}
307
308int AliHLTGlobalEsdToFlatConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId)
309{
310 // see header file for class documentation
311 int iResult=0;
312 const char* path=NULL;
313 const char* defaultNotify="";
314 if (cdbEntry) {
315 path=cdbEntry;
316 defaultNotify=" (default)";
317 }
318 if (path) {
319 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
320 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
321 if (pEntry) {
322 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
323 if (pString) {
324 HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
325 iResult=Configure(pString->String().Data());
326 } else {
327 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
328 }
329 } else {
330 HLTError("can not fetch object \"%s\" from CDB", path);
331 }
332 }
333
334 return iResult;
335}