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
22 #include "AliHLTdNdPtAnalysisMergerComponent.h"
23 #include "AlidNdPtAnalysisPbPb.h"
25 #include "AliCDBEntry.h"
26 #include "AliCDBManager.h"
29 #include "TObjString.h"
30 #include "TObjArray.h"
34 #include "AliESDEvent.h"
35 #include "AliESDtrack.h"
37 #include "AliHLTMessage.h"
38 #include "TTimeStamp.h"
40 //#include "AliHLTTPC.h"
46 AliHLTdNdPtAnalysisMergerComponent::AliHLTdNdPtAnalysisMergerComponent() :
48 fBenchmark("dNdPtMerger"),
51 // see header file for class documentation
53 // refer to README to build package
55 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
59 AliHLTdNdPtAnalysisMergerComponent::~AliHLTdNdPtAnalysisMergerComponent()
61 // see header file for class documentation
63 if( fAnalysis ) delete fAnalysis;
66 // Public functions to implement AliHLTComponent's interface.
67 // These functions are required for the registration process
69 const char* AliHLTdNdPtAnalysisMergerComponent::GetComponentID()
71 // see header file for class documentation
73 return "dNdPtAnalysisMerger";
76 void AliHLTdNdPtAnalysisMergerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
78 // see header file for class documentation
80 list.push_back( kAliHLTDataTypedNdPt|kAliHLTDataOriginAny );
83 AliHLTComponentDataType AliHLTdNdPtAnalysisMergerComponent::GetOutputDataType()
85 // see header file for class documentation
86 return kAliHLTDataTypedNdPt | kAliHLTDataOriginOut;
89 void AliHLTdNdPtAnalysisMergerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
91 // see header file for class documentation
92 // XXX TODO: Find more realistic values.
97 AliHLTComponent* AliHLTdNdPtAnalysisMergerComponent::Spawn()
99 // see header file for class documentation
100 return new AliHLTdNdPtAnalysisMergerComponent;
103 void AliHLTdNdPtAnalysisMergerComponent::SetDefaultConfiguration()
105 // Set default configuration for the CA merger component
106 // Some parameters can be later overwritten from the OCDB
109 fBenchmark.SetTimer(0,"total");
110 fBenchmark.SetTimer(1,"reco");
115 int AliHLTdNdPtAnalysisMergerComponent::ReadConfigurationString( const char* arguments )
117 // Set configuration parameters for the CA merger component from the string
120 if ( !arguments ) return iResult;
122 TString allArgs = arguments;
124 int bMissingParam = 0;
126 TObjArray* pTokens = allArgs.Tokenize( " " );
128 int nArgs = pTokens ? pTokens->GetEntries() : 0;
130 for ( int i = 0; i < nArgs; i++ ) {
131 argument = ( ( TObjString* )pTokens->At( i ) )->GetString();
132 if ( argument.IsNull() ) continue;
133 HLTError( "Unknown option \"%s\"", argument.Data() );
138 if ( bMissingParam ) {
139 HLTError( "Specifier missed for parameter \"%s\"", argument.Data() );
146 int AliHLTdNdPtAnalysisMergerComponent::ReadCDBEntry( const char* cdbEntry, const char* chainId )
148 // see header file for class documentation
150 const char* defaultNotify = "";
154 cdbEntry = "HLT/ConfigAnalysis/dNdPtAnalysisMerger";
155 defaultNotify = " (default)";
159 HLTInfo( "configure from entry \"%s\"%s, chain id %s", cdbEntry, defaultNotify, ( chainId != NULL && chainId[0] != 0 ) ? chainId : "<none>" );
160 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get( cdbEntry );//,GetRunNo());
163 HLTError( "cannot fetch object \"%s\" from CDB", cdbEntry );
167 TObjString* pString = dynamic_cast<TObjString*>( pEntry->GetObject() );
170 HLTError( "configuration object \"%s\" has wrong type, required TObjString", cdbEntry );
174 HLTInfo( "received configuration object string: \"%s\"", pString->GetString().Data() );
176 return ReadConfigurationString( pString->GetString().Data() );
179 int AliHLTdNdPtAnalysisMergerComponent::Configure( const char* cdbEntry, const char* chainId, const char *commandLine )
181 // Configure the component
182 // There are few levels of configuration,
183 // parameters which are set on one step can be overwritten on the next step
186 //* read hard-coded values
188 SetDefaultConfiguration();
190 //* read the default CDB entry
192 int iResult1 = ReadCDBEntry( NULL, chainId );
194 //* read the actual CDB entry if required
196 int iResult2 = ( cdbEntry ) ? ReadCDBEntry( cdbEntry, chainId ) : 0;
198 //* read extra parameters from input (if they are)
202 if ( commandLine && commandLine[0] != '\0' ) {
203 HLTInfo( "received configuration string from HLT framework: \"%s\"", commandLine );
204 iResult3 = ReadConfigurationString( commandLine );
207 return iResult1 ? iResult1 : ( iResult2 ? iResult2 : iResult3 );
210 int AliHLTdNdPtAnalysisMergerComponent::Reconfigure( const char* cdbEntry, const char* chainId )
212 // Reconfigure the component from OCDB
214 return Configure( cdbEntry, chainId, NULL );
218 int AliHLTdNdPtAnalysisMergerComponent::DoInit( int argc, const char** argv )
224 fBenchmark.SetTimer(0,"total");
225 fBenchmark.SetTimer(1,"reco");
227 TString arguments = "";
228 for ( int i = 0; i < argc; i++ ) {
229 if ( !arguments.IsNull() ) arguments += " ";
230 arguments += argv[i];
233 int iResult = Configure( NULL, NULL, arguments.Data() );
238 int AliHLTdNdPtAnalysisMergerComponent::DoDeinit()
240 // see header file for class documentation
242 if( fAnalysis ) delete fAnalysis;
248 int AliHLTdNdPtAnalysisMergerComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/)
250 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) {
254 fBenchmark.StartNewEvent();
259 fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID;
262 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(); i!=NULL; i=GetNextInputBlock() ){
263 fBenchmark.AddInput(i->fSize);
266 TList *list = new TList();
268 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypedNdPt); iter != NULL; iter = GetNextInputObject() ) {
270 AlidNdPtAnalysisPbPb *instance = dynamic_cast<AlidNdPtAnalysisPbPb*>(const_cast<TObject*>( iter ) );
272 HLTWarning("Wrong AlidNdPtAnalysisPbPb object received");
279 if( !list->IsEmpty() ){
281 fAnalysis = new AlidNdPtAnalysisPbPb;
283 HLTError("Out of memory");
287 fAnalysis->Merge(list);
291 if( fAnalysis ) PushBack( (TObject*) fAnalysis, kAliHLTDataTypedNdPt,fUID);
295 HLTInfo(fBenchmark.GetStatistics());