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