CbmRoot
Loading...
Searching...
No Matches
CbmLitNearestHitTofMerger.cxx
Go to the documentation of this file.
1/* Copyright (C) 2013-2016 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer] */
4
12
13#include "data/CbmLitHit.h"
14#include "data/CbmLitTofTrack.h"
15#include "data/CbmLitTrack.h"
19#include "utils/CbmLitMath.h"
20
21#include <iostream>
22#include <map>
23
24using std::map;
25
27 : fFieldPropagator()
28 , fLinePropagator()
29 , fFilter()
30 , fPDG(211)
31 , fChiSqCut(25.)
32{
33}
34
36
38{
39 // First find hit with minimum Z position and build map from Z hit position
40 // to track parameter to improve the calculation speed.
41 litfloat zMin = std::numeric_limits<litfloat>::max();
42 map<litfloat, CbmLitTrackParam> zParamMap;
43 for (HitPtrIterator it = hits.begin(); it != hits.end(); it++) {
44 const CbmLitHit* hit = *it;
45 zMin = std::min(zMin, hit->GetZ());
46 zParamMap[hit->GetZ()] = CbmLitTrackParam();
47 }
48
49 // Loop over input tracks
50 for (TrackPtrIterator it = tracks.begin(); it != tracks.end(); it++) {
51 CbmLitTrack* track = *it;
52 if (track->GetQuality() != kLITGOODMERGE) {
53 continue;
54 }
55 CbmLitTrackParam par(*track->GetParamLast());
56
57 // Extrapolate track minimum Z position of hit using magnetic field propagator.
58 if (fFieldPropagator->Propagate(&par, zMin, fPDG) == kLITERROR) {
59 continue; // skip this track if its propagation failed
60 }
61
62 // Extrapolate track parameters to each Z position in the map.
63 // This is done to improve calculation speed.
64 // In case of planar TOF geometry only 1 track extrapolation is required,
65 // since all hits located at the same Z.
66 for (map<litfloat, CbmLitTrackParam>::iterator it2 = zParamMap.begin(); it2 != zParamMap.end(); it2++) {
67 (*it2).second = par;
68 fLinePropagator->Propagate(&(*it2).second, (*it2).first, fPDG);
69 }
70
71 // Loop over hits
72 litfloat minChiSq = std::numeric_limits<litfloat>::max(); // minimum chi-square of hit
73 const CbmLitHit* minHit = NULL; // Pointer to hit with minimum chi-square
74 CbmLitTrackParam minPar; // Track parameters for closest hit
75 for (HitPtrIterator it = hits.begin(); it != hits.end(); it++) {
76 const CbmLitHit* hit = *it;
77 if (zParamMap.find(hit->GetZ()) == zParamMap.end()) { // This should never happen
78 std::cout << "-E- CbmLitNearestHitTofMerger::DoMerge: Z position " << hit->GetZ()
79 << " not found in map. Something is wrong.\n";
80 assert(0);
81 }
82 CbmLitTrackParam tpar(zParamMap[hit->GetZ()]);
83 litfloat chi = 1.e10;
84 fFilter->Update(&tpar, hit, chi);
85
86 // Check if hit is inside validation gate.
87 if (fChiSqCut >= 0. && chi >= fChiSqCut) {
88 continue;
89 }
90
91 if (chi < minChiSq) { // Check if hit is closer to the track.
92 minChiSq = chi;
93 minHit = hit;
94 minPar = tpar;
95 }
96 }
97
98 if (minHit != NULL) { // Check if hit was added
99 //Create new TOF track
100 CbmLitTofTrack* tofTrack = new CbmLitTofTrack();
101 tofTrack->SetTrack(track);
102 tofTrack->SetHit(minHit);
103 tofTrack->SetTrackParam(&minPar);
104 tofTrack->SetDistance(minChiSq);
105 tofTracks.push_back(tofTrack);
106 }
107 }
108 return kLITSUCCESS;
109}
TClonesArray * tracks
@ kLITGOODMERGE
Definition CbmLitEnums.h:41
LitStatus
Definition CbmLitEnums.h:29
@ kLITERROR
Definition CbmLitEnums.h:31
@ kLITSUCCESS
Definition CbmLitEnums.h:30
double litfloat
Definition CbmLitFloat.h:19
Base data class for hits.
Hit-to-track merging in TOF detector using nearest hit approach.
Data class for track parameters.
Interface for track update algorithm.
Base data class for track.
vector< CbmLitTofTrack * > TofTrackPtrVector
Definition CbmLitTypes.h:37
static vector< vector< QAHit > > hits
std::vector< CbmTofHit * >::iterator HitPtrIterator
Definition CbmTofTypes.h:21
std::vector< CbmTofTrack * >::iterator TrackPtrIterator
Definition CbmTofTypes.h:25
std::vector< CbmTofTrack * > TrackPtrVector
Definition CbmTofTypes.h:26
std::vector< CbmTofHit * > HitPtrVector
Definition CbmTofTypes.h:20
Base data class for hits.
Definition CbmLitHit.h:29
litfloat GetZ() const
Definition CbmLitHit.h:44
virtual LitStatus DoMerge(HitPtrVector &hits, TrackPtrVector &tracks, TofTrackPtrVector &tofTracks)
Inherited from CbmLitHitToTrackMerger.
virtual ~CbmLitNearestHitTofMerger()
Destructor.
void SetDistance(litfloat distance)
void SetTrackParam(const CbmLitTrackParam *par)
void SetHit(const CbmLitHit *hit)
void SetTrack(const CbmLitTrack *track)
Data class for track parameters.
Base data class for track.
Definition CbmLitTrack.h:34
const CbmLitTrackParam * GetParamLast() const
Definition CbmLitTrack.h:69
LitTrackQa GetQuality() const
Definition CbmLitTrack.h:63