ATLAS Offline Software
AFPFastReco.h
Go to the documentation of this file.
1 #ifndef AFP_MONITORING_AFPFASTRECO_H
2 #define AFP_MONITORING_AFPFASTRECO_H
3 
4 #include <array>
5 #include <list>
6 #include <utility>
7 #include <vector>
8 
9 #include "xAODForward/AFPSiHit.h"
11 
12 namespace AFPMon {
13 
14 struct AFPCluster
15 {
16  AFPCluster(float x_, float y_, float z_, int s, int l, int sumToT_)
17  : x {x_}, y {y_}, z {z_}, station {s}, layer {l}, sumToT{sumToT_} {}
18 
19  float x;
20  float y;
21  float z;
22  int station;
23  int layer;
24  int sumToT;
25  };
26 
27 inline bool operator==(const AFPCluster& lhs, const AFPCluster& rhs)
28 {
29  if (lhs.x != rhs.x) return false;
30  if (lhs.y != rhs.y) return false;
31  if (lhs.z != rhs.z) return false;
32  if (lhs.station != rhs.station) return false;
33  if (lhs.layer != rhs.layer) return false;
34  if (lhs.sumToT != rhs.sumToT) return false;
35 
36  return true;
37 }
38 
39 struct AFPTrack
40 {
41  AFPTrack(float x_, float y_, int s, std::array<int, 4> a)
42  : x {x_}, y {y_}, station {s}, layerClusters {std::move(a)} {}
43 
44  float x;
45  float y;
46  int station;
47  std::array<int, 4> layerClusters;
48 };
49 
51 {
52  public:
55 
57  void reco();
58 
60  const std::vector<AFPCluster>& clusters() const { return m_clusters; }
61 
63  const std::vector<AFPTrack>& tracks() const { return m_tracks; }
64 
65  private:
67  void recoClusters();
68 
70  void recoTracks();
71 
73  std::pair<double, double> linReg(const std::vector<std::pair<double, double>>& YX) const;
74 
76  template <class T>
77  std::vector<T> findAround(T init, std::list<T>& toJoin) const;
78 
80  bool areNeighbours(const xAOD::AFPSiHit* lhs, const xAOD::AFPSiHit* rhs) const;
81 
83  bool areNeighbours(const AFPCluster& lhs, const AFPCluster& rhs) const;
84 
87 
89  std::vector<AFPCluster> m_clusters;
90 
92  std::vector<AFPTrack> m_tracks;
93 
95  static constexpr int s_afpStations = 4;
96 
98  static constexpr int s_afpLayers = 4;
99 
101  static constexpr int s_trackSize = 3;
102 
104  static constexpr float s_clusterDistance = 0.4;
105  };
106 
107 template <class T> std::vector<T> AFPFastReco::findAround(T init, std::list<T>& toJoin) const
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  }
140 
141 } // namespace AFPMon
142 
143 #endif /* AFP_MONITORING_AFPFASTRECO_H */
144 
AFPMon::AFPCluster::x
float x
Definition: AFPFastReco.h:19
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
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::AFPCluster::y
float y
Definition: AFPFastReco.h:20
AFPMon::AFPFastReco::s_afpStations
static constexpr int s_afpStations
Number of AFP stations.
Definition: AFPFastReco.h:95
AFPMon::AFPTrack::x
float x
Definition: AFPFastReco.h:44
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
AFPMon::AFPTrack
Definition: AFPFastReco.h:40
AFPMon::AFPTrack::AFPTrack
AFPTrack(float x_, float y_, int s, std::array< int, 4 > a)
Definition: AFPFastReco.h:41
AFPMon::AFPCluster::z
float z
Definition: AFPFastReco.h:21
xAOD::AFPSiHit_v2
Class representing a hit in silicon detector.
Definition: AFPSiHit_v2.h:30
AFPMon::AFPFastReco::s_clusterDistance
static constexpr float s_clusterDistance
Maximum distance between cluster.
Definition: AFPFastReco.h:104
AFPMon::AFPTrack::y
float y
Definition: AFPFastReco.h:45
AFPMon::AFPFastReco::clusters
const std::vector< AFPCluster > & clusters() const
Returns vector of clusters.
Definition: AFPFastReco.h:60
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
AFPMon::AFPTrack::station
int station
Definition: AFPFastReco.h:46
AFPMon::operator==
bool operator==(const AFPCluster &lhs, const AFPCluster &rhs)
Definition: AFPFastReco.h:27
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
AFPMon::AFPFastReco::areNeighbours
bool areNeighbours(const xAOD::AFPSiHit *lhs, const xAOD::AFPSiHit *rhs) const
Checks if given hits are neighbours.
Definition: AFPFastReco.cxx:129
AFPMon::AFPCluster::sumToT
int sumToT
Definition: AFPFastReco.h:24
AFPMon::AFPFastReco::m_tracks
std::vector< AFPTrack > m_tracks
Vector of tracks.
Definition: AFPFastReco.h:92
AFPMon::AFPFastReco::recoClusters
void recoClusters()
Performs fast cluster reconstruction.
Definition: AFPFastReco.cxx:22
AFPMon
Definition: AFPFastReco.h:12
AFPMon::AFPCluster::station
int station
Definition: AFPFastReco.h:22
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
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
AFPSiHit.h
AFPMon::AFPFastReco::m_clusters
std::vector< AFPCluster > m_clusters
Vector of clusters.
Definition: AFPFastReco.h:89
AFPMon::AFPFastReco::AFPFastReco
AFPFastReco(const xAOD::AFPSiHitContainer *hits)
Constructor. Sets input hit container.
Definition: AFPFastReco.h:54
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
AFPMon::AFPFastReco::reco
void reco()
Performs fast reconstruction of clusters and tracks.
Definition: AFPFastReco.cxx:16
AFPMon::AFPCluster::AFPCluster
AFPCluster(float x_, float y_, float z_, int s, int l, int sumToT_)
Definition: AFPFastReco.h:16
AFPMon::AFPFastReco::s_afpLayers
static constexpr int s_afpLayers
Number of layers in each station.
Definition: AFPFastReco.h:98
python.PyKernel.init
def init(v_theApp, v_rootStream=None)
Definition: PyKernel.py:45
AFPSiHitContainer.h
AFPMon::AFPCluster::layer
int layer
Definition: AFPFastReco.h:23
a
TList * a
Definition: liststreamerinfos.cxx:10
AFPMon::AFPTrack::layerClusters
std::array< int, 4 > layerClusters
Definition: AFPFastReco.h:47
AFPMon::AFPFastReco::tracks
const std::vector< AFPTrack > & tracks() const
Returns vector of tracks.
Definition: AFPFastReco.h:63
AFPMon::AFPCluster
Definition: AFPFastReco.h:15
AFPMon::AFPFastReco
Definition: AFPFastReco.h:51