CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions
tmtt::ChiSquaredFit4 Class Reference

#include <ChiSquaredFit4.h>

Inheritance diagram for tmtt::ChiSquaredFit4:
tmtt::ChiSquaredFitBase tmtt::TrackFitGeneric

Public Member Functions

 ChiSquaredFit4 (const Settings *settings, const uint nPar)
 
- Public Member Functions inherited from tmtt::ChiSquaredFitBase
 ChiSquaredFitBase (const Settings *settings, const uint nPar)
 
L1fittedTrack fit (const L1track3D &l1track3D) override
 
- Public Member Functions inherited from tmtt::TrackFitGeneric
 TrackFitGeneric (const Settings *settings, const std::string &fitterName="")
 
virtual ~TrackFitGeneric ()=default
 

Protected Member Functions

TMatrixD D (const TVectorD &x) override
 
TVectorD residuals (const TVectorD &x) override
 
TVectorD seed (const L1track3D &l1track3D) override
 
TMatrixD Vinv () override
 

Additional Inherited Members

- Public Types inherited from tmtt::ChiSquaredFitBase
enum  PAR_IDS {
  INVR, PHI0, T, Z0,
  D0
}
 
- Protected Attributes inherited from tmtt::ChiSquaredFitBase
double chiSq_
 
int ilargestresid_
 
float largestresid_
 
uint nPar_
 
double qOverPt_seed_
 
std::vector< Stub * > stubs_
 
TVectorD trackParams_
 
- Protected Attributes inherited from tmtt::TrackFitGeneric
const std::string fitterName_
 
const Settingssettings_
 

Detailed Description

Definition at line 8 of file ChiSquaredFit4.h.

Constructor & Destructor Documentation

◆ ChiSquaredFit4()

tmtt::ChiSquaredFit4::ChiSquaredFit4 ( const Settings settings,
const uint  nPar 
)

Definition at line 8 of file ChiSquaredFit4.cc.

8  : ChiSquaredFitBase(settings, nPar) {
9  largestresid_ = -1.0;
10  ilargestresid_ = -1;
11  }

References tmtt::ChiSquaredFitBase::ilargestresid_, and tmtt::ChiSquaredFitBase::largestresid_.

Member Function Documentation

◆ D()

TMatrixD tmtt::ChiSquaredFit4::D ( const TVectorD &  x)
overrideprotectedvirtual

Implements tmtt::ChiSquaredFitBase.

Definition at line 24 of file ChiSquaredFit4.cc.

24  {
25  TMatrixD D(2 * stubs_.size(), nPar_); // Empty matrix
26  D.Zero();
27  int j = 0;
28  double rInv = x[INVR];
29  double phi0 = x[PHI0];
30  double t = x[T];
31  for (unsigned i = 0; i < stubs_.size(); i++) {
32  double ri = stubs_[i]->r();
33  if (stubs_[i]->barrel()) {
34  // Derivatives of r*phi
35  D(j, INVR) = -0.5 * ri * ri;
36  D(j, PHI0) = ri;
37  j++;
38  // Derivatives of z
39  D(j, T) = ri;
40  D(j, Z0) = 1;
41  j++;
42  } else {
43  double phii = stubs_[i]->phi();
44  int iphi = stubs_[i]->iphi();
45 
46  // N.B. These represent HALF the width and number of strips of sensor.
47  double width = 0.5 * stubs_[i]->trackerModule()->sensorWidth();
48  double nstrip = 0.5 * stubs_[i]->nStrips();
49 
50  double Deltai = width * (iphi - nstrip) / nstrip; // Non-radial endcap 2S strip correction
51  if (stubs_[i]->z() > 0.0)
52  Deltai = -Deltai;
53  double DeltaiOverRi = Deltai / ri;
54  double theta0 = DeltaiOverRi + (2. / 3.) * DeltaiOverRi * DeltaiOverRi * DeltaiOverRi;
55 
56  double phi_track = phi0 - 0.5 * rInv * ri; //Expected phi hit given the track
57 
58  double tInv = 1 / t;
59  // Derivatives of r
60  D(j, INVR) = -1 * ri * ri * ri * rInv;
61  D(j, PHI0) = 0;
62  D(j, T) = -ri * tInv;
63  D(j, Z0) = -1 * tInv;
64  j++;
65  // Derivatives of r*phi
66  D(j, INVR) = -0.5 * ri * ri;
67  D(j, PHI0) = ri;
68  D(j, T) = ri * 0.5 * rInv * ri * tInv - ((phi_track - phii) - theta0) * ri * tInv;
69  D(j, Z0) = ri * 0.5 * rInv * tInv - ((phi_track - phii) - theta0) * tInv;
70  j++;
71  }
72  }
73  return D;
74  }

References Reference_intrackfit_cff::barrel, mps_fire::i, tmtt::ChiSquaredFitBase::INVR, LEDCalibrationChannels::iphi, dqmiolumiharvest::j, tmtt::ChiSquaredFitBase::nPar_, tmtt::ChiSquaredFitBase::PHI0, tmtt::ChiSquaredFitBase::stubs_, tmtt::ChiSquaredFitBase::T, submitPVValidationJobs::t, ApeEstimator_cff::width, and tmtt::ChiSquaredFitBase::Z0.

◆ residuals()

TVectorD tmtt::ChiSquaredFit4::residuals ( const TVectorD &  x)
overrideprotectedvirtual

Implements tmtt::ChiSquaredFitBase.

Definition at line 101 of file ChiSquaredFit4.cc.

101  {
102  unsigned int n = stubs_.size();
103 
104  TVectorD delta(2 * n);
105 
106  double rInv = x[INVR];
107  double phi0 = x[PHI0];
108  double t = x[T];
109  double z0 = x[Z0];
110 
111  double chiSq = 0.0;
112 
113  unsigned int j = 0;
114 
115  largestresid_ = -1.0;
116  ilargestresid_ = -1;
117 
118  // Scattering term scaling as 1/Pt.
119  double sigmaScat = settings_->kalmanMultiScattTerm() * std::abs(qOverPt_seed_);
120 
121  for (unsigned int i = 0; i < n; i++) {
122  double ri = stubs_[i]->r();
123  double zi = stubs_[i]->z();
124  double phii = stubs_[i]->phi();
125  double sigmaPerp = stubs_[i]->sigmaPerp();
126  double sigmaPar = stubs_[i]->sigmaPar();
127  sigmaPerp = sqrt(sigmaPerp * sigmaPerp + sigmaScat * sigmaScat * ri * ri);
128 
129  if (stubs_[i]->barrel()) {
130  double halfRinvRi = 0.5 * ri * rInv;
131  double aSinHalfRinvRi = halfRinvRi + (2. / 3.) * halfRinvRi * halfRinvRi * halfRinvRi;
132  double deltaphi = reco::deltaPhi(phi0 - aSinHalfRinvRi - phii, 0.);
133  delta[j++] = (ri * deltaphi) / sigmaPerp;
134  delta[j++] = (z0 + (2.0 / rInv) * t * aSinHalfRinvRi - zi) / sigmaPar;
135  } else {
136  double tInv = 1 / t;
137  double r_track = (zi - z0) * tInv;
138  double phi_track = phi0 - 0.5 * rInv * (zi - z0) * tInv;
139  int iphi = stubs_[i]->iphi();
140 
141  // N.B. These represent HALF the width and number of strips of sensor.
142  double width = 0.5 * stubs_[i]->trackerModule()->sensorWidth();
143  double nstrip = 0.5 * stubs_[i]->nStrips();
144 
145  double Deltai = width * (iphi - nstrip) / nstrip; // Non-radial endcap 2S strip correction
146 
147  if (stubs_[i]->z() > 0.0)
148  Deltai = -Deltai;
149 
150  double DeltaiOverRi = Deltai / ri;
151  double theta0 = DeltaiOverRi + (2. / 3.) * DeltaiOverRi * DeltaiOverRi * DeltaiOverRi;
152  double Delta = Deltai - r_track * (theta0 - (phi_track - phii));
153 
154  delta[j++] = (r_track - ri) / sigmaPar;
155  delta[j++] = Delta / sigmaPerp;
156  }
157 
158  chiSq += delta[j - 2] * delta[j - 2] + delta[j - 1] * delta[j - 1];
159 
160  if (std::abs(delta[j - 2]) > largestresid_) {
161  largestresid_ = std::abs(delta[j - 2]);
162  ilargestresid_ = i;
163  }
164 
165  if (std::abs(delta[j - 1]) > largestresid_) {
166  largestresid_ = std::abs(delta[j - 1]);
167  ilargestresid_ = i;
168  }
169  }
170 
171  return delta;
172  }

References funct::abs(), Reference_intrackfit_cff::barrel, dumpMFGeometry_cfg::delta, reco::deltaPhi(), mps_fire::i, tmtt::ChiSquaredFitBase::ilargestresid_, tmtt::ChiSquaredFitBase::INVR, LEDCalibrationChannels::iphi, dqmiolumiharvest::j, tmtt::Settings::kalmanMultiScattTerm(), tmtt::ChiSquaredFitBase::largestresid_, dqmiodumpmetadata::n, tmtt::ChiSquaredFitBase::PHI0, tmtt::ChiSquaredFitBase::qOverPt_seed_, tmtt::TrackFitGeneric::settings_, mathSSE::sqrt(), tmtt::ChiSquaredFitBase::stubs_, tmtt::ChiSquaredFitBase::T, submitPVValidationJobs::t, ApeEstimator_cff::width, tmtt::ChiSquaredFitBase::Z0, and HLTMuonOfflineAnalyzer_cfi::z0.

◆ seed()

TVectorD tmtt::ChiSquaredFit4::seed ( const L1track3D l1track3D)
overrideprotectedvirtual

Implements tmtt::ChiSquaredFitBase.

Definition at line 13 of file ChiSquaredFit4.cc.

13  {
14  TVectorD x(4);
15  x[INVR] = settings_->invPtToInvR() * l1track3D.qOverPt();
16  x[PHI0] = l1track3D.phi0();
17  x[T] = l1track3D.tanLambda();
18  x[Z0] = l1track3D.z0();
19  return x;
20  }

References tmtt::Settings::invPtToInvR(), tmtt::ChiSquaredFitBase::INVR, tmtt::ChiSquaredFitBase::PHI0, tmtt::L1track3D::phi0(), tmtt::L1track3D::qOverPt(), tmtt::TrackFitGeneric::settings_, tmtt::ChiSquaredFitBase::T, tmtt::L1track3D::tanLambda(), tmtt::ChiSquaredFitBase::Z0, and tmtt::L1track3D::z0().

◆ Vinv()

TMatrixD tmtt::ChiSquaredFit4::Vinv ( )
overrideprotectedvirtual

Implements tmtt::ChiSquaredFitBase.

Definition at line 79 of file ChiSquaredFit4.cc.

79  {
80  TMatrixD Vinv(2 * stubs_.size(), 2 * stubs_.size());
81  // Scattering term scaling as 1/Pt.
82  double sigmaScat = settings_->kalmanMultiScattTerm() * std::abs(qOverPt_seed_);
83  for (unsigned i = 0; i < stubs_.size(); i++) {
84  double sigmaPerp = stubs_[i]->sigmaPerp();
85  double sigmaPar = stubs_[i]->sigmaPar();
86  double ri = stubs_[i]->r();
87  sigmaPerp = sqrt(sigmaPerp * sigmaPerp + sigmaScat * sigmaScat * ri * ri);
88  if (stubs_[i]->barrel()) {
89  Vinv(2 * i, 2 * i) = 1 / sigmaPerp;
90  Vinv(2 * i + 1, 2 * i + 1) = 1 / sigmaPar;
91  } else {
92  Vinv(2 * i, 2 * i) = 1 / sigmaPar;
93  Vinv(2 * i + 1, 2 * i + 1) = 1 / sigmaPerp;
94  }
95  }
96  return Vinv;
97  }

References funct::abs(), Reference_intrackfit_cff::barrel, mps_fire::i, tmtt::Settings::kalmanMultiScattTerm(), tmtt::ChiSquaredFitBase::qOverPt_seed_, tmtt::TrackFitGeneric::settings_, mathSSE::sqrt(), and tmtt::ChiSquaredFitBase::stubs_.

ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
tmtt::ChiSquaredFitBase::Z0
Definition: ChiSquaredFitBase.h:23
mps_fire.i
i
Definition: mps_fire.py:428
tmtt::ChiSquaredFitBase::INVR
Definition: ChiSquaredFitBase.h:23
tmtt::ChiSquaredFitBase::PHI0
Definition: ChiSquaredFitBase.h:23
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
tmtt::ChiSquaredFitBase::nPar_
uint nPar_
Definition: ChiSquaredFitBase.h:41
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
HcalResponse_cfi.nPar
nPar
Definition: HcalResponse_cfi.py:33
tmtt::TrackFitGeneric::settings_
const Settings * settings_
Definition: TrackFitGeneric.h:31
tmtt::ChiSquaredFit4::D
TMatrixD D(const TVectorD &x) override
Definition: ChiSquaredFit4.cc:24
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HLTMuonOfflineAnalyzer_cfi.z0
z0
Definition: HLTMuonOfflineAnalyzer_cfi.py:98
tmtt::Settings::kalmanMultiScattTerm
double kalmanMultiScattTerm() const
Definition: Settings.h:324
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
tmtt::ChiSquaredFitBase::qOverPt_seed_
double qOverPt_seed_
Definition: ChiSquaredFitBase.h:38
tmtt::ChiSquaredFitBase::largestresid_
float largestresid_
Definition: ChiSquaredFitBase.h:42
tmtt::ChiSquaredFitBase::stubs_
std::vector< Stub * > stubs_
Definition: ChiSquaredFitBase.h:39
T
long double T
Definition: Basic3DVectorLD.h:48
genVertex_cff.x
x
Definition: genVertex_cff.py:12
tmtt::ChiSquaredFitBase::ChiSquaredFitBase
ChiSquaredFitBase(const Settings *settings, const uint nPar)
Definition: ChiSquaredFitBase.cc:17
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
tmtt::ChiSquaredFitBase::T
Definition: ChiSquaredFitBase.h:23
tmtt::ChiSquaredFit4::Vinv
TMatrixD Vinv() override
Definition: ChiSquaredFit4.cc:79
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
tmtt::Settings::invPtToInvR
double invPtToInvR() const
Definition: Settings.h:395
tmtt::ChiSquaredFitBase::ilargestresid_
int ilargestresid_
Definition: ChiSquaredFitBase.h:43