]>
Commit | Line | Data |
---|---|---|
e09e5bba | 1 | // $Id$ |
2 | ||
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
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 | ||
19 | // @file AliHLTGlobalOfflineVertexerComponent.cxx | |
20 | // @author Matthias Richter | |
21 | // @date 2010-04-19 | |
22 | // @brief Component wrapping the offline vertexer | |
23 | // @ingroup alihlt_global | |
24 | ||
25 | #if __GNUC__== 3 | |
26 | using namespace std; | |
27 | #endif | |
28 | ||
29 | #include "AliHLTGlobalOfflineVertexerComponent.h" | |
30 | #include "AliESDEvent.h" | |
31 | #include "AliESDtrack.h" | |
32 | #include "AliVertexerTracks.h" | |
33 | #include "AliESDVertex.h" | |
2471b7fc | 34 | #include "AliGRPRecoParam.h" |
e09e5bba | 35 | #include "AliLog.h" |
36 | #include "TMap.h" | |
37 | ||
38 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
39 | ClassImp(AliHLTGlobalOfflineVertexerComponent) | |
40 | ||
41 | AliHLTGlobalOfflineVertexerComponent::AliHLTGlobalOfflineVertexerComponent() | |
42 | : AliHLTProcessor() | |
43 | , fVertexer(NULL) | |
44 | , fBenchmark("GlobalOfflineVertexer") | |
45 | { | |
46 | // The component subscribes to the HLT ESD and calculates the vertex | |
47 | // using the offline vertexer. | |
48 | // | |
49 | // see header file for class documentation | |
50 | // or | |
51 | // refer to README to build package | |
52 | // or | |
53 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
54 | // | |
55 | // NOTE: all helper classes should be instantiated in DoInit() | |
56 | } | |
57 | ||
58 | AliHLTGlobalOfflineVertexerComponent::~AliHLTGlobalOfflineVertexerComponent() | |
59 | { | |
60 | // destructor | |
61 | // | |
62 | // NOTE: implement proper cleanup in DoDeinit() | |
63 | } | |
64 | ||
65 | const char* AliHLTGlobalOfflineVertexerComponent::GetComponentID() | |
66 | { | |
67 | // component property: id | |
68 | return "GlobalOfflineVertexer"; | |
69 | } | |
70 | ||
71 | void AliHLTGlobalOfflineVertexerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
72 | { | |
73 | // component property: list of input data types | |
74 | list.push_back(kAliHLTDataTypeESDObject); | |
75 | } | |
76 | ||
77 | AliHLTComponentDataType AliHLTGlobalOfflineVertexerComponent::GetOutputDataType() | |
78 | { | |
79 | // component property: output data type | |
80 | return kAliHLTAnyDataType; | |
81 | } | |
82 | ||
83 | void AliHLTGlobalOfflineVertexerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
84 | { | |
85 | // component property: output size estimator | |
86 | constBase = 0; | |
87 | inputMultiplier = 1.0; | |
88 | } | |
89 | ||
90 | void AliHLTGlobalOfflineVertexerComponent::GetOCDBObjectDescription( TMap* const targetMap) | |
91 | { | |
92 | // Get a list of OCDB object description. | |
93 | // The list of objects is provided in a TMap | |
94 | // - key: complete OCDB path, e.g. GRP/GRP/Data | |
95 | // - value: short description why the object is needed | |
96 | // Key and value objects created inside this class go into ownership of | |
97 | // target TMap. | |
98 | if (!targetMap) return; | |
593cd4f6 | 99 | // targetMap->Add(new TObjString("HLT/ConfigHLT/GlobalOfflineVertexer"), |
100 | // new TObjString("configuration object")); | |
e09e5bba | 101 | targetMap->Add(new TObjString("GRP/GRP/Data"), |
102 | new TObjString("GRP object")); | |
103 | } | |
104 | ||
105 | AliHLTComponent* AliHLTGlobalOfflineVertexerComponent::Spawn() | |
106 | { | |
107 | // Spawn function, return new class instance | |
108 | return new AliHLTGlobalOfflineVertexerComponent; | |
109 | } | |
110 | ||
111 | int AliHLTGlobalOfflineVertexerComponent::DoInit( int argc, const char** argv ) | |
112 | { | |
113 | // see header file for class documentation | |
114 | int iResult=0; | |
115 | ||
116 | // init stage 1: default values for all data members | |
117 | ||
118 | // init stage 2: read configuration object | |
119 | // ScanConfigurationArgument() needs to be implemented | |
120 | TString cdbPath="HLT/ConfigHLT/"; | |
121 | cdbPath+=GetComponentID(); | |
122 | ||
123 | // TODO: activate later when the object has been copied to the | |
124 | // Grid OCDB | |
125 | //iResult=ConfigureFromCDBTObjString(cdbPath); | |
126 | ||
127 | // init stage 3: read the component arguments | |
128 | if (iResult>=0) { | |
129 | iResult=ConfigureFromArgumentString(argc, argv); | |
130 | } | |
131 | ||
132 | if (iResult>=0) { | |
133 | // implement the component initialization | |
134 | fVertexer=new AliVertexerTracks; | |
593cd4f6 | 135 | if (fVertexer) { |
136 | fVertexer->SetFieldkG(GetBz()); | |
2471b7fc | 137 | |
138 | // initialize for TPC + ITS primary vertex | |
139 | fVertexer->SetITSMode(); | |
140 | fVertexer->SetConstraintOff(); | |
141 | // get cuts for vertexer from AliGRPRecoParam | |
142 | AliGRPRecoParam *grpRecoParam=NULL; | |
143 | TObject* obj=LoadAndExtractOCDBObject("GRP/Calib/RecoParam"); | |
144 | if (obj) grpRecoParam=dynamic_cast<AliGRPRecoParam*>(obj); | |
145 | if (grpRecoParam) { | |
146 | Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts(); | |
147 | Double_t *cutsVertexer = new Double_t[nCutsVertexer]; | |
148 | grpRecoParam->GetVertexerTracksCutsITS(cutsVertexer); | |
149 | fVertexer->SetCuts(cutsVertexer); | |
150 | delete [] cutsVertexer; cutsVertexer = NULL; | |
151 | } | |
152 | // to run on HLT events we do not require ITS refit | |
153 | fVertexer->SetITSrefitNotRequired(); | |
593cd4f6 | 154 | } |
e09e5bba | 155 | } |
156 | ||
157 | if (iResult<0) { | |
158 | // implement cleanup | |
159 | } | |
160 | ||
161 | fBenchmark.SetTimer(0,"total"); | |
162 | ||
163 | return iResult; | |
164 | } | |
165 | ||
166 | int AliHLTGlobalOfflineVertexerComponent::ScanConfigurationArgument(int /*argc*/, const char** /*argv*/) | |
167 | { | |
168 | // Scan configuration arguments | |
169 | // Return the number of processed arguments | |
170 | // -EPROTO if argument format error (e.g. number expected but not found) | |
171 | // | |
172 | // The AliHLTComponent base class implements a parsing loop for argument strings and | |
173 | // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString | |
174 | // The component needs to implement ScanConfigurationArgument in order to decode the arguments. | |
175 | ||
176 | return 0; | |
177 | } | |
178 | ||
179 | int AliHLTGlobalOfflineVertexerComponent::DoDeinit() | |
180 | { | |
181 | // component cleanup, delete all instances of helper classes here | |
182 | if (fVertexer) delete fVertexer; | |
183 | fVertexer=NULL; | |
184 | ||
185 | return 0; | |
186 | } | |
187 | ||
188 | int AliHLTGlobalOfflineVertexerComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, | |
189 | AliHLTComponentTriggerData& /*trigData*/) | |
190 | { | |
191 | // event processing function | |
2471b7fc | 192 | int iResult=0; |
e09e5bba | 193 | |
194 | // check if this is a data event, there are a couple of special events | |
195 | // which should be ignored for normal processing | |
196 | if (!fVertexer) return -ENODEV; | |
197 | if (!IsDataEvent()) return 0; | |
198 | ||
199 | fBenchmark.StartNewEvent(); | |
200 | fBenchmark.Start(0); | |
201 | ||
2471b7fc | 202 | for (const TObject* obj = GetFirstInputObject(kAliHLTDataTypeESDObject, "AliESDEvent"); |
203 | obj; obj = GetNextInputObject()) { | |
e09e5bba | 204 | |
205 | // input objects are not supposed to be changed by the component, so they | |
206 | // are defined const. However, the implementation of AliESDEvent does not | |
207 | // support this and we need the const_cast | |
593cd4f6 | 208 | AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj)); |
e09e5bba | 209 | if (esd != NULL) { |
593cd4f6 | 210 | esd->GetStdContent(); |
211 | for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) { | |
212 | AliESDtrack* track = esd->GetTrack(i); | |
213 | // TODO: this is just a quick hack, the vertexer requires kITSrefit and | |
214 | // at least 4 points | |
215 | // the HLT reconstruction needs to be adapted according to that requirement | |
216 | // we have to check which flag needs to be set at what stage | |
217 | track->SetStatus(AliESDtrack::kITSrefit); | |
218 | } | |
e09e5bba | 219 | AliESDVertex* vertex=fVertexer->FindPrimaryVertex(esd); |
220 | if (vertex) { | |
221 | AliInfoClass("Offline Vertexer using the HLT ESD:"); | |
222 | vertex->Print(); | |
2471b7fc | 223 | iResult = PushBack( vertex, kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut); |
e09e5bba | 224 | } |
2471b7fc | 225 | break; |
226 | } | |
e09e5bba | 227 | } |
228 | ||
229 | fBenchmark.Stop(0); | |
230 | AliInfoClass( fBenchmark.GetStatistics() ); | |
231 | ||
2471b7fc | 232 | return iResult; |
e09e5bba | 233 | } |
234 | ||
235 | int AliHLTGlobalOfflineVertexerComponent::Reconfigure(const char* cdbEntry, const char* chainId) | |
236 | { | |
237 | // reconfigure the component from the specified CDB entry, or default CDB entry | |
238 | HLTInfo("reconfigure '%s' from entry %s", chainId, cdbEntry); | |
239 | ||
240 | return 0; | |
241 | } | |
242 | ||
243 | int AliHLTGlobalOfflineVertexerComponent::ReadPreprocessorValues(const char* modules) | |
244 | { | |
245 | // read the preprocessor values for the detectors in the modules list | |
246 | int iResult=0; | |
247 | TString detectors(modules!=NULL?modules:""); | |
248 | HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data()); | |
249 | return iResult; | |
250 | } |