1#include "QPMonteCarlo.hpp"
3#include "QPRandomBase.hpp"
4#include "QPDigitizerBase.hpp"
5#include "QPSignalGaussian.hpp"
12: fDigitizer(digitizer), fRandom(random){;}
15 const double& ymin,
const double& ymax){
38 fThreshold = threshold;
47 rec.
fAmp = fRandomAmp ? fRandom.
Uniform(fAmpMin, fAmpMax) : fAmp;
63 std::vector<Record> records;
64 records.reserve(ntrial > 0 ? ntrial : 0);
65 for(
int i=0; i<ntrial; i++){
66 records.push_back(
Shoot());
72 const std::string& filename){
73 std::FILE* out = std::fopen(filename.c_str(),
"w");
74 if(out ==
nullptr)
return false;
75 std::fprintf(out,
"amp,x,y,sig,npix\n");
76 for(
const Record& r : records){
77 std::fprintf(out,
"%.17g,%.17g,%.17g,%.17g,%d\n",
78 r.fAmp, r.fX, r.fY, r.fSigma, r.fNpix);
Abstract pixel-matrix digitizer: owns the injected signals and the matrix geometry; concrete classes ...
void InjectSignal(QPSignalBase *signal)
Hands a signal to the digitizer, which takes ownership: the default ClearSignal() deletes it.
void ClearSignal(bool removeall=true)
Empties the signal store.
std::deque< QPPixelBase * > GetFiredPixel(double threshold)
Builds every pixel and keeps those whose digital signal exceeds threshold; the rest are deleted inter...
Dense m×n matrix of double with hand-rolled linear algebra.
void SetThreshold(const double &threshold)
Pixel firing threshold.
Record Shoot()
Generate one event.
void SetAmplitude(const double &)
Fixed amplitude for every event; disables the amplitude draw.
void SetSigma(const double &sigma)
Width of the injected Gaussian.
QPMonteCarlo(QPDigitizerBase *digitizer, QPRandomBase &random)
std::vector< Record > Run(int ntrial)
Shoot() ntrial times.
static bool WriteCSV(const std::vector< Record > &records, const std::string &filename)
Write records as CSV: header line amp,x,y,sig,npix, values with %.17g (round-trip double precision).
void SetPositionRange(const double &xmin, const double &xmax, const double &ymin, const double &ymax)
Uniform draw ranges for the signal position, µm.
void SetAmplitudeRange(const double &min, const double &max)
Per-event uniform amplitude draw.
Abstract random number source.
virtual double Uniform(double a, double b)=0
Uniform deviate between a and b.
2D Gaussian signal in covariance-matrix form,
3-component double vector with hand-rolled operations.
One generated event, plain data only.
int fNpix
pixels above threshold (cluster size)
double fSigma
value placed on both diagonal entries of the covariance-form matrix S
double fAmp
signal amplitude, electrons
double fY
signal position y, µm
double fX
signal position x, µm