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

Enumerator
INVR 
PHI0 
Z0 
D0 

Definition at line 23 of file ChiSquaredFitBase.h.

23 { INVR, PHI0, T, Z0, D0 };

Constructor & Destructor Documentation

◆ ChiSquaredFitBase()

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

Definition at line 17 of file ChiSquaredFitBase.cc.

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  }

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_.

Member Function Documentation

◆ calculateChiSq()

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

Definition at line 30 of file ChiSquaredFitBase.cc.

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  }

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

Referenced by fit().

◆ calculateDeltaChiSq()

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

Definition at line 39 of file ChiSquaredFitBase.cc.

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

References chiSq_, and mps_fire::i.

Referenced by fit().

◆ 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.

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  }

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_, RunInfoPI::valid, Vinv(), and Z0.

Referenced by trackingPlots.Iteration::modules().

◆ 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.

tmtt::ChiSquaredFitBase::Vinv
virtual TMatrixD Vinv()=0
tmtt::ChiSquaredFitBase::residuals
virtual TVectorD residuals(const TVectorD &x)=0
tmtt::Settings::numTrackFitIterations
unsigned int numTrackFitIterations() const
Definition: Settings.h:260
tmtt::ChiSquaredFitBase::Z0
Definition: ChiSquaredFitBase.h:23
mps_fire.i
i
Definition: mps_fire.py:428
tmtt::ChiSquaredFitBase::calculateDeltaChiSq
void calculateDeltaChiSq(const TVectorD &deltaX, const TVectorD &covX)
Definition: ChiSquaredFitBase.cc:39
tmtt::ChiSquaredFitBase::INVR
Definition: ChiSquaredFitBase.h:23
tmtt::ChiSquaredFitBase::PHI0
Definition: ChiSquaredFitBase.h:23
tmtt::Utility::countLayers
unsigned int countLayers(const Settings *settings, const std::vector< const Stub * > &stubs, bool disableReducedLayerID=false, bool onlyPS=false)
Definition: Utility.cc:25
tmtt::ChiSquaredFitBase::calculateChiSq
void calculateChiSq(const TVectorD &resids)
Definition: ChiSquaredFitBase.cc:30
tmtt::Settings::minStubLayers
unsigned int minStubLayers() const
Definition: Settings.h:216
tmtt::Settings::killingResidualCut
double killingResidualCut() const
Definition: Settings.h:267
tmtt::ChiSquaredFitBase::nPar_
uint nPar_
Definition: ChiSquaredFitBase.h:41
tmtt::ChiSquaredFitBase::minStubLayersRed_
unsigned int minStubLayersRed_
Definition: ChiSquaredFitBase.h:56
parallelization.uint
uint
Definition: parallelization.py:124
HcalResponse_cfi.nPar
nPar
Definition: HcalResponse_cfi.py:33
tmtt::Utility::FIT
Definition: Utility.h:28
tmtt::TrackFitGeneric::settings_
const Settings * settings_
Definition: TrackFitGeneric.h:31
tmtt::ChiSquaredFitBase::generalResidualCut_
double generalResidualCut_
Definition: ChiSquaredFitBase.h:52
tmtt::ChiSquaredFitBase::killingResidualCut_
double killingResidualCut_
Definition: ChiSquaredFitBase.h:53
tmtt::ChiSquaredFitBase::minStubLayers_
unsigned int minStubLayers_
Definition: ChiSquaredFitBase.h:55
tmtt::ChiSquaredFitBase::D0
Definition: ChiSquaredFitBase.h:23
MuonTCMETValueMapProducer_cff.nLayers
nLayers
Definition: MuonTCMETValueMapProducer_cff.py:38
tmtt::ChiSquaredFitBase::D
virtual TMatrixD D(const TVectorD &x)=0
tmtt::ChiSquaredFitBase::seed
virtual TVectorD seed(const L1track3D &l1track3D)=0
tmtt::ChiSquaredFitBase::numFittingIterations_
int numFittingIterations_
Definition: ChiSquaredFitBase.h:50
tmtt::Utility::numLayerCut
unsigned int numLayerCut(Utility::AlgoStep algo, const Settings *settings, unsigned int iPhiSec, unsigned int iEtaReg, float invPt, float eta=0.)
Definition: Utility.cc:141
tmtt::ChiSquaredFitBase::qOverPt_seed_
double qOverPt_seed_
Definition: ChiSquaredFitBase.h:38
tmtt::Settings::generalResidualCut
double generalResidualCut() const
Definition: Settings.h:266
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
tmtt::ChiSquaredFitBase::killTrackFitWorstHit_
int killTrackFitWorstHit_
Definition: ChiSquaredFitBase.h:51
genVertex_cff.x
x
Definition: genVertex_cff.py:13
tmtt::Settings::killTrackFitWorstHit
bool killTrackFitWorstHit() const
Definition: Settings.h:262
ztail.d
d
Definition: ztail.py:151
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
RunInfoPI::valid
Definition: RunInfoPayloadInspectoHelper.h:16
tmtt::ChiSquaredFitBase::T
Definition: ChiSquaredFitBase.h:23
tmtt::TrackFitGeneric::TrackFitGeneric
TrackFitGeneric(const Settings *settings, const std::string &fitterName="")
Definition: TrackFitGeneric.h:21
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
tmtt::Settings::invPtToInvR
double invPtToInvR() const
Definition: Settings.h:395
tmtt::ChiSquaredFitBase::chiSq_
double chiSq_
Definition: ChiSquaredFitBase.h:44
tmtt::ChiSquaredFitBase::ilargestresid_
int ilargestresid_
Definition: ChiSquaredFitBase.h:43