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 "GlobalEsdToFlatConverster";
84 // #################################################################################
85 void AliHLTGlobalEsdToFlatConverterComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
86 // see header file for class documentation
87 list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginOut);
88 list.push_back( kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut );
91 // #################################################################################
92 AliHLTComponentDataType AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataType() {
93 // see header file for class documentation
94 return kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
97 // #################################################################################
98 void AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
99 // see header file for class documentation
101 inputMultiplier = 1.0;
105 // #################################################################################
106 AliHLTComponent* AliHLTGlobalEsdToFlatConverterComponent::Spawn() {
107 // see header file for class documentation
108 return new AliHLTGlobalEsdToFlatConverterComponent;
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 * ---------------------------------------------------------------------------------
119 // #################################################################################
120 Int_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
128 // default list of skiped ESD objects
139 // "AliMultiplicity,"
142 // "SPDPileupVertices,"
143 // "TrkPileupVertices,"
146 "AliRawDataErrorLogs,"
149 iResult=Reconfigure(NULL, NULL);
150 TString allArgs = "";
151 for ( int i = 0; i < argc; i++ ) {
152 if ( !allArgs.IsNull() ) allArgs += " ";
156 TObjArray* pTokens=allArgs.Tokenize(" ");
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;
165 HLTError("unknown argument %s", argument.Data());
172 HLTError("missing parameter for argument %s", argument.Data());
186 // #################################################################################
187 Int_t AliHLTGlobalEsdToFlatConverterComponent::DoDeinit() {
188 // see header file for class documentation
194 // #################################################################################
195 Int_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
203 printf("AliHLTGlobalEsdToFlatConverterComponent::DoEvent\n");
206 // -- Only use data event
210 const AliESDEvent *esd;
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);
216 cout<<"N ESD tracks: "<<esd->GetNumberOfTracks()<<endl;
219 cout<<"ESD pointer is NULL "<<endl;
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);
228 cout<<"N friend tracks: "<<esdFriend->GetNumberOfTracks()<<endl;
230 cout<<"ESD friend pointer is NULL "<<endl;
239 Bool_t useESDFriends = 0;
240 AliFlatESDEvent *flatEsd ;
241 Byte_t *mem = new Byte_t[AliFlatESDEvent::EstimateSize(const_cast<AliESDEvent*>(esd), useESDFriends)];
243 flatEsd = reinterpret_cast<AliFlatESDEvent*>(mem);
244 new (flatEsd) AliFlatESDEvent;
245 flatEsd->Fill(esd,useESDFriends);
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 );
259 outputBlocks.push_back( outBlock );
261 size += outBlock.fSize;
271 // #################################################################################
272 Int_t AliHLTGlobalEsdToFlatConverterComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
273 // see header file for class documentation
274 ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
279 int AliHLTGlobalEsdToFlatConverterComponent::Configure(const char* arguments)
281 // see header file for class documentation
283 if (!arguments) return iResult;
285 TString allArgs=arguments;
289 TObjArray* pTokens=allArgs.Tokenize(" ");
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());
301 HLTError("missing parameter for argument %s", argument.Data());
308 int AliHLTGlobalEsdToFlatConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId)
310 // see header file for class documentation
312 const char* path=NULL;
313 const char* defaultNotify="";
316 defaultNotify=" (default)";
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()*/);
322 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
324 HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
325 iResult=Configure(pString->String().Data());
327 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
330 HLTError("can not fetch object \"%s\" from CDB", path);