ATLAS Offline Software
Loading...
Searching...
No Matches
T2GeometryTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5/********************************************************************
6
7 NAME: T2GeometryTool.h
8 PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloCommon
9
10 AUTHOR: Denis Oliveira Damazio
11 Carlos Osuna Escamilla
12
13 PURPOSE: This Tools provides the information about whether
14 a cell is part of a cluster for different cluster sizes.
15*******************************************************************/
16
17#ifndef TRIGT2CALO_T2GEOMETRY
18#define TRIGT2CALO_T2GEOMETRY
21#include <iostream>
22#include <math.h>
23
24
25class T2GeometryTool : virtual public IT2GeometryTool , public AthAlgTool{
26public :
28 T2GeometryTool (const std::string & type, const std::string &name,
29 const IInterface* parent);
30
32 virtual StatusCode initialize() override;
33
42 virtual
43 int EtaPhiRange(const int nCaloType, const int nCaloSamp,
44 const double& energyEta, const double& energyPhi) override;
45
52 virtual
53 bool CellInNorCluster( const int nCaloType,const int nCaloSamp,
54 const double& etaCell, const double& phiCell) override;
61 virtual
62 bool CellInNarCluster( const int nCaloType,const int nCaloSamp,
63 const double& etaCell, const double& phiCell) override;
70 virtual
71 bool CellInWidCluster( const int nCaloType,const int nCaloSamp,
72 const double& etaCell, const double& phiCell) override;
73
74 // Not sure these methods will ever be used
77 * @param[in] layer: integer to identify the EM sampling
78 */
79
80 virtual
81 int nStripetaEMnar(const int layer) const override;
82
85
85 */
86 virtual
87 int nStripphiEMnar(const int layer) const override;
88
92 virtual
93 int nStripetaEMwid(const int layer) const override;
94
97 */
98 virtual
99 int nStripphiEMwid(const int layer) const override;
100
104 virtual
105 int nStripetaEMnor(const int layer) const override;
110 virtual
111 int nStripphiEMnor(const int layer) const override;
112
114
116 virtual
117 int nStripetaHADnar(const int layer) const override;
118
122 virtual
123 int nStripphiHADnar(const int layer) const override;
124
128 virtual
129 int nStripetaHADwid(const int layer) const override;
130
134 virtual
135 int nStripphiHADwid(const int layer) const override;
136
140 virtual
141 int nStripetaHADnor(const int layer) const override;
142
146 virtual
147 int nStripphiHADnor(const int layer) const override;
148
149private :
150
151 // This is the internal version that is repeated three
152 // times to prepare the cluster cuts
153 virtual
154 int EtaPhiRangeInt(const int layer, const int& nStripEta,
155 const int& nStripPhi,const double& energyEta,
156 const double& energyPhi,const int index_size) override;
166
168 //int m_nStripetaEM[4]{};// 0.075, 0.075, 0.075, 0.1
169 //int m_nStripphiEM[4]{};// 0.2, 0.2, 0.175, 0.175
170
171 //int m_nStripetaHAD[3]{}; // 0.2, 0.2, 0.2
172 //int m_nStripphiHAD[3]{}; // 0.2, 0.2, 0.2
173
174 int m_nStripetaEMnar[4]{};// 0.075,0.075,0.075,0.1
175 int m_nStripphiEMnar[4]{}; // 0.2, 0.2, 0.125, 0.2
176
177 int m_nStripetaEMwid[4]{};// 0.2, 0.2, 0.175, 0.2
178 int m_nStripphiEMwid[4]{}; // 0.2, 0.2, 0.175, 0.2
179
180 int m_nStripetaEMnor[4]{}; // 0.2, 0.2, 0.2, 0.2
181 int m_nStripphiEMnor[4]{}; // 0.2, 0.2, 0.2, 0.2
182
183 int m_nStripetaHADnar[3]{}; // 0.2, 0.2, 0.2
184 int m_nStripphiHADnar[3]{}; // 0.2, 0.2, 0.2
185
186 int m_nStripetaHADwid[3]{}; // 0.4, 0.4, 0.4
187 int m_nStripphiHADwid[3]{}; // 0.4, 0.4, 0.4
188
189 int m_nStripetaHADnor[3]{}; //0.4, 0.4, 0.4
190 int m_nStripphiHADnor[3]{}; //0.4, 0.4, 0.4
191
193 static const int m_netareg[7];
194 static const double m_etareg[7][8];
195 static const double m_etaGran[7][7];
196 static const int m_nphireg[7];
197 static const double m_phireg[7][4];
198 static const double m_phiGran[7][3];
199
200};
201
202inline int T2GeometryTool::EtaPhiRangeInt(const int layer,
203 const int& nStripEta, const int& nStripPhi,
204 const double& energyEta, const double& energyPhi,const int index_size){
205
206 double aeta = fabs(energyEta);
207 double dgra = m_etaGran[layer][0]; // eta granularity at eta=0
208 int netaregions=m_netareg[layer]; // number of different eta regions
209 double CellEtaMin=0.;
210 double CellEtaMax=0.;
211 double CellPhiMin=0.;
212 double CellPhiMax=0.;
213
214 CellEtaMin = aeta - dgra*nStripEta*0.5;
215 int EtaMinSign = 1;
216 if ( CellEtaMin < 0. ) {
217 EtaMinSign = -1;
218 CellEtaMin = fabs(CellEtaMin ); // need a non-negative value
219 }
220 ATH_MSG_DEBUG( "At start of EtaPhiRange. layer " << layer <<
221 " aeta " << aeta << " dgra " << dgra << " netaregions " << netaregions
222 << " First CellEtaMin " << CellEtaMin );
223
224 // Go by cell edges not centres since boundaries are at edges.
225 // Determine correct cell edges below, if seed is exactly at a cell
226 // edge rounding uncertainties could theoretically result in wrong
227 // number of cells being used, this is not checked.
228
229 // When dealing with a non-integer number of cells (due to including cells
230 // with a different granularity then the central region) round up to the next
231 // integer number of cells if at least 30% of the cell would be in the
232 // desired range (i.e. error on the side of including too much rather
233 // then too little). This is an arbitrary choice and not proven to be ideal.
234
235 int irmin;
236 int irmax;
237 double dgra1;
238
239if( CellEtaMin < m_etareg[layer][netaregions]){
240 for (irmin=0;irmin<netaregions;irmin++) {
241
242 if (CellEtaMin >= m_etareg[layer][irmin] &&
243 CellEtaMin < m_etareg[layer][irmin+1]) {
244
245 dgra1 = m_etaGran[layer][irmin];
246 CellEtaMin = (CellEtaMin-m_etareg[layer][irmin])/dgra1; //number of cells
247 if(CellEtaMin - trunc(CellEtaMin) > 0.7 ) CellEtaMin++; //round down
248 CellEtaMin = dgra1*trunc(CellEtaMin) + m_etareg[layer][irmin];
249
250 CellEtaMin = CellEtaMin*EtaMinSign; // correct for edge that spans 0
251 CellEtaMax = aeta + dgra*nStripEta * 0.5;
252
253
254 for (irmax=irmin;irmax<netaregions;irmax++) {
255 if (CellEtaMax > m_etareg[layer][irmax] &&
256 CellEtaMax <= m_etareg[layer][irmax+1]) {
257 dgra1 = m_etaGran[layer][irmax];
258 CellEtaMax = (CellEtaMax-m_etareg[layer][irmax])/dgra1; //number of cells
259 if (CellEtaMax-trunc(CellEtaMax) >= 0.3) CellEtaMax++; // round up
260 CellEtaMax = dgra1*trunc(CellEtaMax)+m_etareg[layer][irmax];
261 }
262 } // for (irmax=irmin+1;irmax<netaregions;irmax++)
263 } // if (*CellEtaMin >= m_etareg[layer][irmin]...
264 } // for (irmin=0;irmin<=netaregions;irmin++)
265} // if (CellEtaMin < m_etareg[layer][netaregions])
266
267 // set to correct sign
268 double tempeta;
269 if (energyEta < 0) {
270 tempeta=-CellEtaMin;
271 CellEtaMin=-CellEtaMax;
272 CellEtaMax=tempeta;
273
274 }
275
276 // set phi range based only on phi granularity in the eta region
277 // of CellEtaMin, this may not be the optimum method when the eta
278 // range spans a change in phi granularity but the only place that
279 // might be a concern is the crack region of EM samp 1 since the
280 // other phi gran. changes occur at eta > 2.5
281
282 double dgrap= m_phiGran[layer][0]; // phi granularity at eta=0
283 int nphiregions=m_nphireg[layer]; // number of different phi regions
284 CellPhiMin = energyPhi - dgrap*nStripPhi*0.5;
285
286if (fabs(CellEtaMin) < m_phireg[layer][nphiregions]){
287 for (irmin=0;irmin<nphiregions;irmin++) {
288
289 if (fabs(CellEtaMin) >= m_phireg[layer][irmin] &&
290 fabs(CellEtaMin) < m_phireg[layer][irmin+1]) {
291
292 dgra1 = m_phiGran[layer][irmin];
293 CellPhiMin = dgra1*rint(CellPhiMin/dgra1);
294 CellPhiMax = CellPhiMin + dgrap*nStripPhi;
295 } // if *(CellEtaMin >= m_phireg[layer][irmin]...
296 } // for (irmin=0;irmin<=nphiregions;irmin++)
297} // if (fabs(CellEtaMin) < m_phireg[layer][nphiregions]){
298
299 if (CellPhiMax > M_PI) CellPhiMax -= 2*M_PI;
300 if (CellPhiMin <= -M_PI) CellPhiMin += 2*M_PI;
301 if (CellPhiMin > M_PI) CellPhiMin -= 2*M_PI;
302 if (CellPhiMax <= -M_PI) CellPhiMax += 2*M_PI;
303
304 if( index_size == 0)
305 {
306 m_CellEtaNarMax[layer] = CellEtaMax;
307 m_CellEtaNarMin[layer] = CellEtaMin;
308 m_CellPhiNarMax[layer] = CellPhiMax;
309 m_CellPhiNarMin[layer] = CellPhiMin;
310 }
311 else if (index_size == 1)
312 {
313 m_CellEtaWidMax[layer] = CellEtaMax;
314 m_CellEtaWidMin[layer] = CellEtaMin;
315 m_CellPhiWidMax[layer] = CellPhiMax;
316 m_CellPhiWidMin[layer] = CellPhiMin;
317 }
318 else if (index_size == 2)
319 {
320 m_CellEtaNorMax[layer] = CellEtaMax;
321 m_CellEtaNorMin[layer] = CellEtaMin;
322 m_CellPhiNorMax[layer] = CellPhiMax;
323 m_CellPhiNorMin[layer] = CellPhiMin;
324 }
325
326
327 return 0;
328} // End of EtaPhiRangeInt method
329
330inline int T2GeometryTool::EtaPhiRange(const int nCaloType,const int nCaloSamp,
331 const double& energyEta,const double& energyPhi){
332
333 // test for invalid calorimeter type
334 if (nCaloType < 0 || nCaloType > 1) {
335 ATH_MSG_ERROR("Invalid CaloType");
336 return 0;
337 }
338 if (nCaloSamp < 0 || nCaloSamp > 3 || (nCaloSamp == 3 && nCaloType == 1)) {
339 ATH_MSG_ERROR("Invalid CaloSamp");
340 return 0;
341 }
342 int layer = nCaloType*4+nCaloSamp;
343
344 if( nCaloType == 0)
345 {
346
347 EtaPhiRangeInt(layer,m_nStripetaEMnar[nCaloSamp],
348 m_nStripphiEMnar[nCaloSamp],energyEta,energyPhi,0);
349 EtaPhiRangeInt(layer,m_nStripetaEMwid[nCaloSamp],
350 m_nStripphiEMwid[nCaloSamp],energyEta,energyPhi,1);
351 EtaPhiRangeInt(layer,m_nStripetaEMnor[nCaloSamp],
352 m_nStripphiEMnor[nCaloSamp],energyEta,energyPhi,2);
353 }
354 else
355 {
356 EtaPhiRangeInt(layer,m_nStripetaHADnar[nCaloSamp],
357 m_nStripphiHADnar[nCaloSamp],energyEta,energyPhi,0);
358 EtaPhiRangeInt(layer,m_nStripetaHADwid[nCaloSamp],
359 m_nStripphiHADwid[nCaloSamp],energyEta,energyPhi,1);
360 EtaPhiRangeInt(layer,m_nStripetaHADnor[nCaloSamp],
361 m_nStripphiHADnor[nCaloSamp],energyEta,energyPhi,2);
362
363 }
364
365 // log removed, this is not an AlgTool
366 ATH_MSG_DEBUG( "At end of EtaPhiRange. layer " << layer
367 << " CellEtaNorMin : " << m_CellEtaNorMin[layer] << " CellEtaNorMax : "
368 << m_CellEtaNorMax[layer] << " CellPhiNorMin : " << m_CellPhiNorMin[layer]
369 << " CellPhiNorMax : " << m_CellPhiNorMax[layer] << " deta : "
370 << m_CellEtaNorMin[layer] - energyEta << " dphi : "
371 << m_CellPhiNorMin[layer] - energyPhi );
372
373 ATH_MSG_DEBUG( " Nar variables ----> CellEtaNarMin : "
374 << m_CellEtaNarMin[layer]
375 << " CellEtaNarMax : " << m_CellEtaNarMax[layer] << " CellPhiNarMin : "
376 << m_CellPhiNarMin[layer] << " CellPhiNarMax : " << m_CellPhiNarMax[layer]
377 << " detaNar : " << m_CellEtaNarMin[layer] - energyEta << " dphiNar : "
378 << m_CellPhiNarMin[layer] - energyPhi );
379
380 ATH_MSG_DEBUG( " Wid variables ----> CellEtaWidMin : "
381 << m_CellEtaWidMin[layer] << " CellEtaWidMax : " << m_CellEtaWidMax[layer]
382 << " CellPhiWidMin : " << m_CellPhiWidMin[layer] << " CellPhiWidMax : "
383 << m_CellPhiWidMax[layer] << " detaWid : "
384 << m_CellEtaWidMin[layer] - energyEta << " dphiWid : "
385 << m_CellPhiWidMin[layer] - energyPhi );
386
387
388
389
390 return 0;
391} // End of EtaPhiRange
392
393inline bool T2GeometryTool::CellInNorCluster( const int nCaloType,
394 const int nCaloSamp, const double& etaCell, const double& phiCell){
395
396 // test for invalid calorimeter type
397 if (nCaloType < 0 || nCaloType > 1) {
398 ATH_MSG_ERROR("Invalid CaloType");
399 return false;
400 }
401 if (nCaloSamp < 0 || nCaloSamp > 3 || (nCaloSamp == 3 && nCaloType == 1)) {
402 ATH_MSG_ERROR("Invalid CaloSamp");
403 return false;
404 }
405
406 int layer = nCaloType*4+nCaloSamp;
407
408 int IetaPass=0;
409 int IphiPass=0;
410 if ( (etaCell > m_CellEtaNorMin[layer]) &&
411 (etaCell < m_CellEtaNorMax[layer] ) ) IetaPass=1;
412 if ( ((m_CellPhiNorMax[layer] > m_CellPhiNorMin[layer]) &&
413 (phiCell > m_CellPhiNorMin[layer]) &&
414 (phiCell < m_CellPhiNorMax[layer]) ) ||
415 ( (m_CellPhiNorMax[layer] < m_CellPhiNorMin[layer] &&
416 phiCell > 0 && phiCell > m_CellPhiNorMin[layer] &&
417 phiCell -2*M_PI < m_CellPhiNorMax[layer] ) ||
418 ( phiCell < 0 && phiCell < m_CellPhiNorMax[layer] &&
419 phiCell +2*M_PI > m_CellPhiNorMin[layer] ) )
420 ) IphiPass=1;
421
422 if ( IetaPass == 1 && IphiPass == 1 ) return true;
423 else return false;
424} // end of CellInCluster
425
426inline bool T2GeometryTool::CellInNarCluster( const int nCaloType,
427 const int nCaloSamp, const double& etaCell, const double& phiCell){
428 // test for invalid calorimeter type
429 if (nCaloType < 0 || nCaloType > 1) {
430 ATH_MSG_ERROR("Invalid CaloType");
431 return false;
432 }
433 if (nCaloSamp < 0 || nCaloSamp > 3 || (nCaloSamp == 3 && nCaloType == 1)) {
434 ATH_MSG_ERROR("Invalid CaloSamp");
435 return false;
436 }
437 int layer = nCaloType*4+nCaloSamp;
438
439 int IetaPass=0;
440 int IphiPass=0;
441 if ( (etaCell > m_CellEtaNarMin[layer]) &&
442 (etaCell < m_CellEtaNarMax[layer]) ) IetaPass=1;
443 if ( ( m_CellPhiNarMax[layer] > m_CellPhiNarMin[layer] &&
444 phiCell > m_CellPhiNarMin[layer] &&
445 phiCell < m_CellPhiNarMax[layer] ) ||
446 ( ( m_CellPhiNarMax[layer] < m_CellPhiNarMin[layer] &&
447 phiCell > 0 && phiCell > m_CellPhiNarMin[layer] &&
448 phiCell -2*M_PI < m_CellPhiNarMax[layer] ) ||
449 ( phiCell < 0 && phiCell < m_CellPhiNarMax[layer] &&
450 phiCell +2*M_PI > m_CellPhiNarMin[layer] ) )
451 ) IphiPass=1;
452
453 if ( IetaPass == 1 && IphiPass == 1 ) return true;
454 else return false;
455} // end of CellInCluster
456
457inline bool T2GeometryTool::CellInWidCluster( const int nCaloType,
458 const int nCaloSamp, const double& etaCell, const double& phiCell){
459 // test for invalid calorimeter type
460 if (nCaloType < 0 || nCaloType > 1) {
461 ATH_MSG_ERROR("Invalid CaloType");
462 return false;
463 }
464 if (nCaloSamp < 0 || nCaloSamp > 3 || (nCaloSamp == 3 && nCaloType == 1)) {
465 ATH_MSG_ERROR("Invalid CaloSamp");
466 return false;
467 }
468 int layer = nCaloType*4+nCaloSamp;
469
470
471 int IetaPass=0;
472 int IphiPass=0;
473 if ( (etaCell > m_CellEtaWidMin[layer] ) &&
474 (etaCell < m_CellEtaWidMax[layer] ) ) IetaPass=1;
475 if ( ( m_CellPhiWidMax[layer] > m_CellPhiWidMin[layer] &&
476 phiCell > m_CellPhiWidMin[layer] &&
477 phiCell < m_CellPhiWidMax[layer] ) ||
478 ( ( m_CellPhiWidMax[layer] < m_CellPhiWidMin[layer] &&
479 phiCell > 0 && phiCell > m_CellPhiWidMin[layer] &&
480 phiCell -2*M_PI < m_CellPhiWidMax[layer] ) ||
481 ( phiCell < 0 && phiCell < m_CellPhiWidMax[layer] &&
482 phiCell +2*M_PI > m_CellPhiWidMin[layer] ) )
483 ) IphiPass=1;
484
485 if ( IetaPass == 1 && IphiPass == 1 ) return true;
486 else return false;
487} // end of CellInWidCluster
488
489
490inline int T2GeometryTool::nStripetaEMnar(const int layer) const
491 { return m_nStripetaEMnar[layer]; }
492inline int T2GeometryTool::nStripphiEMnar(const int layer) const
493 { return m_nStripphiEMnar[layer]; }
494
495inline int T2GeometryTool::nStripetaEMwid(const int layer) const
496 { return m_nStripetaEMwid[layer]; }
497inline int T2GeometryTool::nStripphiEMwid(const int layer) const
498 { return m_nStripphiEMwid[layer]; }
499
500inline int T2GeometryTool::nStripetaEMnor(const int layer) const
501 { return m_nStripetaEMnor[layer]; }
502inline int T2GeometryTool::nStripphiEMnor(const int layer) const
503 { return m_nStripphiEMnor[layer]; }
504
505inline int T2GeometryTool::nStripetaHADnar(const int layer) const
506 { return m_nStripetaHADnar[layer]; }
507inline int T2GeometryTool::nStripphiHADnar(const int layer) const
508 { return m_nStripphiHADnar[layer]; }
509
510inline int T2GeometryTool::nStripetaHADwid(const int layer) const
511 { return m_nStripetaHADwid[layer]; }
512inline int T2GeometryTool::nStripphiHADwid(const int layer) const
513 { return m_nStripphiHADwid[layer]; }
514
515inline int T2GeometryTool::nStripetaHADnor(const int layer) const
516 { return m_nStripetaHADnor[layer]; }
517inline int T2GeometryTool::nStripphiHADnor(const int layer) const
518 { return m_nStripphiHADnor[layer]; }
519
520#endif
#define M_PI
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
double m_CellPhiNarMax[7]
virtual int nStripphiEMwid(const int layer) const override
Get number of cells in phi for Wide Sized Cluster in EM calorimeter.
virtual int nStripphiEMnar(const int layer) const override
Get number of cells in phi for Narrow Sized Cluster in EM calorimeter.
double m_CellPhiNorMin[7]
virtual int nStripetaEMnar(const int layer) const override
Get number of cells in eta for Narrow Sized Cluster in EM calorimeter.
virtual StatusCode initialize() override
Initialize method.
static const int m_nphireg[7]
double m_CellPhiNorMax[7]
virtual int nStripphiHADnor(const int layer) const override
Get number of cells in phi for Normal Sized Cluster in HAD calorimeter.
double m_CellEtaNorMax[7]
virtual int nStripetaEMwid(const int layer) const override
Get number of cells in eta for Wide Sized Cluster in EM calorimeter.
virtual int EtaPhiRangeInt(const int layer, const int &nStripEta, const int &nStripPhi, const double &energyEta, const double &energyPhi, const int index_size) override
static const int m_netareg[7]
Granularity and eta ranges relevant for above energy sums.
double m_CellPhiWidMax[7]
virtual int nStripetaEMnor(const int layer) const override
Get number of cells in eta for Normal Sized Cluster in EM calorimeter.
virtual int nStripphiEMnor(const int layer) const override
Get number of cells in phi for Normal Sized Cluster in EM calorimeter.
double m_CellPhiWidMin[7]
T2GeometryTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
virtual bool CellInWidCluster(const int nCaloType, const int nCaloSamp, const double &etaCell, const double &phiCell) override
Finds whether a cell is in a Wide Sized Cluster.
static const double m_etareg[7][8]
virtual bool CellInNorCluster(const int nCaloType, const int nCaloSamp, const double &etaCell, const double &phiCell) override
Finds whether a cell is in a Normal Sized Cluster.
static const double m_phireg[7][4]
virtual int nStripphiHADnar(const int layer) const override
Get number of cells in phi for Narrow Sized Cluster in HAD calorimeter.
virtual int nStripetaHADwid(const int layer) const override
Get number of cells in eta for Wide Sized Cluster in HADcalorimeter.
virtual bool CellInNarCluster(const int nCaloType, const int nCaloSamp, const double &etaCell, const double &phiCell) override
Finds whether a cell is in a Narrow Sized Cluster.
double m_CellEtaWidMin[7]
Wider cluster variables.
double m_CellPhiNarMin[7]
static const double m_etaGran[7][7]
virtual int nStripetaHADnor(const int layer) const override
Get number of cells in eta for Normal Sized Cluster in HAD calorimeter.
double m_CellEtaNarMin[7]
Narrow cluster variables.
int m_nStripetaEMnar[4]
Reference changed to vectors.
double m_CellEtaWidMax[7]
static const double m_phiGran[7][3]
double m_CellEtaNorMin[7]
Normal cluster variables.
double m_CellEtaNarMax[7]
virtual int nStripphiHADwid(const int layer) const override
Get number of cells in phi for Wide Sized Cluster in HAD calorimeter.
virtual int EtaPhiRange(const int nCaloType, const int nCaloSamp, const double &energyEta, const double &energyPhi) override
This prepares internal tables based on the cluster position.
virtual int nStripetaHADnar(const int layer) const override
Get number of cells in eta for Narrow Sized Cluster in HAD calorimeter.
#define private