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

#include <Samplers.h>

Inheritance diagram for DisjointUniformSampler:
Collaboration diagram for DisjointUniformSampler:

Public Member Functions

 ~DisjointUniformSampler ()
 
 DisjointUniformSampler (const std::vector< float > &ranges)
 
 DisjointUniformSampler (const std::vector< std::pair< float, float > > &ranges)
 
const std::vector< std::pair< float, float > > & _getRanges ()
 
void _setRanges ()
 
float _map_unit_to_val (float x)
 
float shoot ()
 

Public Attributes

float m_low {}
 
float m_high {1.0}
 
float m_val {}
 
TRandom m_random
 

Private Attributes

std::vector< std::pair< float, float > > m_ranges
 
float m_totalwidth {}
 
std::vector< float > m_divisions
 

Detailed Description

Definition at line 84 of file Samplers.h.

Constructor & Destructor Documentation

◆ ~DisjointUniformSampler()

DisjointUniformSampler::~DisjointUniformSampler ( )
inline

Definition at line 98 of file Samplers.h.

98 {};

◆ DisjointUniformSampler() [1/2]

DisjointUniformSampler::DisjointUniformSampler ( const std::vector< float > &  ranges)
inline

Definition at line 99 of file Samplers.h.

99  {
100  for (unsigned int i=0; i<ranges.size();) {
101  std::pair<float,float> p(ranges[i],ranges[i+1]);
102  i+=2;
103  m_ranges.push_back(p);
104  }
105  _setRanges();
106  };

◆ DisjointUniformSampler() [2/2]

DisjointUniformSampler::DisjointUniformSampler ( const std::vector< std::pair< float, float > > &  ranges)
inline

Definition at line 107 of file Samplers.h.

107 : m_ranges(ranges){ _setRanges();}

Member Function Documentation

◆ _getRanges()

const std::vector< std::pair<float,float> >& DisjointUniformSampler::_getRanges ( )
inline

Definition at line 109 of file Samplers.h.

109 { return m_ranges; };

◆ _map_unit_to_val()

float DisjointUniformSampler::_map_unit_to_val ( float  x)
inline

Definition at line 127 of file Samplers.h.

127  {
128  assert(x >= 0 && x <= 1);
129  unsigned int idx = -1, rem = 0;
130  for (unsigned int i=0; i<m_divisions.size()-1; i++)
131  if (x >= m_divisions[i] and x < m_divisions[i+1]) {
132  idx = i;
133  rem = x - m_divisions[i];
134  break;
135  }
136  float val = m_ranges[idx].first + m_totalwidth * rem;
137  return val;
138  };

◆ _setRanges()

void DisjointUniformSampler::_setRanges ( )
inline

Definition at line 111 of file Samplers.h.

111  {
112  for (unsigned int i=0; i<m_ranges.size(); i++) {
113  m_totalwidth += m_ranges[i].second - m_ranges[i].first;
114  };
115  float runningwidth = 0.0;
116  m_divisions.push_back(0.0);
117  for (unsigned int i=0; i<m_ranges.size(); i++) {
118  assert(m_ranges[i].second >= m_ranges[i].first);
119  runningwidth += float(m_ranges[i].second - m_ranges[i].first);
120  m_divisions.push_back(runningwidth);
121  }
122  m_totalwidth = runningwidth;
123  for (unsigned int i=0; i<m_ranges.size(); i++)
125  };

◆ shoot()

float DisjointUniformSampler::shoot ( )
inlinevirtual

Reimplemented from UniformSampler.

Definition at line 140 of file Samplers.h.

140  {
141  float rand = m_random.Uniform();
142  float val = _map_unit_to_val(rand);
143  return val;
144  };

Member Data Documentation

◆ m_divisions

std::vector<float> DisjointUniformSampler::m_divisions
private

Definition at line 148 of file Samplers.h.

◆ m_high

float UniformSampler::m_high {1.0}
inherited

Definition at line 61 of file Samplers.h.

◆ m_low

float UniformSampler::m_low {}
inherited

Definition at line 61 of file Samplers.h.

◆ m_random

TRandom Sampler::m_random
inherited

Definition at line 25 of file Samplers.h.

◆ m_ranges

std::vector< std::pair<float,float> > DisjointUniformSampler::m_ranges
private

Definition at line 146 of file Samplers.h.

◆ m_totalwidth

float DisjointUniformSampler::m_totalwidth {}
private

Definition at line 147 of file Samplers.h.

◆ m_val

float Sampler::m_val {}
inherited

Definition at line 24 of file Samplers.h.


The documentation for this class was generated from the following file:
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
trigbs_pickEvents.ranges
ranges
Definition: trigbs_pickEvents.py:60
DisjointUniformSampler::m_divisions
std::vector< float > m_divisions
Definition: Samplers.h:148
DisjointUniformSampler::m_totalwidth
float m_totalwidth
Definition: Samplers.h:147
x
#define x
Sampler::m_random
TRandom m_random
Definition: Samplers.h:25
DisjointUniformSampler::_setRanges
void _setRanges()
Definition: Samplers.h:111
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
LArG4FSStartPointFilter.rand
rand
Definition: LArG4FSStartPointFilter.py:80
lumiFormat.i
int i
Definition: lumiFormat.py:85
DisjointUniformSampler::m_ranges
std::vector< std::pair< float, float > > m_ranges
Definition: Samplers.h:144
DisjointUniformSampler::_map_unit_to_val
float _map_unit_to_val(float x)
Definition: Samplers.h:127
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
DeMoScan.first
bool first
Definition: DeMoScan.py:536
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
readCCLHist.float
float
Definition: readCCLHist.py:83