ATLAS Offline Software
GNN_DataStorage.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 #include "GNN_DataStorage.h"
10 
11 #include<cmath>
12 #include<cstring>
13 #include<algorithm>
14 
16  m_in.clear();
17  m_vn.clear();
18  m_params.clear();
19 }
20 
22  m_in.clear();
23  m_vn.clear();
24  m_params.clear();
25 }
26 
28  std::sort(m_vn.begin(), m_vn.end(), TrigFTF_GNN_EtaBin::CompareByPhi());
29 }
30 
32 
33  m_params.resize(m_vn.size());
34  m_in.resize(m_vn.size());
35 
36  for(unsigned int nIdx=0;nIdx<m_vn.size();nIdx++) {
37  m_in[nIdx].reserve(50);//reasonably high number of incoming edges per node
38  m_params[nIdx][0] = -100.0;//default cut on cot(theta)
39  m_params[nIdx][1] = 100.0; //default cut on cot(theta)
40  m_params[nIdx][2] = m_vn[nIdx]->phi();
41  m_params[nIdx][3] = m_vn[nIdx]->r();
42  m_params[nIdx][4] = m_vn[nIdx]->z();
43  }
44 }
45 
47 
48  for(unsigned int nIdx=0;nIdx<m_vn.size();nIdx++) {
49 
50  float phi = m_params[nIdx][2];
51  if(phi <= M_PI-dphi) continue;
52  m_vPhiNodes.push_back(std::pair<float, unsigned int>(phi - 2*M_PI, nIdx));
53 
54  }
55 
56  for(unsigned int nIdx=0;nIdx<m_vn.size();nIdx++) {
57  float phi = m_params[nIdx][2];
58  m_vPhiNodes.push_back(std::pair<float, unsigned int>(phi, nIdx));
59  }
60 
61  for(unsigned int nIdx=0;nIdx<m_vn.size();nIdx++) {
62 
63  float phi = m_params[nIdx][2];
64  if(phi >= -M_PI + dphi) break;
65  m_vPhiNodes.push_back(std::pair<float, unsigned int>(phi + 2*M_PI, nIdx));
66  }
67 }
68 
70  m_etaBins.resize(g.num_bins());
71 }
72 
74 
76 
78 
79  if(pL==nullptr) return -1;
80 
81  int binIndex = pL->getEtaBin(sp->z(), sp->r());
82 
83  if(binIndex == -1) {
84  return -2;
85  }
86 
87  bool isStrip = sp->offlineSpacePoint()->clusterList().second != nullptr;
88 
89  if(isStrip) {
90  m_etaBins.at(binIndex).m_vn.push_back(sp);
91  return 0;
92  }
93 
94  bool isBarrel = (pL->m_layer.m_type == 0);
95 
96  if(isBarrel) {
97  m_etaBins.at(binIndex).m_vn.push_back(sp);
98  }
99  else {
100  if (useML) {
101  const Trk::SpacePoint* osp = sp->offlineSpacePoint();
102  const InDet::PixelCluster* pCL = dynamic_cast<const InDet::PixelCluster*>(osp->clusterList().first);
103  float cluster_width = pCL->width().widthPhiRZ().y();
104  if(cluster_width > 0.2) return -3;
105  }
106  m_etaBins.at(binIndex).m_vn.push_back(sp);
107 
108  }
109 
110  return 0;
111 }
112 
114 
115  unsigned int n=0;
116 
117  for(auto& b : m_etaBins) {
118  n += b.m_vn.size();
119  }
120  return n;
121 }
122 
124  for(auto& b : m_etaBins) b.sortByPhi();
125 }
126 
128  for(auto& b : m_etaBins) {
129  b.initializeNodes();
130  }
131 
132  if(!useML) return;
133 
134  unsigned int nL = m_geo.num_layers();
135 
136  for(unsigned int layerIdx=0;layerIdx<nL;layerIdx++) {
137 
139 
140  if(pL->m_layer.m_subdet < 20000) {//skip strips volumes: layers in range [1200X-1400X]
141  continue;
142  }
143 
144  bool isBarrel = (pL->m_layer.m_type == 0);
145 
146  if(!isBarrel) continue;
147 
148  int nBins = pL->m_bins.size();
149 
150  for(int b=0;b<nBins;b++) {//loop over eta-bins in Layer
151 
152  TrigFTF_GNN_EtaBin& B = m_etaBins.at(pL->m_bins.at(b));
153 
154  if(B.empty()) continue;
155 
156  for(unsigned int nIdx=0;nIdx<B.m_vn.size();nIdx++) {
157 
158  const Trk::SpacePoint* osp = B.m_vn[nIdx]->offlineSpacePoint();
159  const InDet::PixelCluster* pCL = dynamic_cast<const InDet::PixelCluster*>(osp->clusterList().first);
160 
161  float cluster_width = pCL->width().widthPhiRZ().y();
162  //adjusting cuts using fitted boundaries of |cot(theta)| vs. cluster z-width distribution
163  float min_tau = 6.7*(cluster_width - 0.2);//linear fit
164  float max_tau = 1.6 + 0.15/(cluster_width + 0.2) + 6.1*(cluster_width - 0.2);//linear fit + correction for short clusters
165 
166  B.m_params[nIdx][0] = min_tau;
167  B.m_params[nIdx][1] = max_tau;
168 
169  }
170  }
171  }
172 }
173 
175  for(auto& b : m_etaBins) b.generatePhiIndexing(dphi);
176 }
177 
TrigFTF_GNN_EtaBin
Definition: GNN_DataStorage.h:21
Trk::SpacePoint::clusterList
const std::pair< const PrepRawData *, const PrepRawData * > & clusterList() const
return the pair of cluster pointers by reference
Definition: Tracking/TrkEvent/TrkSpacePoint/TrkSpacePoint/SpacePoint.h:127
Trk::SpacePoint
Definition: Tracking/TrkEvent/TrkSpacePoint/TrkSpacePoint/SpacePoint.h:35
TrigFTF_GNN_EtaBin::m_in
std::vector< std::vector< unsigned int > > m_in
Definition: GNN_DataStorage.h:45
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
TrigFTF_GNN_EtaBin::m_vn
std::vector< const TrigSiSpacePointBase * > m_vn
Definition: GNN_DataStorage.h:43
PixelCluster.h
TrigFTF_GNN_Geometry::num_layers
unsigned int num_layers() const
Definition: GNN_Geometry.h:59
TrigFTF_GNN_DataStorage::sortByPhi
void sortByPhi()
Definition: GNN_DataStorage.cxx:123
InDet::SiWidth::widthPhiRZ
const Amg::Vector2D & widthPhiRZ() const
Definition: SiWidth.h:121
TrigFTF_GNN_EtaBin::TrigFTF_GNN_EtaBin
TrigFTF_GNN_EtaBin()
Definition: GNN_DataStorage.cxx:15
M_PI
#define M_PI
Definition: ActiveFraction.h:11
TrigFTF_GNN_Layer::m_bins
std::vector< int > m_bins
Definition: GNN_Geometry.h:31
TrigFTF_GNN_EtaBin::~TrigFTF_GNN_EtaBin
~TrigFTF_GNN_EtaBin()
Definition: GNN_DataStorage.cxx:21
TrigSiSpacePointBase::offlineSpacePoint
const Trk::SpacePoint * offlineSpacePoint() const
Definition: TrigSiSpacePointBase.h:81
TrigSiSpacePointBase::z
void z(const double z)
Definition: TrigSiSpacePointBase.h:53
TrigSiSpacePointBase::layer
long layer() const
Definition: TrigSiSpacePointBase.h:68
TrigInDetSiLayer.h
TrigSiSpacePointBase::r
void r(const double r)
Definition: TrigSiSpacePointBase.h:51
TrigFTF_GNN_DataStorage::m_etaBins
std::vector< TrigFTF_GNN_EtaBin > m_etaBins
Definition: GNN_DataStorage.h:70
TrigFTF_GNN_DataStorage::TrigFTF_GNN_DataStorage
TrigFTF_GNN_DataStorage(const TrigFTF_GNN_Geometry &)
Definition: GNN_DataStorage.cxx:69
TrigFTF_GNN_DataStorage::generatePhiIndexing
void generatePhiIndexing(float)
Definition: GNN_DataStorage.cxx:174
TrigFTF_GNN_EtaBin::CompareByPhi
Definition: GNN_DataStorage.h:24
TrigFTF_GNN_EtaBin::m_vPhiNodes
std::vector< std::pair< float, unsigned int > > m_vPhiNodes
Definition: GNN_DataStorage.h:44
TrigFTF_GNN_EtaBin::initializeNodes
void initializeNodes()
Definition: GNN_DataStorage.cxx:31
TrigSiSpacePointBase.h
beamspotman.n
n
Definition: beamspotman.py:731
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
TrigFTF_GNN_Layer::m_layer
const TrigInDetSiLayer & m_layer
Definition: GNN_Geometry.h:30
TrigFTF_GNN_DataStorage::numberOfNodes
unsigned int numberOfNodes() const
Definition: GNN_DataStorage.cxx:113
IDPVM::binIndex
unsigned int binIndex(const T &val, const std::vector< T > &partitions)
general utility function to return bin index given a value and the upper endpoints of each bin
Definition: InDetPhysValMonitoringUtilities.h:43
TrigFTF_GNN_DataStorage::addSpacePoint
int addSpacePoint(const TrigSiSpacePointBase *, bool)
Definition: GNN_DataStorage.cxx:75
TrigInDetSiLayer::m_type
int m_type
Definition: TrigInDetSiLayer.h:11
TrigFTF_GNN_Geometry::getTrigFTF_GNN_LayerByIndex
const TrigFTF_GNN_Layer * getTrigFTF_GNN_LayerByIndex(int) const
Definition: GNN_Geometry.cxx:284
TrigFTF_GNN_DataStorage::initializeNodes
void initializeNodes(bool)
Definition: GNN_DataStorage.cxx:127
dumpTgcDigiJitter.nBins
list nBins
Definition: dumpTgcDigiJitter.py:29
dumpTgcDigiThreshold.isStrip
list isStrip
Definition: dumpTgcDigiThreshold.py:33
TrigFTF_GNN_Layer
Definition: GNN_Geometry.h:16
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
TrigFTF_GNN_EtaBin::generatePhiIndexing
void generatePhiIndexing(float)
Definition: GNN_DataStorage.cxx:46
dqt_zlumi_alleff_HIST.B
B
Definition: dqt_zlumi_alleff_HIST.py:110
TrigFTF_GNN_Geometry
Definition: GNN_Geometry.h:50
InDet::PixelCluster
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:49
InDet::SiCluster::width
const InDet::SiWidth & width() const
return width class reference
python.LArCondContChannels.isBarrel
isBarrel
Definition: LArCondContChannels.py:659
TrigFTF_GNN_DataStorage::m_geo
const TrigFTF_GNN_Geometry & m_geo
Definition: GNN_DataStorage.h:68
TrigFTF_GNN_EtaBin::sortByPhi
void sortByPhi()
Definition: GNN_DataStorage.cxx:27
TrigSiSpacePointBase
Definition: TrigSiSpacePointBase.h:23
GNN_DataStorage.h
TrigFTF_GNN_Layer::getEtaBin
int getEtaBin(float, float) const
Definition: GNN_Geometry.cxx:184
TrigFTF_GNN_DataStorage::~TrigFTF_GNN_DataStorage
~TrigFTF_GNN_DataStorage()
Definition: GNN_DataStorage.cxx:73
TrigInDetSiLayer::m_subdet
int m_subdet
Definition: TrigInDetSiLayer.h:10
TrigFTF_GNN_EtaBin::m_params
std::vector< std::array< float, 5 > > m_params
Definition: GNN_DataStorage.h:46
GNN_Geometry.h