ATTPCROOT
0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
|
Interface for randomly sampling AtHits. More...
#include <AtSample.h>
Public Member Functions | |
virtual | ~AtSample ()=default |
virtual std::vector< AtHit > | SampleHits (int N) |
Sample hits (AtHit) from fHits. More... | |
std::vector< ROOT::Math::XYZPoint > | SamplePoints (int N) |
Sample spacial locations (XYZPoints) from fHits. More... | |
virtual void | SetHitsToSample (const std::vector< const AtHit * > &hits)=0 |
void | SetHitsToSample (const std::vector< HitPtr > &hits) |
void | SetHitsToSample (const std::vector< AtHit > &hits) |
void | SetSampleWithReplacement (bool val) |
Protected Types | |
using | HitPtr = std::unique_ptr< AtHit > |
Protected Member Functions | |
virtual std::vector< double > | PDF (const AtHit &hit)=0 |
void | FillCDF () |
std::vector< int > | sampleIndicesFromCDF (int N, std::vector< int > vetoed={}) |
int | getIndexFromCDF (double r, double rmCFD, std::vector< int > vetoed) |
Get the index i where CDF[i] >= r and CDF[i-1] < r. More... | |
double | getPDFfromCDF (int index) |
Static Protected Member Functions | |
template<typename T > | |
static bool | isInVector (T val, std::vector< T > vec) |
Protected Attributes | |
const std::vector< const AtHit * > * | fHits |
std::vector< double > | fCDF |
bool | fWithReplacement {false} |
Interface for randomly sampling AtHits.
Samples according to the cumulitive distribution function fCDF.
Definition at line 35 of file AtSample.h.
|
protected |
Definition at line 37 of file AtSample.h.
|
virtualdefault |
|
protected |
Fill the cumulitive distribution function to sample using the marginal PDFs returned by the function PDF(const AtHit &hit) from every entry in the vector fHits.
Each marginal PDF is normalized to construct the final CDF. Assumes the marginal PDFs are independent (i.e. the joint PDF is just the product of all marginal PDFs)
Definition at line 115 of file AtSample.cxx.
|
protected |
Get the index i where CDF[i] >= r and CDF[i-1] < r.
Loop through fCDF, skipping any index in vetoed, for the index that corresponds to r So need to track what indices are not allowed (vetoed) and the amount of the CDF that has been removed (i.e. sum of PDFs for all removed indices). (rmCDF) The new CDF is then oldCDF/(1-rmCDF) We then need to loop through CDF and look for index where CDF[i] >= r
[in] | r | Random number between [0,1) to compare to fCDF |
[in] | vetoed | Indices to ignore while searching fCDF |
Definition at line 54 of file AtSample.cxx.
|
protected |
Definition at line 104 of file AtSample.cxx.
|
inlinestaticprotected |
Definition at line 72 of file AtSample.h.
|
protectedpure virtual |
Computes the unnormalized marginal PDFs at the hit.
For example, a charge-weighted and spacial gaussian would looke like return {charge, gaussian_pdf(distance, sigma)};
Implemented in RandomSample::AtIndependentSample, RandomSample::AtWeightedGaussian, RandomSample::AtY, RandomSample::AtGaussian, RandomSample::AtUniform, RandomSample::AtWeightedGaussianTrunc, and RandomSample::AtChargeWeighted.
|
virtual |
Sample hits (AtHit) from fHits.
Assumes fCDF is already setup and we are just using it.
Reimplemented in RandomSample::AtY, RandomSample::AtSampleFromReference, RandomSample::AtWeightedY, RandomSample::AtUniform, and RandomSample::AtWeightedGaussianTrunc.
Definition at line 20 of file AtSample.cxx.
|
protected |
Get a list of indices aampled according to the constructed fCDF (assumes FillCDF() has been called already)
[in] | N | number of pcoints to sample. If sampling without replacement this should be small compared to the total number of hits in the hit array. |
[in] | vetoed | Indices to not sample (even if sampling with replacement). |
Definition at line 77 of file AtSample.cxx.
std::vector< ROOT::Math::XYZPoint > AtSample::SamplePoints | ( | int | N | ) |
Sample spacial locations (XYZPoints) from fHits.
Calls SampleHits(int N).
Definition at line 34 of file AtSample.cxx.
void AtSample::SetHitsToSample | ( | const std::vector< AtHit > & | hits | ) |
Definition at line 151 of file AtSample.cxx.
|
pure virtual |
void AtSample::SetHitsToSample | ( | const std::vector< HitPtr > & | hits | ) |
Definition at line 146 of file AtSample.cxx.
|
inline |
Definition at line 52 of file AtSample.h.
|
protected |
Definition at line 39 of file AtSample.h.
|
protected |
Definition at line 38 of file AtSample.h.
|
protected |
Definition at line 40 of file AtSample.h.