ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
FPGATrackSimFitConstantBank Class Reference

#include <FPGATrackSimFitConstantBank.h>

Inheritance diagram for FPGATrackSimFitConstantBank:
Collaboration diagram for FPGATrackSimFitConstantBank:

Public Member Functions

 FPGATrackSimFitConstantBank (FPGATrackSimPlaneMap const *pmap, int ncoords, std::string const &fname, bool isFirstStage, float phishift, int missingPlane=-1)
 
int getBankID () const
 
int getNConstr () const
 
int getNCoords () const
 
int getNPars () const
 
int getNSectors () const
 
int getMissingPlane () const
 
bool getIsGood (sector_t sector) const
 
float getFitConst (int isec, int ipar) const
 
float getFitPar (int isec, int ipar, int icoord) const
 
float getKaverage (int isec, int iconstr) const
 
float getKernel (int isec, int iconstr, int icoord) const
 
bool linfit (sector_t sector, FPGATrackSimTrack &track, bool isSecondStage) const
 
void linfit_chisq (sector_t sector, FPGATrackSimTrack &trk) const
 
void linfit_pars_eval (sector_t sector, FPGATrackSimTrack &trk) const
 
int missing_point_guess (sector_t sector, FPGATrackSimTrack &track, bool isFirstStage, bool doExtrapolation) const
 
void invlinfit (sector_t sector, FPGATrackSimTrack &track, double const *constr) const
 This method uses the track parameters and additional constraints to use the constants to calculate the corresponding hits. More...
 
void setIdealCoordFit (bool v)
 
void setPhiShift (float v)
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Member Functions

void readHeader (std::ifstream &geocfile)
 
void readSectorInfo (std::ifstream &geocfile)
 
void calculateMajority ()
 
void prepareInvFitConstants ()
 
void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

FPGATrackSimPlaneMap constm_pmap = nullptr
 
int m_bankID
 
int m_nsectors
 
int m_npars = 0
 
int m_ncoords
 
int m_nconstr
 
int m_npixcy
 
float m_phiShift
 
int m_missingPlane
 
bool m_isIdealCoordFit
 
std::vector< int > m_missid
 
std::vector< bool > m_sector_good
 
vector3D< float > m_fit_pars
 
vector2D< float > m_fit_const
 
vector3D< float > m_kernel
 
vector2D< float > m_kaverage
 
vector2D< float > m_maj_a
 
vector3D< float > m_maj_kk
 
vector3D< float > m_maj_invkk
 
std::vector< Eigen::MatrixXf, Eigen::aligned_allocator< Eigen::MatrixXf > > m_invfit_consts
 
vector2D< int > m_WCs
 
std::string m_nm
 Message source name. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

Detailed Description

Definition at line 23 of file FPGATrackSimFitConstantBank.h.

Constructor & Destructor Documentation

◆ FPGATrackSimFitConstantBank()

FPGATrackSimFitConstantBank::FPGATrackSimFitConstantBank ( FPGATrackSimPlaneMap const pmap,
int  ncoords,
std::string const fname,
bool  isFirstStage,
float  phishift,
int  missingPlane = -1 
)

Definition at line 22 of file FPGATrackSimFitConstantBank.cxx.

22  :
23  AthMessaging ("FPGATrackSimFitConstantBank"),
24  m_pmap(pmap),
25  m_bankID(0),
26  m_nsectors(0),
27  m_ncoords(ncoords),
28  m_nconstr(0),
29  m_npixcy(0),
30  m_phiShift(phishift),
31  m_missingPlane(missingPlane),
32 // m_isFirstStage(isFirstStage),
33  m_isIdealCoordFit(true)
34 {
35  std::ifstream geocfile(fname);
36  if (not geocfile.is_open()) {
37  ATH_MSG_WARNING("FitConstants file: " << fname << " cannot be opened");
38  }
39  else {
40  ATH_MSG_INFO("Reading " << fname);
41  // Read the file header
42  readHeader(geocfile);
43  ATH_MSG_INFO("Settings: m_ncoords="<<m_ncoords<<" m_npars="<<m_npars);
44  // Read the sector constants
45  readSectorInfo(geocfile);
46  // Pre-calculate the majority logic elements
47  if (m_missingPlane == -1)
49 
50  if (sizeof(float) * CHAR_BIT != 32)
51  ATH_MSG_WARNING("Floating points on this computer are not 32 bit. This may cause a problem for the hardware agreement. Be careful!");
52 
53  setIdealCoordFit(true);
55  }
56 }

Member Function Documentation

◆ calculateMajority()

void FPGATrackSimFitConstantBank::calculateMajority ( )
private

Definition at line 169 of file FPGATrackSimFitConstantBank.cxx.

170 {
171 
172  for (int isec=0;isec!=m_nsectors;++isec)
173  {
174  // Fill m_maj_a and m_maj_kk
175  for (int ix=0;ix!=m_ncoords;++ix)
176  {
177  for (int row=0;row!=m_nconstr;++row)
178  m_maj_a(isec, ix) += m_kaverage(isec, row) * m_kernel(isec, row, ix);
179  for (int jx=0;jx!=m_ncoords;++jx)
180  {
181  for (int row=0;row!=m_nconstr;++row)
182  m_maj_kk(isec, ix, jx) += m_kernel(isec, row, ix) * m_kernel(isec, row, jx);
183  }
184  }
185 
186  // Fill m_maj_invkk
187 
188  // Pixel layers (2 coordinates each), assume these come first!
189  for (int ix=0;ix!=m_npixcy;ix+=2)
190  {
191  float det = m_maj_kk(isec, ix, ix) * m_maj_kk(isec, ix+1, ix+1)
192  - m_maj_kk(isec, ix+1, ix) * m_maj_kk(isec, ix, ix+1);
193  if (det == 0) continue;
194 
195  m_maj_invkk(isec, ix, ix) = m_maj_kk(isec, ix+1, ix+1)/det;
196  m_maj_invkk(isec, ix, ix+1) = -m_maj_kk(isec, ix+1, ix)/det;
197  m_maj_invkk(isec, ix+1, ix) = -m_maj_kk(isec, ix, ix+1)/det;
198  m_maj_invkk(isec, ix+1, ix+1) = m_maj_kk(isec, ix, ix)/det;
199  }
200 
201  // Strip layers (1 coordinate)
202  for (int ix=m_npixcy;ix!=m_ncoords;++ix) {
203  if (m_maj_kk(isec, ix, ix) == 0) continue;
204  m_maj_invkk(isec, ix, ix) = 1./m_maj_kk(isec, ix, ix);
205  }
206  }
207 }

◆ getBankID()

int FPGATrackSimFitConstantBank::getBankID ( ) const
inline

Definition at line 33 of file FPGATrackSimFitConstantBank.h.

33 { return m_bankID; }

◆ getFitConst()

float FPGATrackSimFitConstantBank::getFitConst ( int  isec,
int  ipar 
) const
inline

Definition at line 42 of file FPGATrackSimFitConstantBank.h.

42 { return m_fit_const(isec, ipar); }

◆ getFitPar()

float FPGATrackSimFitConstantBank::getFitPar ( int  isec,
int  ipar,
int  icoord 
) const
inline

Definition at line 43 of file FPGATrackSimFitConstantBank.h.

43 { return m_fit_pars(isec, ipar, icoord); }

◆ getIsGood()

bool FPGATrackSimFitConstantBank::getIsGood ( sector_t  sector) const
inline

Definition at line 41 of file FPGATrackSimFitConstantBank.h.

41 { return m_sector_good[sector]; }

◆ getKaverage()

float FPGATrackSimFitConstantBank::getKaverage ( int  isec,
int  iconstr 
) const
inline

Definition at line 44 of file FPGATrackSimFitConstantBank.h.

44 { return m_kaverage(isec, iconstr); }

◆ getKernel()

float FPGATrackSimFitConstantBank::getKernel ( int  isec,
int  iconstr,
int  icoord 
) const
inline

Definition at line 45 of file FPGATrackSimFitConstantBank.h.

45 { return m_kernel(isec, iconstr, icoord); }

◆ getMissingPlane()

int FPGATrackSimFitConstantBank::getMissingPlane ( ) const
inline

Definition at line 38 of file FPGATrackSimFitConstantBank.h.

38 { return m_missingPlane; }

◆ getNConstr()

int FPGATrackSimFitConstantBank::getNConstr ( ) const
inline

Definition at line 34 of file FPGATrackSimFitConstantBank.h.

34 { return m_nconstr; }

◆ getNCoords()

int FPGATrackSimFitConstantBank::getNCoords ( ) const
inline

Definition at line 35 of file FPGATrackSimFitConstantBank.h.

35 { return m_ncoords; }

◆ getNPars()

int FPGATrackSimFitConstantBank::getNPars ( ) const
inline

Definition at line 36 of file FPGATrackSimFitConstantBank.h.

36 { return m_npars; }

◆ getNSectors()

int FPGATrackSimFitConstantBank::getNSectors ( ) const
inline

Definition at line 37 of file FPGATrackSimFitConstantBank.h.

37 { return m_nsectors; }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40 {
42  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ invlinfit()

void FPGATrackSimFitConstantBank::invlinfit ( sector_t  sector,
FPGATrackSimTrack track,
double const constr 
) const

This method uses the track parameters and additional constraints to use the constants to calculate the corresponding hits.

This method is the base of the patt-from-constant generation.

Definition at line 548 of file FPGATrackSimFitConstantBank.cxx.

549 {
550  // vector of the acutal parameters, it is zeroed
551  Eigen::VectorXf pars(m_ncoords);
552 
553  for (int ip = 0; ip < m_npars; ++ip)
554  {
555  // The first elements are the track parameters. The track are shifted using the sector constants
556  pars(ip) = track.getParameter(ip) - m_fit_const(sector, ip);
557  if (ip == 2) pars(ip) = remainder(pars(ip), 2.*M_PI);
558  }
559  for (int ic = 0; ic < m_nconstr; ++ic)
560  {
561  // The rest of the paramaters are the external constraints.
562  // The external constraint is also shifted by the kAverage value
563  if (!constr)
564  pars(m_npars+ic) = -m_kaverage(sector, ic);
565  else
566  pars(m_npars+ic) = constr[ic] - m_kaverage(sector, ic);
567  }
568 
569  // The raw hits are obtained multiplying the parameters to the inverted constants
570  Eigen::VectorXf rawhits = (m_invfit_consts[sector]) * pars;
571 
572  // The hits are assigned to the original track
573  for (int j = 0; j < m_ncoords ; ++j) {
574  int plane = m_pmap->getCoordLayer(j);
575  SiliconTech Tech = m_pmap->getDetType(plane);
576  FPGATrackSimHit hit;
578  hit.setDetType(Tech);
579  hit.setLayer(plane);
580  if (m_WCs(sector,j))
581  hit.setPhiCoord(-1); // to keep track later on, set hit position negative
582  else
583  hit.setPhiCoord(rawhits(j));
584 
585  if (Tech == SiliconTech::pixel) {
586  if (m_WCs(sector,j))
587  hit.setEtaCoord(-1); // to keep track later on, set hit position negative
588  else
589  hit.setEtaCoord(rawhits(j+1));
590 
591  ++j; // skip a coordinate if doing two at once
592  }
593  track.setFPGATrackSimHit(plane, hit);
594  }
595 }

◆ linfit()

bool FPGATrackSimFitConstantBank::linfit ( sector_t  sector,
FPGATrackSimTrack track,
bool  isSecondStage 
) const

Definition at line 304 of file FPGATrackSimFitConstantBank.cxx.

305 {
306  // Do majority guess if it's needed
307  if (m_missingPlane == -1 && !m_isIdealCoordFit)
308  {
309  int nmissing = track.getNMissing();
310  if (nmissing > 0)
311  {
312  int guess_res = missing_point_guess(sector, track, !isSecondStage, false);
313  if (nmissing != guess_res) return false; // majority failed
314  }
315  }
316 
317  // evaluate the chi2
318  linfit_chisq(sector, track);
319 
320  // Do the fit
321  linfit_pars_eval(sector, track);
322 
323  return true;
324 }

◆ linfit_chisq()

void FPGATrackSimFitConstantBank::linfit_chisq ( sector_t  sector,
FPGATrackSimTrack trk 
) const

we don't want to shift phi for the outer hits in a SP, so check that!

Definition at line 469 of file FPGATrackSimFitConstantBank.cxx.

470 {
471  float chi2 = 0;
472 
473  for (int i = 0; i < m_nconstr; i++)
474  {
475  float chi_component = m_kaverage(sector, i);
476  for (int ix = 0; ix != m_npixcy/2; ix++) // pxl plane loop (divide by two to get number of pix planes from pix coords)
477  {
478  chi_component += m_kernel(sector, i, 2*ix) * (m_phiShift+trk.getPhiCoord(m_pmap->getCoordLayer(2*ix)));
479  chi_component += m_kernel(sector, i, 2*ix+1) * trk.getEtaCoord(m_pmap->getCoordLayer(2*ix));
480  }
481 
482  for (int ix = m_npixcy; ix != m_ncoords; ix++) // strip coords, easier
483  {
485  float phishift = m_phiShift;
486  int layer = m_pmap->getCoordLayer(ix);
488  if (((hit.getPhysLayer() %2) == 1) && hit.getHitType() == HitType::spacepoint) phishift = 0.0;
489 
490  chi_component += m_kernel(sector, i, ix) * (phishift+trk.getPhiCoord(m_pmap->getCoordLayer(ix)));
491  }
492 
493  chi2 += chi_component * chi_component;
494  }
495 
496  trk.setChi2(chi2);
497 }

◆ linfit_pars_eval()

void FPGATrackSimFitConstantBank::linfit_pars_eval ( sector_t  sector,
FPGATrackSimTrack trk 
) const

we don't want to shift phi for the outer hits in a SP, so check that!

Definition at line 507 of file FPGATrackSimFitConstantBank.cxx.

508 {
509  std::vector<float> pars(m_npars);
510 
511  for (int ip = 0; ip < m_npars; ip++)
512  {
513  pars[ip] = m_fit_const(sector, ip);
514 
515  for (int coord = 0; coord < m_ncoords; coord++) {
516 
518  float phishift = m_phiShift;
521  if (((hit.getPhysLayer() %2) == 1) && hit.getHitType() == HitType::spacepoint) phishift = 0.0;
522 
523  pars[ip] += m_fit_pars(sector, ip, coord) * (phishift+trk.getPhiCoord(m_pmap->getCoordLayer(coord)));
524  if (m_pmap->getDim(m_pmap->getCoordLayer(coord)) == 2) { // do two at a time if 2d, then skip ahead
525  pars[ip] += m_fit_pars(sector, ip, coord+1) * trk.getEtaCoord(m_pmap->getCoordLayer(coord));
526  ++coord;
527  }
528  }
529  }
530 
531  trk.setQOverPt(pars[0]);
532  trk.setD0(pars[1]);
533  trk.setPhi(pars[2]-m_phiShift); // angle is moved within -pi to +pi, and shift phi back to the range we want
534  trk.setZ0(pars[3]);
535  trk.setEta(pars[4]);
536  if (trk.getDoDeltaGPhis()) {
537  trk.setQOverPt(trk.getHoughY()/1000.0 - trk.getQOverPt()); // final q/pT = q/pT from HT + delta q/pT
538  trk.setPhi(trk.getHoughX() - trk.getPhi()); // final phi_0 = phi_0 from HT + delta phi_0
539  }
540 
541 }

◆ missing_point_guess()

int FPGATrackSimFitConstantBank::missing_point_guess ( sector_t  sector,
FPGATrackSimTrack track,
bool  isFirstStage,
bool  doExtrapolation 
) const

we don't want to shift phi for the outer hits in a SP, so check that!

Definition at line 327 of file FPGATrackSimFitConstantBank.cxx.

328 {
329 
330  std::vector<int> coordsmask(m_ncoords);
331  std::vector<int> missid;
332 
333  // Keep track of which hits are missing
334  int nmissing = 0;
335  std::vector<int> missing_planes;
336  for (int j = 0; j < m_ncoords ; ++j)
337  {
338  coordsmask[j] = (track.getHitMap()>>j) & 1;
339  if (!coordsmask[j]) {
340  int plane = m_pmap->getCoordLayer(j);
341  if(missing_planes.size() == 0) {
342  missing_planes.push_back(plane);
343  }
344  else {
345  for (unsigned k = 0; k < missing_planes.size(); k++) {
346  if(plane == missing_planes[k]) break;
347  if(k == missing_planes.size() - 1) missing_planes.push_back(plane);
348  }
349  }
350  missid.push_back(j);
351  nmissing++;
352  }
353  }
354 
355  if(!doExtrapolation){
356  if(isFirstStage){
357  if(missing_planes.size() > 1){
358  ATH_MSG_WARNING("missing_point_guess() Can only guess 1 layer in the first stage");
359  return 0;
360  }
361  if (nmissing > 2){
362  ATH_MSG_WARNING("missing_point_guess() Cannot guess more than two coordinates in the first stage");
363  return 0;
364  }
365  }
366  else{
367  if(missing_planes.size() > 2){
368  ATH_MSG_WARNING("missing_point_guess() Can only guess 2 layers in the second stage");
369  return 0;
370  }
371  if (nmissing > 4){
372  ATH_MSG_WARNING("missing_point_guess() Cannot guess more than four coordinates in the second stage");
373  return 0;
374  }
375  }
376  }
377 
378  Eigen::MatrixXd coef(nmissing,nmissing);
379  Eigen::VectorXd a(nmissing);
380 
381  for (int i=0; i<nmissing; ++i)
382  {
383  a[i] = -m_maj_a(sector, missid[i]);
384  // complete the calculation with the terms that depend on the known hits
385  for (int col=0; col<m_ncoords; ++col)
386  {
387  if (!coordsmask[col]) continue;
388 
390  float phishift = m_phiShift;
391  int layer = m_pmap->getCoordLayer(col);
392  FPGATrackSimHit hit = (track.getFPGATrackSimHits())[layer];
393  if (((hit.getPhysLayer() %2) == 1) && hit.getHitType() == HitType::spacepoint) phishift = 0.0;
394 
395  a[i] -= m_maj_kk(sector, col, missid[i])*(phishift+track.getPhiCoord(m_pmap->getCoordLayer(col)));
396 
397  if (m_pmap->getDim(m_pmap->getCoordLayer(col)) == 2) { // do two at a time if 2d, then skip ahead
398  a[i] -= m_maj_kk(sector, col+1, missid[i])*track.getEtaCoord(m_pmap->getCoordLayer(col));
399  ++col;
400  }
401  }
402 
403  for (int j=0; j<nmissing; ++j)
404  {
405  // here for missing pieces need to know the coordinate and sector number only
406  coef(i,j) = m_maj_kk(sector, missid[i], missid[j]);
407  }
408  }
409 
410  if (coef.determinant()==0) return -1;
411  Eigen::VectorXd missing_hits = coef.inverse()*a; // our missing hits!
412 
413  for(int m=0; m<nmissing; m++){
414 
415  int missedplane = m_pmap->getCoordLayer(missid[m]);
416 
417  if(m_pmap->getDim(m_pmap->getCoordLayer(missid[m])) == 1){
418 
419  FPGATrackSimHit newhit;
420  if(!doExtrapolation)
422  else
425  newhit.setLayer(missedplane);
426  newhit.setSection(0);
427  if (m_isIdealCoordFit) {
428  // TODO: all the missing hit logic will eventually need spacepoint updates.
429  double target_r = track.getIdealRadius(missedplane);
430  newhit.setX(target_r*TMath::Cos(missing_hits[m]));
431  newhit.setY(target_r*TMath::Sin(missing_hits[m]));
432  }
433  else{
434  newhit.setPhiCoord(missing_hits[m]);
435  }
436 
437  track.setFPGATrackSimHit(missedplane, newhit);
438  }
439  else if (m_pmap->getDim(m_pmap->getCoordLayer(missid[m])) == 2){
440 
441  FPGATrackSimHit newhit;
442  if(!doExtrapolation)
444  else
447  newhit.setLayer(missedplane);
448  newhit.setSection(0);
449  if (m_isIdealCoordFit) {
450  // TODO This will also eventually ned spacepoint updates.
451  double target_r = track.getIdealRadius(missedplane);
452  newhit.setX(target_r*TMath::Cos(missing_hits[m]));
453  newhit.setY(target_r*TMath::Sin(missing_hits[m]));
454  newhit.setZ(missing_hits[m+1]);
455  }
456  else {
457  newhit.setPhiCoord(missing_hits[m]);
458  newhit.setEtaCoord(missing_hits[m+1]);
459  }
460  m++; //skip ahead
461 
462  track.setFPGATrackSimHit(missedplane, newhit);
463  }
464  }
465 
466  return nmissing;
467 }

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level  lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152 {
153  if (!m_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ prepareInvFitConstants()

void FPGATrackSimFitConstantBank::prepareInvFitConstants ( )
private

Definition at line 211 of file FPGATrackSimFitConstantBank.cxx.

212 {
213  m_invfit_consts.resize(m_nsectors);
214 
215  for (int isec=0;isec!=m_nsectors;++isec)
216  {
217  Eigen::MatrixXf thisMatrix(m_ncoords, m_ncoords);
218 
219  // Parameters, by row
220  for (int ip=0;ip!=m_npars;++ip)
221  for (int ix=0;ix!=m_ncoords;++ix)
222  thisMatrix(ip,ix)= (m_fit_pars(isec, ip, ix));
223 
224  // Constraints, by row
225  for (int ic=0;ic!=m_nconstr;++ic)
226  for (int ix=0;ix!=m_ncoords;++ix)
227  thisMatrix(ic+m_npars,ix) = m_kernel(isec, ic, ix);
228 
229  // reset usable coordinate
230  for (int ix = 0; ix != m_ncoords; ++ix)
231  m_WCs(isec,ix) = 1; // start with all WCs
232 
233  // now let's check if we have any "null" row or column, and if so, we will get rid of them temporarily
234  // we don't have access to module/WC information at this stage should just look for non-zero values
235  for (int ix=0;ix!=m_ncoords;++ix) {
236  bool foundrow = false;
237  bool foundcolumn = false;
238  for (int iy=0;iy!=m_ncoords;++iy) {
239  if (abs(thisMatrix(ix,iy)) > MTX_TOLERANCE) foundrow = true;
240  if (abs(thisMatrix(iy,ix)) > MTX_TOLERANCE) foundcolumn = true;
241  }
242  if (foundrow && foundcolumn) m_WCs(isec,ix) = 0;
243  }
244 
245  // now count the number of usable entries
246  size_t nDimToUse = 0; for (int ix=0;ix!=m_ncoords;++ix) if(!m_WCs(isec,ix)) ++nDimToUse;
247 
248  Eigen::MatrixXf tempMatrix(nDimToUse, nDimToUse); // this is the matrix we will invert
249 
250  size_t counteri = 0, counterj = 0;
251  for (int i = 0; i < m_ncoords; i++) {
252  counterj = 0;
253  if (!m_WCs(isec,i)) {
254  for (int j = 0; j < m_ncoords; j++) {
255  if (!m_WCs(isec,j)) {
256  tempMatrix(counteri,counterj) = thisMatrix(i,j); // if we use this coordinate, copy it over
257  counterj++; // iterate counter
258  }
259  }
260  counteri++;
261  }
262  }
263 
264  // Invert the matrix
265  Eigen::MatrixXf inverted = tempMatrix.inverse();
266 
267  // this is the full matrix that includes inverted coordinates plus the padded zeros
268  Eigen::MatrixXf fullInverted(m_ncoords, m_ncoords);
269 
270  // now we put things back into the full matrix, adding back the padded zeros
271  counteri = 0; counterj = 0;
272  for (int i = 0; i < m_ncoords; i++) {
273  counterj = 0;
274  if (!m_WCs(isec,i)) {
275  for (int j = 0; j < m_ncoords; j++) {
276  if (!m_WCs(isec,j)) {
277  fullInverted(i,j) = inverted(counteri,counterj); // if we use this coordinate, copy it over
278  counterj++; // iterate counter
279  }
280  else {
281  fullInverted(i,j) = 0;
282  }
283  }
284  counteri++;
285  }
286  else {
287  for (int j = 0; j < m_ncoords; j++) {
288  fullInverted(i,j) = 0;
289  }
290  }
291  }
292  m_invfit_consts[isec]= fullInverted;
293 
294  }
295 }

◆ readHeader()

void FPGATrackSimFitConstantBank::readHeader ( std::ifstream &  geocfile)
private

Definition at line 60 of file FPGATrackSimFitConstantBank.cxx.

61 {
62  std::string key;
63  int ival;
64  int nplanes;
65 
66  for (int i = 0; i < 5; ++i) getline(geocfile, key); // skip 5 lines
67 
68  geocfile >> key;
69  if (key != "NPLANES") ATH_MSG_ERROR("Invalid file format");
70  geocfile >> nplanes;
71 
72  geocfile >> key;
73  if (key!="NSECTORS") ATH_MSG_ERROR("Invalid file format");
74  geocfile >> m_nsectors;
75 
76  geocfile >> key;
77  if (key!="NDIM") ATH_MSG_ERROR("Invalid file format");
78  geocfile >> ival;
79 
80  // Set derived configuration variables
81  if (ival==1) m_npars = 3;
82  else if (ival==2) m_npars = 5;
83  else ATH_MSG_ERROR("Number of dimensions invalid");
84 
85  m_npixcy = 2*(m_ncoords - nplanes); // difference between number of coordinates and planes is number of 2d measurements
87 
88  // Allocate the block of pointer per sector
89  m_sector_good.resize(m_nsectors);
94 
96 
100 }

◆ readSectorInfo()

void FPGATrackSimFitConstantBank::readSectorInfo ( std::ifstream &  geocfile)
private

Definition at line 104 of file FPGATrackSimFitConstantBank.cxx.

105 {
106  std::string key;
107  int ival;
108  double dval; // temp value used to conver from double to float
109 
110  for (int isec = 0; isec < m_nsectors; ++isec)
111  {
112  // Read sector number
113  geocfile >> key >> ival;
114  if (ival != isec) ATH_MSG_WARNING("Reached sector " << ival << " but expected sector " << isec);
115 
116  // Read fit parameters
117  for (int ipar = 0; ipar < m_npars; ++ipar)
118  {
119  geocfile >> key;
120  // no check on key?
121  for (int icoord = 0; icoord < m_ncoords; ++icoord)
122  {
123  geocfile >> dval;
124  if (geocfile.fail())
125  ATH_MSG_WARNING("par loop (1) key=\"" << key << "\" ipar,icoord=" << ipar << "," << icoord);
126 
127  if (dval != 0) m_sector_good[isec] = true;
128  m_fit_pars(isec, ipar, icoord) = dval;
129  }
130  }
131 
132  // Read k averages
133  geocfile >> key;
134  assert(key=="kaverages");
135  for (int ik=0;ik<m_nconstr;++ik)
136  {
137  geocfile >> dval;
138  if (dval != 0) m_sector_good[isec] = true;
139  m_kaverage(isec,ik) = dval;
140  }
141 
142  // Read kernel
143  geocfile >> key;
144  assert(key=="kernel");
145  for (int ik=0;ik<m_nconstr;++ik)
146  {
147  for (int ik2=0;ik2<m_ncoords;++ik2)
148  {
149  geocfile >> dval;
150  if (dval != 0) m_sector_good[isec] = true;
151  m_kernel(isec, ik, ik2) = dval;
152  }
153  }
154 
155  // Read fit const
156  for (int ipar=0;ipar<m_npars;++ipar)
157  {
158  geocfile >> key;
159  geocfile >> dval;
160  if (dval != 0) m_sector_good[isec] = true;
161  m_fit_const(isec, ipar) = dval;
162  }
163 
164  }
165 }

◆ setIdealCoordFit()

void FPGATrackSimFitConstantBank::setIdealCoordFit ( bool  v)
inline

Definition at line 56 of file FPGATrackSimFitConstantBank.h.

56 { m_isIdealCoordFit = v;}

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level  lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29 {
30  m_lvl = lvl;
31 }

◆ setPhiShift()

void FPGATrackSimFitConstantBank::setPhiShift ( float  v)
inline

Definition at line 57 of file FPGATrackSimFitConstantBank.h.

57 {m_phiShift = v;}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_bankID

int FPGATrackSimFitConstantBank::m_bankID
private

Definition at line 66 of file FPGATrackSimFitConstantBank.h.

◆ m_fit_const

vector2D<float> FPGATrackSimFitConstantBank::m_fit_const
private

Definition at line 86 of file FPGATrackSimFitConstantBank.h.

◆ m_fit_pars

vector3D<float> FPGATrackSimFitConstantBank::m_fit_pars
private

Definition at line 85 of file FPGATrackSimFitConstantBank.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_invfit_consts

std::vector<Eigen::MatrixXf, Eigen::aligned_allocator<Eigen::MatrixXf> > FPGATrackSimFitConstantBank::m_invfit_consts
private

Definition at line 94 of file FPGATrackSimFitConstantBank.h.

◆ m_isIdealCoordFit

bool FPGATrackSimFitConstantBank::m_isIdealCoordFit
private

Definition at line 75 of file FPGATrackSimFitConstantBank.h.

◆ m_kaverage

vector2D<float> FPGATrackSimFitConstantBank::m_kaverage
private

Definition at line 88 of file FPGATrackSimFitConstantBank.h.

◆ m_kernel

vector3D<float> FPGATrackSimFitConstantBank::m_kernel
private

Definition at line 87 of file FPGATrackSimFitConstantBank.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ m_maj_a

vector2D<float> FPGATrackSimFitConstantBank::m_maj_a
private

Definition at line 90 of file FPGATrackSimFitConstantBank.h.

◆ m_maj_invkk

vector3D<float> FPGATrackSimFitConstantBank::m_maj_invkk
private

Definition at line 92 of file FPGATrackSimFitConstantBank.h.

◆ m_maj_kk

vector3D<float> FPGATrackSimFitConstantBank::m_maj_kk
private

Definition at line 91 of file FPGATrackSimFitConstantBank.h.

◆ m_missid

std::vector<int> FPGATrackSimFitConstantBank::m_missid
private

Definition at line 80 of file FPGATrackSimFitConstantBank.h.

◆ m_missingPlane

int FPGATrackSimFitConstantBank::m_missingPlane
private

Definition at line 73 of file FPGATrackSimFitConstantBank.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nconstr

int FPGATrackSimFitConstantBank::m_nconstr
private

Definition at line 70 of file FPGATrackSimFitConstantBank.h.

◆ m_ncoords

int FPGATrackSimFitConstantBank::m_ncoords
private

Definition at line 69 of file FPGATrackSimFitConstantBank.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_npars

int FPGATrackSimFitConstantBank::m_npars = 0
private

Definition at line 68 of file FPGATrackSimFitConstantBank.h.

◆ m_npixcy

int FPGATrackSimFitConstantBank::m_npixcy
private

Definition at line 71 of file FPGATrackSimFitConstantBank.h.

◆ m_nsectors

int FPGATrackSimFitConstantBank::m_nsectors
private

Definition at line 67 of file FPGATrackSimFitConstantBank.h.

◆ m_phiShift

float FPGATrackSimFitConstantBank::m_phiShift
private

Definition at line 72 of file FPGATrackSimFitConstantBank.h.

◆ m_pmap

FPGATrackSimPlaneMap const* FPGATrackSimFitConstantBank::m_pmap = nullptr
private

Definition at line 61 of file FPGATrackSimFitConstantBank.h.

◆ m_sector_good

std::vector<bool> FPGATrackSimFitConstantBank::m_sector_good
private

Definition at line 84 of file FPGATrackSimFitConstantBank.h.

◆ m_WCs

vector2D<int> FPGATrackSimFitConstantBank::m_WCs
private

Definition at line 96 of file FPGATrackSimFitConstantBank.h.


The documentation for this class was generated from the following files:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
FPGATrackSimTrack::getPhiCoord
float getPhiCoord(int ilayer) const
Definition: FPGATrackSimTrack.cxx:67
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
query_example.row
row
Definition: query_example.py:24
FPGATrackSimHit::setSection
void setSection(unsigned v)
Definition: FPGATrackSimHit.h:93
FPGATrackSimTrack::setD0
void setD0(float v)
Definition: FPGATrackSimTrack.h:93
SiliconTech::strip
@ strip
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
FPGATrackSimHit::getPhysLayer
unsigned getPhysLayer() const
Definition: FPGATrackSimHit.cxx:69
HitType::extrapolated
@ extrapolated
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FPGATrackSimTrack::getDoDeltaGPhis
bool getDoDeltaGPhis() const
Definition: FPGATrackSimTrack.h:27
FPGATrackSimFitConstantBank::readSectorInfo
void readSectorInfo(std::ifstream &geocfile)
Definition: FPGATrackSimFitConstantBank.cxx:104
TRTCalib_Extractor.det
det
Definition: TRTCalib_Extractor.py:36
FPGATrackSimFitConstantBank::m_kernel
vector3D< float > m_kernel
Definition: FPGATrackSimFitConstantBank.h:87
FPGATrackSimHit::setPhiCoord
void setPhiCoord(float v)
Definition: FPGATrackSimHit.h:104
FPGATrackSimTrack::getPhi
float getPhi() const
Definition: FPGATrackSimTrack.h:40
FPGATrackSimFitConstantBank::readHeader
void readHeader(std::ifstream &geocfile)
Definition: FPGATrackSimFitConstantBank.cxx:60
M_PI
#define M_PI
Definition: ActiveFraction.h:11
FPGATrackSimFitConstantBank::m_maj_a
vector2D< float > m_maj_a
Definition: FPGATrackSimFitConstantBank.h:90
FPGATrackSimFitConstantBank::m_fit_const
vector2D< float > m_fit_const
Definition: FPGATrackSimFitConstantBank.h:86
FPGATrackSimFitConstantBank::m_missingPlane
int m_missingPlane
Definition: FPGATrackSimFitConstantBank.h:73
HitType::spacepoint
@ spacepoint
FPGATrackSimFitConstantBank::m_nconstr
int m_nconstr
Definition: FPGATrackSimFitConstantBank.h:70
FPGATrackSimHit::setY
void setY(float v)
Definition: FPGATrackSimHit.h:135
FPGATrackSimFitConstantBank::m_fit_pars
vector3D< float > m_fit_pars
Definition: FPGATrackSimFitConstantBank.h:85
FPGATrackSimFitConstantBank::m_nsectors
int m_nsectors
Definition: FPGATrackSimFitConstantBank.h:67
FPGATrackSimFitConstantBank::m_ncoords
int m_ncoords
Definition: FPGATrackSimFitConstantBank.h:69
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
FPGATrackSimTrack::getHoughY
float getHoughY() const
Definition: FPGATrackSimTrack.h:36
HitType::guessed
@ guessed
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
FPGATrackSimPlaneMap::getCoordLayer
uint32_t getCoordLayer(uint32_t coord) const
Definition: FPGATrackSimPlaneMap.h:98
FPGATrackSimTrack::setZ0
void setZ0(float v)
Definition: FPGATrackSimTrack.h:95
FPGATrackSimTrack::getQOverPt
float getQOverPt() const
Definition: FPGATrackSimTrack.h:37
FPGATrackSimHit
Definition: FPGATrackSimHit.h:41
FPGATrackSimPlaneMap::getDim
uint32_t getDim(size_t logiLayer) const
Definition: FPGATrackSimPlaneMap.h:78
FPGATrackSimTrack::setPhi
void setPhi(float v, bool ForceRange=true)
Definition: FPGATrackSimTrack.cxx:116
FPGATrackSimFitConstantBank::m_npixcy
int m_npixcy
Definition: FPGATrackSimFitConstantBank.h:71
FPGATrackSimTrack::getFPGATrackSimHits
const std::vector< FPGATrackSimHit > & getFPGATrackSimHits() const
Definition: FPGATrackSimTrack.h:63
FPGATrackSimHit::setDetType
void setDetType(SiliconTech detType)
Definition: FPGATrackSimHit.h:55
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:134
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
WriteCellNoiseToCool.ival
ival
Definition: WriteCellNoiseToCool.py:337
vector3D::resize
void resize(size_t x1, size_t x2, size_t x3, T const &t=T())
Definition: FPGATrackSimVectors.h:166
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
FPGATrackSimFitConstantBank::linfit_chisq
void linfit_chisq(sector_t sector, FPGATrackSimTrack &trk) const
Definition: FPGATrackSimFitConstantBank.cxx:469
SiliconTech
SiliconTech
Definition: FPGATrackSimTypes.h:25
lumiFormat.i
int i
Definition: lumiFormat.py:85
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
FPGATrackSimPlaneMap::getDetType
SiliconTech getDetType(size_t logiLayer) const
Definition: FPGATrackSimPlaneMap.h:79
FPGATrackSimHit::setEtaCoord
void setEtaCoord(float v)
Definition: FPGATrackSimHit.h:105
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:523
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
FPGATrackSimTrack::getEtaCoord
float getEtaCoord(int ilayer) const
Definition: FPGATrackSimTrack.cxx:57
FPGATrackSimFitConstantBank::m_npars
int m_npars
Definition: FPGATrackSimFitConstantBank.h:68
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
grepfile.ic
int ic
Definition: grepfile.py:33
FPGATrackSimFitConstantBank::m_maj_kk
vector3D< float > m_maj_kk
Definition: FPGATrackSimFitConstantBank.h:91
remainder
std::vector< std::string > remainder(const std::vector< std::string > &v1, const std::vector< std::string > &v2)
list of entries in a vector that are not in another
Definition: compareFlatTrees.cxx:44
MTX_TOLERANCE
#define MTX_TOLERANCE
Definition: FPGATrackSimConstants.h:10
FPGATrackSimFitConstantBank::prepareInvFitConstants
void prepareInvFitConstants()
Definition: FPGATrackSimFitConstantBank.cxx:211
FPGATrackSimFitConstantBank::linfit_pars_eval
void linfit_pars_eval(sector_t sector, FPGATrackSimTrack &trk) const
Definition: FPGATrackSimFitConstantBank.cxx:507
FPGATrackSimFitConstantBank::missing_point_guess
int missing_point_guess(sector_t sector, FPGATrackSimTrack &track, bool isFirstStage, bool doExtrapolation) const
Definition: FPGATrackSimFitConstantBank.cxx:327
FPGATrackSimFitConstantBank::m_phiShift
float m_phiShift
Definition: FPGATrackSimFitConstantBank.h:72
FPGATrackSimTrack::setQOverPt
void setQOverPt(float v)
Definition: FPGATrackSimTrack.h:92
query_example.col
col
Definition: query_example.py:7
JetVoronoiDiagramHelpers::coord
double coord
Definition: JetVoronoiDiagramHelpers.h:45
FPGATrackSimTrack::setEta
void setEta(float v)
Definition: FPGATrackSimTrack.h:96
FPGATrackSimFitConstantBank::m_pmap
FPGATrackSimPlaneMap const * m_pmap
Definition: FPGATrackSimFitConstantBank.h:61
FPGATrackSimHit::setZ
void setZ(float v)
Definition: FPGATrackSimHit.h:136
HitType::mapped
@ mapped
FPGATrackSimFitConstantBank::m_invfit_consts
std::vector< Eigen::MatrixXf, Eigen::aligned_allocator< Eigen::MatrixXf > > m_invfit_consts
Definition: FPGATrackSimFitConstantBank.h:94
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
python.PyAthena.v
v
Definition: PyAthena.py:154
FPGATrackSimFitConstantBank::setIdealCoordFit
void setIdealCoordFit(bool v)
Definition: FPGATrackSimFitConstantBank.h:56
FPGATrackSimFitConstantBank::m_sector_good
std::vector< bool > m_sector_good
Definition: FPGATrackSimFitConstantBank.h:84
a
TList * a
Definition: liststreamerinfos.cxx:10
FPGATrackSimHit::setLayer
void setLayer(unsigned v)
Definition: FPGATrackSimHit.h:92
FPGATrackSimTrack::setChi2
void setChi2(float v)
Definition: FPGATrackSimTrack.h:97
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
FPGATrackSimFitConstantBank::calculateMajority
void calculateMajority()
Definition: FPGATrackSimFitConstantBank.cxx:169
vector2D::resize
void resize(size_t x1, size_t x2, T const &t=T())
Definition: FPGATrackSimVectors.h:51
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
FPGATrackSimFitConstantBank::m_WCs
vector2D< int > m_WCs
Definition: FPGATrackSimFitConstantBank.h:96
FPGATrackSimFitConstantBank::m_bankID
int m_bankID
Definition: FPGATrackSimFitConstantBank.h:66
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
FPGATrackSimFitConstantBank::m_maj_invkk
vector3D< float > m_maj_invkk
Definition: FPGATrackSimFitConstantBank.h:92
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
FPGATrackSimFitConstantBank::m_kaverage
vector2D< float > m_kaverage
Definition: FPGATrackSimFitConstantBank.h:88
FPGATrackSimTrack::getHoughX
float getHoughX() const
Definition: FPGATrackSimTrack.h:35
FPGATrackSimFitConstantBank::m_isIdealCoordFit
bool m_isIdealCoordFit
Definition: FPGATrackSimFitConstantBank.h:75
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
WriteCalibToCool.coef
coef
Definition: WriteCalibToCool.py:582
SiliconTech::pixel
@ pixel
FPGATrackSimHit::getHitType
HitType getHitType() const
Definition: FPGATrackSimHit.h:57
fitman.k
k
Definition: fitman.py:528
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37