]>
Commit | Line | Data |
---|---|---|
f078d002 | 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: Timur Pocheptsov <Timur.Pocheptsov@cern.ch> * | |
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 AliHLTV0FinderComponent.cxx | |
20 | /// @author Timur Pocheptsov | |
21 | /// @date 2010-12-26 | |
22 | /// @brief V0 finder component | |
23 | /// | |
24 | ||
25 | #include "TString.h" | |
26 | ||
27 | #include "AliHLTDataTypes.h" | |
28 | #include "AliHLTV0FinderComponent.h" | |
29 | ||
30 | ClassImp(AliHLTV0FinderComponent) | |
31 | ||
32 | const double AliHLTV0FinderComponent::fgDaughterPrimDeviation = 2.5; | |
33 | const double AliHLTV0FinderComponent::fgPrimDeviation = 3.5; | |
34 | const double AliHLTV0FinderComponent::fgChi = 3.5; | |
35 | const double AliHLTV0FinderComponent::fgDecayLengthInSigmas = 3.; | |
36 | ||
37 | //________________________________________________________________________ | |
38 | AliHLTV0FinderComponent::AliHLTV0FinderComponent() | |
39 | : fPrimaryVtx(), | |
40 | fPrimaryTracks(), | |
41 | fNPrimaryTracks(0), | |
42 | fMinPrimID(0), | |
43 | fMaxPrimID(0), | |
44 | fDaughterPrimDeviation(fgDaughterPrimDeviation), | |
45 | fPrimDeviation(fgPrimDeviation), | |
46 | fChi(fgChi), | |
47 | fDecayLengthInSigmas(fgDecayLengthInSigmas), | |
48 | fPosPID(211), | |
49 | fNegPID(211), | |
50 | fV0s(), | |
51 | fGammaFinder(false) | |
52 | { | |
53 | //Default ctor. | |
54 | } | |
55 | ||
56 | //________________________________________________________________________ | |
57 | const char* AliHLTV0FinderComponent::GetComponentID() | |
58 | { | |
59 | //Component's "name". | |
60 | return "V0Finder"; | |
61 | } | |
62 | ||
63 | //________________________________________________________________________ | |
64 | void AliHLTV0FinderComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) | |
65 | { | |
66 | //Input to the primary vertex finder: | |
67 | //a)tracks from ESD object; | |
68 | //b)hlt tracks (ITS) | |
69 | //c)hlt tracks (TPC) | |
70 | //d)primary vertex (AliKFVertex) | |
71 | //e)indices of primary tracks. | |
72 | list.clear(); | |
73 | //Input tracks. | |
74 | list.push_back(kAliHLTDataTypeESDObject); | |
75 | list.push_back(kAliHLTDataTypeTrack | kAliHLTDataOriginITS); | |
76 | list.push_back(kAliHLTDataTypeTrack | kAliHLTDataOriginTPC); | |
77 | //Input from primary finder: | |
78 | //Primary vertex. | |
79 | list.push_back(kAliHLTDataTypeKFVertex | kAliHLTDataOriginOut); | |
80 | //Primary tracks' indices. | |
81 | list.push_back(kAliHLTDataTypePrimaryFinder | kAliHLTDataOriginOut); | |
82 | } | |
83 | ||
84 | //________________________________________________________________________ | |
85 | AliHLTComponentDataType AliHLTV0FinderComponent::GetOutputDataType() | |
86 | { | |
87 | //Data type of output. | |
88 | return kAliHLTMultipleDataType; | |
89 | } | |
90 | ||
91 | //________________________________________________________________________ | |
92 | int AliHLTV0FinderComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) | |
93 | { | |
94 | //Output type for V0 finder. | |
95 | tgtList.clear(); | |
96 | //Indices of tracks, participating in V0s. | |
97 | tgtList.push_back(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut); | |
98 | ||
99 | return tgtList.size(); | |
100 | } | |
101 | ||
102 | //________________________________________________________________________ | |
103 | void AliHLTV0FinderComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) | |
104 | { | |
105 | //These numbers are complete crap. | |
106 | constBase = 80000; | |
107 | inputMultiplier = 2.; | |
108 | } | |
109 | ||
110 | //________________________________________________________________________ | |
111 | AliHLTComponent* AliHLTV0FinderComponent::Spawn() | |
112 | { | |
113 | //Create primary vertex finder componet. | |
114 | return new AliHLTV0FinderComponent; | |
115 | } | |
116 | ||
117 | //________________________________________________________________________ | |
bf0b4a59 | 118 | int AliHLTV0FinderComponent::DoInit(int argc, const char** argv) |
f078d002 | 119 | { |
120 | //1. Default parameters. | |
121 | fDaughterPrimDeviation = fgDaughterPrimDeviation; | |
122 | fPrimDeviation = fgPrimDeviation; | |
123 | fChi = fgChi; | |
124 | fDecayLengthInSigmas = fgDecayLengthInSigmas; | |
125 | fPosPID = 211; | |
126 | fNegPID = 211; | |
127 | fGammaFinder = false; | |
128 | ||
f078d002 | 129 | //2. Parameters from OCDB. |
130 | TString cdbPath("HLT/ConfigHLT/"); | |
131 | cdbPath += GetComponentID(); | |
132 | ||
133 | int res = ConfigureFromCDBTObjString(cdbPath); | |
134 | if (res < 0) | |
135 | return res; | |
136 | ||
137 | //3. "Command line" parameters. | |
138 | if (argc) | |
139 | res = ConfigureFromArgumentString(argc, argv); | |
140 | ||
bf0b4a59 | 141 | return res; |
f078d002 | 142 | } |
143 | ||
144 | //________________________________________________________________________ | |
145 | int AliHLTV0FinderComponent::ScanConfigurationArgument(int argc, const char** argv) | |
146 | { | |
147 | //Scan one argument and its parameters from the list | |
148 | //Return number of processed entries. | |
149 | //Possible arguments: | |
150 | //-daughterPrimDeviation num | |
151 | //-primDeviation num | |
152 | //-chi num | |
153 | //-decayLengthInSigmas num | |
154 | //-posPID int_num | |
155 | //-negPid int_num | |
156 | //-gammaFinder 0/1 | |
157 | ||
158 | AliHLTUtility::CmdLineParser parser; | |
159 | parser.Add("-daughterPrimDeviation", &fDaughterPrimDeviation); | |
160 | parser.Add("-primDeviation", &fPrimDeviation); | |
161 | parser.Add("-chi", &fChi); | |
162 | parser.Add("-decayLengthInSigmas", &fDecayLengthInSigmas); | |
163 | parser.Add("-posPID", &fPosPID); | |
164 | parser.Add("-negPID", &fNegPID); | |
165 | parser.Add("-gammaFinder", &fGammaFinder); | |
166 | ||
167 | const int nParsed = parser.Parse(argc, argv, 0); | |
168 | if (nParsed < 0) { | |
169 | HLTError(parser.GetError().Data()); | |
170 | return -EPROTO; | |
171 | } | |
172 | ||
173 | return nParsed; | |
174 | } | |
175 | ||
176 | //________________________________________________________________________ | |
177 | int AliHLTV0FinderComponent::DoDeinit() | |
178 | { | |
179 | //Reset parameters to default. | |
180 | fDaughterPrimDeviation = fgDaughterPrimDeviation; | |
181 | fPrimDeviation = fgPrimDeviation; | |
182 | fChi = fgChi; | |
183 | fDecayLengthInSigmas = fgDecayLengthInSigmas; | |
184 | fPosPID = 211; | |
185 | fNegPID = 211; | |
186 | fGammaFinder = false; | |
187 | ||
188 | return 0; | |
189 | } | |
190 | ||
191 | //________________________________________________________________________ | |
192 | int AliHLTV0FinderComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, | |
193 | AliHLTComponentTriggerData& /*trigData*/) | |
194 | { | |
195 | //Find primary vertex. | |
196 | if (GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) | |
197 | return 0; | |
198 | ||
199 | //Clean all previous track infos. | |
200 | fTrackInfos.clear(); | |
201 | fPrimaryTracks.clear(); | |
202 | ||
203 | //Initialize KF package. | |
204 | AliKFParticle::SetField(GetBz()); | |
205 | ||
206 | if (!ReadPrimaryVertex()) | |
207 | return 0; | |
208 | ||
209 | if (!ReadTracks()) | |
210 | return 0; | |
211 | ||
212 | FindV0s(); | |
213 | ||
214 | return DoOutput(); | |
215 | } | |
216 | ||
217 | //________________________________________________________________________ | |
218 | bool AliHLTV0FinderComponent::ReadPrimaryVertex() | |
219 | { | |
220 | //Primary finder produces primary vertex (AliKFVertex) and | |
221 | //indices for primary tracks. | |
222 | //1. Try to extract primary vertex. | |
223 | const TObject* obj = GetFirstInputObject(kAliHLTDataTypeKFVertex | kAliHLTDataOriginOut); | |
224 | const AliKFVertex* kfVtx = dynamic_cast<const AliKFVertex*>(obj); | |
225 | ||
226 | if (!kfVtx) { | |
227 | HLTError("V0 finder requires KF vertex (primary vertex) as input"); | |
228 | return false; | |
229 | } | |
230 | ||
231 | //2. Try to read primary track indices. | |
232 | const AliHLTComponentBlockData* p = GetFirstInputBlock(kAliHLTDataTypePrimaryFinder | |
233 | | kAliHLTDataOriginOut); | |
234 | if (!p || !p->fSize || !p->fPtr) { | |
235 | HLTError("Array of primary track indices expected"); | |
236 | return false; | |
237 | } | |
238 | ||
239 | //Data block from primary finder | |
240 | const PrimaryFinderBlock* blk = static_cast<PrimaryFinderBlock*>(p->fPtr); | |
241 | //Track ids must be positive integers. | |
242 | if (blk->fMinPrimID < 0 || blk->fMaxPrimID < 0) { | |
243 | HLTError("Got negative track ID from primary finder, internal HLT error"); | |
244 | return false; | |
245 | } | |
246 | ||
247 | //3. Got correct data, modify the component's state. | |
248 | //KF vertex. | |
249 | fPrimaryVtx = *kfVtx; | |
250 | //Primary tracks. | |
251 | fNPrimaryTracks = blk->fNPrimaryTracks; | |
252 | fMinPrimID = blk->fMinPrimID; | |
253 | fMaxPrimID = blk->fMaxPrimID; | |
254 | ||
255 | fPrimaryTracks.assign(fMaxPrimID + 1, 0); | |
256 | for (int i = 0; i < fNPrimaryTracks; ++i) | |
257 | fPrimaryTracks[blk->fPrimTrackIds[i]] = 1; | |
258 | ||
259 | return true; | |
260 | } | |
261 | ||
262 | //________________________________________________________________________ | |
263 | bool AliHLTV0FinderComponent::ReadTracks() | |
264 | { | |
265 | //The logic, how vertex finder reads input tracks, | |
266 | //is taken from the original global vertexer. | |
267 | //First, try to read tracks from ESD event. | |
bf0b4a59 | 268 | ReadESDTracks(fPosPID, fNegPID); |
f078d002 | 269 | if (fTrackInfos.size()) { |
270 | FindPrimaryDeviations(); | |
271 | return true; | |
272 | } | |
273 | ||
274 | //No good esd tracks, try: | |
bf0b4a59 | 275 | ReadHLTTracks(kAliHLTDataTypeTrack | kAliHLTDataOriginITS, fPosPID, fNegPID); |
f078d002 | 276 | if (fTrackInfos.size()) { |
277 | FindPrimaryDeviations(); | |
278 | return true; | |
279 | } | |
280 | ||
281 | //If no good its tracks, try: | |
bf0b4a59 | 282 | ReadHLTTracks(kAliHLTDataTypeTrack | kAliHLTDataOriginTPC, fPosPID, fNegPID); |
f078d002 | 283 | if (fTrackInfos.size()) { |
284 | FindPrimaryDeviations(); | |
285 | return true; | |
286 | } | |
287 | ||
288 | HLTError("No input tracks found for V0 finder"); | |
289 | ||
290 | return false; | |
291 | } | |
292 | ||
293 | //________________________________________________________________________ | |
294 | void AliHLTV0FinderComponent::FindPrimaryDeviations() | |
295 | { | |
296 | //Quite a tricky part. | |
297 | for (VectorSize_t i = 0; i < fTrackInfos.size(); ++i) { | |
298 | AliHLTTrackInfo& info = fTrackInfos[i]; | |
299 | if (IsPrimaryTrack(info.fID)) { | |
300 | info.fPrimUsed = true; | |
301 | //The way primary deviation is computed in primary finder: | |
302 | if (fNPrimaryTracks <= 20) { | |
303 | AliKFVertex tmp(fPrimaryVtx - info.fParticle); | |
304 | info.fPrimDeviation = info.fParticle.GetDeviationFromVertex(tmp); | |
305 | } else | |
306 | info.fPrimDeviation = info.fParticle.GetDeviationFromVertex(fPrimaryVtx); | |
307 | } else { | |
308 | info.fPrimUsed = false; | |
309 | info.fPrimDeviation = info.fParticle.GetDeviationFromVertex(fPrimaryVtx); | |
310 | } | |
311 | } | |
312 | } | |
313 | ||
314 | //________________________________________________________________________ | |
315 | bool AliHLTV0FinderComponent::IsPrimaryTrack(int id)const | |
316 | { | |
317 | if (id < fMinPrimID || id > fMaxPrimID) | |
318 | return false; | |
319 | ||
320 | return fPrimaryTracks[id]; | |
321 | } | |
322 | ||
323 | //________________________________________________________________________ | |
324 | void AliHLTV0FinderComponent::FindV0s() | |
325 | { | |
326 | //Here's the core. | |
327 | if (fPrimaryVtx.GetNContributors() < 3) | |
328 | return; | |
329 | ||
330 | fV0s.clear(); | |
331 | fV0s.push_back(0); //Number of v0s. | |
332 | ||
333 | for (int iTr = 0, ei = fTrackInfos.size(); iTr < ei; ++iTr) { | |
334 | AliHLTTrackInfo& info = fTrackInfos[iTr]; | |
335 | if (info.fParticle.GetQ() > 0) | |
336 | continue; | |
337 | if (info.fPrimDeviation < fDaughterPrimDeviation) | |
338 | continue; | |
339 | ||
340 | for (int jTr = 0; jTr < ei; ++jTr) { | |
341 | AliHLTTrackInfo& jnfo = fTrackInfos[jTr]; | |
342 | if (jnfo.fParticle.GetQ() < 0) | |
343 | continue; | |
344 | if (jnfo.fPrimDeviation < fDaughterPrimDeviation) | |
345 | continue; | |
346 | ||
347 | //Check if the particles fit | |
348 | if (info.fParticle.GetDeviationFromParticle(jnfo.fParticle) > fChi) | |
349 | continue; | |
350 | ||
351 | //Construct V0 mother | |
352 | AliKFParticle v0(info.fParticle, jnfo.fParticle /*, bGammaFinder*/); | |
353 | //Check V0 Chi^2 | |
354 | if (v0.GetChi2() < 0. || v0.GetChi2() > fChi * fChi * v0.GetNDF()) | |
355 | continue; | |
356 | ||
357 | //Subtruct daughters from primary vertex | |
358 | AliKFVertex primVtxCopy(fPrimaryVtx); | |
359 | ||
360 | if (info.fPrimUsed) { | |
361 | if (primVtxCopy.GetNContributors() <= 2) | |
362 | continue; | |
363 | primVtxCopy -= info.fParticle; | |
364 | } | |
365 | ||
366 | if (jnfo.fPrimUsed) { | |
367 | if (primVtxCopy.GetNContributors() <= 2) | |
368 | continue; | |
369 | primVtxCopy -= jnfo.fParticle; | |
370 | } | |
371 | ||
372 | //Check v0 Chi^2 deviation from primary vertex | |
373 | if (v0.GetDeviationFromVertex(primVtxCopy) > fPrimDeviation) | |
374 | continue; | |
375 | //Add V0 to primary vertex to improve the primary vertex resolution | |
376 | primVtxCopy += v0; | |
377 | //Set production vertex for V0 | |
378 | v0.SetProductionVertex(primVtxCopy); | |
379 | //Get V0 decay length with estimated error | |
380 | double length = 0., sigmaLength = 0.; | |
381 | if (v0.GetDecayLength(length, sigmaLength)) | |
382 | continue; | |
383 | //Reject V0 if it decays too close[sigma] to the primary vertex | |
384 | if (length < fDecayLengthInSigmas * sigmaLength) | |
385 | continue; | |
386 | //Keep v0 | |
130ddc9e | 387 | fV0s.push_back(info.fID); |
388 | fV0s.push_back(jnfo.fID); | |
f078d002 | 389 | |
390 | fV0s[0] += 1; | |
391 | } | |
392 | } | |
393 | } | |
394 | ||
395 | //________________________________________________________________________ | |
396 | int AliHLTV0FinderComponent::DoOutput() | |
397 | { | |
398 | //Save V0s' track pairs' indices. | |
399 | if (!fV0s.size() || !fV0s[0]) { | |
400 | HLTInfo("No v0s were found"); | |
401 | return 0; | |
402 | } | |
403 | ||
404 | //Indices of primary tracks. | |
405 | return PushBack(&fV0s[0], fV0s.size() * sizeof(int), | |
406 | kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut); | |
407 | } |