ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
AFPMon::AFPFastReco Class Reference

#include <AFPFastReco.h>

Collaboration diagram for AFPMon::AFPFastReco:

Public Member Functions

 AFPFastReco (const xAOD::AFPSiHitContainer *hits)
 Constructor. Sets input hit container. More...
 
void reco ()
 Performs fast reconstruction of clusters and tracks. More...
 
const std::vector< AFPCluster > & clusters () const
 Returns vector of clusters. More...
 
const std::vector< AFPTrack > & tracks () const
 Returns vector of tracks. More...
 

Private Member Functions

void recoClusters ()
 Performs fast cluster reconstruction. More...
 
void recoTracks ()
 Performs fast track reconstruction. More...
 
std::pair< double, double > linReg (const std::vector< std::pair< double, double >> &YX) const
 Returns parameters of fitted line. More...
 
template<class T >
std::vector< T > findAround (T init, std::list< T > &toJoin) const
 Finds hits/clusters around given init element. More...
 
bool areNeighbours (const xAOD::AFPSiHit *lhs, const xAOD::AFPSiHit *rhs) const
 Checks if given hits are neighbours. More...
 
bool areNeighbours (const AFPCluster &lhs, const AFPCluster &rhs) const
 Checks if given clusters are neighbours. More...
 

Private Attributes

const xAOD::AFPSiHitContainerm_hitContainer
 Pointer to hit container. More...
 
std::vector< AFPClusterm_clusters
 Vector of clusters. More...
 
std::vector< AFPTrackm_tracks
 Vector of tracks. More...
 

Static Private Attributes

static constexpr int s_afpStations = 4
 Number of AFP stations. More...
 
static constexpr int s_afpLayers = 4
 Number of layers in each station. More...
 
static constexpr int s_trackSize = 3
 Minimum number of clusters in track. More...
 
static constexpr float s_clusterDistance = 0.4
 Maximum distance between cluster. More...
 

Detailed Description

Definition at line 50 of file AFPFastReco.h.

Constructor & Destructor Documentation

◆ AFPFastReco()

AFPMon::AFPFastReco::AFPFastReco ( const xAOD::AFPSiHitContainer hits)
inline

Constructor. Sets input hit container.

Definition at line 54 of file AFPFastReco.h.

54 : m_hitContainer {hits} {}

Member Function Documentation

◆ areNeighbours() [1/2]

bool AFPMon::AFPFastReco::areNeighbours ( const AFPCluster lhs,
const AFPCluster rhs 
) const
private

Checks if given clusters are neighbours.

Definition at line 139 of file AFPFastReco.cxx.

140 {
141  if (lhs.station != rhs.station) return false;
142 
143  const float dx = lhs.x - rhs.x;
144  const float dy = lhs.y - rhs.y;
145  return dx * dx + dy * dy <= s_clusterDistance;
146 }

◆ areNeighbours() [2/2]

bool AFPMon::AFPFastReco::areNeighbours ( const xAOD::AFPSiHit lhs,
const xAOD::AFPSiHit rhs 
) const
private

Checks if given hits are neighbours.

Definition at line 129 of file AFPFastReco.cxx.

130 {
131  if (lhs->stationID() != rhs->stationID()) return false;
132  if (lhs->pixelLayerID() != rhs->pixelLayerID()) return false;
133  if (lhs->pixelColIDChip() != rhs->pixelColIDChip()) return false;
134  if (abs(lhs->pixelRowIDChip() - rhs->pixelRowIDChip()) != 1) return false;
135 
136  return true;
137 }

◆ clusters()

const std::vector<AFPCluster>& AFPMon::AFPFastReco::clusters ( ) const
inline

Returns vector of clusters.

Definition at line 60 of file AFPFastReco.h.

60 { return m_clusters; }

◆ findAround()

template<class T >
std::vector< T > AFPMon::AFPFastReco::findAround ( init,
std::list< T > &  toJoin 
) const
private

Finds hits/clusters around given init element.

Definition at line 107 of file AFPFastReco.h.

108 {
109  std::vector<T> element;
110  element.push_back(init);
111 
112  std::vector<T> newNeighbours;
113  do
114  {
115  newNeighbours.clear();
116  for (auto& b : toJoin)
117  {
118  bool isNew = false;
119  for (auto& a : element)
120  if (areNeighbours(a, b))
121  {
122  isNew = true;
123  break;
124  }
125 
126  if (isNew)
127  {
128  newNeighbours.push_back(b);
129  element.push_back(b);
130  }
131  }
132 
133  for (auto& t : newNeighbours)
134  toJoin.remove(t);
135 
136  } while (newNeighbours.size() > 0);
137 
138  return element;
139  }

◆ linReg()

std::pair< double, double > AFPMon::AFPFastReco::linReg ( const std::vector< std::pair< double, double >> &  YX) const
private

Returns parameters of fitted line.

Definition at line 99 of file AFPFastReco.cxx.

100 {
101  double meanx = 0;
102  double meany = 0;
103  for (const auto& yx : YX)
104  {
105  meany += yx.first;
106  meanx += yx.second;
107  }
108 
109  meanx /= YX.size();
110  meany /= YX.size();
111 
112  double numerator = 0;
113  double denumerator = 0;
114  for (const auto& yx : YX)
115  {
116  const double dy = yx.first - meany;
117  const double dx = yx.second - meanx;
118  numerator += dx * dy;
119  denumerator += dx * dx;
120  }
121 
122  if(denumerator==0.0) denumerator=1e-6;
123  const double slope = numerator / denumerator;
124  const double position = meany - slope * meanx;
125 
126  return {position, slope};
127 }

◆ reco()

void AFPMon::AFPFastReco::reco ( )

Performs fast reconstruction of clusters and tracks.

Definition at line 16 of file AFPFastReco.cxx.

17 {
18  recoClusters();
19  recoTracks();
20 }

◆ recoClusters()

void AFPMon::AFPFastReco::recoClusters ( )
private

Performs fast cluster reconstruction.

Definition at line 22 of file AFPFastReco.cxx.

23 {
24  constexpr float dx = 0.25; // [mm]
25  constexpr float dy = 0.05; // [mm]
26  constexpr float dz = 9.00; // [mm]
27  constexpr float tilt = 14. / 180. * M_PI;
28 
30 
31  while (!toCluster.empty())
32  {
33  const auto *init = *(toCluster.begin());
34  toCluster.pop_front();
35  auto clusteredHits = findAround(init, toCluster);
36 
37  float sumX = 0;
38  float sumY = 0;
39  float sumCharge = 0;
40  int sumToT_temp = 0;
41  for (const xAOD::AFPSiHit* h : clusteredHits)
42  {
43  const float charge = h->depositedCharge();
44  const float pixX = dx * h->pixelColIDChip();
45  const float pixY = dy * h->pixelRowIDChip();
46  sumX += charge * pixX;
47  sumY += charge * pixY;
48  sumCharge += charge;
49  sumToT_temp += h->timeOverThreshold();
50  }
51 
52  const float xPlane = sumX / sumCharge;
53  const float yPlane = sumY / sumCharge;
54 
55  const int stationID = init->stationID();
56  const int layerID = init->pixelLayerID();
57 
58  const float x = xPlane;
59  const float y = yPlane * std::cos(tilt);
60  const float z = yPlane * std::sin(tilt) + dz * layerID;
61 
62  m_clusters.emplace_back(x, y, z, stationID, layerID, sumToT_temp);
63  }
64 }

◆ recoTracks()

void AFPMon::AFPFastReco::recoTracks ( )
private

Performs fast track reconstruction.

Definition at line 66 of file AFPFastReco.cxx.

67 {
68  std::list toTrack(m_clusters.begin(), m_clusters.end());
69 
70  while (!toTrack.empty())
71  {
72  auto init = *(toTrack.begin());
73  toTrack.pop_front();
74  auto trackCandidate = findAround(init, toTrack);
75 
76  if (trackCandidate.size() < s_trackSize) continue;
77 
78  std::array<int, 4> clusters {};
79 
80  std::vector<std::pair<double, double>> XZ;
81  std::vector<std::pair<double, double>> YZ;
82 
83  for (const auto& cluster : trackCandidate)
84  {
85  clusters[cluster.layer]++;
86 
87  XZ.emplace_back(cluster.x, cluster.z);
88  YZ.emplace_back(cluster.y, cluster.z);
89  }
90 
91  const auto [x, xSlope] = linReg(XZ);
92  const auto [y, ySlope] = linReg(YZ);
93  const int station = trackCandidate[0].station;
94 
95  m_tracks.emplace_back(x, y, station, clusters);
96  }
97 }

◆ tracks()

const std::vector<AFPTrack>& AFPMon::AFPFastReco::tracks ( ) const
inline

Returns vector of tracks.

Definition at line 63 of file AFPFastReco.h.

63 { return m_tracks; }

Member Data Documentation

◆ m_clusters

std::vector<AFPCluster> AFPMon::AFPFastReco::m_clusters
private

Vector of clusters.

Definition at line 89 of file AFPFastReco.h.

◆ m_hitContainer

const xAOD::AFPSiHitContainer* AFPMon::AFPFastReco::m_hitContainer
private

Pointer to hit container.

Definition at line 86 of file AFPFastReco.h.

◆ m_tracks

std::vector<AFPTrack> AFPMon::AFPFastReco::m_tracks
private

Vector of tracks.

Definition at line 92 of file AFPFastReco.h.

◆ s_afpLayers

constexpr int AFPMon::AFPFastReco::s_afpLayers = 4
staticconstexprprivate

Number of layers in each station.

Definition at line 98 of file AFPFastReco.h.

◆ s_afpStations

constexpr int AFPMon::AFPFastReco::s_afpStations = 4
staticconstexprprivate

Number of AFP stations.

Definition at line 95 of file AFPFastReco.h.

◆ s_clusterDistance

constexpr float AFPMon::AFPFastReco::s_clusterDistance = 0.4
staticconstexprprivate

Maximum distance between cluster.

Definition at line 104 of file AFPFastReco.h.

◆ s_trackSize

constexpr int AFPMon::AFPFastReco::s_trackSize = 3
staticconstexprprivate

Minimum number of clusters in track.

Definition at line 101 of file AFPFastReco.h.


The documentation for this class was generated from the following files:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
AFPMon::AFPFastReco::findAround
std::vector< T > findAround(T init, std::list< T > &toJoin) const
Finds hits/clusters around given init element.
Definition: AFPFastReco.h:107
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
AFPMon::AFPFastReco::s_trackSize
static constexpr int s_trackSize
Minimum number of clusters in track.
Definition: AFPFastReco.h:101
AFPMon::AFPFastReco::linReg
std::pair< double, double > linReg(const std::vector< std::pair< double, double >> &YX) const
Returns parameters of fitted line.
Definition: AFPFastReco.cxx:99
xAOD::AFPSiHit_v2::pixelLayerID
int pixelLayerID() const
Index of the layer of pixels, i.e.
xAOD::AFPSiHit_v2
Class representing a hit in silicon detector.
Definition: AFPSiHit_v2.h:30
M_PI
#define M_PI
Definition: ActiveFraction.h:11
AFPMon::AFPFastReco::s_clusterDistance
static constexpr float s_clusterDistance
Maximum distance between cluster.
Definition: AFPFastReco.h:104
AFPMon::AFPFastReco::clusters
const std::vector< AFPCluster > & clusters() const
Returns vector of clusters.
Definition: AFPFastReco.h:60
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
AFPMon::AFPFastReco::areNeighbours
bool areNeighbours(const xAOD::AFPSiHit *lhs, const xAOD::AFPSiHit *rhs) const
Checks if given hits are neighbours.
Definition: AFPFastReco.cxx:129
x
#define x
AFPMon::AFPFastReco::m_tracks
std::vector< AFPTrack > m_tracks
Vector of tracks.
Definition: AFPFastReco.h:92
xAOD::AFPSiHit_v2::pixelColIDChip
int pixelColIDChip() const
Index of the pixel column in chip coordinate system.
AFPMon::AFPFastReco::recoClusters
void recoClusters()
Performs fast cluster reconstruction.
Definition: AFPFastReco.cxx:22
z
#define z
Muon::nsw::STGTPSegments::moduleIDBits::stationID
constexpr uint8_t stationID
Large or Small wedge.
Definition: NSWSTGTPDecodeBitmaps.h:152
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
AFPMon::AFPFastReco::m_hitContainer
const xAOD::AFPSiHitContainer * m_hitContainer
Pointer to hit container.
Definition: AFPFastReco.h:86
AFPMon::AFPFastReco::recoTracks
void recoTracks()
Performs fast track reconstruction.
Definition: AFPFastReco.cxx:66
AFPMon::AFPFastReco::m_clusters
std::vector< AFPCluster > m_clusters
Vector of clusters.
Definition: AFPFastReco.h:89
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
charge
double charge(const T &p)
Definition: AtlasPID.h:538
python.PyKernel.init
def init(v_theApp, v_rootStream=None)
Definition: PyKernel.py:45
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
makeTRTBarrelCans.dy
tuple dy
Definition: makeTRTBarrelCans.py:21
xAOD::AFPSiHit_v2::pixelRowIDChip
int pixelRowIDChip() const
Index of the pixel row in chip coordinate system.
a
TList * a
Definition: liststreamerinfos.cxx:10
y
#define y
h
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
xAOD::AFPSiHit_v2::stationID
int stationID() const
Index of the station with pixel hit.
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.