CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
tmtt::ChiSquaredFitBase Class Referenceabstract

#include <ChiSquaredFitBase.h>

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

Public Types

enum  PAR_IDS {
  INVR, PHI0, T, Z0,
  D0
}
 

Public Member Functions

 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

virtual TMatrixD D (const TVectorD &x)=0
 
virtual TVectorD residuals (const TVectorD &x)=0
 
virtual TVectorD seed (const L1track3D &l1track3D)=0
 
virtual TMatrixD Vinv ()=0
 

Protected Attributes

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_
 

Private Member Functions

void calculateChiSq (const TVectorD &resids)
 
void calculateDeltaChiSq (const TVectorD &deltaX, const TVectorD &covX)
 

Private Attributes

double generalResidualCut_
 
double killingResidualCut_
 
int killTrackFitWorstHit_
 
unsigned int minStubLayers_
 
unsigned int minStubLayersRed_
 
int numFittingIterations_
 

Detailed Description

Definition at line 21 of file ChiSquaredFitBase.h.

Member Enumeration Documentation

◆ PAR_IDS

Constructor & Destructor Documentation

◆ ChiSquaredFitBase()

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

Definition at line 17 of file ChiSquaredFitBase.cc.

References tmtt::Settings::generalResidualCut(), generalResidualCut_, tmtt::Settings::killingResidualCut(), killingResidualCut_, tmtt::Settings::killTrackFitWorstHit(), killTrackFitWorstHit_, tmtt::Settings::minStubLayers(), minStubLayers_, HcalResponse_cfi::nPar, nPar_, numFittingIterations_, tmtt::Settings::numTrackFitIterations(), and tmtt::TrackFitGeneric::settings_.

18  : TrackFitGeneric(settings), chiSq_(0.0) {
19  // Bad stub killing settings
22  generalResidualCut_ = settings_->generalResidualCut(); // The cut used to remove bad stubs (if nStubs > minLayers)
23  killingResidualCut_ = settings_->killingResidualCut(); // The cut used to kill off tracks entirely
24 
25  //--- These two parameters are used to check if after the fit, there are still enough stubs on the track
27  nPar_ = nPar;
28  }
unsigned int numTrackFitIterations() const
Definition: Settings.h:260
bool killTrackFitWorstHit() const
Definition: Settings.h:262
const Settings * settings_
TrackFitGeneric(const Settings *settings, const std::string &fitterName="")
unsigned int minStubLayers() const
Definition: Settings.h:216
double generalResidualCut() const
Definition: Settings.h:266
double killingResidualCut() const
Definition: Settings.h:267

Member Function Documentation

◆ calculateChiSq()

void tmtt::ChiSquaredFitBase::calculateChiSq ( const TVectorD &  resids)
private

Definition at line 30 of file ChiSquaredFitBase.cc.

References chiSq_, mps_fire::i, dqmiolumiharvest::j, stubs_, and parallelization::uint.

Referenced by fit().

30  {
31  chiSq_ = 0.0;
32  uint j = 0;
33  for (uint i = 0; i < stubs_.size(); i++) {
34  chiSq_ += resids[j] * resids[j] + resids[j + 1] * resids[j + 1];
35  j = j + 2;
36  }
37  }
std::vector< Stub * > stubs_

◆ calculateDeltaChiSq()

void tmtt::ChiSquaredFitBase::calculateDeltaChiSq ( const TVectorD &  deltaX,
const TVectorD &  covX 
)
private

Definition at line 39 of file ChiSquaredFitBase.cc.

References chiSq_, and mps_fire::i.

Referenced by fit().

39  {
40  for (int i = 0; i < covX.GetNrows(); i++) {
41  chiSq_ -= (delX[i]) * covX[i];
42  }
43  }

◆ D()

virtual TMatrixD tmtt::ChiSquaredFitBase::D ( const TVectorD &  x)
protectedpure virtual

Implemented in tmtt::ChiSquaredFit4.

Referenced by fit().

◆ fit()

L1fittedTrack tmtt::ChiSquaredFitBase::fit ( const L1track3D l1track3D)
overridevirtual

Reimplemented from tmtt::TrackFitGeneric.

Definition at line 45 of file ChiSquaredFitBase.cc.

References funct::abs(), calculateChiSq(), calculateDeltaChiSq(), chiSq_, tmtt::Utility::countLayers(), D(), ztail::d, tmtt::L1track3D::eta(), tmtt::Utility::FIT, generalResidualCut_, mps_fire::i, tmtt::L1track3D::iEtaReg(), ilargestresid_, tmtt::Settings::invPtToInvR(), INVR, tmtt::L1track3D::iPhiSec(), killingResidualCut_, killTrackFitWorstHit_, largestresid_, minStubLayersRed_, MuonTCMETValueMapProducer_cff::nLayers, nPar_, numFittingIterations_, tmtt::Utility::numLayerCut(), PHI0, tmtt::L1track3D::qOverPt(), qOverPt_seed_, residuals(), seed(), tmtt::TrackFitGeneric::settings_, tmtt::L1track3D::stubs(), stubs_, validateGeometry_cfg::valid, Vinv(), x, and Z0.

Referenced by trackingPlots.Iteration::modules().

45  {
46  qOverPt_seed_ = l1track3D.qOverPt();
47  stubs_ = l1track3D.stubs();
48 
49  // Get cut on number of layers including variation due to dead sectors, pt dependence etc.
51  settings_,
52  l1track3D.iPhiSec(),
53  l1track3D.iEtaReg(),
54  std::abs(l1track3D.qOverPt()),
55  l1track3D.eta());
56 
57  TVectorD x = seed(l1track3D);
58 
59  for (int i = 0; i < numFittingIterations_; i++) {
60  TMatrixD d = D(x);
61  TMatrixD dTrans(TMatrixD::kTransposed, d);
62  TMatrixD dtVinv = dTrans * Vinv();
63  TMatrixD dtVinvTrans(TMatrixD::kTransposed, dtVinv);
64  //TMatrixD M = dtVinv * d; // Must insert extra factor Vinv, due to unconventional Vinv() definition.
65  TMatrixD M = dtVinv * dtVinvTrans;
66  TMatrixD Minv(TMatrixD::kInverted, M);
67  TVectorD resids = residuals(x);
68  TVectorD deltaX = Minv * dtVinv * resids;
69  x = x - deltaX;
70  TVectorD covX = dTrans * Vinv() * resids;
71  calculateChiSq(resids);
72  calculateDeltaChiSq(deltaX, covX);
73 
74  if (i < numFittingIterations_ - 1) { // Don't kill stub if will not refit.
75 
76  resids = residuals(x); // update resids & largestresid_
77 
78  bool killWorstStub = false;
81  killWorstStub = true;
82  } else if (largestresid_ > generalResidualCut_) {
83  std::vector<Stub*> stubsTmp = stubs_;
84  stubsTmp.erase(stubsTmp.begin() + ilargestresid_);
86  killWorstStub = true;
87  } else {
88  // Get better apparent tracking performance by always killing worst stub until only 4 layers left.
90  killWorstStub = true;
91  }
92  }
93 
94  if (killWorstStub) {
95  stubs_.erase(stubs_.begin() + ilargestresid_);
96 
97  // Reject tracks with too many killed stubs & stop iterating.
98  unsigned int nLayers = Utility::countLayers(settings_, stubs_); // Count tracker layers with stubs
100 
101  if (not valid) {
102  L1fittedTrack rejectedTrk;
103  return rejectedTrk;
104  }
105  } else {
106  break;
107  }
108  }
109  }
110 
111  // Reject tracks with too many killed stubs
112  unsigned int nLayers = Utility::countLayers(settings_, stubs_); // Count tracker layers with stubs
113  bool valid = nLayers >= minStubLayersRed_;
114 
115  if (valid) {
116  const unsigned int hitPattern = 0; // FIX: Needs setting
117  const float chi2rz = 0; // FIX: Needs setting
118  return L1fittedTrack(settings_,
119  &l1track3D,
120  stubs_,
121  hitPattern,
122  x[INVR] / (settings_->invPtToInvR()),
123  0,
124  x[PHI0],
125  x[Z0],
126  x[T],
127  chiSq_,
128  chi2rz,
129  nPar_);
130  } else {
131  L1fittedTrack rejectedTrk;
132  return rejectedTrk;
133  }
134  }
virtual TVectorD residuals(const TVectorD &x)=0
void calculateChiSq(const TVectorD &resids)
virtual TMatrixD D(const TVectorD &x)=0
virtual TMatrixD Vinv()=0
virtual TVectorD seed(const L1track3D &l1track3D)=0
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const Settings * settings_
std::vector< Stub * > stubs_
void calculateDeltaChiSq(const TVectorD &deltaX, const TVectorD &covX)
d
Definition: ztail.py:151
unsigned int numLayerCut(Utility::AlgoStep algo, const Settings *settings, unsigned int iPhiSec, unsigned int iEtaReg, float invPt, float eta=0.)
Definition: Utility.cc:141
unsigned int countLayers(const Settings *settings, const std::vector< const Stub *> &stubs, bool disableReducedLayerID=false, bool onlyPS=false)
Definition: Utility.cc:25
long double T
double invPtToInvR() const
Definition: Settings.h:395

◆ residuals()

virtual TVectorD tmtt::ChiSquaredFitBase::residuals ( const TVectorD &  x)
protectedpure virtual

Implemented in tmtt::ChiSquaredFit4.

Referenced by fit().

◆ seed()

virtual TVectorD tmtt::ChiSquaredFitBase::seed ( const L1track3D l1track3D)
protectedpure virtual

Implemented in tmtt::ChiSquaredFit4.

Referenced by fit().

◆ Vinv()

virtual TMatrixD tmtt::ChiSquaredFitBase::Vinv ( )
protectedpure virtual

Implemented in tmtt::ChiSquaredFit4.

Referenced by fit().

Member Data Documentation

◆ chiSq_

double tmtt::ChiSquaredFitBase::chiSq_
protected

Definition at line 44 of file ChiSquaredFitBase.h.

Referenced by calculateChiSq(), calculateDeltaChiSq(), and fit().

◆ generalResidualCut_

double tmtt::ChiSquaredFitBase::generalResidualCut_
private

Definition at line 52 of file ChiSquaredFitBase.h.

Referenced by ChiSquaredFitBase(), and fit().

◆ ilargestresid_

int tmtt::ChiSquaredFitBase::ilargestresid_
protected

◆ killingResidualCut_

double tmtt::ChiSquaredFitBase::killingResidualCut_
private

Definition at line 53 of file ChiSquaredFitBase.h.

Referenced by ChiSquaredFitBase(), and fit().

◆ killTrackFitWorstHit_

int tmtt::ChiSquaredFitBase::killTrackFitWorstHit_
private

Definition at line 51 of file ChiSquaredFitBase.h.

Referenced by ChiSquaredFitBase(), and fit().

◆ largestresid_

float tmtt::ChiSquaredFitBase::largestresid_
protected

◆ minStubLayers_

unsigned int tmtt::ChiSquaredFitBase::minStubLayers_
private

Definition at line 55 of file ChiSquaredFitBase.h.

Referenced by ChiSquaredFitBase().

◆ minStubLayersRed_

unsigned int tmtt::ChiSquaredFitBase::minStubLayersRed_
private

Definition at line 56 of file ChiSquaredFitBase.h.

Referenced by fit().

◆ nPar_

uint tmtt::ChiSquaredFitBase::nPar_
protected

Definition at line 41 of file ChiSquaredFitBase.h.

Referenced by ChiSquaredFitBase(), tmtt::ChiSquaredFit4::D(), and fit().

◆ numFittingIterations_

int tmtt::ChiSquaredFitBase::numFittingIterations_
private

Definition at line 50 of file ChiSquaredFitBase.h.

Referenced by ChiSquaredFitBase(), and fit().

◆ qOverPt_seed_

double tmtt::ChiSquaredFitBase::qOverPt_seed_
protected

◆ stubs_

std::vector<Stub*> tmtt::ChiSquaredFitBase::stubs_
protected

◆ trackParams_

TVectorD tmtt::ChiSquaredFitBase::trackParams_
protected

Definition at line 40 of file ChiSquaredFitBase.h.