CMS 3D CMS Logo

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

#include <KFbase.h>

Inheritance diagram for tmtt::KFbase:
tmtt::TrackFitGeneric tmtt::KFParamsComb

Public Types

enum  MEAS_IDS { PHI, Z }
 
enum  PAR_IDS {
  INV2R, PHI0, T, Z0,
  D0
}
 
enum  PAR_IDS_VAR { QOVERPT }
 

Public Member Functions

L1fittedTrack fit (const L1track3D &l1track3D) override
 
 KFbase (const KFbase &kf)=delete
 
 KFbase (const Settings *settings, const uint nHelixPar, const std::string &fitterName="", const uint nMeas=2)
 
 KFbase (KFbase &&kf)=delete
 
KFbaseoperator= (const KFbase &kf)=delete
 
KFbaseoperator= (KFbase &&kf)=delete
 
 ~KFbase () override
 
- Public Member Functions inherited from tmtt::TrackFitGeneric
 TrackFitGeneric (const Settings *settings, const std::string &fitterName="")
 
virtual ~TrackFitGeneric ()=default
 

Protected Member Functions

virtual void adjustChi2 (const KalmanState *state, const TMatrixD &covRinv, const TVectorD &delta, double &chi2rphi, double &chi2rz) const
 
void adjustState (const TMatrixD &K, const TMatrixD &pxcov, const TVectorD &x, const TMatrixD &h, const TVectorD &delta, TVectorD &new_x, TMatrixD &new_xcov) const
 
float approxB (float z, float r) const
 
const KalmanStatedoKF (const L1track3D &l1track3D, const std::vector< Stub * > &stubs, const TP *tpa)
 
TMatrixD getKalmanGainMatrix (const TMatrixD &h, const TMatrixD &pxcov, const TMatrixD &covRinv) const
 
virtual bool isGoodState (const KalmanState &state) const =0
 
virtual bool isHLS ()
 
virtual bool kalmanAmbiguousLayer (unsigned int iEtaReg, unsigned int kfLayer)
 
std::set< unsigned > kalmanDeadLayers (bool &remove2PSCut) const
 
virtual unsigned int kalmanLayer (unsigned int iEtaReg, unsigned int layerIDreduced, bool barrel, float r, float z) const
 
virtual const KalmanStatekalmanUpdate (unsigned nSkipped, unsigned layer, Stub *stub, const KalmanState *state, const TP *tp)
 
virtual TMatrixD matrixF (const Stub *stub=nullptr, const KalmanState *state=nullptr) const =0
 
virtual TMatrixD matrixH (const Stub *stub) const =0
 
TMatrixD matrixHCHt (const TMatrixD &h, const TMatrixD &c) const
 
TMatrixD matrixRinv (const TMatrixD &matH, const TMatrixD &matCref, const TMatrixD &matV) const
 
virtual TMatrixD matrixV (const Stub *stub, const KalmanState *state) const =0
 
const KalmanStatemkState (const L1track3D &candidate, unsigned nSkipped, unsigned layer, const KalmanState *last_state, const TVectorD &x, const TMatrixD &pxx, const TMatrixD &K, const TMatrixD &dcov, Stub *stub, double chi2rphi, double chi2rz)
 
void printStub (const Stub *stub) const
 
void printStubLayers (const std::vector< Stub * > &stubs, unsigned int iEtaReg) const
 
void printStubs (const std::vector< Stub * > &stubs) const
 
void printTP (const TP *tp) const
 
void resetStates ()
 
virtual TVectorD residual (const Stub *stub, const TVectorD &x, double candQoverPt) const
 
double sectorPhi () const
 
virtual TMatrixD seedC (const L1track3D &l1track3D) const =0
 
virtual TVectorD seedX (const L1track3D &l1track3D) const =0
 
virtual TVectorD trackParams (const KalmanState *state) const =0
 
virtual TVectorD trackParams_BeamConstr (const KalmanState *state, double &chi2rphi_bcon) const =0
 
virtual TVectorD vectorM (const Stub *stub) const =0
 

Protected Attributes

unsigned int iEtaReg_
 
unsigned int iPhiSec_
 
std::vector< std::unique_ptr< const KalmanState > > listAllStates_
 
unsigned nHelixPar_
 
unsigned nMeas_
 
unsigned numEtaRegions_
 
unsigned int numUpdateCalls_
 
const TPtpa_
 
- Protected Attributes inherited from tmtt::TrackFitGeneric
const std::string fitterName_
 
const Settingssettings_
 

Detailed Description

Definition at line 31 of file KFbase.h.

Member Enumeration Documentation

◆ MEAS_IDS

Enumerator
PHI 

Definition at line 35 of file KFbase.h.

35 { PHI, Z };

◆ PAR_IDS

Enumerator
INV2R 
PHI0 
Z0 
D0 

Definition at line 33 of file KFbase.h.

33 { INV2R, PHI0, T, Z0, D0 };

◆ PAR_IDS_VAR

Enumerator
QOVERPT 

Definition at line 34 of file KFbase.h.

34 { QOVERPT };

Constructor & Destructor Documentation

◆ KFbase() [1/3]

tmtt::KFbase::KFbase ( const Settings settings,
const uint  nHelixPar,
const std::string &  fitterName = "",
const uint  nMeas = 2 
)

◆ ~KFbase()

tmtt::KFbase::~KFbase ( )
inlineoverride

Definition at line 41 of file KFbase.h.

41 { this->resetStates(); }

References resetStates().

◆ KFbase() [2/3]

tmtt::KFbase::KFbase ( const KFbase kf)
delete

◆ KFbase() [3/3]

tmtt::KFbase::KFbase ( KFbase &&  kf)
delete

Member Function Documentation

◆ adjustChi2()

void tmtt::KFbase::adjustChi2 ( const KalmanState state,
const TMatrixD &  covRinv,
const TVectorD &  delta,
double &  chi2rphi,
double &  chi2rz 
) const
protectedvirtual

Definition at line 659 of file KFbase.cc.

663  {
664  // Change in chi2 (with r-phi/r-z correlation term included in r-phi component)
665  double delChi2rphi = delta[PHI] * delta[PHI] * matRinv[PHI][PHI] + 2 * delta[PHI] * delta[Z] * matRinv[PHI][Z];
666  double delChi2rz = delta[Z] * delta[Z] * matRinv[Z][Z];
667 
668  if (settings_->kalmanDebugLevel() >= 4) {
669  PrintL1trk() << "delta(chi2rphi)=" << delChi2rphi << " delta(chi2rz)= " << delChi2rz;
670  }
671  chi2rphi = state->chi2rphi() + delChi2rphi;
672  chi2rz = state->chi2rz() + delChi2rz;
673  return;
674  }

References tmtt::KalmanState::chi2rphi(), tmtt::KalmanState::chi2rz(), dumpMFGeometry_cfg::delta, tmtt::Settings::kalmanDebugLevel(), PHI, tmtt::TrackFitGeneric::settings_, and Z.

Referenced by kalmanUpdate().

◆ adjustState()

void tmtt::KFbase::adjustState ( const TMatrixD &  K,
const TMatrixD &  pxcov,
const TVectorD &  x,
const TMatrixD &  h,
const TVectorD &  delta,
TVectorD &  new_x,
TMatrixD &  new_xcov 
) const
protected

Definition at line 644 of file KFbase.cc.

650  {
651  new_vecX = vecXref + matK * delta;
652  const TMatrixD unitMatrix(TMatrixD::kUnit, TMatrixD(nHelixPar_, nHelixPar_));
653  TMatrixD tmp = unitMatrix - matK * matH;
654  new_matC = tmp * matCref;
655  }

References dumpMFGeometry_cfg::delta, nHelixPar_, and createJobs::tmp.

Referenced by kalmanUpdate().

◆ approxB()

float tmtt::KFbase::approxB ( float  z,
float  r 
) const
protected

◆ doKF()

const KalmanState * tmtt::KFbase::doKF ( const L1track3D l1track3D,
const std::vector< Stub * > &  stubs,
const TP tpa 
)
protected

Definition at line 166 of file KFbase.cc.

166  {
167  const KalmanState *finished_state = nullptr;
168 
169  map<unsigned int, const KalmanState *, std::greater<unsigned int>>
170  best_state_by_nstubs; // Best state (if any) for each viable no. of stubs on track value.
171 
172  // seed helix params & their covariance.
173  TVectorD x0 = seedX(l1track3D);
174  TMatrixD pxx0 = seedC(l1track3D);
175  TMatrixD K(nHelixPar_, 2);
176  TMatrixD dcov(2, 2);
177 
178  const KalmanState *state0 = mkState(l1track3D, 0, -1, nullptr, x0, pxx0, K, dcov, nullptr, 0, 0);
179 
180  // internal containers - i.e. the state FIFO. Contains estimate of helix params in last/next layer, with multiple entries if there were multiple stubs, yielding multiple states.
181  vector<const KalmanState *> new_states;
182  vector<const KalmanState *> prev_states;
183  prev_states.push_back(state0);
184 
185  // Get dead layers, if any.
186  bool remove2PSCut = settings_->kalmanRemove2PScut();
187  set<unsigned> kfDeadLayers = kalmanDeadLayers(remove2PSCut);
188 
189  // arrange stubs into Kalman layers according to eta region
190  int etaReg = l1track3D.iEtaReg();
191  map<int, vector<Stub *>> layerStubs;
192 
193  for (auto stub : stubs) {
194  // Get Kalman encoded layer ID for this stub.
195  int kalmanLay = this->kalmanLayer(etaReg, stub->layerIdReduced(), stub->barrel(), stub->r(), stub->z());
196 
197  constexpr unsigned int invalidKFlayer = 7;
198  if (kalmanLay != invalidKFlayer) {
199  if (layerStubs[kalmanLay].size() < settings_->kalmanMaxStubsPerLayer()) {
200  layerStubs[kalmanLay].push_back(stub);
201  } else {
202  // If too many stubs, FW keeps the last stub.
203  layerStubs[kalmanLay].back() = stub;
204  }
205  }
206  }
207 
208  // iterate using state->nextLayer() to determine next Kalman layer(s) to add stubs from
209  constexpr unsigned int nTypicalLayers = 6; // Number of tracker layers a typical track can pass through.
210  // If user asked to add up to 7 layers to track, increase number of iterations by 1.
211  const unsigned int maxIterations = std::max(nTypicalLayers, settings_->kalmanMaxNumStubs());
212  for (unsigned iteration = 0; iteration < maxIterations; iteration++) {
213  int combinations_per_iteration = 0;
214 
215  bool easy = (l1track3D.numStubs() < settings_->kalmanMaxStubsEasy());
216  unsigned int kalmanMaxSkipLayers =
218 
219  // update each state from previous iteration (or seed) using stubs in next Kalman layer
220  vector<const KalmanState *>::const_iterator i_state = prev_states.begin();
221  for (; i_state != prev_states.end(); i_state++) {
222  const KalmanState *the_state = *i_state;
223 
224  unsigned int layer = the_state->nextLayer(); // Get KF layer where stubs to be searched for next
225  unsigned nSkipped = the_state->nSkippedLayers();
226 
227  // If this layer is known to be dead, skip to the next layer (layer+1)
228  // The next_states_skipped will then look at layer+2
229  // However, if there are stubs in this layer, then don't skip (e.g. our phi/eta boundaries might not line up exactly with a dead region)
230  // Continue to skip until you reach a functioning layer (or a layer with stubs)
231  unsigned nSkippedDeadLayers = 0;
232  unsigned nSkippedAmbiguousLayers = 0;
233  while (kfDeadLayers.find(layer) != kfDeadLayers.end() && layerStubs[layer].empty()) {
234  layer += 1;
235  ++nSkippedDeadLayers;
236  }
237  while (this->kalmanAmbiguousLayer(etaReg, layer) && layerStubs[layer].empty()) {
238  layer += 1;
239  ++nSkippedAmbiguousLayers;
240  }
241 
242  // containers for updated state+stub combinations
243  vector<const KalmanState *> next_states;
244  vector<const KalmanState *> next_states_skipped;
245 
246  // find stubs for this layer
247  // (If layer > 6, this will return empty vector, so safe).
248  vector<Stub *> thislay_stubs = layerStubs[layer];
249 
250  // find stubs for next layer if we skip a layer, except when we are on the penultimate layer,
251  // or we have exceeded the max skipped layers
252  vector<Stub *> nextlay_stubs;
253 
254  // If the next layer (layer+1) is a dead layer, then proceed to the layer after next (layer+2), if possible
255  // Also note if we need to increase "skipped" by one more for these states
256  unsigned nSkippedDeadLayers_nextStubs = 0;
257  unsigned nSkippedAmbiguousLayers_nextStubs = 0;
258  if (nSkipped < kalmanMaxSkipLayers) {
259  if (kfDeadLayers.find(layer + 1) != kfDeadLayers.end() && layerStubs[layer + 1].empty()) {
260  nextlay_stubs = layerStubs[layer + 2];
261  nSkippedDeadLayers_nextStubs++;
262  } else if (this->kalmanAmbiguousLayer(etaReg, layer) && layerStubs[layer + 1].empty()) {
263  nextlay_stubs = layerStubs[layer + 2];
264  nSkippedAmbiguousLayers_nextStubs++;
265  } else {
266  nextlay_stubs = layerStubs[layer + 1];
267  }
268  }
269 
270  // If track was not rejected by isGoodState() is previous iteration, failure here usually means the tracker ran out of layers to explore.
271  // (Due to "kalmanLay" not having unique ID for each layer within a given eta sector).
272  if (settings_->kalmanDebugLevel() >= 2 && best_state_by_nstubs.empty() && thislay_stubs.empty() &&
273  nextlay_stubs.empty())
274  PrintL1trk() << "State is lost by start of iteration " << iteration
275  << " : #thislay_stubs=" << thislay_stubs.size() << " #nextlay_stubs=" << nextlay_stubs.size()
276  << " layer=" << layer << " eta=" << l1track3D.iEtaReg();
277 
278  // If we skipped over a dead layer, only increment "nSkipped" after the stubs in next+1 layer have been obtained
279  nSkipped += nSkippedDeadLayers;
280  nSkipped += nSkippedAmbiguousLayers;
281 
282  // check to guarantee no fewer than 2PS hits per state at iteration 1
283  // (iteration 0 will always include a PS hit, but iteration 1 could use 2S hits
284  // unless we include this)
285  if (iteration == 1 && !remove2PSCut) {
286  vector<Stub *> temp_thislaystubs;
287  vector<Stub *> temp_nextlaystubs;
288  for (auto stub : thislay_stubs) {
289  if (stub->psModule())
290  temp_thislaystubs.push_back(stub);
291  }
292  for (auto stub : nextlay_stubs) {
293  if (stub->psModule())
294  temp_nextlaystubs.push_back(stub);
295  }
296  thislay_stubs = temp_thislaystubs;
297  nextlay_stubs = temp_nextlaystubs;
298  }
299 
300  combinations_per_iteration += thislay_stubs.size() + nextlay_stubs.size();
301 
302  // loop over each stub in this layer and check for compatibility with this state
303  for (unsigned i = 0; i < thislay_stubs.size(); i++) {
304  Stub *stub = thislay_stubs[i];
305 
306  // Update helix params by adding this stub.
307  const KalmanState *new_state = kalmanUpdate(nSkipped, layer, stub, the_state, tpa);
308 
309  // Cut on track chi2, pt etc.
310  if (isGoodState(*new_state))
311  next_states.push_back(new_state);
312  }
313 
314  // loop over each stub in next layer if we skip, and check for compatibility with this state
315  for (unsigned i = 0; i < nextlay_stubs.size(); i++) {
316  Stub *stub = nextlay_stubs[i];
317 
318  const KalmanState *new_state =
319  kalmanUpdate(nSkipped + 1 + nSkippedDeadLayers_nextStubs + nSkippedAmbiguousLayers_nextStubs,
320  layer + 1 + nSkippedDeadLayers_nextStubs + nSkippedAmbiguousLayers_nextStubs,
321  stub,
322  the_state,
323  tpa);
324 
325  if (isGoodState(*new_state))
326  next_states_skipped.push_back(new_state);
327  }
328 
329  // post Kalman filter local sorting per state
330  auto orderByChi2 = [](const KalmanState *a, const KalmanState *b) {
331  return bool(a->chi2scaled() < b->chi2scaled());
332  };
333  sort(next_states.begin(), next_states.end(), orderByChi2);
334  sort(next_states_skipped.begin(), next_states_skipped.end(), orderByChi2);
335 
336  new_states.insert(new_states.end(), next_states.begin(), next_states.end());
337  new_states.insert(new_states.end(), next_states_skipped.begin(), next_states_skipped.end());
338  /*
339  i = 0;
340  for (auto state : next_states) {
341  new_states.push_back(state);
342  i++;
343  }
344 
345  i = 0;
346  for (auto state : next_states_skipped) {
347  new_states.push_back(state);
348  i++;
349  }
350 */
351  } //end of state loop
352 
353  // copy new_states into prev_states for next iteration or end if we are on
354  // last iteration by clearing all states and making final state selection
355 
356  auto orderByMinSkipChi2 = [](const KalmanState *a, const KalmanState *b) {
357  return bool((a->chi2scaled()) * (a->nSkippedLayers() + 1) < (b->chi2scaled()) * (b->nSkippedLayers() + 1));
358  };
359  sort(new_states.begin(), new_states.end(), orderByMinSkipChi2); // Sort by chi2*(skippedLayers+1)
360 
361  unsigned int nStubs = iteration + 1;
362  // Success. We have at least one state that passes all cuts. Save best state found with this number of stubs.
363  if (nStubs >= settings_->kalmanMinNumStubs() && not new_states.empty())
364  best_state_by_nstubs[nStubs] = new_states[0];
365 
366  if (nStubs == settings_->kalmanMaxNumStubs()) {
367  // We're done.
368  prev_states.clear();
369  new_states.clear();
370 
371  } else {
372  // Continue iterating.
373  prev_states = new_states;
374  new_states.clear();
375  }
376  }
377 
378  if (not best_state_by_nstubs.empty()) {
379  // Select state with largest number of stubs.
380  finished_state = best_state_by_nstubs.begin()->second; // First element has largest number of stubs.
381  if (settings_->kalmanDebugLevel() >= 1) {
382  std::stringstream text;
383  text << std::fixed << std::setprecision(4);
384  text << "Track found! final state selection: nLay=" << finished_state->nStubLayers()
385  << " hitPattern=" << std::hex << finished_state->hitPattern() << std::dec
386  << " phiSec=" << l1track3D.iPhiSec() << " etaReg=" << l1track3D.iEtaReg() << " HT(m,c)=("
387  << l1track3D.cellLocationHT().first << "," << l1track3D.cellLocationHT().second << ")";
388  TVectorD y = trackParams(finished_state);
389  text << " q/pt=" << y[QOVERPT] << " tanL=" << y[T] << " z0=" << y[Z0] << " phi0=" << y[PHI0];
390  if (nHelixPar_ == 5)
391  text << " d0=" << y[D0];
392  text << " chosen from states:";
393  for (const auto &p : best_state_by_nstubs)
394  text << " " << p.second->chi2() << "/" << p.second->nStubLayers();
395  PrintL1trk() << text.str();
396  }
397  } else {
398  if (settings_->kalmanDebugLevel() >= 1) {
399  PrintL1trk() << "Track lost";
400  }
401  }
402 
403  return finished_state;
404  }

References a, b, electrons_cff::bool, tmtt::L1track3D::cellLocationHT(), D0, TauDecayModes::dec, alignBH_cfg::fixed, tmtt::KalmanState::hitPattern(), mps_fire::i, tmtt::L1track3D::iEtaReg(), tmtt::L1track3D::iPhiSec(), isGoodState(), align_cfg::iteration, kalmanAmbiguousLayer(), kalmanDeadLayers(), tmtt::Settings::kalmanDebugLevel(), kalmanLayer(), tmtt::Settings::kalmanMaxNumStubs(), tmtt::Settings::kalmanMaxSkipLayersEasy(), tmtt::Settings::kalmanMaxSkipLayersHard(), tmtt::Settings::kalmanMaxStubsEasy(), tmtt::Settings::kalmanMaxStubsPerLayer(), tmtt::Settings::kalmanMinNumStubs(), tmtt::Settings::kalmanRemove2PScut(), kalmanUpdate(), SiStripPI::max, HLT_2018_cff::maxIterations, mkState(), tmtt::KalmanState::nextLayer(), nHelixPar_, tmtt::KalmanState::nSkippedLayers(), tmtt::KalmanState::nStubLayers(), tmtt::L1track3D::numStubs(), AlCaHLTBitMon_ParallelJobs::p, PHI0, QOVERPT, seedC(), seedX(), tmtt::TrackFitGeneric::settings_, findQualityFiles::size, T, runonSM::text, trackParams(), and Z0.

Referenced by fit().

◆ fit()

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

Reimplemented from tmtt::TrackFitGeneric.

Definition at line 38 of file KFbase.cc.

38  {
39  iPhiSec_ = l1track3D.iPhiSec();
40  iEtaReg_ = l1track3D.iEtaReg();
41  resetStates();
42  numUpdateCalls_ = 0;
43 
44  vector<Stub *> stubs = l1track3D.stubs();
45 
46  auto orderByLayer = [](const Stub *a, const Stub *b) { return bool(a->layerId() < b->layerId()); };
47  sort(stubs.begin(), stubs.end(), orderByLayer); // Makes debug printout pretty.
48 
49  //TP
50  const TP *tpa(nullptr);
51  if (l1track3D.matchedTP()) {
52  tpa = l1track3D.matchedTP();
53  }
54  tpa_ = tpa;
55 
56  //track information dump
57  if (settings_->kalmanDebugLevel() >= 1) {
58  PrintL1trk() << "===============================================================================";
59  std::stringstream text;
60  text << std::fixed << std::setprecision(4);
61  text << "Input track cand: [phiSec,etaReg]=[" << l1track3D.iPhiSec() << "," << l1track3D.iEtaReg() << "]";
62  text << " HT(m,c)=(" << l1track3D.cellLocationHT().first << "," << l1track3D.cellLocationHT().second
63  << ") q/pt=" << l1track3D.qOverPt() << " tanL=" << l1track3D.tanLambda() << " z0=" << l1track3D.z0()
64  << " phi0=" << l1track3D.phi0() << " nStubs=" << l1track3D.numStubs() << " d0=" << l1track3D.d0();
65  PrintL1trk() << text.str();
66  if (not settings_->hybrid())
67  printTP(tpa);
68  if (settings_->kalmanDebugLevel() >= 2) {
69  printStubLayers(stubs, l1track3D.iEtaReg());
70  printStubs(stubs);
71  }
72  }
73 
74  //Kalman Filter
75  const KalmanState *cand = doKF(l1track3D, stubs, tpa);
76 
77  //return L1fittedTrk for the selected state (if KF produced one it was happy with).
78  if (cand != nullptr) {
79  // Get track helix params.
80  TVectorD trackPars = trackParams(cand);
81  double d0 = (nHelixPar_ == 5) ? trackPars[D0] : 0.;
82 
83  L1fittedTrack fitTrk(settings_,
84  &l1track3D,
85  cand->stubs(),
86  cand->hitPattern(),
87  trackPars[QOVERPT],
88  d0,
89  trackPars[PHI0],
90  trackPars[Z0],
91  trackPars[T],
92  cand->chi2rphi(),
93  cand->chi2rz(),
94  nHelixPar_);
95 
96  // Store supplementary info, specific to KF fitter.
97  fitTrk.setInfoKF(cand->nSkippedLayers(), numUpdateCalls_);
98 
99  // If doing 5 parameter fit, optionally also calculate helix params & chi2 with beam-spot constraint applied,
100  // and store inside L1fittedTrack object.
102  if (nHelixPar_ == 5) {
103  double chi2rphi_bcon = 0.;
104  TVectorD trackPars_bcon = trackParams_BeamConstr(cand, chi2rphi_bcon);
105  fitTrk.setBeamConstr(trackPars_bcon[QOVERPT], trackPars_bcon[PHI0], chi2rphi_bcon);
106  }
107  }
108 
109  // Fitted track params must lie in same sector as HT originally found track in.
110  if (!settings_->hybrid()) { // consistentSector() function not yet working for Hybrid.
111 
112  // Bodge to take into account digitisation in sector consistency check.
113  if (settings_->enableDigitize())
114  fitTrk.digitizeTrack("KF4ParamsComb");
115 
116  if (!fitTrk.consistentSector()) {
117  if (settings_->kalmanDebugLevel() >= 1)
118  PrintL1trk() << "Track rejected by sector consistency test";
119  L1fittedTrack rejectedTrk;
120  return rejectedTrk;
121  }
122  }
123 
124  return fitTrk;
125 
126  } else { // Track rejected by fitter
127 
128  if (settings_->kalmanDebugLevel() >= 1) {
129  bool goodTrack = (tpa && tpa->useForAlgEff()); // Matches truth particle.
130  if (goodTrack) {
131  int tpin = tpa->index();
132  PrintL1trk() << "TRACK LOST: eta=" << l1track3D.iEtaReg() << " pt=" << l1track3D.pt() << " tp=" << tpin;
133 
134  for (auto stub : stubs) {
135  int kalmanLay =
136  this->kalmanLayer(l1track3D.iEtaReg(), stub->layerIdReduced(), stub->barrel(), stub->r(), stub->z());
137  std::stringstream text;
138  text << std::fixed << std::setprecision(4);
139  text << " Stub: lay_red=" << stub->layerIdReduced() << " KFlay=" << kalmanLay << " r=" << stub->r()
140  << " z=" << stub->z() << " assoc TPs =";
141  for (const TP *tp_i : stub->assocTPs())
142  text << " " << tp_i->index();
143  PrintL1trk() << text.str();
144  if (stub->assocTPs().empty())
145  PrintL1trk() << " none";
146  }
147  PrintL1trk() << "=====================";
148  }
149  }
150 
151  //dump on the missed TP for efficiency calculation.
152  if (settings_->kalmanDebugLevel() >= 3) {
153  if (tpa && tpa->useForAlgEff()) {
154  PrintL1trk() << "TP for eff. missed addr. index : " << tpa << " " << tpa->index();
155  printStubs(stubs);
156  }
157  }
158 
159  L1fittedTrack rejectedTrk;
160  return rejectedTrk;
161  }
162  }

References a, b, electrons_cff::bool, tmtt::L1track3D::cellLocationHT(), D0, d0, tmtt::L1track3D::d0(), doKF(), tmtt::Settings::enableDigitize(), alignBH_cfg::fixed, spr::goodTrack(), tmtt::Settings::hybrid(), tmtt::L1track3D::iEtaReg(), iEtaReg_, tmtt::L1track3D::iPhiSec(), iPhiSec_, tmtt::Settings::kalmanAddBeamConstr(), tmtt::Settings::kalmanDebugLevel(), kalmanLayer(), tmtt::L1track3D::matchedTP(), nHelixPar_, tmtt::L1track3D::numStubs(), numUpdateCalls_, PHI0, tmtt::L1track3D::phi0(), printStubLayers(), printStubs(), printTP(), tmtt::L1track3D::pt(), QOVERPT, tmtt::L1track3D::qOverPt(), resetStates(), tmtt::L1fittedTrack::setInfoKF(), tmtt::TrackFitGeneric::settings_, tmtt::L1track3D::stubs(), T, tmtt::L1track3D::tanLambda(), runonSM::text, tpa_, trackParams(), trackParams_BeamConstr(), Z0, and tmtt::L1track3D::z0().

Referenced by trackingPlots.Iteration::modules().

◆ getKalmanGainMatrix()

TMatrixD tmtt::KFbase::getKalmanGainMatrix ( const TMatrixD &  h,
const TMatrixD &  pxcov,
const TMatrixD &  covRinv 
) const
protected

Definition at line 579 of file KFbase.cc.

579  {
580  TMatrixD matHtrans(TMatrixD::kTransposed, matH);
581  TMatrixD matCrefht = matCref * matHtrans;
582  TMatrixD matK = matCrefht * matRinv;
583  return matK;
584  }

Referenced by kalmanUpdate().

◆ isGoodState()

virtual bool tmtt::KFbase::isGoodState ( const KalmanState state) const
protectedpure virtual

Implemented in tmtt::KFParamsComb.

Referenced by doKF().

◆ isHLS()

virtual bool tmtt::KFbase::isHLS ( )
inlineprotectedvirtual

Definition at line 141 of file KFbase.h.

141 { return false; };

◆ kalmanAmbiguousLayer()

bool tmtt::KFbase::kalmanAmbiguousLayer ( unsigned int  iEtaReg,
unsigned int  kfLayer 
)
protectedvirtual

Definition at line 790 of file KFbase.cc.

790  {
791  // Only helps in extreme forward sector, and there not significantly.
792  // UNDERSTAND IF CAN BE USED ELSEWHERE.
793 
794  /*
795  const unsigned int nEta = 16;
796  const unsigned int nKFlayer = 7;
797  constexpr bool ambiguityMap[nEta/2][nKFlayer] =
798  {
799  {false, false, false, false, false, false, false},
800  {false, false, false, false, false, false, false},
801  {false, false, false, false, false, false, false},
802  {false, false, false, false, false, false, false},
803  {false, false, false, false, false, false, false},
804  {false, false, false, false, false, false, false},
805  {false, false, false, false, false, false, false},
806  {true , false, false, false, false, false, false},
807  };
808 
809  unsigned int kfEtaReg; // KF VHDL eta sector def: small in barrel & large in endcap.
810  if (iEtaReg < numEtaRegions_/2) {
811  kfEtaReg = numEtaRegions_/2 - 1 - iEtaReg;
812  } else {
813  kfEtaReg = iEtaReg - numEtaRegions_/2;
814  }
815 
816  bool ambiguous = ambiguityMap[kfEtaReg][kfLayer];
817  */
818 
819  bool ambiguous = false;
820  return ambiguous;
821  }

Referenced by doKF().

◆ kalmanDeadLayers()

set< unsigned > tmtt::KFbase::kalmanDeadLayers ( bool &  remove2PSCut) const
protected

Definition at line 825 of file KFbase.cc.

825  {
826  // Kill scenarios described StubKiller.cc
827 
828  // By which Stress Test scenario (if any) are dead modules being emulated?
829  const StubKiller::KillOptions killScenario = static_cast<StubKiller::KillOptions>(settings_->killScenario());
830  // Should TMTT tracking be modified to reduce efficiency loss due to dead modules?
831  const bool killRecover = settings_->killRecover();
832 
833  set<pair<unsigned, bool>> deadGPlayers; // GP layer ID & boolean indicating if in barrel.
834 
835  // Range of sectors chosen to cover dead regions from StubKiller.
836  if (killRecover) {
837  if (killScenario == StubKiller::KillOptions::layer5) { // barrel layer 5
838  if (iEtaReg_ >= 3 && iEtaReg_ <= 7 && iPhiSec_ >= 1 && iPhiSec_ <= 5) {
839  deadGPlayers.insert(pair<unsigned, bool>(4, true));
840  }
841  } else if (killScenario == StubKiller::KillOptions::layer1) { // barrel layer 1
842  if (iEtaReg_ <= 7 && iPhiSec_ >= 1 && iPhiSec_ <= 5) {
843  deadGPlayers.insert(pair<unsigned, bool>(1, true));
844  }
845  remove2PSCut = true;
846  } else if (killScenario == StubKiller::KillOptions::layer1layer2) { // barrel layers 1 & 2
847  if (iEtaReg_ <= 7 && iPhiSec_ >= 1 && iPhiSec_ <= 5) {
848  deadGPlayers.insert(pair<unsigned, bool>(1, true));
849  }
850  if (iEtaReg_ >= 1 && iEtaReg_ <= 7 && iPhiSec_ >= 1 && iPhiSec_ <= 5) {
851  deadGPlayers.insert(pair<unsigned, bool>(2, true));
852  }
853  remove2PSCut = true;
854  } else if (killScenario == StubKiller::KillOptions::layer1disk1) { // barrel layer 1 & disk 1
855  if (iEtaReg_ <= 7 && iPhiSec_ >= 1 && iPhiSec_ <= 5) {
856  deadGPlayers.insert(pair<unsigned, bool>(1, true));
857  }
858  if (iEtaReg_ <= 3 && iPhiSec_ >= 1 && iPhiSec_ <= 5) {
859  deadGPlayers.insert(pair<unsigned, bool>(3, false));
860  }
861  remove2PSCut = true;
862  }
863  }
864 
865  set<unsigned> kfDeadLayers;
866  for (const auto &p : deadGPlayers) {
867  unsigned int layer = p.first;
868  bool barrel = p.second;
869  float r = 0.; // This fails for r-dependent parts of kalmanLayer(). FIX
870  float z = 999.;
871  unsigned int kalmanLay = this->kalmanLayer(iEtaReg_, layer, barrel, r, z);
872  kfDeadLayers.insert(kalmanLay);
873  }
874 
875  return kfDeadLayers;
876  }

References Reference_intrackfit_cff::barrel, iEtaReg_, iPhiSec_, kalmanLayer(), tmtt::Settings::killRecover(), tmtt::Settings::killScenario(), tmtt::StubKiller::layer1, tmtt::StubKiller::layer1disk1, tmtt::StubKiller::layer1layer2, tmtt::StubKiller::layer5, AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::r, and tmtt::TrackFitGeneric::settings_.

Referenced by doKF().

◆ kalmanLayer()

unsigned int tmtt::KFbase::kalmanLayer ( unsigned int  iEtaReg,
unsigned int  layerIDreduced,
bool  barrel,
float  r,
float  z 
) const
protectedvirtual

Definition at line 682 of file KFbase.cc.

683  {
684  // index across is GP encoded layer ID (where barrel layers=1,2,7,5,4,3 & endcap wheels=3,4,5,6,7 & 0 never occurs)
685  // index down is eta reg
686  // element is kalman layer, where 7 is invalid
687 
688  // If stub with given GP encoded layer ID can have different KF layer ID depending on whether it
689  // is barrel or endcap, then in layerMap, the the barrel case is assumed.
690  // The endcap case is fixed by hand later in this function.
691 
692  const unsigned int nEta = 16;
693  const unsigned int nGPlayID = 7;
694 
695  if (nEta != numEtaRegions_)
696  throw cms::Exception("LogicError")
697  << "ERROR KFbase::getKalmanLayer hardwired value of nEta differs from NumEtaRegions cfg param";
698 
699  // In cases where identical GP encoded layer ID present in this sector from both barrel & endcap, this array filled considering barrel. The endcap is fixed by subsequent code.
700 
701  constexpr unsigned layerMap[nEta / 2][nGPlayID + 1] = {
702  {7, 0, 1, 5, 4, 3, 7, 2}, // B1 B2 B3 B4 B5 B6
703  {7, 0, 1, 5, 4, 3, 7, 2}, // B1 B2 B3 B4 B5 B6
704  {7, 0, 1, 5, 4, 3, 7, 2}, // B1 B2 B3 B4 B5 B6
705  {7, 0, 1, 5, 4, 3, 7, 2}, // B1 B2 B3 B4 B5 B6
706  {7, 0, 1, 5, 4, 3, 7, 2}, // B1 B2 B3 B4(/D3) B5(/D2) B6(/D1)
707 
708  {7, 0, 1, 3, 4, 2, 6, 2}, // B1 B2 B3(/D5)+B4(/D3) D1 D2 X D4 -- current FW
709  //{ 7, 0, 1, 3, 4, 3, 6, 2 }, // B1 B2 B3(/D5) D1+B4(/D3) D2 X D4 -- for use with "Fix cases" below.
710 
711  {7, 0, 1, 1, 2, 3, 4, 5}, // B1 B2+D1 D2 D3 D5 D6
712 
713  //{ 7, 0, 7, 1, 2, 3, 4, 5 }, // B1 D1 D2 D3 D4 D5 = current FW (or when Ambiguous function used)
714  {7, 0, 7, 0, 1, 2, 3, 4}, // Avoid effi loss for eta > 2.3 when Ambiguous function not used.
715  };
716 
717  unsigned int kfEtaReg; // KF VHDL eta sector def: small in barrel & large in endcap.
718  if (iEtaReg < numEtaRegions_ / 2) {
719  kfEtaReg = numEtaRegions_ / 2 - 1 - iEtaReg;
720  } else {
721  kfEtaReg = iEtaReg - numEtaRegions_ / 2;
722  }
723 
724  unsigned int kalmanLay = layerMap[kfEtaReg][layerIDreduced];
725 
726  // Fixes to endcap stubs, for cases where identical GP encoded layer ID present in this sector from both barrel & endcap.
727 
728  if (not barrel) {
729  switch (kfEtaReg) {
730  case 4: // B1 B2 B3 B4 B5/D1 B6/D2 D3
731  if (layerIDreduced == 3) {
732  kalmanLay = 4;
733  } else if (layerIDreduced == 4) {
734  kalmanLay = 5;
735  } else if (layerIDreduced == 5) {
736  kalmanLay = 6;
737  }
738  break;
739  //case 5: // B1 B2 B3+B4 D1 D2 D3 D4/D5
740  case 5: // B1 B2 B3 D1+B4 D2 D3 D4/D5
741  if (layerIDreduced == 5) {
742  kalmanLay = 5;
743  } else if (layerIDreduced == 7) {
744  kalmanLay = 6;
745  }
746  break;
747  default:
748  break;
749  }
750  }
751 
752  /*
753  // Fix cases where a barrel layer only partially crosses the eta sector.
754  // (Logically should work, but actually reduces efficiency -- INVESTIGATE).
755 
756  const float barrelHalfLength = 120.;
757  const float barrel4Radius = 68.8;
758  const float barrel5Radius = 86.1;
759 
760  if ( not barrel) {
761  switch ( kfEtaReg ) {
762  case 4:
763  if (layerIDreduced==3) { // D1
764  float disk1_rCut = barrel5Radius*(std::abs(z)/barrelHalfLength);
765  if (r > disk1_rCut) kalmanLay++;
766  }
767  break;
768  case 5:
769  if (layerIDreduced==3) { // D1
770  float disk1_rCut = barrel4Radius*(std::abs(z)/barrelHalfLength);
771  if (r > disk1_rCut) kalmanLay++;
772  }
773  if (layerIDreduced==4) { // D2
774  float disk2_rCut = barrel4Radius*(std::abs(z)/barrelHalfLength);
775  if (r > disk2_rCut) kalmanLay++;
776  }
777  break;
778  default:
779  break;
780  }
781  }
782  */
783 
784  return kalmanLay;
785  }

References Reference_intrackfit_cff::barrel, Exception, HLT_2018_cff::nEta, and numEtaRegions_.

Referenced by doKF(), fit(), kalmanDeadLayers(), and printStubLayers().

◆ kalmanUpdate()

const KalmanState * tmtt::KFbase::kalmanUpdate ( unsigned  nSkipped,
unsigned  layer,
Stub stub,
const KalmanState state,
const TP tp 
)
protectedvirtual

Definition at line 408 of file KFbase.cc.

409  {
410  if (settings_->kalmanDebugLevel() >= 4) {
411  PrintL1trk() << "---------------";
412  PrintL1trk() << "kalmanUpdate";
413  PrintL1trk() << "---------------";
414  printStub(stub);
415  }
416 
417  numUpdateCalls_++; // For monitoring, count calls to updator per track.
418 
419  // Helix params & their covariance.
420  TVectorD vecX = state->vectorX();
421  TMatrixD matC = state->matrixC();
422  if (state->barrel() && !stub->barrel()) {
423  if (settings_->kalmanDebugLevel() >= 4) {
424  PrintL1trk() << "STATE BARREL TO ENDCAP BEFORE ";
425  PrintL1trk() << "state : " << vecX[0] << " " << vecX[1] << " " << vecX[2] << " " << vecX[3];
426  PrintL1trk() << "cov(x): ";
427  matC.Print();
428  }
429  if (settings_->kalmanDebugLevel() >= 4) {
430  PrintL1trk() << "STATE BARREL TO ENDCAP AFTER ";
431  PrintL1trk() << "state : " << vecX[0] << " " << vecX[1] << " " << vecX[2] << " " << vecX[3];
432  PrintL1trk() << "cov(x): ";
433  matC.Print();
434  }
435  }
436  // Matrix to propagate helix reference point from one layer to next.
437  TMatrixD matF = matrixF(stub, state);
438  TMatrixD matFtrans(TMatrixD::kTransposed, matF);
439  if (settings_->kalmanDebugLevel() >= 4) {
440  PrintL1trk() << "matF";
441  matF.Print();
442  }
443 
444  // Multiply matrices to get helix params relative to reference point at next layer.
445  TVectorD vecXref = matF * vecX;
446  if (settings_->kalmanDebugLevel() >= 4) {
447  PrintL1trk() << "vecFref = [";
448  for (unsigned i = 0; i < nHelixPar_; i++)
449  PrintL1trk() << vecXref[i] << ", ";
450  PrintL1trk() << "]";
451  }
452 
453  // Get stub residuals.
454  TVectorD delta = residual(stub, vecXref, state->candidate().qOverPt());
455  if (settings_->kalmanDebugLevel() >= 4) {
456  PrintL1trk() << "delta = " << delta[0] << ", " << delta[1];
457  }
458 
459  // Derivative of predicted (phi,z) intercept with layer w.r.t. helix params.
460  TMatrixD matH = matrixH(stub);
461  if (settings_->kalmanDebugLevel() >= 4) {
462  PrintL1trk() << "matH";
463  matH.Print();
464  }
465 
466  if (settings_->kalmanDebugLevel() >= 4) {
467  PrintL1trk() << "previous state covariance";
468  matC.Print();
469  }
470  // Get scattering contribution to helix parameter covariance (currently zero).
471  TMatrixD matScat(nHelixPar_, nHelixPar_);
472 
473  // Get covariance on helix parameters at new reference point including scattering..
474  TMatrixD matCref = matF * matC * matFtrans + matScat;
475  if (settings_->kalmanDebugLevel() >= 4) {
476  PrintL1trk() << "matCref";
477  matCref.Print();
478  }
479  // Get hit position covariance matrix.
480  TMatrixD matV = matrixV(stub, state);
481  if (settings_->kalmanDebugLevel() >= 4) {
482  PrintL1trk() << "matV";
483  matV.Print();
484  }
485 
486  TMatrixD matRinv = matrixRinv(matH, matCref, matV);
487  if (settings_->kalmanDebugLevel() >= 4) {
488  PrintL1trk() << "matRinv";
489  matRinv.Print();
490  }
491 
492  // Calculate Kalman Gain matrix.
493  TMatrixD matK = getKalmanGainMatrix(matH, matCref, matRinv);
494  if (settings_->kalmanDebugLevel() >= 4) {
495  PrintL1trk() << "matK";
496  matK.Print();
497  }
498 
499  // Update helix state & its covariance matrix with new stub.
500  TVectorD new_vecX(nHelixPar_);
501  TMatrixD new_matC(nHelixPar_, nHelixPar_);
502  adjustState(matK, matCref, vecXref, matH, delta, new_vecX, new_matC);
503 
504  // Update track fit chi2 with new stub.
505  double new_chi2rphi = 0, new_chi2rz = 0;
506  this->adjustChi2(state, matRinv, delta, new_chi2rphi, new_chi2rz);
507 
508  if (settings_->kalmanDebugLevel() >= 4) {
509  if (nHelixPar_ == 4)
510  PrintL1trk() << "adjusted x = " << new_vecX[0] << ", " << new_vecX[1] << ", " << new_vecX[2] << ", "
511  << new_vecX[3];
512  else if (nHelixPar_ == 5)
513  PrintL1trk() << "adjusted x = " << new_vecX[0] << ", " << new_vecX[1] << ", " << new_vecX[2] << ", "
514  << new_vecX[3] << ", " << new_vecX[4];
515  PrintL1trk() << "adjusted C ";
516  new_matC.Print();
517  PrintL1trk() << "adjust chi2rphi=" << new_chi2rphi << " chi2rz=" << new_chi2rz;
518  }
519 
520  const KalmanState *new_state = mkState(
521  state->candidate(), nSkipped, layer, state, new_vecX, new_matC, matK, matV, stub, new_chi2rphi, new_chi2rz);
522 
523  return new_state;
524  }

References adjustChi2(), adjustState(), tmtt::KalmanState::barrel(), tmtt::Stub::barrel(), tmtt::KalmanState::candidate(), dumpMFGeometry_cfg::delta, getKalmanGainMatrix(), mps_fire::i, tmtt::Settings::kalmanDebugLevel(), tmtt::KalmanState::matrixC(), matrixF(), matrixH(), matrixRinv(), matrixV(), mkState(), nHelixPar_, numUpdateCalls_, printStub(), tmtt::L1track3D::qOverPt(), residual(), tmtt::TrackFitGeneric::settings_, and tmtt::KalmanState::vectorX().

Referenced by doKF().

◆ matrixF()

virtual TMatrixD tmtt::KFbase::matrixF ( const Stub stub = nullptr,
const KalmanState state = nullptr 
) const
protectedpure virtual

Implemented in tmtt::KFParamsComb.

Referenced by kalmanUpdate().

◆ matrixH()

virtual TMatrixD tmtt::KFbase::matrixH ( const Stub stub) const
protectedpure virtual

Implemented in tmtt::KFParamsComb.

Referenced by kalmanUpdate(), and residual().

◆ matrixHCHt()

TMatrixD tmtt::KFbase::matrixHCHt ( const TMatrixD &  h,
const TMatrixD &  c 
) const
protected

Definition at line 549 of file KFbase.cc.

549  {
550  TMatrixD matHtrans(TMatrixD::kTransposed, matH);
551  return matH * matC * matHtrans;
552  }

Referenced by matrixRinv().

◆ matrixRinv()

TMatrixD tmtt::KFbase::matrixRinv ( const TMatrixD &  matH,
const TMatrixD &  matCref,
const TMatrixD &  matV 
) const
protected

Definition at line 556 of file KFbase.cc.

556  {
557  TMatrixD matHCHt = matrixHCHt(matH, matCref);
558  TMatrixD matR = matV + matHCHt;
559  TMatrixD matRinv(2, 2);
560  if (matR.Determinant() > 0) {
561  matRinv = TMatrixD(TMatrixD::kInverted, matR);
562  } else {
563  // Protection against rare maths instability.
564  const TMatrixD unitMatrix(TMatrixD::kUnit, TMatrixD(nHelixPar_, nHelixPar_));
565  const double big = 9.9e9;
566  matRinv = big * unitMatrix;
567  }
568  if (settings_->kalmanDebugLevel() >= 4) {
569  PrintL1trk() << "matHCHt";
570  matHCHt.Print();
571  PrintL1trk() << "matR";
572  matR.Print();
573  }
574  return matRinv;
575  }

References tmtt::Settings::kalmanDebugLevel(), matrixHCHt(), nHelixPar_, and tmtt::TrackFitGeneric::settings_.

Referenced by kalmanUpdate().

◆ matrixV()

virtual TMatrixD tmtt::KFbase::matrixV ( const Stub stub,
const KalmanState state 
) const
protectedpure virtual

Implemented in tmtt::KFParamsComb.

Referenced by kalmanUpdate().

◆ mkState()

const KalmanState * tmtt::KFbase::mkState ( const L1track3D candidate,
unsigned  nSkipped,
unsigned  layer,
const KalmanState last_state,
const TVectorD &  x,
const TMatrixD &  pxx,
const TMatrixD &  K,
const TMatrixD &  dcov,
Stub stub,
double  chi2rphi,
double  chi2rz 
)
protected

Definition at line 528 of file KFbase.cc.

538  {
539  auto new_state = std::make_unique<const KalmanState>(
540  settings_, candidate, nSkipped, layer, last_state, vecX, matC, matK, matV, stub, chi2rphi, chi2rz);
541 
542  const KalmanState *p_new_state = new_state.get();
543  listAllStates_.push_back(std::move(new_state)); // Vector keeps ownership of all states.
544  return p_new_state;
545  }

References listAllStates_, eostools::move(), and tmtt::TrackFitGeneric::settings_.

Referenced by doKF(), and kalmanUpdate().

◆ operator=() [1/2]

KFbase& tmtt::KFbase::operator= ( const KFbase kf)
delete

◆ operator=() [2/2]

KFbase& tmtt::KFbase::operator= ( KFbase &&  kf)
delete

◆ printStub()

void tmtt::KFbase::printStub ( const Stub stub) const
protected

Definition at line 942 of file KFbase.cc.

942  {
943  std::stringstream text;
944  text << std::fixed << std::setprecision(4);
945  text << "stub ";
946  text << "index=" << stub->index() << " ";
947  text << "layerId=" << stub->layerId() << " ";
948  text << "r=" << stub->r() << " ";
949  text << "phi=" << stub->phi() << " ";
950  text << "z=" << stub->z() << " ";
951  text << "sigmaX=" << stub->sigmaPerp() << " ";
952  text << "sigmaZ=" << stub->sigmaPar() << " ";
953  text << "TPids=";
954  std::set<const TP *> tps = stub->assocTPs();
955  for (auto tp : tps)
956  text << tp->index() << ",";
957  PrintL1trk() << text.str();
958  }

References tmtt::Stub::assocTPs(), alignBH_cfg::fixed, tmtt::Stub::index(), tmtt::Stub::layerId(), tmtt::Stub::phi(), tmtt::Stub::r(), tmtt::Stub::sigmaPar(), tmtt::Stub::sigmaPerp(), runonSM::text, cmsswSequenceInfo::tp, and tmtt::Stub::z().

Referenced by kalmanUpdate(), and printStubs().

◆ printStubLayers()

void tmtt::KFbase::printStubLayers ( const std::vector< Stub * > &  stubs,
unsigned int  iEtaReg 
) const
protected

Definition at line 914 of file KFbase.cc.

914  {
915  std::stringstream text;
916  text << std::fixed << std::setprecision(4);
917  if (stubs.empty())
918  text << "stub layers = []\n";
919  else {
920  text << "stub layers = [ ";
921  for (unsigned i = 0; i < stubs.size(); i++) {
922  text << stubs[i]->layerId();
923  if (i != stubs.size() - 1)
924  text << ", ";
925  }
926  text << " ] ";
927  text << "KF stub layers = [ ";
928  for (unsigned j = 0; j < stubs.size(); j++) {
929  unsigned int kalmanLay =
930  this->kalmanLayer(iEtaReg, stubs[j]->layerIdReduced(), stubs[j]->barrel(), stubs[j]->r(), stubs[j]->z());
931  text << kalmanLay;
932  if (j != stubs.size() - 1)
933  text << ", ";
934  }
935  text << " ]\n";
936  }
937  PrintL1trk() << text.str();
938  }

References Reference_intrackfit_cff::barrel, alignBH_cfg::fixed, mps_fire::i, dqmiolumiharvest::j, kalmanLayer(), alignCSCRings::r, and runonSM::text.

Referenced by fit().

◆ printStubs()

void tmtt::KFbase::printStubs ( const std::vector< Stub * > &  stubs) const
protected

Definition at line 962 of file KFbase.cc.

962  {
963  for (auto &stub : stubs) {
964  printStub(stub);
965  }
966  }

References printStub().

Referenced by fit().

◆ printTP()

void tmtt::KFbase::printTP ( const TP tp) const
protected

Definition at line 886 of file KFbase.cc.

886  {
887  TVectorD tpParams(5);
888  bool useForAlgEff(false);
889  if (tp) {
890  useForAlgEff = tp->useForAlgEff();
891  tpParams[QOVERPT] = tp->qOverPt();
892  tpParams[PHI0] = tp->phi0();
893  tpParams[Z0] = tp->z0();
894  tpParams[T] = tp->tanLambda();
895  tpParams[D0] = tp->d0();
896  }
897  std::stringstream text;
898  text << std::fixed << std::setprecision(4);
899  if (tp) {
900  text << " TP index = " << tp->index() << " useForAlgEff = " << useForAlgEff << " ";
901  const string helixNames[5] = {"qOverPt", "phi0", "z0", "tanL", "d0"};
902  for (int i = 0; i < tpParams.GetNrows(); i++) {
903  text << helixNames[i] << ":" << tpParams[i] << ", ";
904  }
905  text << " inv2R = " << tp->qOverPt() * settings_->invPtToInvR() * 0.5;
906  } else {
907  text << " Fake";
908  }
909  PrintL1trk() << text.str();
910  }

References D0, alignBH_cfg::fixed, mps_fire::i, tmtt::Settings::invPtToInvR(), PHI0, QOVERPT, tmtt::TrackFitGeneric::settings_, T, runonSM::text, cmsswSequenceInfo::tp, and Z0.

Referenced by fit().

◆ resetStates()

void tmtt::KFbase::resetStates ( )
protected

Definition at line 678 of file KFbase.cc.

678 { listAllStates_.clear(); }

References listAllStates_.

Referenced by fit(), and ~KFbase().

◆ residual()

TVectorD tmtt::KFbase::residual ( const Stub stub,
const TVectorD &  x,
double  candQoverPt 
) const
protectedvirtual

Definition at line 588 of file KFbase.cc.

588  {
589  TVectorD vd = vectorM(stub); // Get (phi relative to sector, z) of hit.
590  TMatrixD h = matrixH(stub);
591  TVectorD hx = h * vecX; // Get intercept of helix with layer (linear approx).
592  TVectorD delta = vd - hx;
593 
594  // Calculate higher order corrections to residuals.
595 
596  if (not settings_->kalmanHOfw()) {
597  TVectorD correction(2);
598 
599  float inv2R = (settings_->invPtToInvR()) * 0.5 * candQoverPt;
600  float tanL = vecX[T];
601  float z0 = vecX[Z0];
602 
603  float deltaS = 0.;
604  if (settings_->kalmanHOhelixExp()) {
605  // Higher order correction correction to circle expansion for improved accuracy at low Pt.
606  double corr = stub->r() * inv2R;
607 
608  // N.B. In endcap 2S, this correction to correction[0] is exactly cancelled by the deltaS-dependent correction to it below.
609  correction[0] += (1. / 6.) * pow(corr, 3);
610 
611  deltaS = (1. / 6.) * (stub->r()) * pow(corr, 2);
612  correction[1] -= deltaS * tanL;
613  }
614 
615  if ((not stub->barrel()) && not(stub->psModule())) {
616  // These corrections rely on inside --> outside tracking, so r-z track params in 2S modules known.
617  float rShift = (stub->z() - z0) / tanL - stub->r();
618 
620  rShift -= deltaS;
621 
622  if (settings_->kalmanHOprojZcorr() == 1) {
623  // Add correlation term related to conversion of stub residuals from (r,phi) to (z,phi).
624  correction[0] += inv2R * rShift;
625  }
626 
627  if (settings_->kalmanHOalpha() == 1) {
628  // Add alpha correction for non-radial 2S endcap strips..
629  correction[0] += stub->alpha() * rShift;
630  }
631  }
632 
633  // Apply correction to residuals.
634  delta += correction;
635  }
636 
637  delta[0] = reco::deltaPhi(delta[0], 0.);
638 
639  return delta;
640  }

References tmtt::Stub::alpha(), tmtt::Stub::barrel(), alignCSCRings::corr, pfMETCorrectionType0_cfi::correction, dumpMFGeometry_cfg::delta, reco::deltaPhi(), tmtt::Settings::invPtToInvR(), tmtt::Settings::kalmanHOalpha(), tmtt::Settings::kalmanHOfw(), tmtt::Settings::kalmanHOhelixExp(), tmtt::Settings::kalmanHOprojZcorr(), matrixH(), funct::pow(), tmtt::Stub::psModule(), tmtt::Stub::r(), tmtt::TrackFitGeneric::settings_, T, vectorM(), tmtt::Stub::z(), Z0, and HLTMuonOfflineAnalyzer_cfi::z0.

Referenced by kalmanUpdate().

◆ sectorPhi()

double tmtt::KFbase::sectorPhi ( ) const
inlineprotected

◆ seedC()

virtual TMatrixD tmtt::KFbase::seedC ( const L1track3D l1track3D) const
protectedpure virtual

Implemented in tmtt::KFParamsComb.

Referenced by doKF().

◆ seedX()

virtual TVectorD tmtt::KFbase::seedX ( const L1track3D l1track3D) const
protectedpure virtual

Implemented in tmtt::KFParamsComb.

Referenced by doKF().

◆ trackParams()

virtual TVectorD tmtt::KFbase::trackParams ( const KalmanState state) const
protectedpure virtual

Implemented in tmtt::KFParamsComb.

Referenced by doKF(), and fit().

◆ trackParams_BeamConstr()

virtual TVectorD tmtt::KFbase::trackParams_BeamConstr ( const KalmanState state,
double &  chi2rphi_bcon 
) const
protectedpure virtual

Implemented in tmtt::KFParamsComb.

Referenced by fit().

◆ vectorM()

virtual TVectorD tmtt::KFbase::vectorM ( const Stub stub) const
protectedpure virtual

Implemented in tmtt::KFParamsComb.

Referenced by residual().

Member Data Documentation

◆ iEtaReg_

unsigned int tmtt::KFbase::iEtaReg_
protected

Definition at line 158 of file KFbase.h.

Referenced by fit(), and kalmanDeadLayers().

◆ iPhiSec_

unsigned int tmtt::KFbase::iPhiSec_
protected

Definition at line 157 of file KFbase.h.

Referenced by fit(), kalmanDeadLayers(), and sectorPhi().

◆ listAllStates_

std::vector<std::unique_ptr<const KalmanState> > tmtt::KFbase::listAllStates_
protected

Definition at line 163 of file KFbase.h.

Referenced by mkState(), and resetStates().

◆ nHelixPar_

unsigned tmtt::KFbase::nHelixPar_
protected

◆ nMeas_

unsigned tmtt::KFbase::nMeas_
protected

Definition at line 154 of file KFbase.h.

◆ numEtaRegions_

unsigned tmtt::KFbase::numEtaRegions_
protected

Definition at line 155 of file KFbase.h.

Referenced by kalmanLayer().

◆ numUpdateCalls_

unsigned int tmtt::KFbase::numUpdateCalls_
protected

Definition at line 160 of file KFbase.h.

Referenced by fit(), and kalmanUpdate().

◆ tpa_

const TP* tmtt::KFbase::tpa_
protected

Definition at line 165 of file KFbase.h.

Referenced by fit(), and tmtt::KFParamsComb::isGoodState().

tmtt::KFbase::matrixF
virtual TMatrixD matrixF(const Stub *stub=nullptr, const KalmanState *state=nullptr) const =0
tmtt::Settings::kalmanHOfw
bool kalmanHOfw() const
Definition: Settings.h:335
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
tmtt::Settings::kalmanHOalpha
unsigned int kalmanHOalpha() const
Definition: Settings.h:331
tmtt::KFbase::adjustChi2
virtual void adjustChi2(const KalmanState *state, const TMatrixD &covRinv, const TVectorD &delta, double &chi2rphi, double &chi2rz) const
Definition: KFbase.cc:659
tmtt::KFbase::isGoodState
virtual bool isGoodState(const KalmanState &state) const =0
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
tmtt::KFbase::printStubs
void printStubs(const std::vector< Stub * > &stubs) const
Definition: KFbase.cc:962
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
tmtt::KFbase::doKF
const KalmanState * doKF(const L1track3D &l1track3D, const std::vector< Stub * > &stubs, const TP *tpa)
Definition: KFbase.cc:166
tmtt::Settings::numPhiNonants
unsigned int numPhiNonants() const
Definition: Settings.h:109
tmtt::KFbase::iPhiSec_
unsigned int iPhiSec_
Definition: KFbase.h:157
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
tmtt::Settings::kalmanDebugLevel
unsigned kalmanDebugLevel() const
Definition: Settings.h:297
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
tmtt::StubKiller::KillOptions::layer1
tmtt::KFbase::resetStates
void resetStates()
Definition: KFbase.cc:678
tmtt::KFbase::QOVERPT
Definition: KFbase.h:34
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
tmtt::StubKiller::KillOptions::layer1layer2
tmtt::KFbase::numEtaRegions_
unsigned numEtaRegions_
Definition: KFbase.h:155
tmtt::KFbase::D0
Definition: KFbase.h:33
tmtt::Settings::enableDigitize
bool enableDigitize() const
Definition: Settings.h:80
DigiToRawDM_cff.TP
TP
Definition: DigiToRawDM_cff.py:51
tmtt::KFbase::residual
virtual TVectorD residual(const Stub *stub, const TVectorD &x, double candQoverPt) const
Definition: KFbase.cc:588
tmtt::KFbase::numUpdateCalls_
unsigned int numUpdateCalls_
Definition: KFbase.h:160
spr::goodTrack
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
Definition: TrackSelection.cc:10
tmtt::KFbase::PHI0
Definition: KFbase.h:33
vd
std::vector< DeviationSensor2D * > vd
Definition: DeviationsFromFileSensor2D.h:21
tmtt::Settings::kalmanMaxSkipLayersEasy
unsigned int kalmanMaxSkipLayersEasy() const
Definition: Settings.h:308
tmtt::KFbase::matrixHCHt
TMatrixD matrixHCHt(const TMatrixD &h, const TMatrixD &c) const
Definition: KFbase.cc:549
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
tmtt::Settings::kalmanMaxStubsPerLayer
unsigned int kalmanMaxStubsPerLayer() const
Definition: Settings.h:320
tmtt::KFbase::printStub
void printStub(const Stub *stub) const
Definition: KFbase.cc:942
tmtt::KFbase::Z0
Definition: KFbase.h:33
tmtt::KFbase::PHI
Definition: KFbase.h:35
tmtt::KFbase::trackParams
virtual TVectorD trackParams(const KalmanState *state) const =0
tmtt::TrackFitGeneric::settings_
const Settings * settings_
Definition: TrackFitGeneric.h:31
tmtt::KFbase::matrixH
virtual TMatrixD matrixH(const Stub *stub) const =0
h
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
tmtt::KFbase::mkState
const KalmanState * mkState(const L1track3D &candidate, unsigned nSkipped, unsigned layer, const KalmanState *last_state, const TVectorD &x, const TMatrixD &pxx, const TMatrixD &K, const TMatrixD &dcov, Stub *stub, double chi2rphi, double chi2rz)
Definition: KFbase.cc:528
tmtt::KFbase::iEtaReg_
unsigned int iEtaReg_
Definition: KFbase.h:158
HLTMuonOfflineAnalyzer_cfi.z0
z0
Definition: HLTMuonOfflineAnalyzer_cfi.py:98
tmtt::KFbase::T
Definition: KFbase.h:33
b
double b
Definition: hdecay.h:118
tmtt::KFbase::kalmanUpdate
virtual const KalmanState * kalmanUpdate(unsigned nSkipped, unsigned layer, Stub *stub, const KalmanState *state, const TP *tp)
Definition: KFbase.cc:408
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
tmtt::KFbase::nHelixPar_
unsigned nHelixPar_
Definition: KFbase.h:153
tmtt::Settings::bApprox_intercept
double bApprox_intercept() const
Definition: Settings.h:105
a
double a
Definition: hdecay.h:119
tmtt::Settings::kalmanMaxStubsEasy
unsigned int kalmanMaxStubsEasy() const
Definition: Settings.h:310
tmtt::KFbase::vectorM
virtual TVectorD vectorM(const Stub *stub) const =0
tmtt::Settings::killRecover
bool killRecover() const
Definition: Settings.h:343
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
tmtt::StubKiller::KillOptions
KillOptions
Definition: StubKiller.h:22
tmtt::Settings::kalmanMaxSkipLayersHard
unsigned int kalmanMaxSkipLayersHard() const
Definition: Settings.h:307
tmtt::Settings::kalmanRemove2PScut
bool kalmanRemove2PScut() const
Definition: Settings.h:305
pfMETCorrectionType0_cfi.correction
correction
Definition: pfMETCorrectionType0_cfi.py:39
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
tmtt::Settings::kalmanHOprojZcorr
unsigned int kalmanHOprojZcorr() const
Definition: Settings.h:333
cand
Definition: decayParser.h:34
tmtt::KFbase::getKalmanGainMatrix
TMatrixD getKalmanGainMatrix(const TMatrixD &h, const TMatrixD &pxcov, const TMatrixD &covRinv) const
Definition: KFbase.cc:579
tmtt::KFbase::printStubLayers
void printStubLayers(const std::vector< Stub * > &stubs, unsigned int iEtaReg) const
Definition: KFbase.cc:914
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
HLT_2018_cff.nEta
nEta
Definition: HLT_2018_cff.py:5271
tmtt::Settings::numPhiSectors
unsigned int numPhiSectors() const
Definition: Settings.h:110
tmtt::KFbase::Z
Definition: KFbase.h:35
tmtt::KFbase::kalmanDeadLayers
std::set< unsigned > kalmanDeadLayers(bool &remove2PSCut) const
Definition: KFbase.cc:825
tmtt::KFbase::trackParams_BeamConstr
virtual TVectorD trackParams_BeamConstr(const KalmanState *state, double &chi2rphi_bcon) const =0
tmtt::Settings::kalmanMinNumStubs
unsigned int kalmanMinNumStubs() const
Definition: Settings.h:299
alignCSCRings.r
r
Definition: alignCSCRings.py:93
tmtt::KFbase::kalmanAmbiguousLayer
virtual bool kalmanAmbiguousLayer(unsigned int iEtaReg, unsigned int kfLayer)
Definition: KFbase.cc:790
tmtt::KFbase::matrixV
virtual TMatrixD matrixV(const Stub *stub, const KalmanState *state) const =0
eostools.move
def move(src, dest)
Definition: eostools.py:511
tmtt::Settings::kalmanHOhelixExp
bool kalmanHOhelixExp() const
Definition: Settings.h:329
tmtt::KFbase::seedX
virtual TVectorD seedX(const L1track3D &l1track3D) const =0
HLT_2018_cff.maxIterations
maxIterations
Definition: HLT_2018_cff.py:11849
tmtt::StubKiller::KillOptions::layer1disk1
Exception
Definition: hltDiff.cc:246
tmtt::Settings::kalmanAddBeamConstr
bool kalmanAddBeamConstr() const
Definition: Settings.h:303
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
tmtt::KFbase::tpa_
const TP * tpa_
Definition: KFbase.h:165
tmtt::KFbase::printTP
void printTP(const TP *tp) const
Definition: KFbase.cc:886
tmtt::KFbase::kalmanLayer
virtual unsigned int kalmanLayer(unsigned int iEtaReg, unsigned int layerIDreduced, bool barrel, float r, float z) const
Definition: KFbase.cc:682
tmtt::Settings::hybrid
bool hybrid() const
Definition: Settings.h:407
big
Definition: big.h:8
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
runonSM.text
text
Definition: runonSM.py:43
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
tmtt::Settings::kalmanMaxNumStubs
unsigned int kalmanMaxNumStubs() const
Definition: Settings.h:301
tmtt::KFbase::INV2R
Definition: KFbase.h:33
d0
static constexpr float d0
Definition: L1EGammaCrystalsEmulatorProducer.cc:85
align_cfg.iteration
iteration
Definition: align_cfg.py:5
tmtt::Settings::bApprox_gradient
double bApprox_gradient() const
Definition: Settings.h:104
tmtt::KFbase::seedC
virtual TMatrixD seedC(const L1track3D &l1track3D) const =0
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
tmtt::StubKiller::KillOptions::layer5
tmtt::KFbase::adjustState
void adjustState(const TMatrixD &K, const TMatrixD &pxcov, const TVectorD &x, const TMatrixD &h, const TVectorD &delta, TVectorD &new_x, TMatrixD &new_xcov) const
Definition: KFbase.cc:644
tmtt::Settings::invPtToInvR
double invPtToInvR() const
Definition: Settings.h:393
tmtt::Settings::killScenario
unsigned int killScenario() const
Definition: Settings.h:341
tmtt::KFbase::matrixRinv
TMatrixD matrixRinv(const TMatrixD &matH, const TMatrixD &matCref, const TMatrixD &matV) const
Definition: KFbase.cc:556
tmtt::KFbase::listAllStates_
std::vector< std::unique_ptr< const KalmanState > > listAllStates_
Definition: KFbase.h:163
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443