[a617744] | 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>
|
---|
[ebf40fd] | 8 | #include "SolGeom.h"
|
---|
[a617744] | 9 | #include "SolGridCov.h"
|
---|
| 10 | #include "ObsTrk.h"
|
---|
| 11 | //
|
---|
| 12 | // Constructors
|
---|
| 13 | //
|
---|
[ebf40fd] | 14 | // x(3) track origin, p(3) track momentum at origin, Q charge, B ma gnetic field in Tesla
|
---|
| 15 | ObsTrk::ObsTrk(TVector3 x, TVector3 p, Double_t Q, SolGridCov *GC, SolGeom *G)
|
---|
[a617744] | 16 | {
|
---|
[ebf40fd] | 17 | fB = G->B();
|
---|
| 18 | SetB(fB);
|
---|
| 19 | fG = G;
|
---|
[a617744] | 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);
|
---|
[ebf40fd] | 40 | //
|
---|
| 41 | fObsPar = GenToObsPar(fGenPar);
|
---|
[a617744] | 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
|
---|
[ebf40fd] | 54 | ObsTrk::ObsTrk(Double_t *x, Double_t *p, Double_t Q, SolGridCov* GC, SolGeom *G)
|
---|
[a617744] | 55 | {
|
---|
[ebf40fd] | 56 | fB = G->B();
|
---|
| 57 | SetB(fB);
|
---|
| 58 | fG = G;
|
---|
[a617744] | 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);
|
---|
[ebf40fd] | 78 | //
|
---|
| 79 | fObsPar = GenToObsPar(fGenPar);
|
---|
[a617744] | 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
|
---|
| 90 | ObsTrk::~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 | //
|
---|
[ebf40fd] | 110 | TVectorD ObsTrk::GenToObsPar(TVectorD gPar)
|
---|
[a617744] | 111 | {
|
---|
| 112 | //
|
---|
| 113 | // Check ranges
|
---|
[ebf40fd] | 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;
|
---|
[a617744] | 124 | //
|
---|
[ebf40fd] | 125 | TMatrixDSym Cov(5);
|
---|
[a617744] | 126 | //
|
---|
[ebf40fd] | 127 | // Check if track origin is inside beampipe and betwen the first disks
|
---|
[a617744] | 128 | //
|
---|
[ebf40fd] | 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
|
---|
[a617744] | 143 | {
|
---|
[ebf40fd] | 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;
|
---|
[a617744] | 151 | }
|
---|
[ebf40fd] | 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);
|
---|
[a617744] | 158 | //
|
---|
| 159 | return oPar;
|
---|
| 160 | }
|
---|