ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Rand4Hits Class Reference

#include <Rand4Hits.h>

Collaboration diagram for Rand4Hits:

Public Member Functions

 Rand4Hits ()=default
 
 ~Rand4Hits ()
 
float * rand_ptr (int nhits)
 
float * rand_ptr_base ()
 
void set_rand_ptr (float *ptr)
 
void set_t_a_hits (int nhits)
 
void set_c_hits (int nhits)
 
unsigned int get_c_hits ()
 
unsigned int get_t_a_hits ()
 
void create_gen (unsigned long long seed, size_t numhits, bool useCPU=false)
 
void allocate_simulation (long long maxhits, unsigned short maxbins, unsigned short maxhitct, unsigned long n_cells)
 
float * get_cells_energy ()
 
Cell_Eget_cell_e ()
 
Cell_Eget_cell_e_h ()
 
int * get_ct ()
 
unsigned long * get_hitcells ()
 
int * get_hitcells_ct ()
 
void rd_regen ()
 
void add_a_hits (int nhits)
 
bool over_alloc (int nhits)
 

Private Member Functions

float * genCPU (size_t num)
 
void createCPUGen (unsigned long long seed)
 
void destroyCPUGen ()
 

Private Attributes

float * m_rand_ptr {nullptr}
 
unsigned int m_total_a_hits {0}
 
unsigned int m_current_hits {0}
 
void * m_gen {nullptr}
 
bool m_useCPU {false}
 
float * m_cells_energy {0}
 
Cell_Em_cell_e {0}
 
int * m_ct {0}
 
unsigned long * m_hitcells {nullptr}
 
int * m_hitcells_ct {nullptr}
 
Cell_Em_cell_e_h {nullptr}
 
std::vector< float > m_rnd_cpu
 

Detailed Description

Definition at line 13 of file Rand4Hits.h.

Constructor & Destructor Documentation

◆ Rand4Hits()

Rand4Hits::Rand4Hits ( )
default

◆ ~Rand4Hits()

Rand4Hits::~Rand4Hits ( )

Member Function Documentation

◆ add_a_hits()

void Rand4Hits::add_a_hits ( int  nhits)
inline

Definition at line 49 of file Rand4Hits.h.

49  {
50  if ( over_alloc( nhits ) )
51  m_current_hits = nhits;
52  else
53  m_current_hits += nhits;
54  };

◆ allocate_simulation()

void Rand4Hits::allocate_simulation ( long long  maxhits,
unsigned short  maxbins,
unsigned short  maxhitct,
unsigned long  n_cells 
)

◆ create_gen()

void Rand4Hits::create_gen ( unsigned long long  seed,
size_t  numhits,
bool  useCPU = false 
)

◆ createCPUGen()

void Rand4Hits::createCPUGen ( unsigned long long  seed)
private

Definition at line 7 of file Rand4Hits_cpu.cxx.

7  {
8  cpu_randgen_t* eng = new cpu_randgen_t( seed );
9  m_gen = (void*)eng;
10 }

◆ destroyCPUGen()

void Rand4Hits::destroyCPUGen ( )
private

Definition at line 12 of file Rand4Hits_cpu.cxx.

12  {
13  if ( m_gen ) { delete (cpu_randgen_t*)m_gen; }
14 }

◆ genCPU()

float * Rand4Hits::genCPU ( size_t  num)
private

Definition at line 16 of file Rand4Hits_cpu.cxx.

16  {
17  m_rnd_cpu.resize( num );
18 
19  cpu_randgen_t* eng = (cpu_randgen_t*)( m_gen );
20 
21  auto RNG = [eng]( float low, float high ) {
22  auto randomFunc = [distribution_ = std::uniform_real_distribution<float>( low, high ),
23  random_engine_ = *eng]() mutable { return distribution_( random_engine_ ); };
24  return randomFunc;
25  };
26 
27  std::generate_n( m_rnd_cpu.begin(), num, RNG( 0.f, 1.f ) );
28 
29  return m_rnd_cpu.data();
30 }

◆ get_c_hits()

unsigned int Rand4Hits::get_c_hits ( )
inline

Definition at line 31 of file Rand4Hits.h.

31 { return m_current_hits; };

◆ get_cell_e()

Cell_E* Rand4Hits::get_cell_e ( )
inline

Definition at line 39 of file Rand4Hits.h.

39 { return m_cell_e; };

◆ get_cell_e_h()

Cell_E* Rand4Hits::get_cell_e_h ( )
inline

Definition at line 40 of file Rand4Hits.h.

40 { return m_cell_e_h; };

◆ get_cells_energy()

float* Rand4Hits::get_cells_energy ( )
inline

Definition at line 38 of file Rand4Hits.h.

38 { return m_cells_energy; };

◆ get_ct()

int* Rand4Hits::get_ct ( )
inline

Definition at line 42 of file Rand4Hits.h.

42 { return m_ct; };

◆ get_hitcells()

unsigned long* Rand4Hits::get_hitcells ( )
inline

Definition at line 44 of file Rand4Hits.h.

44 { return m_hitcells; };

◆ get_hitcells_ct()

int* Rand4Hits::get_hitcells_ct ( )
inline

Definition at line 45 of file Rand4Hits.h.

45 { return m_hitcells_ct; };

◆ get_t_a_hits()

unsigned int Rand4Hits::get_t_a_hits ( )
inline

Definition at line 32 of file Rand4Hits.h.

32 { return m_total_a_hits; };

◆ over_alloc()

bool Rand4Hits::over_alloc ( int  nhits)
inline

Definition at line 55 of file Rand4Hits.h.

55  {
56  return m_current_hits + nhits > m_total_a_hits;
57  }; // return true if hits over spill, need regenerat rand..

◆ rand_ptr()

float* Rand4Hits::rand_ptr ( int  nhits)
inline

Definition at line 18 of file Rand4Hits.h.

18  {
19  if ( over_alloc( nhits ) ) {
20  rd_regen();
21  return m_rand_ptr;
22  } else {
23  float* f_ptr = &( m_rand_ptr[3 * m_current_hits] );
24  return f_ptr;
25  }
26  };

◆ rand_ptr_base()

float* Rand4Hits::rand_ptr_base ( )
inline

Definition at line 27 of file Rand4Hits.h.

27 { return m_rand_ptr; }

◆ rd_regen()

void Rand4Hits::rd_regen ( )

◆ set_c_hits()

void Rand4Hits::set_c_hits ( int  nhits)
inline

Definition at line 30 of file Rand4Hits.h.

30 { m_current_hits = nhits; };

◆ set_rand_ptr()

void Rand4Hits::set_rand_ptr ( float *  ptr)
inline

Definition at line 28 of file Rand4Hits.h.

28 { m_rand_ptr = ptr; };

◆ set_t_a_hits()

void Rand4Hits::set_t_a_hits ( int  nhits)
inline

Definition at line 29 of file Rand4Hits.h.

29 { m_total_a_hits = nhits; };

Member Data Documentation

◆ m_cell_e

Cell_E* Rand4Hits::m_cell_e {0}
private

Definition at line 72 of file Rand4Hits.h.

◆ m_cell_e_h

Cell_E* Rand4Hits::m_cell_e_h {nullptr}
private

Definition at line 78 of file Rand4Hits.h.

◆ m_cells_energy

float* Rand4Hits::m_cells_energy {0}
private

Definition at line 71 of file Rand4Hits.h.

◆ m_ct

int* Rand4Hits::m_ct {0}
private

Definition at line 73 of file Rand4Hits.h.

◆ m_current_hits

unsigned int Rand4Hits::m_current_hits {0}
private

Definition at line 66 of file Rand4Hits.h.

◆ m_gen

void* Rand4Hits::m_gen {nullptr}
private

Definition at line 67 of file Rand4Hits.h.

◆ m_hitcells

unsigned long* Rand4Hits::m_hitcells {nullptr}
private

Definition at line 76 of file Rand4Hits.h.

◆ m_hitcells_ct

int* Rand4Hits::m_hitcells_ct {nullptr}
private

Definition at line 77 of file Rand4Hits.h.

◆ m_rand_ptr

float* Rand4Hits::m_rand_ptr {nullptr}
private

Definition at line 64 of file Rand4Hits.h.

◆ m_rnd_cpu

std::vector<float> Rand4Hits::m_rnd_cpu
private

Definition at line 80 of file Rand4Hits.h.

◆ m_total_a_hits

unsigned int Rand4Hits::m_total_a_hits {0}
private

Definition at line 65 of file Rand4Hits.h.

◆ m_useCPU

bool Rand4Hits::m_useCPU {false}
private

Definition at line 68 of file Rand4Hits.h.


The documentation for this class was generated from the following files:
Rand4Hits::m_ct
int * m_ct
Definition: Rand4Hits.h:73
Rand4Hits::m_cell_e_h
Cell_E * m_cell_e_h
Definition: Rand4Hits.h:78
Rand4Hits::m_current_hits
unsigned int m_current_hits
Definition: Rand4Hits.h:66
Rand4Hits::m_rand_ptr
float * m_rand_ptr
Definition: Rand4Hits.h:64
Rand4Hits::rd_regen
void rd_regen()
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
Rand4Hits::m_hitcells_ct
int * m_hitcells_ct
Definition: Rand4Hits.h:77
Rand4Hits::over_alloc
bool over_alloc(int nhits)
Definition: Rand4Hits.h:55
cpu_randgen_t
#define cpu_randgen_t
Definition: Rand4Hits_cpu.cxx:5
Rand4Hits::m_hitcells
unsigned long * m_hitcells
Definition: Rand4Hits.h:76
hist_file_dump.f
f
Definition: hist_file_dump.py:135
Rand4Hits::m_cells_energy
float * m_cells_energy
Definition: Rand4Hits.h:71
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
Rand4Hits::m_rnd_cpu
std::vector< float > m_rnd_cpu
Definition: Rand4Hits.h:80
RngCompsConfig.RNG
def RNG(engine="dSFMT", name="AthRNGSvc")
Definition: RngCompsConfig.py:43
Rand4Hits::m_total_a_hits
unsigned int m_total_a_hits
Definition: Rand4Hits.h:65
Rand4Hits::m_cell_e
Cell_E * m_cell_e
Definition: Rand4Hits.h:72
Rand4Hits::m_gen
void * m_gen
Definition: Rand4Hits.h:67