]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/SampleLib/AliHLTSampleESDAnalysisComponent.cxx
Update z position of ADA (Z=1699.7)
[u/mrichter/AliRoot.git] / HLT / SampleLib / AliHLTSampleESDAnalysisComponent.cxx
CommitLineData
e8b9b7f2 1// $Id$
2
3//**************************************************************************
0cfce653 4//* This file is property of and copyright by the *
e8b9b7f2 5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8//* for The ALICE HLT Project. *
9//* *
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//**************************************************************************
18
c5fc3461 19/// @file AliHLTSampleESDAnalysisComponent.cxx
20/// @author Matthias Richter
21/// @date 2010-04-17
22/// @brief A sample processing component for ESD analysis.
23/// @ingroup alihlt_tutorial
e8b9b7f2 24
e8b9b7f2 25#include "AliHLTSampleESDAnalysisComponent.h"
26#include "AliESDEvent.h"
27#include "AliESDtrack.h"
28#include "AliLog.h"
29#include "TMap.h"
30#include "TObjString.h"
31
0cfce653 32using namespace std;
33
e8b9b7f2 34/** ROOT macro for the implementation of ROOT specific class methods */
35ClassImp(AliHLTSampleESDAnalysisComponent)
36
c5fc3461 37/** one global instance used for registration of
38 * AliHLTSampleESDAnalysisComponent
39 * Note: there are two ways of component registration
40 * - via a global object
41 * - via the AliHLTModuleAgent::RegisterComponents function
42 * @see @ref alihlt_component_registration
43 */
e8b9b7f2 44AliHLTSampleESDAnalysisComponent gAliHLTSampleESDAnalysisComponent;
45
46AliHLTSampleESDAnalysisComponent::AliHLTSampleESDAnalysisComponent()
47{
48 // an example component which implements the ALICE HLT processor
49 // interface and does some analysis on the input ESD
50 //
51 // see header file for class documentation
52 // or
53 // refer to README to build package
54 // or
55 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
56 //
57 // NOTE: all helper classes should be instantiated in DoInit()
58}
59
60AliHLTSampleESDAnalysisComponent::~AliHLTSampleESDAnalysisComponent()
61{
62 // destructor
63 //
64 // NOTE: implement proper cleanup in DoDeinit()
65}
66
67const char* AliHLTSampleESDAnalysisComponent::GetComponentID()
68{
69 // component property: id
70 return "SampleESDAnalysis";
71}
72
0cfce653 73void AliHLTSampleESDAnalysisComponent::GetInputDataTypes( AliHLTComponentDataTypeList& list)
e8b9b7f2 74{
75 // component property: list of input data types
c5fc3461 76 list.push_back(kAliHLTDataTypeESDObject);
e8b9b7f2 77}
78
79AliHLTComponentDataType AliHLTSampleESDAnalysisComponent::GetOutputDataType()
80{
81 // component property: output data type
82 return kAliHLTDataTypeTObjArray|kAliHLTDataOriginSample;
83}
84
85void AliHLTSampleESDAnalysisComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
86{
87 // component property: output size estimator
88 constBase = 0;
89 inputMultiplier = 0;
90}
91
92void AliHLTSampleESDAnalysisComponent::GetOCDBObjectDescription( TMap* const targetMap)
93{
94 // Get a list of OCDB object description.
95 // The list of objects is provided in a TMap
96 // - key: complete OCDB path, e.g. GRP/GRP/Data
97 // - value: short description why the object is needed
98 // Key and value objects created inside this class go into ownership of
99 // target TMap.
100 if (!targetMap) return;
101 targetMap->Add(new TObjString("HLT/ConfigSample/SampleESDAnalysis"),
102 new TObjString("configuration object"));
103 targetMap->Add(new TObjString("GRP/GRP/Data"),
104 new TObjString("GRP object"));
105}
106
107AliHLTComponent* AliHLTSampleESDAnalysisComponent::Spawn()
108{
109 // Spawn function, return new class instance
110 return new AliHLTSampleESDAnalysisComponent;
111}
112
113int AliHLTSampleESDAnalysisComponent::DoInit( int argc, const char** argv )
114{
115 // see header file for class documentation
116 int iResult=0;
117
118 // init stage 1: default values for all data members
119
120 // init stage 2: read configuration object
121 // ScanConfigurationArgument() needs to be implemented
122 TString cdbPath="HLT/ConfigSample/";
123 cdbPath+=GetComponentID();
124 iResult=ConfigureFromCDBTObjString(cdbPath);
125
126 // init stage 3: read the component arguments
127 if (iResult>=0) {
128 iResult=ConfigureFromArgumentString(argc, argv);
129 }
130
131 if (iResult>=0) {
132 // implement the component initialization
133 }
134
135 if (iResult<0) {
136 // implement cleanup
137 }
138
139 return iResult;
140}
141
142int AliHLTSampleESDAnalysisComponent::ScanConfigurationArgument(int argc, const char** argv)
143{
144 // Scan configuration arguments
145 // Return the number of processed arguments
146 // -EPROTO if argument format error (e.g. number expected but not found)
147 //
148 // The AliHLTComponent base class implements a parsing loop for argument strings and
149 // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
150 // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
151
152 int i=0;
153 TString argument=argv[i];
154
155 if (argument.IsNull()) return 0;
156
157 // -mandatory1 arg
158 if (argument.CompareTo("-mandatory1")==0) {
159 if (++i>=argc) return -EINVAL;
160 HLTInfo("got \'-mandatory1\' argument: %s", argv[i]);
161 return 2; // keyword + 1 argument
162 }
163
164 // -optional1 arg
165 if (argument.CompareTo("-optional1")==0) {
166 if (++i>=argc) return -EINVAL;
167 HLTInfo("got \'-optional1\' argument: %s", argv[i]);
168 return 2; // keyword + 1 argument
169 }
170
171 // -optional2
172 if (argument.CompareTo("-optional2")==0) {
173 HLTInfo("got \'-optional2\' argument");
174 return 1; // only keyword
175 }
176
177 return 0;
178}
179
180int AliHLTSampleESDAnalysisComponent::DoDeinit()
181{
182 // component cleanup, delete all instances of helper classes here
183
184 return 0;
185}
186
187int AliHLTSampleESDAnalysisComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
188 AliHLTComponentTriggerData& /*trigData*/)
189{
190 // event processing function
191
192 // check if this is a data event, there are a couple of special events
193 // which should be ignored for normal processing
194 if (!IsDataEvent()) return 0;
195
e1fc279a 196 TObjArray output; // an array for publishing the tracks as separate output
197
198 AliInfoClass(Form("==================== event %3d ================================", GetEventCount()));
199 for (const TObject* obj = GetFirstInputObject();
200 obj!=NULL;
201 obj = GetNextInputObject()) {
202 AliInfoClass(Form("object: %s", obj->GetName()));
203 if (obj->IsA()==AliESDEvent::Class()) {
204 // input objects are not supposed to be changed by the component, so they
205 // are defined const. However, the implementation of AliESDEvent does not
206 // support this and we need the const_cast
207 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
208 if (esd != NULL) {
209 esd->GetStdContent();
210 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
211 AliESDtrack* track = esd->GetTrack(i);
212 AliInfoClass(Form("-------------------- track %3d --------------------------------", i));
213 track->Print("");
214 output.Add(track);
215 }
216 }
e8b9b7f2 217 }
218 }
219
220 // publish the array of tracks as output
221 PushBack(&output, kAliHLTDataTypeTObjArray|kAliHLTDataOriginSample);
222
223 return 0;
224}
225
226int AliHLTSampleESDAnalysisComponent::Reconfigure(const char* cdbEntry, const char* chainId)
227{
228 // reconfigure the component from the specified CDB entry, or default CDB entry
229 HLTInfo("reconfigure '%s' from entry %s", chainId, cdbEntry);
230
231 return 0;
232}
233
234int AliHLTSampleESDAnalysisComponent::ReadPreprocessorValues(const char* modules)
235{
236 // read the preprocessor values for the detectors in the modules list
237 int iResult=0;
238 TString detectors(modules!=NULL?modules:"");
239 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());
240 return iResult;
241}