ATLAS Offline Software
Functions
FPGATrackSimTrack.cxx File Reference
#include "FPGATrackSimObjects/FPGATrackSimTrack.h"
#include "FPGATrackSimObjects/FPGATrackSimConstants.h"
#include <iostream>
#include <iomanip>
#include <cmath>
Include dependency graph for FPGATrackSimTrack.cxx:

Go to the source code of this file.

Functions

 ClassImp (FPGATrackSimTrack) std
 
ostream & operator<< (ostream &out, const FPGATrackSimTrack &track)
 

Function Documentation

◆ ClassImp()

ClassImp ( FPGATrackSimTrack  )

Definition at line 14 of file FPGATrackSimTrack.cxx.

19 {
20  std::vector<float> coords;
21  if (ilayer >= m_hits.size())
22  throw std::range_error("FPGATrackSimTrack::getCoords() out of bounds");
23 
24  if (m_trackCorrType == TrackCorrType::None)
25  {
26  coords.push_back(m_hits[ilayer].getEtaCoord());
27  coords.push_back(m_hits[ilayer].getPhiCoord());
28  }
29  else
30  {
31  coords = computeIdealCoords(ilayer);
32  }
33 
34  return coords;
35 }
36 
37 std::vector<float> FPGATrackSimTrack::computeIdealCoords(unsigned ilayer) const
38 {
39  std::vector<float> coords;
40 
41  // rho = 0.33 m * (pT / GeV) / (B/T)
42  // B = 2 T so
43  // rho = 0.33 m * (pT / GeV) / (2)
44  // and then 2*rho = 0.33 m * (pT / GeV)
45  // but distances for us are in mm, so 2*rho = 330 * (pT / GeV)
46  // and 1/(2*rho) = (1 / (pT in GeV)) / 330
47 
48  double target_r = m_idealRadii[ilayer];
49  if (m_hits[ilayer].getHitType() == HitType::spacepoint) {
50  unsigned other_layer = (m_hits[ilayer].getSide() == 0) ? ilayer + 1 : ilayer - 1;
51  target_r = (target_r + m_idealRadii[other_layer]) / 2.;
52  }
53 
54  double hitGPhi = m_hits[ilayer].getGPhi();
55  double houghRho = 0.0003 * getHoughY(); //A*q/pT
56 
57  if (m_doDeltaGPhis) {
58  double expectedGPhi = getHoughX();
59 
60  hitGPhi += (m_hits[ilayer].getR() - target_r) * houghRho; //first order
61  expectedGPhi -= target_r * houghRho; //first order
62 
64  hitGPhi += (std::pow(m_hits[ilayer].getR() * houghRho, 3.0) / 6.0); //higher order
65  expectedGPhi -= (std::pow(target_r * houghRho, 3.0) / 6.0); //higher order
66  }
67 
68  double hitZ = m_hits[ilayer].getZ();
69  if (m_hits[ilayer].getR() > 1e-8) {
70  hitZ -= m_hits[ilayer].getGCotTheta() * (m_hits[ilayer].getR() - target_r); //first order
72  hitZ -= (m_hits[ilayer].getGCotTheta() * std::pow(m_hits[ilayer].getR(), 3.0) * houghRho * houghRho) / 6.0; //higher order
73  }
74 
75  coords.push_back(hitZ);
76  coords.push_back(hitGPhi - expectedGPhi);
77  }
78  else {
79  double houghRho = 0.0003 * getHoughY(); //A*q/pT
80 
81  hitGPhi += (m_hits[ilayer].getR() - target_r) * houghRho; //first order
83  hitGPhi += (pow(m_hits[ilayer].getR() * houghRho, 3.0) / 6.0); //higher order
84  }
85 
86  double z = m_hits[ilayer].getZ();
87  if (m_hits[ilayer].getR() > 1e-8) {
88  z -= m_hits[ilayer].getGCotTheta() * (m_hits[ilayer].getR() - target_r); //first order
90  z -= m_hits[ilayer].getGCotTheta() * (std::pow(m_hits[ilayer].getR(), 3.0) * houghRho * houghRho) / 6.0; //higher order
91  }
92 
93  coords.push_back(z);
94  coords.push_back(hitGPhi);
95  }
96 
97  return coords;
98 }
99 
100 float FPGATrackSimTrack::getEtaCoord(int ilayer) const {
101  auto coords = getCoords(ilayer);
102  if (coords.size() > 0) {
103  return coords.at(0);
104  }
105  else {
106  throw std::range_error("FPGATrackSimTrack::getCoord(layer,coord) out of bounds");
107  }
108 }
109 
110 float FPGATrackSimTrack::getPhiCoord(int ilayer) const {
111  auto coords = getCoords(ilayer);
112 
113  // If this is a spacepoint, and if this is the "outer" hit on a strip module
114  // (side = 1) then we actually return the z/eta coord.
115  // Since spacepoints are duplicated, this avoids using the same phi coord
116  // twice and alsp avoids having to teach the code that strip spacepoints are
117  // "2D" hits despite being in the strips, which everything assumes is 1D.
118  // This makes it easy to mix and match spacepoints with strip hits that aren't
119  // spacepoints (since the number of strip layers is held fixed).
120  unsigned target_coord = 1;
121  if (m_hits[ilayer].getHitType() == HitType::spacepoint && (m_hits[ilayer].getPhysLayer() % 2) == 1) {
122  target_coord = 0;
123  }
124 
125  if (coords.size() > target_coord) {
126  return coords.at(target_coord);
127  }
128  else {
129  throw std::range_error("FPGATrackSimTrack::getCoord(layer,coord) out of bounds");
130  }
131 }
132 
133 int FPGATrackSimTrack::getNCoords() const {
134  int nCoords = 0;
135  for (const auto& hit : m_hits) {
136  nCoords += hit.getDim();
137  }
138  return nCoords;
139 }
140 
141 //set a specific position in m_hits
143 {
144  if (m_hits.size() > i)
145  m_hits[i] = hit;
146  else
147  throw std::range_error("FPGATrackSimTrack::setFPGATrackSimHit() out of bounds");
148 }

◆ operator<<()

ostream& operator<< ( std::ostream &  out,
const FPGATrackSimTrack track 
)

Definition at line 221 of file FPGATrackSimTrack.cxx.

222 {
223 
224  out << "TRACK: ID=" << std::left << setw(8) << track.m_trackID;
225  out << " SECTOR1=" << std::left << setw(8) << track.m_firstSectorID;
226  out << " BANK=" << std::left << setw(8) << track.m_bankID;
227  out << " BARCODE=" << std::left << setw(6) << track.m_barcode;
228  out << " BARCODE_F=" << std::left << setw(9) << track.m_barcode_frac;
229  out << " EVENT=" << std::left << setw(6) << track.m_eventindex;
230  out << " HITMAP=" << std::left << setw(8) << track.getHitMap();
231  out << " TYPE=" << std::left << setw(3) << track.m_typemask;
232  out << " NMISS=" << std::left << setw(3) << track.getNMissing();
233  out << "\n";
234  streamsize oldprec = out.precision();
235  out.precision(4);
236  out << " PHI=" << std::left << setw(10) << track.m_phi;
237  out.setf(ios_base::scientific);
238  out.precision(2);
239  out << " Q/PT=" << std::left << setw(10) << track.m_qoverpt;
240  out.unsetf(ios_base::scientific);
241  out.precision(4);
242  out << " d0=" << std::left << setw(10) << track.m_d0;
243  out << " ETA=" << std::left << setw(10) << track.m_eta;
244  out << " z0=" << std::left << setw(10) << track.m_z0;
245  out << " Chi2=" << std::left << setw(12) << track.m_chi2;
246  out << " OChi2=" << std::left << setw(12) << track.m_origchi2;
247 
248  out << endl;
249  out.precision(oldprec);
250 
251  out << endl;
252 
253  // print the hits
254  int iter = 0;
255  for (const auto& hit : track.m_hits) {
256  out << "Hit " << iter << ": " << hit << "\n";
257  iter++;
258  }
259 
260  return out;
261 }
FPGATrackSimTrack::getPhiCoord
float getPhiCoord(int ilayer) const
FPGATrackSimTrack::m_trackCorrType
TrackCorrType m_trackCorrType
Definition: FPGATrackSimTrack.h:120
FPGATrackSimTrack::computeIdealCoords
std::vector< float > computeIdealCoords(unsigned ilayer) const
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
TrackCorrType::Second
@ Second
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
HitType::spacepoint
@ spacepoint
FPGATrackSimTrack::getNCoords
int getNCoords() const
FPGATrackSimTrack::setFPGATrackSimHit
void setFPGATrackSimHit(unsigned i, const FPGATrackSimHit &hit)
FPGATrackSimTrack::getHoughY
float getHoughY() const
Definition: FPGATrackSimTrack.h:31
FPGATrackSimHit
Definition: FPGATrackSimHit.h:38
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
FPGATrackSimTrack::getEtaCoord
float getEtaCoord(int ilayer) const
FPGATrackSimTrack::getCoords
std::vector< float > getCoords(unsigned ilayer) const
FPGATrackSimTrack::m_idealRadii
std::vector< double > m_idealRadii
Definition: FPGATrackSimTrack.h:162
TrackCorrType::None
@ None
FPGATrackSimTrack::m_hits
std::vector< FPGATrackSimHit > m_hits
Definition: FPGATrackSimTrack.h:147
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
FPGATrackSimTrack::m_doDeltaGPhis
bool m_doDeltaGPhis
Definition: FPGATrackSimTrack.h:122
IDTPM::getR
float getR(const xAOD::TrackParticle &)
Accessor utility function for getting the value of prodR.
Definition: TrackParametersHelper.h:95
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
FPGATrackSimTrack::getHoughX
float getHoughX() const
Definition: FPGATrackSimTrack.h:30