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. *
7 * Primary Authors: Steffen Weber *
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 **************************************************************************/
18 /** @file AliHLTGlobalEsdToFlatConverterComponent.cxx
20 @brief Component to convert ESD objects to flatESD objects
25 #include "TTimeStamp.h"
26 #include "TObjString.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"
36 #include "AliCDBEntry.h"
37 #include "AliCDBManager.h"
41 /** ROOT macro for the implementation of ROOT specific class methods */
42 ClassImp(AliHLTGlobalEsdToFlatConverterComponent)
45 * ---------------------------------------------------------------------------------
46 * Constructor / Destructor
47 * ---------------------------------------------------------------------------------
50 // #################################################################################
51 AliHLTGlobalEsdToFlatConverterComponent::AliHLTGlobalEsdToFlatConverterComponent() :
54 // an example component which implements the ALICE HLT processor
55 // interface and does some analysis on the input raw data
57 // see header file for class documentation
59 // refer to README to build package
61 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
63 // NOTE: all helper classes should be instantiated in DoInit()
66 // #################################################################################
67 AliHLTGlobalEsdToFlatConverterComponent::~AliHLTGlobalEsdToFlatConverterComponent() {
68 // see header file for class documentation
72 * ---------------------------------------------------------------------------------
73 * Public functions to implement AliHLTComponent's interface.
74 * These functions are required for the registration process
75 * ---------------------------------------------------------------------------------
78 // #################################################################################
79 const Char_t* AliHLTGlobalEsdToFlatConverterComponent::GetComponentID() {
80 // see header file for class documentation
81 return "GlobalEsdToFlatConverter";
84 // #################################################################################
85 void AliHLTGlobalEsdToFlatConverterComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
86 // see header file for class documentation
87 list.push_back(kAliHLTDataTypeESDTree|kAliHLTDataOriginOut );
88 list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut );
89 list.push_back( kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut );
92 // #################################################################################
93 AliHLTComponentDataType AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataType() {
94 // see header file for class documentation
95 return kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
98 // #################################################################################
99 void AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
100 // see header file for class documentation
102 inputMultiplier = 1.0;
106 // #################################################################################
107 AliHLTComponent* AliHLTGlobalEsdToFlatConverterComponent::Spawn() {
108 // see header file for class documentation
109 return new AliHLTGlobalEsdToFlatConverterComponent;
113 * ---------------------------------------------------------------------------------
114 * Protected functions to implement AliHLTComponent's interface.
115 * These functions provide initialization as well as the actual processing
116 * capabilities of the component.
117 * ---------------------------------------------------------------------------------
120 // #################################################################################
121 Int_t AliHLTGlobalEsdToFlatConverterComponent::DoInit( Int_t argc, const Char_t** argv ) {
122 // see header file for class documentation
123 printf("AliHLTGlobalEsdToFlatConverterComponent::DoInit\n");
124 // see header file for class documentation
129 // default list of skiped ESD objects
140 // "AliMultiplicity,"
143 // "SPDPileupVertices,"
144 // "TrkPileupVertices,"
147 "AliRawDataErrorLogs,"
150 iResult=Reconfigure(NULL, NULL);
151 TString allArgs = "";
152 for ( int i = 0; i < argc; i++ ) {
153 if ( !allArgs.IsNull() ) allArgs += " ";
157 TObjArray* pTokens=allArgs.Tokenize(" ");
159 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
160 argument=((TObjString*)pTokens->At(i))->String();
161 if (argument.IsNull()) continue;
162 if (argument.Contains("-skipobject=")) {
163 argument.ReplaceAll("-skipobject=", "");
164 skipObjects=argument;
166 HLTError("unknown argument %s", argument.Data());
173 HLTError("missing parameter for argument %s", argument.Data());
187 // #################################################################################
188 Int_t AliHLTGlobalEsdToFlatConverterComponent::DoDeinit() {
189 // see header file for class documentation
195 // #################################################################################
196 Int_t AliHLTGlobalEsdToFlatConverterComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
197 const AliHLTComponentBlockData* /*blocks*/,
198 AliHLTComponentTriggerData& /*trigData*/,
199 AliHLTUInt8_t* /*outputPtr*/,
200 AliHLTUInt32_t& /*size*/,
201 AliHLTComponentBlockDataList& outputBlocks) {
202 // see header file for class documentation
204 printf("AliHLTGlobalEsdToFlatConverterComponent::DoEvent\n");
207 // -- Only use data event
218 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDTree | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {
219 cout<<"Found ESD tree in esd test component !!!"<<endl;
221 tree = dynamic_cast<const TTree*>(iter);
223 pEsd->ReadFromTree( const_cast< TTree*>(tree) );
225 cout<<"N ESD tracks: "<<pEsd->GetNumberOfTracks()<<endl;
228 cout<<"ESD pointer is NULL "<<endl;
238 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {
239 cout<<"Found ESD in esd test component !!!"<<endl;
240 esd =dynamic_cast<AliESDEvent*>(const_cast<TObject*>(iter));
242 esd->GetStdContent();
243 cout<<"N ESD tracks: "<<esd->GetNumberOfTracks()<<endl;
246 cout<<"ESD pointer is NULL "<<endl;
250 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDfriendObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {
251 //fBenchmark.AddInput(pBlock->fSize);
252 cout<<"Found ESD friend in esd test component !!!"<<endl;
253 const AliESDfriend *esdFriend = dynamic_cast<const AliESDfriend*>(iter);
255 cout<<"N friend tracks: "<<esdFriend->GetNumberOfTracks()<<endl;
257 cout<<"ESD friend pointer is NULL "<<endl;
266 Bool_t useESDFriends = 0;
267 AliFlatESDEvent *flatEsd ;
268 Byte_t *mem = new Byte_t[AliFlatESDEvent::EstimateSize(const_cast<AliESDEvent*>(esd), useESDFriends)];
270 flatEsd = reinterpret_cast<AliFlatESDEvent*>(mem);
271 new (flatEsd) AliFlatESDEvent;
272 // flatEsd->Fill(esd,useESDFriends);
279 AliHLTComponentBlockData outBlock;
280 FillBlockData( outBlock );
281 outBlock.fOffset = size;
282 outBlock.fSize = flatEsd->GetSize();
283 outBlock.fDataType = kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
284 outBlock.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( 0, 35, 0, 5 );
286 outputBlocks.push_back( outBlock );
288 size += outBlock.fSize;
298 // #################################################################################
299 Int_t AliHLTGlobalEsdToFlatConverterComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
300 // see header file for class documentation
301 ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
306 int AliHLTGlobalEsdToFlatConverterComponent::Configure(const char* arguments)
308 // see header file for class documentation
310 if (!arguments) return iResult;
312 TString allArgs=arguments;
316 TObjArray* pTokens=allArgs.Tokenize(" ");
318 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
319 argument=((TObjString*)pTokens->At(i))->String();
320 if (argument.IsNull()) continue;
321 HLTError("unknown argument %s", argument.Data());
328 HLTError("missing parameter for argument %s", argument.Data());
335 int AliHLTGlobalEsdToFlatConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId)
337 // see header file for class documentation
339 const char* path=NULL;
340 const char* defaultNotify="";
343 defaultNotify=" (default)";
346 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
347 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
349 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
351 HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
352 iResult=Configure(pString->String().Data());
354 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
357 HLTError("can not fetch object \"%s\" from CDB", path);