ATLAS Offline Software
GNN_Geometry.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 #include<cmath>
10 #include<cstring>
11 #include<algorithm>
12 
13 TrigFTF_GNN_Layer::TrigFTF_GNN_Layer(const TrigInDetSiLayer& ls, float ew, int bin0) : m_layer(ls), m_etaBinWidth(ew) {
14 
15  if(m_layer.m_type == 0) {//barrel
20  }
21  else {//endcap
26  }
27 
28  float t1 = m_z1/m_r1;
29  float eta1 = -std::log(sqrt(1+t1*t1)-t1);
30 
31 
32  float t2 = m_z2/m_r2;
33  float eta2 = -std::log(sqrt(1+t2*t2)-t2);
34 
35  m_minEta = eta1;
36  m_maxEta = eta2;
37 
38  if(m_maxEta < m_minEta) {
39  m_minEta = eta2;
40  m_maxEta = eta1;
41  }
42 
43  m_maxEta += 1e-6;//increasing them slightly to avoid range_check exceptions
44  m_minEta -= 1e-6;
45 
46  float deltaEta = m_maxEta - m_minEta;
47 
48  int binCounter = bin0;
49 
50  if(deltaEta < m_etaBinWidth) {
51  m_nBins = 1;
52  m_bins.push_back(binCounter++);
54  if(m_layer.m_type == 0) {//barrel
55  m_minRadius.push_back(m_layer.m_refCoord - 2.0);
56  m_maxRadius.push_back(m_layer.m_refCoord + 2.0);
57  m_minBinCoord.push_back(m_layer.m_minBound);
58  m_maxBinCoord.push_back(m_layer.m_maxBound);
59  }
60  else {//endcap
61  m_minRadius.push_back(m_layer.m_minBound - 2.0);
62  m_maxRadius.push_back(m_layer.m_maxBound + 2.0);
63  m_minBinCoord.push_back(m_layer.m_minBound);
64  m_maxBinCoord.push_back(m_layer.m_maxBound);
65  }
66  }
67  else {
68  float nB = static_cast<int>(deltaEta/m_etaBinWidth);
69  m_nBins = nB;
71 
73 
74  if(m_nBins == 1) {
75  m_bins.push_back(binCounter++);
76  if(m_layer.m_type == 0) {//barrel
77  m_minRadius.push_back(m_layer.m_refCoord - 2.0);
78  m_maxRadius.push_back(m_layer.m_refCoord + 2.0);
79  m_minBinCoord.push_back(m_layer.m_minBound);
80  m_maxBinCoord.push_back(m_layer.m_maxBound);
81  }
82  else {//endcap
83  m_minRadius.push_back(m_layer.m_minBound - 2.0);
84  m_maxRadius.push_back(m_layer.m_maxBound + 2.0);
85  m_minBinCoord.push_back(m_layer.m_minBound);
86  m_maxBinCoord.push_back(m_layer.m_maxBound);
87  }
88  }
89  else {
90 
91  float eta = m_minEta+0.5*m_etaBin;
92 
93  for(int i=1;i<=m_nBins;i++) {
94 
95  m_bins.push_back(binCounter++);
96 
97  float e1 = eta - 0.5*m_etaBin;
98  float e2 = eta + 0.5*m_etaBin;
99 
100  if(m_layer.m_type == 0) {//barrel
101  m_minRadius.push_back(m_layer.m_refCoord - 2.0);
102  m_maxRadius.push_back(m_layer.m_refCoord + 2.0);
103  float z1 = m_layer.m_refCoord*std::sinh(e1);
104  m_minBinCoord.push_back(z1);
105  float z2 = m_layer.m_refCoord*std::sinh(e2);
106  m_maxBinCoord.push_back(z2);
107  }
108  else {//endcap
109  float r = m_layer.m_refCoord/std::sinh(e1);
110  m_minBinCoord.push_back(r);
111  m_minRadius.push_back(r - 2.0);
112  r = m_layer.m_refCoord/std::sinh(e2);
113  m_maxBinCoord.push_back(r);
114  m_maxRadius.push_back(r + 2.0);
115 
116  }
117 
118  eta += m_etaBin;
119  }
120  }
121  }
122 }
123 
124 bool TrigFTF_GNN_Layer::verifyBin(const TrigFTF_GNN_Layer* pL, int b1, int b2, float min_z0, float max_z0) const {
125 
126  float z1min = m_minBinCoord.at(b1);
127  float z1max = m_maxBinCoord.at(b1);
128  float r1 = m_layer.m_refCoord;
129 
130  if(m_layer.m_type == 0 && pL->m_layer.m_type == 0) {//barrel -> barrel
131 
132  const float tol = 5.0;
133 
134  float min_b2 = pL->m_minBinCoord.at(b2);
135  float max_b2 = pL->m_maxBinCoord.at(b2);
136 
137  float r2 = pL->m_layer.m_refCoord;
138 
139  float A = r2/(r2-r1);
140  float B = r1/(r2-r1);
141 
142  float z0_min = z1min*A - max_b2*B;
143  float z0_max = z1max*A - min_b2*B;
144 
145  if(z0_max < min_z0-tol || z0_min > max_z0+tol) return false;
146 
147  return true;
148  }
149 
150  if(m_layer.m_type == 0 && pL->m_layer.m_type != 0) {//barrel -> endcap
151 
152  const float tol = 10.0;
153 
154  float z2 = pL->m_layer.m_refCoord;
155  float r2max = pL->m_maxBinCoord.at(b2);
156  float r2min = pL->m_minBinCoord.at(b2);
157 
158  if(r2max <= r1) return false;
159 
160  if(r2min <= r1) {
161  r2min = r1 + 1e-3;
162  }
163 
164  float z0_max = 0.0;
165  float z0_min = 0.0;
166 
167  if(z2 > 0) {
168  z0_max = (z1max*r2max - z2*r1)/(r2max-r1);
169  z0_min = (z1min*r2min - z2*r1)/(r2min-r1);
170  }
171  else {
172  z0_max = (z1max*r2min - z2*r1)/(r2min-r1);
173  z0_min = (z1min*r2max - z2*r1)/(r2max-r1);
174  }
175 
176  if(z0_max < min_z0-tol || z0_min > max_z0+tol) return false;
177  return true;
178  }
179 
180  return true;
181 }
182 
183 
184 int TrigFTF_GNN_Layer::getEtaBin(float zh, float rh) const {
185 
186  if(m_bins.size() == 1) return m_bins.at(0);
187 
188  float t1 = zh/rh;
189  float eta = -std::log(std::sqrt(1+t1*t1)-t1);
190 
191 
192  int idx = static_cast<int>((eta-m_minEta)/m_etaBin);
193 
194 
195  if(idx < 0) idx = 0;
196  if(idx >= static_cast<int>(m_bins.size())) idx = static_cast<int>(m_bins.size())-1;
197 
198  return m_bins.at(idx);//index in the global storage
199 }
200 
202  if(idx >= static_cast<int>(m_minRadius.size())) idx = idx-1;
203  if(idx < 0) idx = 0;
204 
205  return m_minRadius.at(idx);
206 }
207 
209  if(idx >= static_cast<int>(m_maxRadius.size())) idx = idx-1;
210  if(idx < 0) idx = 0;
211 
212  return m_maxRadius.at(idx);
213 }
214 
216  m_bins.clear();
217 }
218 
219 TrigFTF_GNN_Geometry::TrigFTF_GNN_Geometry(const std::vector<TrigInDetSiLayer>& layers, const FASTRACK_CONNECTOR* conn) : m_nEtaBins(0) {
220 
221  const float min_z0 = -168.0;
222  const float max_z0 = 168.0;
223 
224  m_etaBinWidth = conn->m_etaBin;
225 
226  for(const auto& layer : layers) {
228  m_nEtaBins += pL->num_bins();
229  }
230 
231  //calculating bin tables in the connector...
232 
233  for(std::map<int, std::vector<FASTRACK_CONNECTION*> >::const_iterator it = conn->m_connMap.begin();it!=conn->m_connMap.end();++it) {
234 
235  const std::vector<FASTRACK_CONNECTION*>& vConn = (*it).second;
236 
237  for(std::vector<FASTRACK_CONNECTION*>::const_iterator cIt=vConn.begin();cIt!=vConn.end();++cIt) {
238 
239  unsigned int src = (*cIt)->m_src;//n2 : the new connectors
240  unsigned int dst = (*cIt)->m_dst;//n1
241 
244 
245  if (pL1==nullptr) {
246  std::cout << " skipping invalid dst layer " << dst << std::endl;
247  continue;
248  }
249  if (pL2==nullptr) {
250  std::cout << " skipping invalid src layer " << src << std::endl;
251  continue;
252  }
253  int nSrcBins = pL2->m_bins.size();
254  int nDstBins = pL1->m_bins.size();
255 
256  (*cIt)->m_binTable.resize(nSrcBins*nDstBins, 0);
257 
258  for(int b1=0;b1<nDstBins;b1++) {//loop over bins in Layer 1
259  for(int b2=0;b2<nSrcBins;b2++) {//loop over bins in Layer 2
260  if(!pL1->verifyBin(pL2, b1, b2, min_z0, max_z0)) continue;
261  int address = b1 + b2*nDstBins;
262  (*cIt)->m_binTable.at(address) = 1;
263  }
264  }
265  }
266  }
267 }
268 
271  delete (*it);
272  }
273  m_layMap.clear();m_layArray.clear();
274 }
275 
277  std::map<unsigned int, TrigFTF_GNN_Layer*>::const_iterator it = m_layMap.find(key);
278  if(it == m_layMap.end()) {
279  return nullptr;
280  }
281  return (*it).second;
282 }
283 
285  return m_layArray.at(idx);
286 }
287 
288 
289 
291 
292  unsigned int layerKey = l.m_subdet;
293 
294  float ew = m_etaBinWidth;
295 
296  TrigFTF_GNN_Layer* pHL = new TrigFTF_GNN_Layer(l, ew, bin0);
297 
298  m_layMap.insert(std::pair<unsigned int, TrigFTF_GNN_Layer*>(layerKey, pHL));
299  m_layArray.push_back(pHL);
300  return pHL;
301 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TrigFTF_GNN_Layer::m_minBinCoord
std::vector< float > m_minBinCoord
Definition: GNN_Geometry.h:34
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
beamspotman.r
def r
Definition: beamspotman.py:676
TrigFTF_GNN_Layer::m_r2
float m_r2
Definition: GNN_Geometry.h:43
checkCorrelInHIST.conn
conn
Definition: checkCorrelInHIST.py:25
TrigFTF_GNN_Layer::~TrigFTF_GNN_Layer
~TrigFTF_GNN_Layer()
Definition: GNN_Geometry.cxx:215
TrigFTF_GNN_Geometry::TrigFTF_GNN_Geometry
TrigFTF_GNN_Geometry(const std::vector< TrigInDetSiLayer > &, const FASTRACK_CONNECTOR *)
Definition: GNN_Geometry.cxx:219
ParticleGun_SamplingFraction.eta2
eta2
Definition: ParticleGun_SamplingFraction.py:96
egammaEnergyPositionAllSamples::e1
double e1(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 1st sampling
WriteCellNoiseToCool.src
src
Definition: WriteCellNoiseToCool.py:513
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
TrigFTF_GNN_Layer::getMinBinRadius
float getMinBinRadius(int) const
Definition: GNN_Geometry.cxx:201
TrigFTF_GNN_Geometry::getTrigFTF_GNN_LayerByKey
const TrigFTF_GNN_Layer * getTrigFTF_GNN_LayerByKey(unsigned int) const
Definition: GNN_Geometry.cxx:276
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
module_driven_slicing.layers
layers
Definition: module_driven_slicing.py:114
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TrigFTF_GNN_Geometry::m_nEtaBins
int m_nEtaBins
Definition: GNN_Geometry.h:70
TrigFTF_GNN_Geometry::m_layMap
std::map< unsigned int, TrigFTF_GNN_Layer * > m_layMap
Definition: GNN_Geometry.h:67
TrigFTF_GNN_Layer::m_bins
std::vector< int > m_bins
Definition: GNN_Geometry.h:31
TrigFTF_GNN_Geometry::m_etaBinWidth
float m_etaBinWidth
Definition: GNN_Geometry.h:65
xAOD::eta1
setEt setPhi setE277 setWeta2 eta1
Definition: TrigEMCluster_v1.cxx:41
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
TrigFTF_GNN_Layer::m_maxRadius
std::vector< float > m_maxRadius
Definition: GNN_Geometry.h:33
TrigFTF_GNN_Layer::m_z1
float m_z1
Definition: GNN_Geometry.h:43
FASTRACK_CONNECTOR
class FasTrackConnector FASTRACK_CONNECTOR
TrigFTF_GNN_Layer::m_etaBinWidth
float m_etaBinWidth
Definition: GNN_Geometry.h:41
TrigInDetSiLayer.h
A
TrigFTF_GNN_Layer::m_r1
float m_r1
Definition: GNN_Geometry.h:43
P4Helpers::deltaEta
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition: P4Helpers.h:66
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigInDetSiLayer::m_maxBound
float m_maxBound
Definition: TrigInDetSiLayer.h:13
TrigSiSpacePointBase.h
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
TrigFTF_GNN_Layer::m_nBins
int m_nBins
Definition: GNN_Geometry.h:44
TrigFTF_GNN_Layer::m_layer
const TrigInDetSiLayer & m_layer
Definition: GNN_Geometry.h:30
TrigFTF_GNN_Layer::m_z2
float m_z2
Definition: GNN_Geometry.h:43
TrigFTF_GNN_Geometry::~TrigFTF_GNN_Geometry
~TrigFTF_GNN_Geometry()
Definition: GNN_Geometry.cxx:269
TrigFTF_GNN_Geometry::m_layArray
std::vector< TrigFTF_GNN_Layer * > m_layArray
Definition: GNN_Geometry.h:68
TrigInDetSiLayer::m_minBound
float m_minBound
Definition: TrigInDetSiLayer.h:13
TrigFTF_GNN_Layer::m_etaBin
float m_etaBin
Definition: GNN_Geometry.h:45
TrigFTF_GNN_Layer::TrigFTF_GNN_Layer
TrigFTF_GNN_Layer(const TrigInDetSiLayer &, float, int)
Definition: GNN_Geometry.cxx:13
TrigFTF_GNN_Layer::m_minEta
float m_minEta
Definition: GNN_Geometry.h:37
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_Layer
Definition: GNN_Geometry.h:16
dqt_zlumi_alleff_HIST.B
B
Definition: dqt_zlumi_alleff_HIST.py:110
RTTAlgmain.address
address
Definition: RTTAlgmain.py:55
TrigFTF_GNN_Layer::m_maxBinCoord
std::vector< float > m_maxBinCoord
Definition: GNN_Geometry.h:35
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
TrigInDetSiLayer::m_refCoord
float m_refCoord
Definition: TrigInDetSiLayer.h:12
egammaEnergyPositionAllSamples::e2
double e2(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 2nd sampling
TrigFTF_GNN_Layer::num_bins
int num_bins() const
Definition: GNN_Geometry.h:26
TrigFTF_GNN_Layer::verifyBin
bool verifyBin(const TrigFTF_GNN_Layer *, int, int, float, float) const
Definition: GNN_Geometry.cxx:124
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TrigInDetSiLayer
Definition: TrigInDetSiLayer.h:8
TrigFTF_GNN_Geometry::addNewLayer
const TrigFTF_GNN_Layer * addNewLayer(const TrigInDetSiLayer &, int)
Definition: GNN_Geometry.cxx:290
TrigFTF_GNN_Layer::getEtaBin
int getEtaBin(float, float) const
Definition: GNN_Geometry.cxx:184
getReferenceRun.ls
def ls(fpath)
Definition: getReferenceRun.py:29
TrigFTF_GNN_Layer::m_maxEta
float m_maxEta
Definition: GNN_Geometry.h:37
TrigFTF_GNN_Layer::getMaxBinRadius
float getMaxBinRadius(int) const
Definition: GNN_Geometry.cxx:208
TrigFTF_GNN_Layer::m_minRadius
std::vector< float > m_minRadius
Definition: GNN_Geometry.h:32
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
GNN_Geometry.h