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"
38 #include "AliSysInfo.h"
42 /** ROOT macro for the implementation of ROOT specific class methods */
43 ClassImp(AliHLTGlobalEsdToFlatConverterComponent)
46 * ---------------------------------------------------------------------------------
47 * Constructor / Destructor
48 * ---------------------------------------------------------------------------------
51 // #################################################################################
52 AliHLTGlobalEsdToFlatConverterComponent::AliHLTGlobalEsdToFlatConverterComponent() :
55 // an example component which implements the ALICE HLT processor
56 // interface and does some analysis on the input raw data
58 // see header file for class documentation
60 // refer to README to build package
62 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
64 // NOTE: all helper classes should be instantiated in DoInit()
67 // #################################################################################
68 AliHLTGlobalEsdToFlatConverterComponent::~AliHLTGlobalEsdToFlatConverterComponent() {
69 // see header file for class documentation
73 * ---------------------------------------------------------------------------------
74 * Public functions to implement AliHLTComponent's interface.
75 * These functions are required for the registration process
76 * ---------------------------------------------------------------------------------
79 // #################################################################################
80 const Char_t* AliHLTGlobalEsdToFlatConverterComponent::GetComponentID() {
81 // see header file for class documentation
82 return "GlobalEsdToFlatConverter";
85 // #################################################################################
86 void AliHLTGlobalEsdToFlatConverterComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
87 // see header file for class documentation
88 list.push_back(kAliHLTDataTypeESDTree|kAliHLTDataOriginOut );
89 list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut );
90 list.push_back( kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut );
93 // #################################################################################
94 AliHLTComponentDataType AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataType() {
95 // see header file for class documentation
96 return kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
99 // #################################################################################
100 void AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
101 // see header file for class documentation
103 inputMultiplier = 10.0;
107 // #################################################################################
108 AliHLTComponent* AliHLTGlobalEsdToFlatConverterComponent::Spawn() {
109 // see header file for class documentation
110 return new AliHLTGlobalEsdToFlatConverterComponent;
114 * ---------------------------------------------------------------------------------
115 * Protected functions to implement AliHLTComponent's interface.
116 * These functions provide initialization as well as the actual processing
117 * capabilities of the component.
118 * ---------------------------------------------------------------------------------
121 // #################################################################################
122 Int_t AliHLTGlobalEsdToFlatConverterComponent::DoInit( Int_t argc, const Char_t** argv ) {
123 // see header file for class documentation
124 printf("AliHLTGlobalEsdToFlatConverterComponent::DoInit\n");
125 // see header file for class documentation
130 // default list of skiped ESD objects
141 // "AliMultiplicity,"
144 // "SPDPileupVertices,"
145 // "TrkPileupVertices,"
148 "AliRawDataErrorLogs,"
151 iResult=Reconfigure(NULL, NULL);
152 TString allArgs = "";
153 for ( int i = 0; i < argc; i++ ) {
154 if ( !allArgs.IsNull() ) allArgs += " ";
158 TObjArray* pTokens=allArgs.Tokenize(" ");
160 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
161 argument=((TObjString*)pTokens->At(i))->String();
162 if (argument.IsNull()) continue;
163 if (argument.Contains("-skipobject=")) {
164 argument.ReplaceAll("-skipobject=", "");
165 skipObjects=argument;
167 HLTError("unknown argument %s", argument.Data());
174 HLTError("missing parameter for argument %s", argument.Data());
188 // #################################################################################
189 Int_t AliHLTGlobalEsdToFlatConverterComponent::DoDeinit() {
190 // see header file for class documentation
196 // #################################################################################
197 Int_t AliHLTGlobalEsdToFlatConverterComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
198 const AliHLTComponentBlockData* /*blocks*/,
199 AliHLTComponentTriggerData& /*trigData*/,
200 AliHLTUInt8_t* outputPtr,
201 AliHLTUInt32_t& size,
202 AliHLTComponentBlockDataList& outputBlocks) {
203 // see header file for class documentation
208 AliSysInfo::AddStamp("AliHLTGlobalEsdToFlatConverterComponent::DoEvent.Start");
213 size_t maxOutputSize = size;
216 // -- Only use data event
223 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {
224 esd =dynamic_cast<AliESDEvent*>(const_cast<TObject*>(iter));
226 esd->GetStdContent();
232 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDfriendObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {
233 //fBenchmark.AddInput(pBlock->fSize);
234 const AliESDfriend *esdFriend = dynamic_cast<const AliESDfriend*>(iter);
241 AliFlatESDEvent *flatEsd ;
243 flatEsd = reinterpret_cast<AliFlatESDEvent*>(outputPtr);
244 new (flatEsd) AliFlatESDEvent;
245 flatEsd->SetFromESD(AliFlatESDEvent::EstimateSize(esd),esd, kTRUE);
248 if( maxOutputSize > flatEsd->GetSize() ){
250 AliHLTComponentBlockData outBlock;
251 FillBlockData( outBlock );
252 outBlock.fOffset = size;
253 outBlock.fSize = flatEsd->GetSize();
254 outBlock.fDataType = kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
255 outBlock.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( 0, 35, 0, 5 );
257 outputBlocks.push_back( outBlock );
259 size += outBlock.fSize;
270 AliSysInfo::AddStamp("AliHLTGlobalEsdToFlatConverterComponent::DoEvent.Stop",0, flatEsd->GetSize(),flatEsd->GetNumberOfV0s(),flatEsd->GetNumberOfTracks());
277 // #################################################################################
278 Int_t AliHLTGlobalEsdToFlatConverterComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
279 // see header file for class documentation
280 ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
285 int AliHLTGlobalEsdToFlatConverterComponent::Configure(const char* arguments)
287 // see header file for class documentation
289 if (!arguments) return iResult;
291 TString allArgs=arguments;
295 TObjArray* pTokens=allArgs.Tokenize(" ");
297 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
298 argument=((TObjString*)pTokens->At(i))->String();
299 if (argument.IsNull()) continue;
300 HLTError("unknown argument %s", argument.Data());
307 HLTError("missing parameter for argument %s", argument.Data());
314 int AliHLTGlobalEsdToFlatConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId)
316 // see header file for class documentation
318 const char* path=NULL;
319 const char* defaultNotify="";
322 defaultNotify=" (default)";
325 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
326 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
328 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
330 HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
331 iResult=Configure(pString->String().Data());
333 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
336 HLTError("can not fetch object \"%s\" from CDB", path);