1 //**************************************************************************
2 //* This file is property of and copyright by the ALICE HLT Project *
3 //* ALICE Experiment at CERN, All rights reserved. *
5 //* Primary Authors: S.Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
6 //* for The ALICE HLT Project. *
8 //* Permission to use, copy, modify and distribute this software and its *
9 //* documentation strictly for non-commercial purposes is hereby granted *
10 //* without fee, provided that the above copyright notice appears in all *
11 //* copies and that both the copyright notice and this permission notice *
12 //* appear in the supporting documentation. The authors make no claims *
13 //* about the suitability of this software for any purpose. It is *
14 //* provided "as is" without express or implied warranty. *
15 //**************************************************************************
17 /** @file AliHLTdNdPtAnalysisMergerComponent.cxx
18 @author Sergey Gorbunov
19 @brief Component for ploting charge in clusters
26 #include "AliHLTdNdPtAnalysisMergerComponent.h"
27 #include "AlidNdPtAnalysisPbPb.h"
29 #include "AliCDBEntry.h"
30 #include "AliCDBManager.h"
33 #include "TObjString.h"
34 #include "TObjArray.h"
38 #include "AliESDEvent.h"
39 #include "AliESDtrack.h"
41 #include "AliHLTMessage.h"
42 #include "TTimeStamp.h"
44 //#include "AliHLTTPC.h"
49 AliHLTdNdPtAnalysisMergerComponent::AliHLTdNdPtAnalysisMergerComponent() :
51 fBenchmark("dNdPtMerger"),
54 // see header file for class documentation
56 // refer to README to build package
58 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
62 AliHLTdNdPtAnalysisMergerComponent::~AliHLTdNdPtAnalysisMergerComponent()
64 // see header file for class documentation
66 if( fAnalysis ) delete fAnalysis;
69 // Public functions to implement AliHLTComponent's interface.
70 // These functions are required for the registration process
72 const char* AliHLTdNdPtAnalysisMergerComponent::GetComponentID()
74 // see header file for class documentation
76 return "dNdPtAnalysisMerger";
79 void AliHLTdNdPtAnalysisMergerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
81 // see header file for class documentation
83 list.push_back( kAliHLTDataTypedNdPt|kAliHLTDataOriginAny );
86 AliHLTComponentDataType AliHLTdNdPtAnalysisMergerComponent::GetOutputDataType()
88 // see header file for class documentation
89 return kAliHLTDataTypedNdPt | kAliHLTDataOriginOut;
92 void AliHLTdNdPtAnalysisMergerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
94 // see header file for class documentation
95 // XXX TODO: Find more realistic values.
100 AliHLTComponent* AliHLTdNdPtAnalysisMergerComponent::Spawn()
102 // see header file for class documentation
103 return new AliHLTdNdPtAnalysisMergerComponent;
106 void AliHLTdNdPtAnalysisMergerComponent::SetDefaultConfiguration()
108 // Set default configuration for the CA merger component
109 // Some parameters can be later overwritten from the OCDB
112 fBenchmark.SetTimer(0,"total");
113 fBenchmark.SetTimer(1,"reco");
118 int AliHLTdNdPtAnalysisMergerComponent::ReadConfigurationString( const char* arguments )
120 // Set configuration parameters for the CA merger component from the string
123 if ( !arguments ) return iResult;
125 TString allArgs = arguments;
127 int bMissingParam = 0;
129 TObjArray* pTokens = allArgs.Tokenize( " " );
131 int nArgs = pTokens ? pTokens->GetEntries() : 0;
133 for ( int i = 0; i < nArgs; i++ ) {
134 argument = ( ( TObjString* )pTokens->At( i ) )->GetString();
135 if ( argument.IsNull() ) continue;
136 HLTError( "Unknown option \"%s\"", argument.Data() );
141 if ( bMissingParam ) {
142 HLTError( "Specifier missed for parameter \"%s\"", argument.Data() );
149 int AliHLTdNdPtAnalysisMergerComponent::ReadCDBEntry( const char* cdbEntry, const char* chainId )
151 // see header file for class documentation
153 const char* defaultNotify = "";
157 cdbEntry = "HLT/ConfigAnalysis/dNdPtAnalysisMerger";
158 defaultNotify = " (default)";
162 HLTInfo( "configure from entry \"%s\"%s, chain id %s", cdbEntry, defaultNotify, ( chainId != NULL && chainId[0] != 0 ) ? chainId : "<none>" );
163 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get( cdbEntry );//,GetRunNo());
166 HLTError( "cannot fetch object \"%s\" from CDB", cdbEntry );
170 TObjString* pString = dynamic_cast<TObjString*>( pEntry->GetObject() );
173 HLTError( "configuration object \"%s\" has wrong type, required TObjString", cdbEntry );
177 HLTInfo( "received configuration object string: \"%s\"", pString->GetString().Data() );
179 return ReadConfigurationString( pString->GetString().Data() );
182 int AliHLTdNdPtAnalysisMergerComponent::Configure( const char* cdbEntry, const char* chainId, const char *commandLine )
184 // Configure the component
185 // There are few levels of configuration,
186 // parameters which are set on one step can be overwritten on the next step
189 //* read hard-coded values
191 SetDefaultConfiguration();
193 //* read the default CDB entry
195 int iResult1 = ReadCDBEntry( NULL, chainId );
197 //* read the actual CDB entry if required
199 int iResult2 = ( cdbEntry ) ? ReadCDBEntry( cdbEntry, chainId ) : 0;
201 //* read extra parameters from input (if they are)
205 if ( commandLine && commandLine[0] != '\0' ) {
206 HLTInfo( "received configuration string from HLT framework: \"%s\"", commandLine );
207 iResult3 = ReadConfigurationString( commandLine );
210 return iResult1 ? iResult1 : ( iResult2 ? iResult2 : iResult3 );
213 int AliHLTdNdPtAnalysisMergerComponent::Reconfigure( const char* cdbEntry, const char* chainId )
215 // Reconfigure the component from OCDB
217 return Configure( cdbEntry, chainId, NULL );
221 int AliHLTdNdPtAnalysisMergerComponent::DoInit( int argc, const char** argv )
227 fBenchmark.SetTimer(0,"total");
228 fBenchmark.SetTimer(1,"reco");
230 TString arguments = "";
231 for ( int i = 0; i < argc; i++ ) {
232 if ( !arguments.IsNull() ) arguments += " ";
233 arguments += argv[i];
236 int iResult = Configure( NULL, NULL, arguments.Data() );
241 int AliHLTdNdPtAnalysisMergerComponent::DoDeinit()
243 // see header file for class documentation
245 if( fAnalysis ) delete fAnalysis;
251 int AliHLTdNdPtAnalysisMergerComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/)
253 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) {
257 fBenchmark.StartNewEvent();
262 fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID;
265 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(); i!=NULL; i=GetNextInputBlock() ){
266 fBenchmark.AddInput(i->fSize);
269 TList *list = new TList();
271 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypedNdPt); iter != NULL; iter = GetNextInputObject() ) {
273 AlidNdPtAnalysisPbPb *instance = dynamic_cast<AlidNdPtAnalysisPbPb*>(const_cast<TObject*>( iter ) );
275 HLTWarning("Wrong AlidNdPtAnalysisPbPb object received");
282 if( !list->IsEmpty() ){
284 fAnalysis = new AlidNdPtAnalysisPbPb;
286 HLTError("Out of memory");
290 fAnalysis->Merge(list);
294 if( fAnalysis ) PushBack( (TObject*) fAnalysis, kAliHLTDataTypedNdPt,fUID);
298 HLTInfo(fBenchmark.GetStatistics());