Belle II Software development
TOPPmtTTSPar Class Reference

Parameterized TTS for each PMT pixel. More...

#include <TOPPmtTTSPar.h>

Inheritance diagram for TOPPmtTTSPar:

Classes

struct  Gaussian
 Gaussian distribution parameters. More...
 

Public Types

enum  { c_NumPmtPixels = 16 }
 number of PMT pixels More...
 

Public Member Functions

 TOPPmtTTSPar ()
 Default constructor.
 
 TOPPmtTTSPar (const std::string &serialNumber)
 Full constructor.
 
void appendGaussian (unsigned pmtPixel, const Gaussian &gaus)
 Append struct gauss.
 
void appendGaussian (unsigned pmtPixel, double fraction, double mean, double sigma)
 Append gaussian using its parameters (frac, mean, sigma)
 
int getNumOfPixels () const
 Returns number of PMT pixels.
 
const std::string & getSerialNumber () const
 Returns PMT serial number.
 
const std::vector< Gaussian > & getGaussians (unsigned pmtPixel) const
 Returns vector of gaussians.
 
double getRandomTime (unsigned pmtPixel) const
 Returns a random number, generated according to the distribution.
 
void normalizeFractions ()
 Normalizes the gaussian fractions to unity.
 

Private Member Functions

 ClassDef (TOPPmtTTSPar, 2)
 ClassDef.
 

Private Attributes

std::string m_serialNumber
 serial number, e.g.
 
std::vector< Gaussianm_gaussians [c_NumPmtPixels]
 TTS distribution composed of Gaussians.
 

Detailed Description

Parameterized TTS for each PMT pixel.

Definition at line 26 of file TOPPmtTTSPar.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

number of PMT pixels

Definition at line 41 of file TOPPmtTTSPar.h.

41{c_NumPmtPixels = 16};

Constructor & Destructor Documentation

◆ TOPPmtTTSPar() [1/2]

TOPPmtTTSPar ( )
inline

Default constructor.

Definition at line 46 of file TOPPmtTTSPar.h.

47 {}

◆ TOPPmtTTSPar() [2/2]

TOPPmtTTSPar ( const std::string &  serialNumber)
inlineexplicit

Full constructor.

Parameters
serialNumberserial number

Definition at line 53 of file TOPPmtTTSPar.h.

53 :
54 m_serialNumber(serialNumber)
55 {}
std::string m_serialNumber
serial number, e.g.
Definition: TOPPmtTTSPar.h:166

Member Function Documentation

◆ appendGaussian() [1/2]

void appendGaussian ( unsigned  pmtPixel,
const Gaussian gaus 
)
inline

Append struct gauss.

Parameters
pmtPixelPMT pixel number (1-based)
gausgaussian to be appended

Definition at line 63 of file TOPPmtTTSPar.h.

64 {
65 pmtPixel--;
66 if (pmtPixel >= c_NumPmtPixels) {
67 B2ERROR("TOPPmtTTSPar::appendGaussian: invalid PMT pixel "
68 << LogVar("PMT pixel", pmtPixel + 1));
69 return;
70 }
71 m_gaussians[pmtPixel].push_back(gaus);
72 }
std::vector< Gaussian > m_gaussians[c_NumPmtPixels]
TTS distribution composed of Gaussians.
Definition: TOPPmtTTSPar.h:167
Class to store variables with their name which were sent to the logging service.

◆ appendGaussian() [2/2]

void appendGaussian ( unsigned  pmtPixel,
double  fraction,
double  mean,
double  sigma 
)
inline

Append gaussian using its parameters (frac, mean, sigma)

Parameters
pmtPixelPMT pixel number (1-based)
fractionnormalization fraction of the gaussian
meanmean of the gaussian
sigmasigma of the gaussian

Definition at line 82 of file TOPPmtTTSPar.h.

83 {
84 Gaussian gaus;
85 gaus.fraction = fraction;
86 gaus.mean = mean;
87 gaus.sigma = sigma;
88 appendGaussian(pmtPixel, gaus);
89 }
void appendGaussian(unsigned pmtPixel, const Gaussian &gaus)
Append struct gauss.
Definition: TOPPmtTTSPar.h:63

◆ getGaussians()

const std::vector< Gaussian > & getGaussians ( unsigned  pmtPixel) const
inline

Returns vector of gaussians.

Parameters
pmtPixelPMT pixel number (1-based)
Returns
vector of gaussians

Definition at line 109 of file TOPPmtTTSPar.h.

110 {
111 pmtPixel--;
112 if (pmtPixel >= c_NumPmtPixels) {
113 B2ERROR("TOPPmtTTSPar::getGaussians: invalid PMT pixel. "
114 "Returning data for pixel 1."
115 << LogVar("PMT pixel", pmtPixel + 1));
116 pmtPixel = 0;
117 }
118 return m_gaussians[pmtPixel];
119 }

◆ getNumOfPixels()

int getNumOfPixels ( ) const
inline

Returns number of PMT pixels.

Returns
number of pixels

Definition at line 95 of file TOPPmtTTSPar.h.

95{return c_NumPmtPixels;}

◆ getRandomTime()

double getRandomTime ( unsigned  pmtPixel) const
inline

Returns a random number, generated according to the distribution.

Parameters
pmtPixelPMT pixel number (1-based)
Returns
random time or 0 for invalid pixel

Definition at line 127 of file TOPPmtTTSPar.h.

128 {
129 pmtPixel--;
130 if (pmtPixel >= c_NumPmtPixels) return 0;
131
132 double prob = gRandom->Rndm();
133 double s = 0;
134 for (const auto& gaus : m_gaussians[pmtPixel]) {
135 s = s + gaus.fraction;
136 if (prob < s) {
137 return gRandom->Gaus(gaus.mean, gaus.sigma);
138 }
139 }
140 return 0; // this should not happen, if fractions are properly normalized
141 }

◆ getSerialNumber()

const std::string & getSerialNumber ( ) const
inline

Returns PMT serial number.

Returns
serial number

Definition at line 101 of file TOPPmtTTSPar.h.

101{return m_serialNumber;}

◆ normalizeFractions()

void normalizeFractions ( )
inline

Normalizes the gaussian fractions to unity.

Definition at line 147 of file TOPPmtTTSPar.h.

148 {
149 double sum = 0;
150 for (int ich = 0 ; ich < c_NumPmtPixels ; ich++) {
151 for (const auto& gaus : m_gaussians[ich]) {
152 sum = sum + gaus.fraction;
153 }
154 if (sum == 0) return;
155 for (auto& gaus : m_gaussians[ich]) {
156 gaus.fraction = gaus.fraction / sum;
157 }
158 }
159 return;
160 }

Member Data Documentation

◆ m_gaussians

std::vector<Gaussian> m_gaussians[c_NumPmtPixels]
private

TTS distribution composed of Gaussians.

Definition at line 167 of file TOPPmtTTSPar.h.

◆ m_serialNumber

std::string m_serialNumber
private

serial number, e.g.

JTxxxx

Definition at line 166 of file TOPPmtTTSPar.h.


The documentation for this class was generated from the following file: