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: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 // @file AliHLTSampleESDAnalysisComponent.cxx
20 // @author Matthias Richter
22 // @brief A sample processing component for ESD analysis.
23 // @ingroup alihlt_tutorial
29 #include "AliHLTSampleESDAnalysisComponent.h"
30 #include "AliESDEvent.h"
31 #include "AliESDtrack.h"
34 #include "TObjString.h"
36 /** ROOT macro for the implementation of ROOT specific class methods */
37 ClassImp(AliHLTSampleESDAnalysisComponent)
39 /** one global instance used for registration */
40 AliHLTSampleESDAnalysisComponent gAliHLTSampleESDAnalysisComponent;
42 AliHLTSampleESDAnalysisComponent::AliHLTSampleESDAnalysisComponent()
44 // an example component which implements the ALICE HLT processor
45 // interface and does some analysis on the input ESD
47 // see header file for class documentation
49 // refer to README to build package
51 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
53 // NOTE: all helper classes should be instantiated in DoInit()
56 AliHLTSampleESDAnalysisComponent::~AliHLTSampleESDAnalysisComponent()
60 // NOTE: implement proper cleanup in DoDeinit()
63 const char* AliHLTSampleESDAnalysisComponent::GetComponentID()
65 // component property: id
66 return "SampleESDAnalysis";
69 void AliHLTSampleESDAnalysisComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
71 // component property: list of input data types
72 list.push_back(kAliHLTDataTypeESDObject);
75 AliHLTComponentDataType AliHLTSampleESDAnalysisComponent::GetOutputDataType()
77 // component property: output data type
78 return kAliHLTDataTypeTObjArray|kAliHLTDataOriginSample;
81 void AliHLTSampleESDAnalysisComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
83 // component property: output size estimator
88 void AliHLTSampleESDAnalysisComponent::GetOCDBObjectDescription( TMap* const targetMap)
90 // Get a list of OCDB object description.
91 // The list of objects is provided in a TMap
92 // - key: complete OCDB path, e.g. GRP/GRP/Data
93 // - value: short description why the object is needed
94 // Key and value objects created inside this class go into ownership of
96 if (!targetMap) return;
97 targetMap->Add(new TObjString("HLT/ConfigSample/SampleESDAnalysis"),
98 new TObjString("configuration object"));
99 targetMap->Add(new TObjString("GRP/GRP/Data"),
100 new TObjString("GRP object"));
103 AliHLTComponent* AliHLTSampleESDAnalysisComponent::Spawn()
105 // Spawn function, return new class instance
106 return new AliHLTSampleESDAnalysisComponent;
109 int AliHLTSampleESDAnalysisComponent::DoInit( int argc, const char** argv )
111 // see header file for class documentation
114 // init stage 1: default values for all data members
116 // init stage 2: read configuration object
117 // ScanConfigurationArgument() needs to be implemented
118 TString cdbPath="HLT/ConfigSample/";
119 cdbPath+=GetComponentID();
120 iResult=ConfigureFromCDBTObjString(cdbPath);
122 // init stage 3: read the component arguments
124 iResult=ConfigureFromArgumentString(argc, argv);
128 // implement the component initialization
138 int AliHLTSampleESDAnalysisComponent::ScanConfigurationArgument(int argc, const char** argv)
140 // Scan configuration arguments
141 // Return the number of processed arguments
142 // -EPROTO if argument format error (e.g. number expected but not found)
144 // The AliHLTComponent base class implements a parsing loop for argument strings and
145 // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
146 // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
149 TString argument=argv[i];
151 if (argument.IsNull()) return 0;
154 if (argument.CompareTo("-mandatory1")==0) {
155 if (++i>=argc) return -EINVAL;
156 HLTInfo("got \'-mandatory1\' argument: %s", argv[i]);
157 return 2; // keyword + 1 argument
161 if (argument.CompareTo("-optional1")==0) {
162 if (++i>=argc) return -EINVAL;
163 HLTInfo("got \'-optional1\' argument: %s", argv[i]);
164 return 2; // keyword + 1 argument
168 if (argument.CompareTo("-optional2")==0) {
169 HLTInfo("got \'-optional2\' argument");
170 return 1; // only keyword
176 int AliHLTSampleESDAnalysisComponent::DoDeinit()
178 // component cleanup, delete all instances of helper classes here
183 int AliHLTSampleESDAnalysisComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
184 AliHLTComponentTriggerData& /*trigData*/)
186 // event processing function
188 // check if this is a data event, there are a couple of special events
189 // which should be ignored for normal processing
190 if (!IsDataEvent()) return 0;
192 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
194 // input objects are not supposed to be changed by the component, so they
195 // are defined const. However, the implementation of AliESDEvent does not
196 // support this and we need the const_cast
197 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
200 AliInfoClass(Form("==================== event %3d ================================", GetEventCount()));
201 esd->GetStdContent();
202 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
203 AliESDtrack* track = esd->GetTrack(i);
204 AliInfoClass(Form("-------------------- track %3d --------------------------------", i));
210 // publish the array of tracks as output
211 PushBack(&output, kAliHLTDataTypeTObjArray|kAliHLTDataOriginSample);
216 int AliHLTSampleESDAnalysisComponent::Reconfigure(const char* cdbEntry, const char* chainId)
218 // reconfigure the component from the specified CDB entry, or default CDB entry
219 HLTInfo("reconfigure '%s' from entry %s", chainId, cdbEntry);
224 int AliHLTSampleESDAnalysisComponent::ReadPreprocessorValues(const char* modules)
226 // read the preprocessor values for the detectors in the modules list
228 TString detectors(modules!=NULL?modules:"");
229 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());