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