CbmRoot
Loading...
Searching...
No Matches
CbmLitAllHitsTofMerger.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 for (HitPtrIterator it = hits.begin(); it != hits.end(); it++) {
73 const CbmLitHit* hit = *it;
74 if (zParamMap.find(hit->GetZ()) == zParamMap.end()) { // This should never happen
75 std::cout << "-E- CbmLitAllHitsTofMerger::DoMerge: Z position " << hit->GetZ()
76 << " 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 (chi < fChiSqCut) { // Check if hit is inside validation gate and closer to the track.
82 //Create new TOF track
83 CbmLitTofTrack* tofTrack = new CbmLitTofTrack();
84 tofTrack->SetTrack(track);
85 tofTrack->SetHit(hit);
86 tofTrack->SetTrackParam(&tpar);
87 tofTrack->SetDistance(chi);
88 tofTracks.push_back(tofTrack);
89 }
90 }
91 }
92 return kLITSUCCESS;
93}
TClonesArray * tracks
Hit-to-track merging in TOF detector attaching all hits in the validation region.
@ 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.
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
TrackPropagatorPtr fFieldPropagator
virtual ~CbmLitAllHitsTofMerger()
Destructor.
virtual LitStatus DoMerge(HitPtrVector &hits, TrackPtrVector &tracks, TofTrackPtrVector &tofTracks)
Inherited from CbmLitHitToTrackMerger.
TrackPropagatorPtr fLinePropagator
Base data class for hits.
Definition CbmLitHit.h:29
litfloat GetZ() const
Definition CbmLitHit.h:44
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