CbmRoot
LxTBTieTracks.cxx
Go to the documentation of this file.
1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 
7 #include "LxTBTieTracks.h"
8 #include "CbmMuch.h"
9 #include "CbmMuchPixelHit.h"
10 #include "CbmTrdHit.h"
11 #include "base/CbmLitToolFactory.h"
12 #include "data/CbmLitTrackParam.h"
13 #include "utils/CbmLitConverter.h"
14 
15 using std::list;
16 
18  const FairTrackParam& par,
19  Double_t chiSq,
20  Double_t time,
21  Int_t selfId /*, Int_t eventId, Int_t fileId*/) {
22  LxTBBinnedStsTrack stsTrack = {
23  par, chiSq, time, selfId /*, eventId, fileId*/};
24  fStsTracks.push_back(stsTrack);
25 }
26 
34 
36  : fFilter(), fPar(), fOutPar(), fChiSq(), fZ(), fPoint(nullptr) {}
37  TieHandlePoint(const TieHandlePoint&) = delete;
39 
40  void HandlePoint(const LxTbBinnedPoint& point) {
42  CbmLitPixelHit litHit;
43  litHit.SetX(point.x);
44  litHit.SetY(point.y);
45  litHit.SetZ(fZ);
46  litHit.SetDx(point.dx);
47  litHit.SetDy(point.dy);
48  litHit.SetDz(0);
49  litHit.SetDxy(0);
50  litHit.SetRefId(0);
51  CbmLitTrackParam par = fPar;
52  fFilter->Update(&par, &litHit, chiSq);
53 
54  if (chiSq < 25 && chiSq < fChiSq) {
55  fChiSq = chiSq;
56  fPoint = &point;
57  fOutPar = par;
58  }
59  }
60 };
61 
63  int nofxb,
64  int nofyb,
65  int noftb,
66  int binSizeT)
67  : fLayers(reinterpret_cast<LxTBBinndedLayer*>(
68  new unsigned char[nofl * sizeof(LxTBBinndedLayer)]))
69  , fNofLayers(nofl)
70  , fStsTracks()
71  , fMuchTracks(nullptr)
72  , fGlobalTracks(nullptr) {
73  for (int i = 0; i < fNofLayers; ++i)
74  new (&fLayers[i]) LxTBBinndedLayer(nofxb, nofyb, noftb, binSizeT);
75 }
76 
78  for (int i = 0; i < fNofLayers; ++i)
79  fLayers[i].Init();
80 }
81 
83  fStsTracks.clear();
84 
85  for (int i = 0; i < fNofLayers; ++i)
86  fLayers[i].Clear();
87 }
88 
89 void LxTBBinnedDetector::SetTSBegin(unsigned long long tsLowBound) {
90  for (int i = 0; i < fNofLayers; ++i)
91  fLayers[i].SetTSBegin(tsLowBound);
92 }
93 
95  //for (int i = 0; i < fFinder.nofTrackBins; ++i)
96  //{
97  //list<LxTbBinnedFinder::Chain*>& recoTracksBin = fFinder.recoTracks[i];
98 
99  //for (list<LxTbBinnedFinder::Chain*>::const_iterator j = recoTracksBin.begin(); j != recoTracksBin.end(); ++j)
100  //recoTracks.push_back(*j);
101  //}
102  TrackPropagatorPtr propagator =
105  //TrackFitterPtr fFitter = CbmLitToolFactory::CreateTrackFitter("lit_kalman");
106  int muchTrackNo = 0;
107  int globalTrackNo = 0;
108 
109  for (list<LxTBBinnedStsTrack>::const_iterator i = fStsTracks.begin();
110  i != fStsTracks.end();
111  ++i) {
112  const LxTBBinnedStsTrack& stsTrack = *i;
113  CbmGlobalTrack* globalTrack =
114  new ((*fGlobalTracks)[globalTrackNo]) CbmGlobalTrack();
115  globalTrack->SetStsTrackIndex(globalTrackNo++);
116  Double_t qp = stsTrack.fPar.GetQp();
117 
118  if (0 == qp) // We want propagate J/psi tracks only.
119  continue;
120 
121  Double_t p = 1 / qp;
122 
123  if (p < 3) // We want propagate J/psi tracks only.
124  continue;
125 
126  Double_t txSq = stsTrack.fPar.GetTx() * stsTrack.fPar.GetTx();
127  Double_t tySq = stsTrack.fPar.GetTy() * stsTrack.fPar.GetTy();
128  Double_t ptSq = p * p * (txSq + tySq) / (1 + txSq + tySq);
129 
130  if (ptSq < 1) // We want propagate J/psi tracks only.
131  continue;
132 
133  Double_t trackChiSq = stsTrack.fChiSq;
134  CbmTrackParam cbmPar;
135  cbmPar.Set(stsTrack.fPar, stsTrack.fTime, 2);
136  CbmLitTrackParam par;
138  &par);
139  CbmLitTrackParam prevPar;
140  CbmLitTrackParam firstPar;
141  bool firstTime = true;
142  timetype t = stsTrack.fTime;
143  int nofMissingHits = 0;
144 
145  struct PointData {
146  const LxTbBinnedPoint* point;
147  bool isTrd;
148  };
149 
150  list<PointData> points;
151 
152  for (int j = 0; j < fNofLayers; ++j) {
153  prevPar = par;
154 
155  if (propagator->Propagate(&par, fLayers[j].z, 13) == kLITERROR) break;
156 
157  scaltype x = par.GetX();
158  scaltype y = par.GetY();
159  timetype length =
160  sqrt((par.GetX() - prevPar.GetX()) * (par.GetX() - prevPar.GetX())
161  + (par.GetY() - prevPar.GetY()) * (par.GetY() - prevPar.GetY())
162  + (par.GetZ() - prevPar.GetZ()) * (par.GetZ() - prevPar.GetZ()));
163  t += 1.e9 * length / speedOfLight;
164  scaltype sigmaXSq = par.GetCovariance(0);
165  scaltype sigmaYSq = par.GetCovariance(6);
166  TieHandlePoint pointHandler;
167  pointHandler.fFilter = filter;
168  pointHandler.fPar = par;
169  pointHandler.fZ = fLayers[j].z;
171  pointHandler.fPoint = 0;
172  fLayers[j].Search(x, sigmaXSq, y, sigmaYSq, t, &pointHandler);
173 
174  if (pointHandler.fPoint) {
175  par = pointHandler.fOutPar;
176  trackChiSq += pointHandler.fChiSq;
177  PointData pd = {pointHandler.fPoint, j > 11};
178  points.push_back(pd);
179 
180  if (firstTime) {
181  firstPar = par;
182  firstTime = false;
183  }
184  } else
185  ++nofMissingHits;
186 
187  if (nofMissingHits > 4) break;
188  }
189 
190  if (points.empty()) continue;
191 
192  CbmMuchTrack* muchTrack = new ((*fMuchTracks)[muchTrackNo]) CbmMuchTrack();
193  globalTrack->SetMuchTrackIndex(muchTrackNo++);
194  Int_t ndf = points.size() * 2 - 5;
195  muchTrack->SetChiSq(trackChiSq);
196  muchTrack->SetNDF(ndf < 1 ? 1 : ndf);
197  muchTrack->SetPreviousTrackId(stsTrack.fSelfId);
198  muchTrack->SetFlag(kLITGOOD);
199  FairTrackParam parLast, parFirst;
201  &parLast);
203  &parFirst);
204  muchTrack->SetParamLast(&parLast);
205  muchTrack->SetParamFirst(&parFirst);
206 
207  for (list<PointData>::const_iterator j = points.begin(); j != points.end();
208  ++j) {
209  const PointData pd = *j;
210  muchTrack->AddHit(pd.point->refId, pd.isTrd ? kTRDHIT : kMUCHPIXELHIT);
211  }
212  }
213 }
CbmLitTrackParam.h
Data class for track parameters.
CbmLitToolFactory::CreateTrackPropagator
static TrackPropagatorPtr CreateTrackPropagator(const string &name)
Create track propagation tool by name.
Definition: CbmLitToolFactory.cxx:58
CbmLitHit::SetZ
void SetZ(litfloat z)
Definition: CbmLitHit.h:62
litfloat
double litfloat
Definition: CbmLitFloat.h:15
TieHandlePoint::fChiSq
litfloat fChiSq
Definition: LxTBTieTracks.cxx:31
kLITGOOD
@ kLITGOOD
Definition: CbmLitEnums.h:32
LxTBBinnedDetector::TieTracks
void TieTracks(LxTbBinnedFinder &fFinder)
Definition: LxTBTieTracks.cxx:94
TieHandlePoint::operator=
TieHandlePoint & operator=(const TieHandlePoint &)=delete
TieHandlePoint
Definition: LxTBTieTracks.cxx:27
LxTBBinnedStsTrack::fSelfId
Int_t fSelfId
Definition: LxTBTieTracks.h:195
LxTBBinndedLayer::z
scaltype z
Definition: LxTBTieTracks.h:24
LxTBBinndedLayer::PointHandler
Definition: LxTBTieTracks.h:92
CbmLitTrackParam::GetX
litfloat GetX() const
Definition: CbmLitTrackParam.h:53
scaltype
#define scaltype
Definition: CbmGlobalTrackingDefs.h:17
sqrt
friend F32vec4 sqrt(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:41
CbmLitPixelHit::SetY
void SetY(litfloat y)
Definition: CbmLitPixelHit.h:45
TrackPropagatorPtr
boost::shared_ptr< CbmLitTrackPropagator > TrackPropagatorPtr
Definition: CbmTofPtrTypes.h:23
CbmLitTrackParam
Data class for track parameters.
Definition: CbmLitTrackParam.h:29
LxTBBinnedDetector::SetTSBegin
void SetTSBegin(unsigned long long tsLowBound)
Definition: LxTBTieTracks.cxx:89
LxTBTieTracks.h
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
TrackUpdatePtr
boost::shared_ptr< CbmLitTrackUpdate > TrackUpdatePtr
Definition: CbmTofPtrTypes.h:26
CbmLitTrackParam::GetY
litfloat GetY() const
Definition: CbmLitTrackParam.h:54
CbmLitToolFactory.h
Tool factory for creation of littrack algorithms.
CbmTrack::SetPreviousTrackId
void SetPreviousTrackId(Int_t previousTrackId)
Definition: CbmTrack.h:72
CbmLitTrackParam::GetCovariance
litfloat GetCovariance(int index) const
Definition: CbmLitTrackParam.h:60
CbmTrack::SetParamLast
void SetParamLast(const FairTrackParam *par)
Definition: CbmTrack.h:76
CbmTrack::SetNDF
void SetNDF(Int_t ndf)
Definition: CbmTrack.h:71
CbmTrackParam::Set
void Set(const FairTrackParam &ftp, Double_t time=0., Double_t timeError=0.)
Definition: CbmTrackParam.cxx:12
CbmLitConverterFairTrackParam::CbmLitTrackParamToFairTrackParam
static void CbmLitTrackParamToFairTrackParam(const CbmLitTrackParam *litPar, FairTrackParam *par)
Definition: CbmLitConverterFairTrackParam.h:110
LxTbBinnedPoint::dx
scaltype dx
Definition: LxTBBinned.h:80
CbmMuchTrack
Definition: CbmMuchTrack.h:16
LxTBBinnedStsTrack::fTime
Double_t fTime
Definition: LxTBTieTracks.h:194
CbmTrack::SetFlag
void SetFlag(Int_t flag)
Definition: CbmTrack.h:69
LxTBBinndedLayer::Search
void Search(scaltype x, scaltype xDiv0, scaltype y, scaltype yDiv0, timetype t, PointHandler *pointHandler)
Definition: LxTBTieTracks.h:97
LxTBBinnedDetector::LxTBBinnedDetector
LxTBBinnedDetector(int nofl, int nofxb, int nofyb, int noftb, int binSizeT)
Definition: LxTBTieTracks.cxx:62
CbmGlobalTrack::SetStsTrackIndex
void SetStsTrackIndex(Int_t iSts)
Definition: CbmGlobalTrack.h:54
CbmLitHit::SetRefId
void SetRefId(Int_t refId)
Definition: CbmLitHit.h:60
LxTBBinnedStsTrack::fChiSq
Double_t fChiSq
Definition: LxTBTieTracks.h:193
LxTbBinnedFinder
Definition: LxTBBinned.h:336
CbmMuch.h
TieHandlePoint::fFilter
TrackUpdatePtr fFilter
Definition: LxTBTieTracks.cxx:28
CbmLitTrackParam::GetZ
litfloat GetZ() const
Definition: CbmLitTrackParam.h:55
TieHandlePoint::TieHandlePoint
TieHandlePoint(const TieHandlePoint &)=delete
kLITERROR
@ kLITERROR
Definition: CbmLitEnums.h:25
LxTBBinnedDetector::fStsTracks
std::list< LxTBBinnedStsTrack > fStsTracks
Definition: LxTBTieTracks.h:203
CbmLitPixelHit
Base data class for pixel hits.
Definition: CbmLitPixelHit.h:22
CbmTrack::SetChiSq
void SetChiSq(Double_t chiSq)
Definition: CbmTrack.h:70
CbmTrdHit.h
Class for hits in TRD detector.
LxTbBinnedPoint::y
scaltype y
Definition: LxTBBinned.h:81
TieHandlePoint::fOutPar
CbmLitTrackParam fOutPar
Definition: LxTBTieTracks.cxx:30
TieHandlePoint::HandlePoint
void HandlePoint(const LxTbBinnedPoint &point)
Definition: LxTBTieTracks.cxx:40
kTRDHIT
@ kTRDHIT
Definition: CbmHit.h:25
LxTBBinnedStsTrack
Definition: LxTBTieTracks.h:191
LxTBBinnedDetector::Clear
void Clear()
Definition: LxTBTieTracks.cxx:82
LxTbBinnedPoint::dy
scaltype dy
Definition: LxTBBinned.h:82
LxTBBinnedDetector::Init
void Init()
Definition: LxTBTieTracks.cxx:77
CbmGlobalTrack
Definition: CbmGlobalTrack.h:26
points
TClonesArray * points
Definition: Analyze_matching.h:18
CbmLitPixelHit::SetDx
void SetDx(litfloat dx)
Definition: CbmLitPixelHit.h:46
timetype
#define timetype
Definition: CbmGlobalTrackingDefs.h:18
TieHandlePoint::fZ
litfloat fZ
Definition: LxTBTieTracks.cxx:32
CbmLitHit::SetDz
void SetDz(litfloat dz)
Definition: CbmLitHit.h:63
CbmLitToolFactory::CreateTrackUpdate
static TrackUpdatePtr CreateTrackUpdate(const string &name)
Create track update tool by name.
Definition: CbmLitToolFactory.cxx:73
speedOfLight
Double_t speedOfLight
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmLitPixelHit::SetDy
void SetDy(litfloat dy)
Definition: CbmLitPixelHit.h:47
LxTBBinnedStsTrack::fPar
FairTrackParam fPar
Definition: LxTBTieTracks.h:192
CbmTrackParam
Definition: CbmTrackParam.h:22
CbmLitPixelHit::SetDxy
void SetDxy(litfloat dxy)
Definition: CbmLitPixelHit.h:48
CbmMuchPixelHit.h
Class for pixel hits in MUCH detector.
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmLitConverter.h
CbmGlobalTrack::SetMuchTrackIndex
void SetMuchTrackIndex(Int_t iMuch)
Definition: CbmGlobalTrack.h:56
CbmTrack::SetParamFirst
void SetParamFirst(const FairTrackParam *par)
Definition: CbmTrack.h:75
kMUCHPIXELHIT
@ kMUCHPIXELHIT
Definition: CbmHit.h:23
TieHandlePoint::fPoint
const LxTbBinnedPoint * fPoint
Definition: LxTBTieTracks.cxx:33
LxTBBinnedDetector::fLayers
LxTBBinndedLayer * fLayers
Definition: LxTBTieTracks.h:201
TieHandlePoint::fPar
CbmLitTrackParam fPar
Definition: LxTBTieTracks.cxx:29
TieHandlePoint::TieHandlePoint
TieHandlePoint()
Definition: LxTBTieTracks.cxx:35
CbmLitPixelHit::SetX
void SetX(litfloat x)
Definition: CbmLitPixelHit.h:44
max
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: L1/vectors/P4_F32vec4.h:36
LxTbBinnedPoint
Definition: LxTBBinned.h:78
LxTBBinnedDetector::AddStsTrack
void AddStsTrack(const FairTrackParam &par, Double_t chiSq, Double_t time, Int_t selfId)
Definition: LxTBTieTracks.cxx:17
CbmTrack::AddHit
void AddHit(Int_t index, HitType type)
Definition: CbmTrack.cxx:75
LxTbBinnedPoint::x
scaltype x
Definition: LxTBBinned.h:79
CbmLitConverterFairTrackParam::FairTrackParamToCbmLitTrackParam
static void FairTrackParamToCbmLitTrackParam(const FairTrackParam *par, CbmLitTrackParam *litPar)
Definition: CbmLitConverterFairTrackParam.h:40
LxTBBinndedLayer
Definition: LxTBTieTracks.h:23
LxTBBinnedDetector::fNofLayers
int fNofLayers
Definition: LxTBTieTracks.h:202