Changes in external/TrackCovariance/ObsTrk.cc [ebf40fd:53f4746] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
external/TrackCovariance/ObsTrk.cc
rebf40fd r53f4746 6 6 #include <TRandom.h> 7 7 #include <iostream> 8 #include "SolGeom.h"9 8 #include "SolGridCov.h" 10 9 #include "ObsTrk.h" … … 12 11 // Constructors 13 12 // 14 // x(3) track origin, p(3) track momentum at origin, Q charge, B ma 15 ObsTrk::ObsTrk(TVector3 x, TVector3 p, Double_t Q, SolGridCov *GC, SolGeom *G)13 // x(3) track origin, p(3) track momentum at origin, Q charge, B magnetic field in Tesla 14 ObsTrk::ObsTrk(TVector3 x, TVector3 p, Double_t Q, Double_t B, SolGridCov *GC) 16 15 { 17 fB = G->B(); 18 SetB(fB); 19 fG = G; 16 SetB(B); 20 17 fGC = GC; 21 18 fGenX = x; 22 19 fGenP = p; 23 20 fGenQ = Q; 21 fB = B; 24 22 fGenPar.ResizeTo(5); 25 23 fGenParMm.ResizeTo(5); … … 38 36 fGenParACTS = ParToACTS(fGenPar); 39 37 fGenParILC = ParToILC(fGenPar); 40 // 41 fObsPar = GenToObsPar(fGenPar); 38 /* 39 cout << "ObsTrk::ObsTrk: fGenPar"; 40 for (Int_t i = 0; i < 5; i++)cout << fGenPar(i) << ", "; 41 cout << endl; 42 */ 43 fObsPar = GenToObsPar(fGenPar, fGC); 42 44 fObsParMm = ParToMm(fObsPar); 43 45 fObsParACTS = ParToACTS(fObsPar); … … 52 54 // 53 55 // x[3] track origin, p[3] track momentum at origin, Q charge, B magnetic field in Tesla 54 ObsTrk::ObsTrk(Double_t *x, Double_t *p, Double_t Q, SolGridCov* GC, SolGeom *G)56 ObsTrk::ObsTrk(Double_t *x, Double_t *p, Double_t Q, Double_t B, SolGridCov* GC) 55 57 { 56 fB = G->B(); 57 SetB(fB); 58 fG = G; 58 SetB(B); 59 59 fGC = GC; 60 60 fGenX.SetXYZ(x[0],x[1],x[2]); 61 61 fGenP.SetXYZ(p[0],p[1],p[2]); 62 62 fGenQ = Q; 63 fB = B; 63 64 fGenPar.ResizeTo(5); 64 65 fGenParMm.ResizeTo(5); … … 76 77 fGenParACTS = ParToACTS(fGenPar); 77 78 fGenParILC = ParToILC(fGenPar); 78 // 79 fObsPar = GenToObsPar(fGenPar); 79 /* 80 cout << "ObsTrk::ObsTrk: fGenPar"; 81 for (Int_t i = 0; i < 5; i++)cout << fGenPar(i) << ", "; 82 cout << endl; 83 */ 84 fObsPar = GenToObsPar(fGenPar, fGC); 80 85 fObsParACTS = ParToACTS(fObsPar); 81 86 fObsParILC = ParToILC(fObsPar); … … 108 113 } 109 114 // 110 TVectorD ObsTrk::GenToObsPar(TVectorD gPar )115 TVectorD ObsTrk::GenToObsPar(TVectorD gPar, SolGridCov *GC) 111 116 { 117 TVector3 p = ParToP(gPar); 118 Double_t pt = p.Pt(); 119 Double_t tanTh = 1.0 / TMath::Abs(gPar(4)); 120 Double_t angd = TMath::ATan(tanTh)*180. / TMath::Pi(); 112 121 // 113 122 // 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 " << angd120 // << " is below grid range of " << minAn << std::endl;121 Double_t maxAn = fGC->GetMaxAng();122 //if (angd > maxAn) std::cout << "Warning ObsTrk::GenToObsPar: angle " << angd123 // << " is above grid range of " << maxAn << std::endl;123 Double_t minPt = GC->GetMinPt (); 124 //if (pt < minPt) cout << "Warning ObsTrk::GenToObsPar: pt " << pt << " is below grid range of " << minPt << endl; 125 Double_t maxPt = GC->GetMaxPt(); 126 //if (pt > maxPt) cout << "Warning ObsTrk::GenToObsPar: pt " << pt << " is above grid range of " << maxPt << endl; 127 Double_t minAn = GC->GetMinAng(); 128 //if (angd < minAn) cout << "Warning ObsTrk::GenToObsPar: angle " << angd 129 // << " is below grid range of " << minAn << endl; 130 Double_t maxAn = GC->GetMaxAng(); 131 //if (angd > maxAn) cout << "Warning ObsTrk::GenToObsPar: angle " << angd 132 // << " is above grid range of " << maxAn << endl; 124 133 // 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 // 134 TMatrixDSym Cov = GC->GetCov(pt, angd); 153 135 fCov = Cov; 154 136 // 155 137 // Now do Choleski decomposition and random number extraction, with appropriate stabilization 156 138 // 157 TVectorD oPar = TrkUtil::CovSmear(gPar, Cov); 139 TMatrixDSym CvN = Cov; 140 TMatrixDSym DCv(5); DCv.Zero(); 141 TMatrixDSym DCvInv(5); DCvInv.Zero(); 142 for (Int_t id = 0; id < 5; id++) 143 { 144 Double_t dVal = TMath::Sqrt(Cov(id, id)); 145 DCv (id, id) = dVal; 146 DCvInv(id, id) = 1.0 / dVal; 147 } 148 CvN.Similarity(DCvInv); // Normalize diagonal to 1 149 TDecompChol Chl(CvN); 150 Bool_t OK = Chl.Decompose(); // Choleski decomposition of normalized matrix 151 TMatrixD U = Chl.GetU(); // Get Upper triangular matrix 152 TMatrixD Ut(TMatrixD::kTransposed, U); // Transposed of U (lower triangular) 153 TVectorD r(5); 154 for (Int_t i = 0; i < 5; i++)r(i) = gRandom->Gaus(0.0, 1.0); // Array of normal random numbers 155 TVectorD oPar = gPar + DCv*(Ut*r); // Observed parameter vector 158 156 // 159 157 return oPar;
Note:
See TracChangeset
for help on using the changeset viewer.