CbmRoot
Loading...
Searching...
No Matches
PairAnalysisTrack.cxx
Go to the documentation of this file.
1/* Copyright (C) 2015-2020 Justus-Liebig-Universitaet Giessen, Giessen
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Julian Book [committer] */
4
5/*
6
7 Analysis track that keep references to all tracklets of sub detectors and
8 provides easy access to them via e.g. GetTrack(ECbmModuleId det).
9
10 Two TLorentzVector hold information on the momentum components and
11 position. Further the SetMassHypo is calculated according to the
12 setting of PairAnalysis::SetLegPdg(pdgLeg1, pdgLeg2) and the actual charge.
13 In addition a track can be refitted using this mass assumption if enabled
14 using PairAnalysis::SetRefitWithMassAssump(kTRUE)
15
16 TObject bits are used to flag the matching between detector tracklets and MC tracks.
17 Bits used are >14 and correspond to CbmDetectorList.h -> ECbmModuleId
18*/
19// //
21
22//#include <TObjArray.h>
23#include "PairAnalysisTrack.h"
24
25#include "CbmGlobalTrack.h"
26#include "CbmKFVertex.h"
27#include "CbmL1PFFitter.h"
29#include "CbmLitPtrTypes.h"
30#include "CbmLitToolFactory.h"
31#include "CbmLitTrackParam.h"
32#include "CbmMCTrack.h"
33#include "CbmMuchTrack.h"
34#include "CbmMvdDetector.h"
35#include "CbmMvdStationPar.h"
36#include "CbmRichRing.h"
37#include "CbmStsTrack.h"
38#include "CbmTofHit.h"
39#include "CbmTrack.h"
40#include "CbmTrackMatchNew.h"
41#include "CbmTrackParam.h"
42#include "CbmTrdTrack.h"
43
44#include "FairTrackParam.h"
45
46#include <TDatabasePDG.h>
47#include <TLorentzVector.h>
48#include <TParticle.h>
49#include <TParticlePDG.h>
50
51#include <vector>
52
54
56 : TNamed()
57 , fMomentum()
58 , fPosition()
59{
60 //
61 // Default Constructor
62 //
63}
64
65//______________________________________________
66PairAnalysisTrack::PairAnalysisTrack(const char* name, const char* title)
67 : TNamed(name, title)
68 , fMomentum()
69 , fPosition()
70{
71 //
72 // Named Constructor
73 //
74}
75
76//______________________________________________
78 : TNamed()
79 , fMCTrack(mctrk)
80 , fMomentum()
81 , fPosition()
82 , fPdgCode(fastTrk->GetPdgCode())
83 , fLabel(fastTrk->GetFirstMother())
84 , fFastTrack(kTRUE)
85{
86 //
87 // Constructor
88 //
89 fastTrk->Momentum(fMomentum);
90 fastTrk->ProductionVertex(fPosition);
91
92 TParticlePDG* mcPart = fastTrk->GetPDG(0);
93 if (mcPart) fCharge = mcPart->Charge() / 3;
94}
95
96//______________________________________________
98 CbmTrdTrack* trdtrk, CbmRichRing* richring, CbmTofHit* tofhit, CbmMCTrack* mctrk,
99 CbmTrackMatchNew* stsmatch, CbmTrackMatchNew* muchmatch,
100 CbmTrackMatchNew* trdmatch, CbmTrackMatchNew* richmatch, FairTrackParam* richproj,
101 Int_t gIndex)
102 : TNamed()
103 , fPrimVertex(vtx)
104 , fGlblTrack(gtrk)
105 , fGlblTrackIndex(gIndex)
106 , fStsTrack(ststrk)
107 , fMuchTrack(muchtrk)
108 , fTrdTrack(trdtrk)
109 , fRichRing(richring)
110 , fTofHit(tofhit)
111 , fMCTrack(mctrk)
112 , fStsTrackMatch(stsmatch)
113 , fMuchTrackMatch(muchmatch)
114 , fTrdTrackMatch(trdmatch)
115 , fRichRingMatch(richmatch)
116 , fRichProj(richproj)
117 , fMvdEntrance(new FairTrackParam())
118 , fMomentum()
119 , fPosition()
120{
121 //
122 // Constructor
123 //
124 Double_t m2 = TMath::Power(TDatabasePDG::Instance()->GetParticle(11)->Mass(), 2);
125
128 if (mvdpar && mvdpar->GetStationCount()) {
129 Double_t zMvd = mvdpar->GetZPosition(0); // z-position of the first mvd station
131 CbmLitTrackParam litParamIn;
133 CbmLitTrackParam litParamOut;
134 fExtrapolator->Extrapolate(&litParamIn, &litParamOut, zMvd, NULL);
136 }
137
139 const CbmTrackParam* ppar = fGlblTrack->GetParamVertex();
140 if (ppar) {
141 fMomentum.SetPxPyPzE(ppar->GetPx(), ppar->GetPy(), ppar->GetPz(), 0.);
142 fMomentum.SetE(TMath::Sqrt(fMomentum.Vect().Mag2() + m2));
143 fPosition.SetXYZM(ppar->GetX(), ppar->GetY(), ppar->GetZ(), TMath::Sqrt(m2));
144 fCharge = (ppar->GetQp() > 0. ? +1. : -1.);
146 }
147 else {
148 Refit(211);
149 }
150
151 if (mctrk) fPdgCode = mctrk->GetPdgCode();
152}
153
154//______________________________________________
156 : TNamed(track.GetName(), track.GetTitle())
157 , fPrimVertex(track.fPrimVertex)
158 , fGlblTrack(track.GetGlobalTrack())
159 , fGlblTrackIndex(track.GetGlobalIndex())
160 , fStsTrack(track.fStsTrack)
161 , fMuchTrack(track.fMuchTrack)
162 , fTrdTrack(track.fTrdTrack)
163 , fRichRing(track.GetRichRing())
164 , fTofHit(track.GetTofHit())
165 , fMCTrack(track.GetMCTrack())
166 , fStsTrackMatch(track.GetTrackMatch(ECbmModuleId::kSts))
167 , fMuchTrackMatch(track.GetTrackMatch(ECbmModuleId::kMuch))
168 , fTrdTrackMatch(track.GetTrackMatch(ECbmModuleId::kTrd))
169 , fRichRingMatch(track.GetTrackMatch(ECbmModuleId::kRich))
170 , fRichProj(track.GetRichProj())
171 , fMvdEntrance(track.GetMvdEntrance())
172 , fMomentum(track.fMomentum)
173 , fPosition(track.fPosition)
174 , fChi2Vtx(track.ChiToVertex())
175 , fCharge(track.Charge())
176 , fPdgCode(track.PdgCode())
177 , fLabel(track.GetLabel())
178 , fWeight(track.GetWeight())
179 , fFastTrack(track.fFastTrack)
180{
181 //
182 // Copy Constructor
183 //
184
185 this->SetBit(BIT(14 + ToIntegralType(ECbmModuleId::kTof)),
186 track.TestBit(BIT(14 + ToIntegralType(ECbmModuleId::kTof))));
187 this->SetBit(BIT(14 + ToIntegralType(ECbmModuleId::kRich)),
188 track.TestBit(BIT(14 + ToIntegralType(ECbmModuleId::kRich))));
189 this->SetBit(BIT(14 + ToIntegralType(ECbmModuleId::kTrd)),
190 track.TestBit(BIT(14 + ToIntegralType(ECbmModuleId::kTrd))));
191 this->SetBit(BIT(14 + ToIntegralType(ECbmModuleId::kSts)),
192 track.TestBit(BIT(14 + ToIntegralType(ECbmModuleId::kSts))));
193 this->SetBit(BIT(14 + ToIntegralType(ECbmModuleId::kMuch)),
194 track.TestBit(BIT(14 + ToIntegralType(ECbmModuleId::kMuch))));
195}
196
197//______________________________________________
199{
200 //
201 // Default Destructor
202 //
203 // if(fPrimVertex) delete fPrimVertex;
204}
205
206//______________________________________________
208{
209 //
210 // get track match depending on detector id
211 //
212 switch (det) {
213 case ECbmModuleId::kMvd: return fStsTrackMatch; // there is no mvd track, hit are associtaed to sts track
218 default: return 0x0;
219 }
220}
221
222//______________________________________________
224{
225 //
226 // get track depending on detector id
227 //
228 switch (det) {
229 case ECbmModuleId::kMvd: return fStsTrack; // there is no mvd track, hit are associtaed to sts track
230 case ECbmModuleId::kSts: return fStsTrack;
231 case ECbmModuleId::kTrd: return fTrdTrack;
232 case ECbmModuleId::kMuch: return fMuchTrack;
233 case ECbmModuleId::kRich: return 0x0;
234 default: return 0x0;
235 }
236}
237
238//______________________________________________
239void PairAnalysisTrack::SetMassHypo(Int_t pdg1, Int_t pdg2, Bool_t refitMassAssump)
240{
241 //
242 // use charge, time and track length information to assign
243 // the best guessed mass hypothesis
244 //
245 const Double_t mpdg1 = TDatabasePDG::Instance()->GetParticle(pdg1)->Mass();
246 const Double_t mpdg2 = TDatabasePDG::Instance()->GetParticle(pdg2)->Mass();
247 const Double_t cpdg1 = TDatabasePDG::Instance()->GetParticle(pdg1)->Charge() * 3;
248 const Double_t cpdg2 = TDatabasePDG::Instance()->GetParticle(pdg2)->Charge() * 3;
249
250 Double_t m2 = 0.;
251 Int_t ppdg = 0; // prefered pdg
252 // match STS charge of track to pid and set mass accordingly
253 if (fCharge * cpdg1 < 0) {
254 m2 = mpdg2 * mpdg2;
255 ppdg = pdg2;
256 }
257 else if (fCharge * cpdg2 < 0) {
258 m2 = mpdg1 * mpdg1;
259 ppdg = pdg1;
260 }
261 else
262 Error("SetMassHypo", "via STS charge went wrong!");
263
264 // use TOF time(ns) and track length(cm) if available
265 if (fTofHit && kFALSE) { //TODO: switched OFF!!
266 m2 = fMomentum.Mag2()
267 * (TMath::Power((fTofHit->GetTime() * 1e-9 * TMath::C()) / fGlblTrack->GetLength() / 100, 2) - 1);
268 }
269
270 // refit (under pdg assumption if activated)
271 if (!refitMassAssump && !fFastTrack) {
273 const CbmTrackParam* ppar = fGlblTrack->GetParamVertex();
274 if (ppar) {
275 fMomentum.SetPxPyPzE(ppar->GetPx(), ppar->GetPy(), ppar->GetPz(), 0.);
276 fMomentum.SetE(TMath::Sqrt(fMomentum.Vect().Mag2() + m2));
277 fPosition.SetXYZM(ppar->GetX(), ppar->GetY(), ppar->GetZ(), TMath::Sqrt(m2));
278 fCharge = (ppar->GetQp() > 0. ? +1. : -1.);
280 }
281 else
282 Refit(211);
283 }
284 else {
285 Refit(ppdg);
286 // fMomentum.Print();
288 fMomentum.SetE(TMath::Sqrt(fMomentum.Vect().Mag2() + m2));
289 // fMomentum.Print();
290 }
291}
292
293//______________________________________________
294void PairAnalysisTrack::Refit(Int_t pidHypo)
295{
296 //
297 // refit the track under certain mass assumption using CbmL1PFFitter
298 // to the primary vertex
299 //
300
302 if (fFastTrack) return;
303
304 vector<CbmStsTrack> stsTracks;
305 stsTracks.resize(1);
306 stsTracks[0] = *fStsTrack;
307 vector<CbmL1PFFitter::PFFieldRegion> vField;
308 vector<float> chiPrim;
309 vector<int> pidHypos;
310 pidHypos.push_back(pidHypo);
311
312 // printf("stst track: %p \t prim vertex: %p\n",fStsTrack,fPrimVertex);
313 // printf(" fit track with mass assumption, pdg: %d (default is: %d)\n",pidHypo,fStsTrack->GetPidHypo());
314
315 CbmL1PFFitter fPFFitter;
316 if (pidHypo) fPFFitter.Fit(stsTracks, pidHypos); // fit with mass hypo
317 // printf(" fit done for mass hypo (%p)\n",&stsTracks[0]);
318
319 // NOTE: as an alternative to fPFFitter.Fit one can use fStsTrack->SetPidHypo(pidHypo);
320 fPFFitter.GetChiToVertex(stsTracks, vField, chiPrim, *fPrimVertex, 3.e6);
321 fChi2Vtx = chiPrim[0];
322 // printf(" track refitted with chi2/ndf: %.3f , param %p \n",fChi2Vtx,stsTracks[0].GetParamFirst());
323
324 const FairTrackParam* vtxTrack = stsTracks[0].GetParamFirst();
325 if (!vtxTrack) Error("Refit", "No track param found!");
326
327 // update position and momentum vectors
328 TVector3 mom;
329 vtxTrack->Momentum(mom);
330 fMomentum.SetVect(mom);
331
332 TVector3 pos;
333 vtxTrack->Position(pos);
334 fPosition.SetVect(pos);
335
336 // set charge based on fit
337 fCharge = (vtxTrack->GetQp() > 0. ? +1. : -1.);
338}
339
340//______________________________________________
342{
343 //
344 // calculation according to CbmL1PFFitter::GetChiToVertex
345 //
346
347 // primary vertex
348 Double_t Cv[3] = {fPrimVertex->GetCovMatrix()[0], fPrimVertex->GetCovMatrix()[1], fPrimVertex->GetCovMatrix()[2]};
349
350 // track params at prim vertex
351 const CbmTrackParam* ppar = fGlblTrack->GetParamVertex();
352
353 // impact param
354 Double_t dx = ppar->GetX() - fPrimVertex->GetRefX();
355 Double_t dy = ppar->GetY() - fPrimVertex->GetRefY();
356
357
358 Double_t c[3] = {ppar->GetCovariance(0, 0), ppar->GetCovariance(1, 0), ppar->GetCovariance(1, 1)};
359 c[0] += Cv[0];
360 c[1] += Cv[1];
361 c[2] += Cv[2];
362
363 Double_t d = c[0] * c[2] - c[1] * c[1];
364 Double_t chi = TMath::Sqrt(TMath::Abs(0.5 * (dx * dx * c[0] - 2 * dx * dy * c[1] + dy * dy * c[2]) / d));
365 Bool_t isNull = (TMath::Abs(d) < 1.e-20);
366
367 if (isNull) fChi2Vtx = -1.;
368 else
369 fChi2Vtx = chi;
370}
XPU_D constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
Definition CbmDefs.h:29
ECbmModuleId
Definition CbmDefs.h:39
@ kMvd
Micro-Vertex Detector.
@ kTrd
Transition Radiation Detector.
@ kTof
Time-of-flight Detector.
@ kSts
Silicon Tracking System.
@ kMuch
Muon detection system.
@ kRich
Ring-Imaging Cherenkov Detector.
Typedefs for algorithm interfaces.
Tool factory for creation of littrack algorithms.
Data class for track parameters.
Data class for STS tracks.
boost::shared_ptr< CbmLitTrackExtrapolator > TrackExtrapolatorPtr
ClassImp(PairAnalysisTrack) PairAnalysisTrack
#define BIT(n)
Definition RTypes.h:14
const CbmTrackParam * GetParamVertex() const
double GetLength() const
double GetTime() const
Definition CbmHit.h:76
Double_t & GetRefX()
Definition CbmKFVertex.h:25
Double_t * GetCovMatrix()
Definition CbmKFVertex.h:28
Double_t & GetRefY()
Definition CbmKFVertex.h:26
void GetChiToVertex(std::vector< CbmStsTrack > &Tracks, std::vector< PFFieldRegion > &field, std::vector< float > &chiToVtx, CbmKFVertex &primVtx, float chiPrim=-1)
void Fit(std::vector< CbmStsTrack > &Tracks, const std::vector< CbmMvdHit > &vMvdHits, const std::vector< CbmStsHit > &vStsHits, const std::vector< int > &pidHypo)
static void FairTrackParamToCbmLitTrackParam(const FairTrackParam *par, CbmLitTrackParam *litPar)
static void CbmLitTrackParamToFairTrackParam(const CbmLitTrackParam *litPar, FairTrackParam *par)
static TrackExtrapolatorPtr CreateTrackExtrapolator(const string &name)
Create track extrapolation tool by name.
Data class for track parameters.
int32_t GetPdgCode() const
Definition CbmMCTrack.h:68
static CbmMvdDetector * Instance()
CbmMvdStationPar * GetParameterFile()
Int_t GetStationCount() const
Double_t GetZPosition(Int_t stationNumber) const
double GetPz() const
double GetPx() const
double GetPy() const
const FairTrackParam * GetParamFirst() const
Definition CbmTrack.h:68
CbmTrackMatchNew * fRichRingMatch
TLorentzVector fMomentum
CbmTrackMatchNew * fMuchTrackMatch
CbmTrackMatchNew * GetTrackMatch(ECbmModuleId det) const
CbmTrack * GetTrack(ECbmModuleId det) const
CbmGlobalTrack * fGlblTrack
TLorentzVector fPosition
void SetMassHypo(Int_t pdg1, Int_t pdg2, Bool_t refitMassAssump)
CbmTrdTrack * fTrdTrack
void Refit(Int_t pidHypo)
CbmTrackMatchNew * fStsTrackMatch
FairTrackParam * fMvdEntrance
CbmMuchTrack * fMuchTrack
CbmTrackMatchNew * fTrdTrackMatch
CbmStsTrack * fStsTrack
CbmKFVertex * fPrimVertex