Fork me on GitHub

source: git/external/TrackCovariance/ObsTrk.cc@ 0983d48

Last change on this file since 0983d48 was ebf40fd, checked in by Franco BEDESCHI <bed@…>, 3 years ago

Major update to handle highly displaced tracks

  • Property mode set to 100644
File size: 4.5 KB
Line 
1#include <TMath.h>
2#include <TVector3.h>
3#include <TMatrixD.h>
4#include <TMatrixDSym.h>
5#include <TDecompChol.h>
6#include <TRandom.h>
7#include <iostream>
8#include "SolGeom.h"
9#include "SolGridCov.h"
10#include "ObsTrk.h"
11//
12// Constructors
13//
14// x(3) track origin, p(3) track momentum at origin, Q charge, B ma gnetic field in Tesla
15ObsTrk::ObsTrk(TVector3 x, TVector3 p, Double_t Q, SolGridCov *GC, SolGeom *G)
16{
17 fB = G->B();
18 SetB(fB);
19 fG = G;
20 fGC = GC;
21 fGenX = x;
22 fGenP = p;
23 fGenQ = Q;
24 fGenPar.ResizeTo(5);
25 fGenParMm.ResizeTo(5);
26 fGenParACTS.ResizeTo(6);
27 fGenParILC.ResizeTo(5);
28 fObsPar.ResizeTo(5);
29 fObsParMm.ResizeTo(5);
30 fObsParACTS.ResizeTo(6);
31 fObsParILC.ResizeTo(5);
32 fCov.ResizeTo(5, 5);
33 fCovMm.ResizeTo(5, 5);
34 fCovACTS.ResizeTo(6, 6);
35 fCovILC.ResizeTo(5, 5);
36 fGenPar = XPtoPar(x,p,Q);
37 fGenParMm = ParToMm(fGenPar);
38 fGenParACTS = ParToACTS(fGenPar);
39 fGenParILC = ParToILC(fGenPar);
40 //
41 fObsPar = GenToObsPar(fGenPar);
42 fObsParMm = ParToMm(fObsPar);
43 fObsParACTS = ParToACTS(fObsPar);
44 fObsParILC = ParToILC(fObsPar);
45 fObsX = ParToX(fObsPar);
46 fObsP = ParToP(fObsPar);
47 fObsQ = ParToQ(fObsPar);
48 fCovMm = CovToMm(fCov);
49 fCovACTS = CovToACTS(fObsPar, fCov);
50 fCovILC = CovToILC(fCov);
51}
52//
53// x[3] track origin, p[3] track momentum at origin, Q charge, B magnetic field in Tesla
54ObsTrk::ObsTrk(Double_t *x, Double_t *p, Double_t Q, SolGridCov* GC, SolGeom *G)
55{
56 fB = G->B();
57 SetB(fB);
58 fG = G;
59 fGC = GC;
60 fGenX.SetXYZ(x[0],x[1],x[2]);
61 fGenP.SetXYZ(p[0],p[1],p[2]);
62 fGenQ = Q;
63 fGenPar.ResizeTo(5);
64 fGenParMm.ResizeTo(5);
65 fGenParACTS.ResizeTo(6);
66 fGenParILC.ResizeTo(5);
67 fObsPar.ResizeTo(5);
68 fObsParMm.ResizeTo(5);
69 fObsParACTS.ResizeTo(6);
70 fObsParILC.ResizeTo(5);
71 fCov.ResizeTo(5, 5);
72 fCovMm.ResizeTo(5, 5);
73 fCovACTS.ResizeTo(6, 6);
74 fCovILC.ResizeTo(5, 5);
75 fGenPar = XPtoPar(fGenX, fGenP, Q);
76 fGenParACTS = ParToACTS(fGenPar);
77 fGenParILC = ParToILC(fGenPar);
78 //
79 fObsPar = GenToObsPar(fGenPar);
80 fObsParACTS = ParToACTS(fObsPar);
81 fObsParILC = ParToILC(fObsPar);
82 fObsX = ParToX(fObsPar);
83 fObsP = ParToP(fObsPar);
84 fObsQ = ParToQ(fObsPar);
85 fCovACTS = CovToACTS(fObsPar, fCov);
86 fCovILC = CovToILC(fCov);
87}
88//
89// Destructor
90ObsTrk::~ObsTrk()
91{
92 fGenX.Clear();
93 fGenP.Clear();
94 fGenPar.Clear();
95 fGenParMm.Clear();
96 fGenParACTS.Clear();
97 fGenParILC.Clear();
98 fObsX.Clear();
99 fObsP.Clear();
100 fObsPar.Clear();
101 fObsParMm.Clear();
102 fObsParACTS.Clear();
103 fObsParILC.Clear();
104 fCov.Clear();
105 fCovMm.Clear();
106 fCovACTS.Clear();
107 fCovILC.Clear();
108}
109//
110TVectorD ObsTrk::GenToObsPar(TVectorD gPar)
111{
112 //
113 // Check ranges
114 Double_t minPt = fGC->GetMinPt();
115 //if (pt < minPt) std::cout << "Warning ObsTrk::GenToObsPar: pt " << pt << " is below grid range of " << minPt << std::endl;
116 Double_t maxPt = fGC->GetMaxPt();
117 //if (pt > maxPt) std::cout << "Warning ObsTrk::GenToObsPar: pt " << pt << " is above grid range of " << maxPt << std::endl;
118 Double_t minAn = fGC->GetMinAng();
119 //if (angd < minAn) std::cout << "Warning ObsTrk::GenToObsPar: angle " << angd
120 // << " is below grid range of " << minAn << std::endl;
121 Double_t maxAn = fGC->GetMaxAng();
122 //if (angd > maxAn) std::cout << "Warning ObsTrk::GenToObsPar: angle " << angd
123 // << " is above grid range of " << maxAn << std::endl;
124 //
125 TMatrixDSym Cov(5);
126 //
127 // Check if track origin is inside beampipe and betwen the first disks
128 //
129 Double_t Rin = fG->GetRmin();
130 Double_t ZinPos = fG->GetZminPos();
131 Double_t ZinNeg = fG->GetZminNeg();
132 Bool_t inside = TrkUtil::IsInside(fGenX, Rin, ZinNeg, ZinPos); // Check if in inner box
133 if (inside)
134 {
135 //std::cout<<"ObsTrk:: inside: x= "<<fGenX(0)<<", y= "<<fGenX(1)
136 // <<", z= "<<fGenX(2)<<std::endl;
137 // Observed track parameters
138 Double_t pt = fGenP.Pt();
139 Double_t angd = fGenP.Theta() * 180. / TMath::Pi();
140 Cov = fGC->GetCov(pt, angd); // Track covariance
141 }
142 else
143 {
144 //std::cout<<"ObsTrk:: outside: x= "<<fGenX(0)<<", y= "<<fGenX(1)
145 // <<", z= "<<fGenX(2)<<std::endl;
146 SolTrack* trk = new SolTrack(fGenX, fGenP, fG);
147 Bool_t Res = kTRUE; Bool_t MS = kTRUE;
148 trk->CovCalc(Res, MS); // Calculate covariance matrix
149 Cov = trk->Cov(); // Track covariance
150 delete trk;
151 }
152 //
153 fCov = Cov;
154 //
155 // Now do Choleski decomposition and random number extraction, with appropriate stabilization
156 //
157 TVectorD oPar = TrkUtil::CovSmear(gPar, Cov);
158 //
159 return oPar;
160}
Note: See TracBrowser for help on using the repository browser.