ATLAS Offline Software
Functions
CaloGpuGeneral_fnc Namespace Reference

Functions

__DEVICE__ long long getDDE (GeoGpu *geo, int sampling, float eta, float phi)
 
__DEVICE__ int find_index_f (float *array, int size, float value)
 
__DEVICE__ int find_index_uint32 (uint32_t *array, int size, uint32_t value)
 
__DEVICE__ void rnd_to_fct2d (float &valuex, float &valuey, float rnd0, float rnd1, FH2D *hf2d)
 
__DEVICE__ float rnd_to_fct1d (float rnd, uint32_t *contents, float *borders, int nbins, uint32_t s_MaxValue)
 
__DEVICE__ void CenterPositionCalculation_d (Hit &hit, const Chain0_Args args)
 
__DEVICE__ void HistoLateralShapeParametrization_d (Hit &hit, unsigned long t, Chain0_Args args, bool reweight)
 
__DEVICE__ void HitCellMapping_d (Hit &hit, unsigned long, Chain0_Args args)
 
__DEVICE__ void HitCellMappingWiggle_d (Hit &hit, Chain0_Args args, unsigned long t)
 

Function Documentation

◆ CenterPositionCalculation_d()

__DEVICE__ void CaloGpuGeneral_fnc::CenterPositionCalculation_d ( Hit hit,
const Chain0_Args  args 
)

Definition at line 157 of file CaloGpuGeneral_fnc.cxx.

157  {
158 
159  hit.setCenter_r( ( 1. - args.extrapWeight ) * args.extrapol_r_ent + args.extrapWeight * args.extrapol_r_ext );
160  hit.setCenter_z( ( 1. - args.extrapWeight ) * args.extrapol_z_ent + args.extrapWeight * args.extrapol_z_ext );
161  hit.setCenter_eta( ( 1. - args.extrapWeight ) * args.extrapol_eta_ent + args.extrapWeight * args.extrapol_eta_ext );
162  hit.setCenter_phi( ( 1. - args.extrapWeight ) * args.extrapol_phi_ent + args.extrapWeight * args.extrapol_phi_ext );
163  }

◆ find_index_f()

__DEVICE__ int CaloGpuGeneral_fnc::find_index_f ( float *  array,
int  size,
float  value 
)

Definition at line 73 of file CaloGpuGeneral_fnc.cxx.

73  {
74 
75  int low = 0;
76  int high = size - 1;
77  int m_index = ( high - low ) / 2;
78  while ( high != low ) {
79  if ( value >= array[m_index] )
80  low = m_index + 1;
81  else
82  high = m_index;
83  m_index = ( high + low ) / 2;
84  }
85  return m_index;
86  }

◆ find_index_uint32()

__DEVICE__ int CaloGpuGeneral_fnc::find_index_uint32 ( uint32_t *  array,
int  size,
uint32_t  value 
)

Definition at line 90 of file CaloGpuGeneral_fnc.cxx.

90  {
91  // find the first index of element which has vaule > value
92  int low = 0;
93  int high = size - 1;
94  int m_index = ( high - low ) / 2;
95  while ( high != low ) {
96  if ( value > array[m_index] )
97  low = m_index + 1;
98  else if ( value == array[m_index] ) {
99  return m_index + 1;
100  } else
101  high = m_index;
102  m_index = ( high - low ) / 2 + low;
103  }
104  return m_index;
105  }

◆ getDDE()

__DEVICE__ long long CaloGpuGeneral_fnc::getDDE ( GeoGpu geo,
int  sampling,
float  eta,
float  phi 
)

Definition at line 13 of file CaloGpuGeneral_fnc.cxx.

13  {
14 
15  float* distance = 0;
16  int* steps = 0;
17 
18  int MAX_SAMPLING = geo->max_sample;
19  Rg_Sample_Index* SampleIdx = geo->sample_index;
20  GeoRegion* regions_g = geo->regions;
21 
22  if ( sampling < 0 ) return -1;
23  if ( sampling >= MAX_SAMPLING ) return -1;
24 
25  int sample_size = SampleIdx[sampling].size;
26  unsigned int sample_index = SampleIdx[sampling].index;
27 
28  GeoRegion* gr = (GeoRegion*)regions_g;
29  if ( sample_size == 0 ) return -1;
30  float dist;
31  long long bestDDE = -1;
32  if ( !distance ) distance = &dist;
33  *distance = +10000000;
34  int intsteps;
35  int beststeps;
36  if ( steps )
37  beststeps = ( *steps );
38  else
39  beststeps = 0;
40 
41  if ( sampling < 21 ) {
42  for ( int skip_range_check = 0; skip_range_check <= 1; ++skip_range_check ) {
43  for ( unsigned int j = sample_index; j < sample_index + sample_size; ++j ) {
44  if ( !skip_range_check ) {
45  if ( eta < gr[j].mineta() ) continue;
46  if ( eta > gr[j].maxeta() ) continue;
47  }
48  if ( steps )
49  intsteps = ( *steps );
50  else
51  intsteps = 0;
52  float newdist;
53  long long newDDE = gr[j].getDDE( eta, phi, &newdist, &intsteps );
54  if ( newdist < *distance ) {
55  bestDDE = newDDE;
56  *distance = newdist;
57  if ( steps ) beststeps = intsteps;
58  if ( newdist < -0.1 ) break; // stop, we are well within the hit cell
59  }
60  }
61  if ( bestDDE >= 0 ) break;
62  }
63  } else {
64  return -3;
65  }
66  if ( steps ) *steps = beststeps;
67 
68  return bestDDE;
69  }

◆ HistoLateralShapeParametrization_d()

__DEVICE__ void CaloGpuGeneral_fnc::HistoLateralShapeParametrization_d ( Hit hit,
unsigned long  t,
Chain0_Args  args,
bool  reweight 
)

Definition at line 167 of file CaloGpuGeneral_fnc.cxx.

167  {
168 
169  // int pdgId = args.pdgId;
170  float charge = args.charge;
171 
172  // int cs=args.charge;
173  float center_eta = hit.center_eta();
174  float center_phi = hit.center_phi();
175  float center_r = hit.center_r();
176  float center_z = hit.center_z();
177 
178  float alpha, r, rnd1, rnd2;
179  rnd1 = args.rand[t];
180  rnd2 = args.rand[t + args.nhits];
181 
182  if ( args.is_phi_symmetric ) {
183  if ( rnd2 >= 0.5 ) { // Fill negative phi half of shape
184  rnd2 -= 0.5;
185  rnd2 *= 2;
186  rnd_to_fct2d( alpha, r, rnd1, rnd2, args.fh2d );
187  alpha = -alpha;
188  } else { // Fill positive phi half of shape
189  rnd2 *= 2;
190  rnd_to_fct2d( alpha, r, rnd1, rnd2, args.fh2d );
191  }
192  } else {
193  rnd_to_fct2d( alpha, r, rnd1, rnd2, args.fh2d );
194  }
195 
196  float delta_eta_mm = r * cos( alpha );
197  float delta_phi_mm = r * sin( alpha );
198 
199  // Particles with negative eta are expected to have the same shape as those with positive eta after transformation:
200  // delta_eta --> -delta_eta
201  if ( center_eta < 0. ) delta_eta_mm = -delta_eta_mm;
202  // Particle with negative charge are expected to have the same shape as positively charged particles after
203  // transformation: delta_phi --> -delta_phi
204  if ( charge < 0. ) delta_phi_mm = -delta_phi_mm;
205 
206  float dist000 = sqrt( center_r * center_r + center_z * center_z );
207  float eta_jakobi = abs( 2.0 * exp( -center_eta ) / ( 1.0 + exp( -2 * center_eta ) ) );
208 
209  float delta_eta = delta_eta_mm / eta_jakobi / dist000;
210  float delta_phi = delta_phi_mm / center_r;
211 
212  if( reweight ){
213  float* histocontents = ( args.fh1d)->h_contents;
214  float* histoborders = ( args.fh1d)->h_borders;
215  float* histoerrors= ( args.fh1d)->h_errors;
216  int nbins = args.fh1d->nbins ;
217  float delta_r_mm = sqrt( delta_eta_mm * delta_eta_mm + delta_phi_mm * delta_phi_mm );
218  int ibin = find_index_f( histoborders, nbins + 1, delta_r_mm);
219  if( ibin < 1 ) ibin = 1 ;
220  if( ibin > nbins ) ibin = nbins ;
221  float weight = histocontents[ibin];
222  float rms = histoerrors[ibin];
223  if(rms>0){
224  float rnd1 = args.rand[t + 2 * args.nhits -100 ];
225  float rnd2 = args.rand[t + 2 * args.nhits -10 ];
226  float logweight= sqrt( r-2. * log(rnd1) )*cos( M_2PI * rnd2) * rms - 0.5 * rms * rms;
227  weight *= exp( logweight );
228  }
229  hit.E() *= weight;
230  }
231 
232  hit.setEtaPhiZE( center_eta + delta_eta, center_phi + delta_phi, center_z, hit.E() );
233  }

◆ HitCellMapping_d()

__DEVICE__ void CaloGpuGeneral_fnc::HitCellMapping_d ( Hit hit,
unsigned long  ,
Chain0_Args  args 
)

Definition at line 237 of file CaloGpuGeneral_fnc.cxx.

237  {
238 
239  long long cellele = getDDE( args.geo, args.cs, hit.eta(), hit.phi() );
240 
241  if ( cellele < 0 ) printf( "cellele not found %lld \n", cellele );
242 
243  atomicAdd( &args.cells_energy[cellele], hit.E() );
244  }

◆ HitCellMappingWiggle_d()

__DEVICE__ void CaloGpuGeneral_fnc::HitCellMappingWiggle_d ( Hit hit,
Chain0_Args  args,
unsigned long  t 
)

Definition at line 248 of file CaloGpuGeneral_fnc.cxx.

248  {
249 
250  int nhist = ( *( args.fhs ) ).nhist;
251  float* bin_low_edge = ( *( args.fhs ) ).low_edge;
252 
253  float eta = fabs( hit.eta() );
254  if ( eta < bin_low_edge[0] || eta > bin_low_edge[nhist] ) { HitCellMapping_d( hit, t, args ); }
255 
256  int bin = nhist;
257  for ( int i = 0; i < nhist + 1; ++i ) {
258  if ( bin_low_edge[i] > eta ) {
259  bin = i;
260  break;
261  }
262  }
263 
264  bin -= 1;
265 
266  unsigned int mxsz = args.fhs->mxsz;
267  uint32_t* contents = &( args.fhs->d_contents1D[bin * mxsz] );
268  float* borders = &( args.fhs->d_borders1D[bin * mxsz] );
269  int h_size = ( *( args.fhs ) ).h_szs[bin];
270  uint32_t s_MaxValue = ( *( args.fhs ) ).s_MaxValue;
271 
272  float rnd = args.rand[t + 2 * args.nhits];
273 
274  float wiggle = rnd_to_fct1d( rnd, contents, borders, h_size, s_MaxValue );
275 
276  float hit_phi_shifted = hit.phi() + wiggle;
277  hit.phi() = Phi_mpi_pi( hit_phi_shifted );
278 
279  HitCellMapping_d( hit, t, args );
280  }

◆ rnd_to_fct1d()

__DEVICE__ float CaloGpuGeneral_fnc::rnd_to_fct1d ( float  rnd,
uint32_t *  contents,
float *  borders,
int  nbins,
uint32_t  s_MaxValue 
)

Definition at line 136 of file CaloGpuGeneral_fnc.cxx.

136  {
137 
138  uint32_t int_rnd = s_MaxValue * rnd;
139 
140  int ibin = find_index_uint32( contents, nbins, int_rnd );
141 
142  int binx = ibin;
143 
144  uint32_t basecont = 0;
145  if ( ibin > 0 ) basecont = contents[ibin - 1];
146 
147  uint32_t dcont = contents[ibin] - basecont;
148  if ( dcont > 0 ) {
149  return borders[binx] + ( ( borders[binx + 1] - borders[binx] ) * ( int_rnd - basecont ) ) / dcont;
150  } else {
151  return borders[binx] + ( borders[binx + 1] - borders[binx] ) / 2;
152  }
153  }

◆ rnd_to_fct2d()

__DEVICE__ void CaloGpuGeneral_fnc::rnd_to_fct2d ( float &  valuex,
float &  valuey,
float  rnd0,
float  rnd1,
FH2D hf2d 
)

Definition at line 109 of file CaloGpuGeneral_fnc.cxx.

109  {
110 
111  int nbinsx = ( *hf2d ).nbinsx;
112  int nbinsy = ( *hf2d ).nbinsy;
113  float* HistoContents = ( *hf2d ).h_contents;
114  float* HistoBorders = ( *hf2d ).h_bordersx;
115  float* HistoBordersy = ( *hf2d ).h_bordersy;
116 
117  int ibin = find_index_f( HistoContents, nbinsx * nbinsy, rnd0 );
118 
119  int biny = ibin / nbinsx;
120  int binx = ibin - nbinsx * biny;
121 
122  float basecont = 0;
123  if ( ibin > 0 ) basecont = HistoContents[ibin - 1];
124 
125  float dcont = HistoContents[ibin] - basecont;
126  if ( dcont > 0 ) {
127  valuex = HistoBorders[binx] + ( HistoBorders[binx + 1] - HistoBorders[binx] ) * ( rnd0 - basecont ) / dcont;
128  } else {
129  valuex = HistoBorders[binx] + ( HistoBorders[binx + 1] - HistoBorders[binx] ) / 2;
130  }
131  valuey = HistoBordersy[biny] + ( HistoBordersy[biny + 1] - HistoBordersy[biny] ) * rnd1;
132  }
beamspotman.r
def r
Definition: beamspotman.py:676
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
CaloGpuGeneral_fnc::find_index_uint32
__DEVICE__ int find_index_uint32(uint32_t *array, int size, uint32_t value)
Definition: CaloGpuGeneral_fnc.cxx:90
bin
Definition: BinsDiffFromStripMedian.h:43
athena.value
value
Definition: athena.py:122
gr
#define gr
CaloGpuGeneral_fnc::HitCellMapping_d
__DEVICE__ void HitCellMapping_d(Hit &hit, unsigned long, Chain0_Args args)
Definition: CaloGpuGeneral_fnc.cxx:237
Hit::center_eta
CUDA_HOSTDEV float & center_eta()
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloGpu/ISF_FastCaloGpu/Hit.h:85
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
Phi_mpi_pi
__HOSTDEV__ double Phi_mpi_pi(double)
Definition: GeoRegion.cxx:7
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
beamspotman.steps
int steps
Definition: beamspotman.py:505
Hit::center_z
CUDA_HOSTDEV float & center_z()
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloGpu/ISF_FastCaloGpu/Hit.h:84
lumiFormat.i
int i
Definition: lumiFormat.py:92
Hit::center_phi
CUDA_HOSTDEV float & center_phi()
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloGpu/ISF_FastCaloGpu/Hit.h:86
CaloGpuGeneral_fnc::getDDE
__DEVICE__ long long getDDE(GeoGpu *geo, int sampling, float eta, float phi)
Definition: CaloGpuGeneral_fnc.cxx:13
contents
void contents(std::vector< std::string > &keys, TDirectory *td, const std::string &directory, const std::string &pattern, const std::string &path)
Definition: computils.cxx:319
lumiFormat.array
array
Definition: lumiFormat.py:98
Rg_Sample_Index::index
int index
Definition: GeoGpu_structs.h:12
Hit::phi
CUDA_HOSTDEV float & phi()
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloGpu/ISF_FastCaloGpu/Hit.h:72
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
charge
double charge(const T &p)
Definition: AtlasPID.h:494
Rg_Sample_Index
Definition: GeoGpu_structs.h:10
CaloGpuGeneral_fnc::rnd_to_fct2d
__DEVICE__ void rnd_to_fct2d(float &valuex, float &valuey, float rnd0, float rnd1, FH2D *hf2d)
Definition: CaloGpuGeneral_fnc.cxx:109
Hit::setCenter_phi
CUDA_HOSTDEV void setCenter_phi(float phi)
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloGpu/ISF_FastCaloGpu/Hit.h:90
CaloGpuGeneral_fnc::find_index_f
__DEVICE__ int find_index_f(float *array, int size, float value)
Definition: CaloGpuGeneral_fnc.cxx:73
GeoRegion
Definition: GeoRegion.h:18
Hit::setEtaPhiZE
CUDA_HOSTDEV void setEtaPhiZE(float eta, float phi, float z, float E)
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloGpu/ISF_FastCaloGpu/Hit.h:48
LArCellConditions.geo
bool geo
Definition: LArCellConditions.py:46
eFEXNTuple.delta_phi
def delta_phi(phi1, phi2)
Definition: eFEXNTuple.py:15
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
beamspotnt.rms
rms
Definition: bin/beamspotnt.py:1266
Hit::setCenter_eta
CUDA_HOSTDEV void setCenter_eta(float eta)
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloGpu/ISF_FastCaloGpu/Hit.h:89
Hit::E
CUDA_HOSTDEV float & E()
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloGpu/ISF_FastCaloGpu/Hit.h:75
Hit::eta
CUDA_HOSTDEV float & eta()
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloGpu/ISF_FastCaloGpu/Hit.h:71
Hit::setCenter_r
CUDA_HOSTDEV void setCenter_r(float r)
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloGpu/ISF_FastCaloGpu/Hit.h:87
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
CaloGpuGeneral_fnc::rnd_to_fct1d
__DEVICE__ float rnd_to_fct1d(float rnd, uint32_t *contents, float *borders, int nbins, uint32_t s_MaxValue)
Definition: CaloGpuGeneral_fnc.cxx:136
M_2PI
#define M_2PI
Definition: CaloGpuGeneral_fnc.cxx:8
Hit::setCenter_z
CUDA_HOSTDEV void setCenter_z(float z)
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloGpu/ISF_FastCaloGpu/Hit.h:88
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
python.CaloScaleNoiseConfig.args
args
Definition: CaloScaleNoiseConfig.py:80
Hit::center_r
CUDA_HOSTDEV float & center_r()
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloGpu/ISF_FastCaloGpu/Hit.h:83
Rg_Sample_Index::size
int size
Definition: GeoGpu_structs.h:11