ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
ISF
ISF_FastCaloSim
ISF_FastCaloGpu
src
GeoRegion.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include "
ISF_FastCaloGpu/GeoRegion.h
"
5
#include <iostream>
6
7
#define M_PI 3.14159265358979323846
8
#define M_2PI 6.28318530717958647692
9
10
__HOSTDEV__
double
Phi_mpi_pi
(
double
x
) {
11
while
(
x
>=
M_PI
)
x
-=
M_2PI
;
12
while
(
x
< -
M_PI
)
x
+=
M_2PI
;
13
return
x
;
14
}
15
16
__HOSTDEV__
bool
GeoRegion::index_range_adjust
(
int
& ieta,
int
& iphi )
const
{
17
while
( iphi < 0 ) { iphi +=
m_cell_grid_phi
; };
18
while
( iphi >=
m_cell_grid_phi
) { iphi -=
m_cell_grid_phi
; };
19
if
( ieta < 0 ) {
20
ieta = 0;
21
return
false
;
22
}
23
if
( ieta >=
m_cell_grid_eta
) {
24
ieta =
m_cell_grid_eta
- 1;
25
return
false
;
26
}
27
return
true
;
28
}
29
30
__HOSTDEV__
float
GeoRegion::calculate_distance_eta_phi
(
const
long
long
DDE,
float
eta
,
float
phi
,
float
& dist_eta0,
31
float
& dist_phi0 )
const
{
32
33
dist_eta0 = (
eta
-
m_all_cells
[DDE].eta() ) /
m_deta_double
;
34
dist_phi0 = (
Phi_mpi_pi
(
phi
-
m_all_cells
[DDE].
phi
() ) ) /
m_dphi_double
;
35
float
abs_dist_eta0 = abs( dist_eta0 );
36
float
abs_dist_phi0 = abs( dist_phi0 );
37
return
max
( abs_dist_eta0, abs_dist_phi0 ) - 0.5;
38
}
39
40
__HOSTDEV__
long
long
GeoRegion::getDDE
(
float
eta
,
float
phi
,
float
* distance,
int
* steps ) {
41
42
float
dist;
43
long
long
bestDDE = -1;
44
if
( !distance ) distance = &dist;
45
*distance = +10000000;
46
int
intsteps = 0;
47
if
( !steps ) steps = &intsteps;
48
49
float
best_eta_corr =
m_eta_correction
;
50
float
best_phi_corr =
m_phi_correction
;
51
52
float
raw_eta =
eta
+ best_eta_corr;
53
float
raw_phi =
phi
+ best_phi_corr;
54
55
int
ieta =
raw_eta_position_to_index
( raw_eta );
56
int
iphi =
raw_phi_position_to_index
( raw_phi );
57
index_range_adjust
( ieta, iphi );
58
59
long
long
newDDE =
m_cells_g
[ieta *
m_cell_grid_phi
+ iphi];
60
float
bestdist = +10000000;
61
++( *steps );
62
int
nsearch = 0;
63
while
( ( newDDE >= 0 ) && nsearch < 3 ) {
64
float
dist_eta0, dist_phi0;
65
66
*distance =
calculate_distance_eta_phi
( newDDE,
eta
,
phi
, dist_eta0, dist_phi0 );
67
68
bestDDE = newDDE;
69
bestdist = *distance;
70
71
if
( *distance < 0 )
return
newDDE;
72
73
// correct ieta and iphi by the observed difference to the hit cell
74
ieta += round( dist_eta0 );
75
iphi += round( dist_phi0 );
76
index_range_adjust
( ieta, iphi );
77
long
long
oldDDE = newDDE;
78
newDDE =
m_cells_g
[ieta *
m_cell_grid_phi
+ iphi];
79
++( *steps );
80
++nsearch;
81
if
( oldDDE == newDDE )
break
;
82
}
83
float
minieta = ieta + floor(
m_mineta_correction
/
cell_grid_eta
() );
84
float
maxieta = ieta + ceil(
m_maxeta_correction
/
cell_grid_eta
() );
85
float
miniphi = iphi + floor(
m_minphi_correction
/
cell_grid_phi
() );
86
float
maxiphi = iphi + ceil(
m_maxphi_correction
/
cell_grid_phi
() );
87
if
( minieta < 0 ) minieta = 0;
88
if
( maxieta >=
m_cell_grid_eta
) maxieta =
m_cell_grid_eta
- 1;
89
for
(
int
iieta = minieta; iieta <= maxieta; ++iieta ) {
90
for
(
int
iiphi = miniphi; iiphi <= maxiphi; ++iiphi ) {
91
ieta = iieta;
92
iphi = iiphi;
93
index_range_adjust
( ieta, iphi );
94
newDDE =
m_cells_g
[ieta *
m_cell_grid_phi
+ iphi];
95
++( *steps );
96
if
( newDDE >= 0 ) {
97
float
dist_eta0, dist_phi0;
98
*distance =
calculate_distance_eta_phi
( newDDE,
eta
,
phi
, dist_eta0, dist_phi0 );
99
100
if
( *distance < 0 )
return
newDDE;
101
if
( *distance < bestdist ) {
102
bestDDE = newDDE;
103
bestdist = *distance;
104
}
105
}
else
{
106
printf(
"GeoRegin::getDDE, windows search ieta=%d iphi=%d is empty\n"
, ieta, iphi );
107
}
108
}
109
}
110
*distance = bestdist;
111
return
bestDDE;
112
}
M_PI
#define M_PI
Definition
ActiveFraction.h:14
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
M_2PI
#define M_2PI
Definition
CaloGpuGeneral_fnc.cxx:11
Phi_mpi_pi
__HOSTDEV__ double Phi_mpi_pi(double x)
Definition
GeoRegion.cxx:10
GeoRegion.h
Phi_mpi_pi
__HOSTDEV__ double Phi_mpi_pi(double)
Definition
GeoRegion.cxx:10
__HOSTDEV__
#define __HOSTDEV__
Definition
GeoRegion.h:13
x
#define x
max
#define max(a, b)
Definition
cfImp.cxx:41
GeoRegion::m_cell_grid_phi
int m_cell_grid_phi
Definition
GeoRegion.h:109
GeoRegion::m_dphi_double
float m_dphi_double
Definition
GeoRegion.h:114
GeoRegion::raw_phi_position_to_index
__HOSTDEV__ int raw_phi_position_to_index(float phi_raw) const
Definition
GeoRegion.h:92
GeoRegion::index_range_adjust
__HOSTDEV__ bool index_range_adjust(int &ieta, int &iphi) const
Definition
GeoRegion.cxx:16
GeoRegion::m_minphi_correction
float m_minphi_correction
Definition
GeoRegion.h:112
GeoRegion::cell_grid_phi
__HOSTDEV__ int cell_grid_phi() const
Definition
GeoRegion.h:79
GeoRegion::m_mineta_correction
float m_mineta_correction
Definition
GeoRegion.h:112
GeoRegion::calculate_distance_eta_phi
__HOSTDEV__ float calculate_distance_eta_phi(const long long DDE, float eta, float phi, float &dist_eta0, float &dist_phi0) const
Definition
GeoRegion.cxx:30
GeoRegion::m_eta_correction
float m_eta_correction
Definition
GeoRegion.h:113
GeoRegion::cell_grid_eta
__HOSTDEV__ int cell_grid_eta() const
Definition
GeoRegion.h:78
GeoRegion::m_cell_grid_eta
int m_cell_grid_eta
Definition
GeoRegion.h:109
GeoRegion::m_all_cells
CaloDetDescrElement_Gpu * m_all_cells
Definition
GeoRegion.h:105
GeoRegion::m_deta_double
float m_deta_double
Definition
GeoRegion.h:114
GeoRegion::raw_eta_position_to_index
__HOSTDEV__ int raw_eta_position_to_index(float eta_raw) const
Definition
GeoRegion.h:89
GeoRegion::getDDE
__HOSTDEV__ long long getDDE(float eta, float phi, float *distance=0, int *steps=0)
Definition
GeoRegion.cxx:40
GeoRegion::m_maxphi_correction
float m_maxphi_correction
Definition
GeoRegion.h:112
GeoRegion::m_cells_g
long long * m_cells_g
Definition
GeoRegion.h:104
GeoRegion::m_maxeta_correction
float m_maxeta_correction
Definition
GeoRegion.h:112
GeoRegion::m_phi_correction
float m_phi_correction
Definition
GeoRegion.h:113
Generated on
for ATLAS Offline Software by
1.17.0