]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/AliHLTGlobalEsdToFlatConverterComponent.cxx
added friends to compare 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"
c2374f56 38#include "AliSysInfo.h"
eb84342b 39
40using namespace std;
41
42/** ROOT macro for the implementation of ROOT specific class methods */
43ClassImp(AliHLTGlobalEsdToFlatConverterComponent)
44
45/*
46 * ---------------------------------------------------------------------------------
47 * Constructor / Destructor
48 * ---------------------------------------------------------------------------------
49 */
50
51// #################################################################################
52AliHLTGlobalEsdToFlatConverterComponent::AliHLTGlobalEsdToFlatConverterComponent() :
53 AliHLTProcessor()
54 {
55 // an example component which implements the ALICE HLT processor
56 // interface and does some analysis on the input raw data
57 //
58 // see header file for class documentation
59 // or
60 // refer to README to build package
61 // or
62 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
63 //
64 // NOTE: all helper classes should be instantiated in DoInit()
65}
66
67// #################################################################################
68AliHLTGlobalEsdToFlatConverterComponent::~AliHLTGlobalEsdToFlatConverterComponent() {
69 // see header file for class documentation
70}
71
72/*
73 * ---------------------------------------------------------------------------------
74 * Public functions to implement AliHLTComponent's interface.
75 * These functions are required for the registration process
76 * ---------------------------------------------------------------------------------
77 */
78
79// #################################################################################
80const Char_t* AliHLTGlobalEsdToFlatConverterComponent::GetComponentID() {
81 // see header file for class documentation
8e0c1b9d 82 return "GlobalEsdToFlatConverter";
eb84342b 83}
84
85// #################################################################################
86void AliHLTGlobalEsdToFlatConverterComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
87 // see header file for class documentation
8e0c1b9d 88 list.push_back(kAliHLTDataTypeESDTree|kAliHLTDataOriginOut );
89 list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut );
eb84342b 90 list.push_back( kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut );
91}
92
a88a189e 93
94AliHLTComponentDataType AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataType()
95{
eb84342b 96 // see header file for class documentation
a88a189e 97 return kAliHLTMultipleDataType;
98}
99
100int AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){
101// see header file for class documentation
102
103 tgtList.clear();
104 tgtList.push_back( kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut );
105 tgtList.push_back( kAliHLTDataTypeFlatESDFriend|kAliHLTDataOriginOut );
106 return tgtList.size();
eb84342b 107}
108
109// #################################################################################
110void AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
111 // see header file for class documentation
a2e57ab1 112 constBase = 10000;
ee82d961 113 inputMultiplier = 10.0;
eb84342b 114}
115
116
117// #################################################################################
118AliHLTComponent* AliHLTGlobalEsdToFlatConverterComponent::Spawn() {
119 // see header file for class documentation
120 return new AliHLTGlobalEsdToFlatConverterComponent;
121}
122
123/*
124 * ---------------------------------------------------------------------------------
125 * Protected functions to implement AliHLTComponent's interface.
126 * These functions provide initialization as well as the actual processing
127 * capabilities of the component.
128 * ---------------------------------------------------------------------------------
129 */
130
131// #################################################################################
132Int_t AliHLTGlobalEsdToFlatConverterComponent::DoInit( Int_t argc, const Char_t** argv ) {
133 // see header file for class documentation
134 printf("AliHLTGlobalEsdToFlatConverterComponent::DoInit\n");
135 // see header file for class documentation
136 int iResult=0;
137 TString argument="";
138 int bMissingParam=0;
139
140 // default list of skiped ESD objects
141 TString skipObjects=
142 // "AliESDRun,"
143 // "AliESDHeader,"
144 // "AliESDZDC,"
145 "AliESDFMD,"
146 // "AliESDVZERO,"
147 // "AliESDTZERO,"
148 // "TPCVertex,"
149 // "SPDVertex,"
150 // "PrimaryVertex,"
151 // "AliMultiplicity,"
152 // "PHOSTrigger,"
153 // "EMCALTrigger,"
154 // "SPDPileupVertices,"
155 // "TrkPileupVertices,"
156 "Cascades,"
157 "Kinks,"
158 "AliRawDataErrorLogs,"
159 "AliESDACORDE";
160
161 iResult=Reconfigure(NULL, NULL);
162 TString allArgs = "";
163 for ( int i = 0; i < argc; i++ ) {
164 if ( !allArgs.IsNull() ) allArgs += " ";
165 allArgs += argv[i];
166 }
167
168 TObjArray* pTokens=allArgs.Tokenize(" ");
169 if (pTokens) {
170 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
171 argument=((TObjString*)pTokens->At(i))->String();
172 if (argument.IsNull()) continue;
173 if (argument.Contains("-skipobject=")) {
174 argument.ReplaceAll("-skipobject=", "");
175 skipObjects=argument;
176 } else {
177 HLTError("unknown argument %s", argument.Data());
178 iResult=-EINVAL;
179 break;
180 }
181 }
182 }
183 if (bMissingParam) {
184 HLTError("missing parameter for argument %s", argument.Data());
185 iResult=-EINVAL;
186 }
187
188
189 if (iResult>=0) {
190 SetupCTPData();
191 }
192
193 return iResult;
194}
195
196
197
198// #################################################################################
199Int_t AliHLTGlobalEsdToFlatConverterComponent::DoDeinit() {
200 // see header file for class documentation
201
202
203 return 0;
204}
205
206// #################################################################################
207Int_t AliHLTGlobalEsdToFlatConverterComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
208 const AliHLTComponentBlockData* /*blocks*/,
209 AliHLTComponentTriggerData& /*trigData*/,
ee82d961 210 AliHLTUInt8_t* outputPtr,
211 AliHLTUInt32_t& size,
eb84342b 212 AliHLTComponentBlockDataList& outputBlocks) {
213 // see header file for class documentation
214
c2374f56 215
216
217
218 AliSysInfo::AddStamp("AliHLTGlobalEsdToFlatConverterComponent::DoEvent.Start");
eb84342b 219 Int_t iResult=0;
220
a88a189e 221 Bool_t err = kFALSE;
a2e57ab1 222
223
224 size_t maxOutputSize = size;
225 size = 0;
226
eb84342b 227 // -- Only use data event
228 if (!IsDataEvent())
229 return 0;
230
b904048c 231 AliESDEvent *esd;
a88a189e 232 AliESDfriend *esdFriend;
8e0c1b9d 233
234
eb84342b 235 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {
b904048c 236 esd =dynamic_cast<AliESDEvent*>(const_cast<TObject*>(iter));
eb84342b 237 if( esd ){
a88a189e 238 cout <<"ESD object found in input"<<endl;
b904048c 239 esd->GetStdContent();
eb84342b 240 iResult=1;
241 } else {
eb84342b 242 }
243 }
244
245 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDfriendObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {
a88a189e 246 esdFriend = dynamic_cast<AliESDfriend*>(const_cast<TObject*>(iter));
eb84342b 247 if( esdFriend ){
a88a189e 248 cout <<"ESD friend object found in input"<<endl;
eb84342b 249 } else {
eb84342b 250 }
251 }
a2e57ab1 252
a88a189e 253 AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent*>(outputPtr);
254 new (flatEsd) AliFlatESDEvent;
255 flatEsd->SetFromESD(AliFlatESDEvent::EstimateSize(esd),esd, kTRUE);
256
257
258
259
a2e57ab1 260
a2e57ab1 261
a88a189e 262
263 if( maxOutputSize > flatEsd->GetSize() ){
eb84342b 264 AliHLTComponentBlockData outBlock;
265 FillBlockData( outBlock );
266 outBlock.fOffset = size;
267 outBlock.fSize = flatEsd->GetSize();
268 outBlock.fDataType = kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
eb84342b 269 outputBlocks.push_back( outBlock );
eb84342b 270 size += outBlock.fSize;
a2e57ab1 271 }
272
273 else {
274
275 return 0;
276 }
a88a189e 277 if(esdFriend){
278 AliFlatESDFriend *flatFriend = reinterpret_cast<AliFlatESDFriend*>(outputPtr + size);
279 size_t freeSpaceTotal = maxOutputSize - size;
280 size_t freeSpace = freeSpaceTotal;
281
282 err = ( freeSpace < sizeof( AliFlatESDEvent ) );
283 if( err ) return 0;
284
285 new (flatFriend) AliFlatESDFriend;
286 freeSpace = freeSpaceTotal - flatFriend->GetSize();
287
288 flatFriend->SetFromESDfriend(AliFlatESDFriend::EstimateSize(esdFriend),esdFriend);
289
290 { // set up the output block description
291
292 AliHLTComponentBlockData outBlock;
293 FillBlockData( outBlock );
294 outBlock.fOffset = size;
295 outBlock.fSize = flatFriend->GetSize();
296 outBlock.fDataType = kAliHLTDataTypeFlatESDFriend|kAliHLTDataOriginOut;
297 outputBlocks.push_back( outBlock );
298 size += outBlock.fSize;
299 }
300
301
302 }
303
c2374f56 304 AliSysInfo::AddStamp("AliHLTGlobalEsdToFlatConverterComponent::DoEvent.Stop",0, flatEsd->GetSize(),flatEsd->GetNumberOfV0s(),flatEsd->GetNumberOfTracks());
eb84342b 305
306
307 return iResult;
308}
309
310
311// #################################################################################
312Int_t AliHLTGlobalEsdToFlatConverterComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
313 // see header file for class documentation
314 ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
315 return 0;
316}
317
318
319int AliHLTGlobalEsdToFlatConverterComponent::Configure(const char* arguments)
320{
321 // see header file for class documentation
322 int iResult=0;
323 if (!arguments) return iResult;
324
325 TString allArgs=arguments;
326 TString argument;
327 int bMissingParam=0;
328
329 TObjArray* pTokens=allArgs.Tokenize(" ");
330 if (pTokens) {
331 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
332 argument=((TObjString*)pTokens->At(i))->String();
333 if (argument.IsNull()) continue;
334 HLTError("unknown argument %s", argument.Data());
335 iResult=-EINVAL;
336 break;
337 }
338 delete pTokens;
339 }
340 if (bMissingParam) {
341 HLTError("missing parameter for argument %s", argument.Data());
342 iResult=-EINVAL;
343 }
344
345 return iResult;
346}
347
348int AliHLTGlobalEsdToFlatConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId)
349{
350 // see header file for class documentation
351 int iResult=0;
352 const char* path=NULL;
353 const char* defaultNotify="";
354 if (cdbEntry) {
355 path=cdbEntry;
356 defaultNotify=" (default)";
357 }
358 if (path) {
359 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
360 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
361 if (pEntry) {
362 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
363 if (pString) {
364 HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
365 iResult=Configure(pString->String().Data());
366 } else {
367 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
368 }
369 } else {
370 HLTError("can not fetch object \"%s\" from CDB", path);
371 }
372 }
373
374 return iResult;
375}