Belle II Software  release-05-01-25
Belle2::SVD Namespace Reference

Namespace to encapsulate code needed for simulation and reconstrucion of the SVD. More...

Classes

class  DefaultWave
 A functor to provide a simple model of APV25 strip response. More...
 
class  EmpiricalDistributionFunction
 Empirical distribution function object is basic for mainpulation of probabilities. More...
 
class  GeoSVDCreator
 The creator for the SVD geometry of the Belle II detector. More...
 
class  NNWaveFitter
 The class uses a neural network to find a probability distribution of arrival times for a sextet of APX25 signal samples. More...
 
class  NNWaveFitTool
 The class holds arrays of bins and bin centers, and a wave generator object containing information on the waveform function. More...
 
class  NoiseMap
 Base Class to represent strip-dependent noise map. More...
 
class  SensorInfo
 Specific implementation of SensorInfo for SVD Sensors which provides additional sensor specific information. More...
 
class  SimpleClusterCandidate
 Class representing a cluster candidate during simple clustering of the SVD. More...
 
struct  stripInCluster
 structure containing the relevant informations of eachstrip of the cluster More...
 
class  SVDBackgroundModule
 SVD Background module. More...
 
class  SVDBeamBackHitFilterModule
 The SVDBeamBackHitFilter module. More...
 
class  SVDClusterizerDirectModule
 SVD Direct Clusterizer. More...
 
class  SVDDatabaseTestModule
 Return the calibration results for the noises and the constants measured during the svd local runs (charge, ADC pulse, peaking time, pulse width). More...
 
class  SVDDigitizerModule
 The SVD Digitizer module. More...
 
class  SVDDQMInjectionModule
 The SVD Occupancy after Injection DQM module. More...
 
class  SVDMissingAPVsClusterCreatorModule
 SVDMissingAPVsClusterCreatorModule: The SVD MissingAPVsClusterCreator. More...
 
class  SVDNNClusterizerModule
 SVD NN Clusterizer. More...
 
class  SVDNNShapeReconstructorModule
 The SVD NNShapeReconstructor. More...
 
class  SVDPackerModule
 SVDPackerModule: The SVD Raw Hits Creator. More...
 
class  SVDShaperDigitSorterModule
 The SVDShaperDigitSorter module. More...
 
class  SVDSignal
 The SVD signal class. More...
 
class  SVDSimpleClusterizerModule
 SVDSimpleClusterizerModule: The SVD SimpleClusterizer. More...
 
class  SVDUnpackerModule
 SVDUnpackerModule: The SVD Raw Hits Decoder. More...
 
class  TauEncoder
 Encoder/decoder for neural network tau values. More...
 
class  WaveFitter
 Waveform fitter class. More...
 
class  WaveGenerator
 Waveform generator This is a functor to calculate signal values. More...
 

Typedefs

typedef std::map< short int, SVDSignalStripSignals
 Map of all signals in one sensor.
 
typedef std::pair< StripSignals, StripSignalsSensor
 Signals of u- and v- strips in one sensor.
 
typedef std::map< VxdID, SensorSensors
 Map of all signals in all sensors.
 
typedef std::vector< double > nnFitterBinData
 Vector of values defined for bins, such as bin times or bin probabilities.
 
typedef std::vector< double > nnFitterBins
 Vector of bin edges, nnFitterBinData.size() + 1.
 
typedef VXD::SensitiveDetector< SVDSimHit, SVDTrueHitSensitiveDetector
 The SVD Sensitive Detector class.
 
typedef double apvSampleBaseType
 Vector of input samples in float form.
 
typedef std::array< apvSampleBaseType, nAPVSamplesapvSamples
 vector od apvSample BaseType objects
 
typedef std::function< double(double)> waveFunction
 Wavefrom function type. More...
 

Functions

double w_expo (double t)
 Gamma waveform, x.exp(-x) This is only historically useful. More...
 
double w_poly3 (double t)
 Polynomial waveform, x. More...
 
double w_betaprime (double t)
 Beta-prime wave function, x^alpha/(1+x)^beta. More...
 
template<typename T >
void zeroSuppress (T &a, double thr)
 pass zero suppression
 
template<typename T >
bool pass3Samples (const T &a, double thr)
 pass 3-samples
 
double tau_raw2real (double raw_tau)
 Convert Hao's raw tau (integral, in latency units) to correct betaprime scale. More...
 
 TEST (NNTimeFitter, DISABLED_CompareNetworkCoefficient)
 Compare NN fitter parameter dump from Python with internal data representation in C++ to verify that the network coefficients were transferred without a significant loss of accuracy. More...
 
 TEST (NNTimeFitter, DISABLED_CompareFits)
 Read a sample of fits from the Python NN suite and check that the C++ NN fitter produces the same results. More...
 
 TEST (SVDModeByte, Constructor)
 Check that both constructors yield the same result.
 
 TEST (SVDModeByte, getters)
 Check getters and setters.
 
 TEST (SVDRecoDigit, ConstructEmpty)
 Check empty object creation and data getters.
 
 TEST (SVDRecoDigit, ConstructFromContainer)
 Check object creation and data getters using a stl container of probabilities.
 
 TEST (SVDRecoDigit, ToString)
 Check object creation and data getters using a stl container of probabilities.
 
 TEST (SVDRecoTimeBase, ConstructEmpty)
 Check empty object creation and data getters.
 
 TEST (SVDRecoTimeBase, ConstructFromContainer)
 Check object creation and data getters.
 
 TEST (SVDRecoTimeBase, toString)
 Check object printout.
 
 TEST (SVDShaperDigit, ConstructEmpty)
 Check empty object creation and data getters.
 
 TEST (SVDShaperDigit, ConstructFromContainer)
 Check object creation and data getters using a stl container of samples.
 
 TEST (SVDShaperDigit, ConstructFromCArray)
 Check object creation and data getters using a c-array of samples.
 
 TEST (SVDShaperDigit, ConstructDefaultTimeMode)
 Check standard object creation without FADC time and mode information.
 
 TEST (SVDShaperDigit, SampleTrimming)
 test sample trimming
 
 TEST (SVDShaperDigit, TrimmingFunction)
 test sample trimming
 
 TEST (SVDSignal, Getters)
 Check object creation and simple object getters.
 
 TEST (SVDSignal, Constructors)
 Check the different constructors.
 
 TEST (SVDSignal, Assignment)
 Check assignment operators.
 
 TEST (SVDSignal, Waveform)
 Check the waveform values and relations.
 
 TEST (SVDSignal, toString)
 Check the waveform string representation.
 
 TEST (TNiel, output)
 Check correct functioning of the class.
 

Variables

geometry::CreatorFactory< GeoSVDCreatorGeoSVDFactory ("SVDCreator")
 Register the creator.
 
const std::size_t nAPVSamples = 6
 Number of APV samples.
 
const double dt_APV = 31.44 * Unit::ns
 APV sampling time.
 
const apvSamples apvTimeBase
 APV time base - times for the 6 signals. More...
 

Detailed Description

Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.

Typedef Documentation

◆ waveFunction

typedef std::function<double(double)> waveFunction

Wavefrom function type.

This is the type for a naked wave function, giving a single value for a properly scaled arguemnt. The functions are scaled to 1.0 at mode, location (shift) 0.0, and scale 1.0.

Definition at line 56 of file SVDSimulationTools.h.

Function Documentation

◆ tau_raw2real()

double Belle2::SVD::tau_raw2real ( double  raw_tau)
inline

Convert Hao's raw tau (integral, in latency units) to correct betaprime scale.

Includes scaling and fit adjustmenta

Definition at line 155 of file SVDSimulationTools.h.

155 { return 7.32313 * raw_tau; }

◆ TEST() [1/2]

Belle2::SVD::TEST ( NNTimeFitter  ,
DISABLED_CompareFits   
)

Read a sample of fits from the Python NN suite and check that the C++ NN fitter produces the same results.

This is the result of select_t0_fits.columns: Index([ 'test', 'amplitude', 't0', 'tau', 'sigma', 's1', 's2', 's3', 's4', 's5', 's6', 'normed_tau', 't0_bin', 'abin', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 'a_fit', 'a_sigma', 'chi2_ndf', 't_fit', 't_sigma', 't_true', 'tau', 'a_true', 't_bin', 'a_bin', 't_diff','a_diff'], dtype='object') Columns labeled by numerals contain probabilities.

Definition at line 55 of file NNFitterTest.cc.

56  {
57  const size_t max_lines = 100; // maximum number of lines to be read
58 
59  // Create an instance of the NN fitter and the fitter tool.
60  NNWaveFitter fitter("SVDTimeNet_6samples");
61  auto fitTool = fitter.getFitTool();
62  size_t nProbs = fitTool.getBinCenters().size();
63 
64  ifstream infile("svd/data/test_sample.csv");
65 
66  // Read the rows one by one and compare results
67  string line;
68  getline(infile, line);
69 
70  for (size_t i_line = 0; i_line < max_lines; i_line++) {
71 
72  getline(infile, line);
73  if (line.size() < 10) break;
74  istringstream sline(line);
75 
76  // Parse header. We want the dimennsion of the probability array.
77  // not needed
78  string cell;
79  getline(sline, cell, ','); // index
80  getline(sline, cell, ','); // test
81 
82  // true values. Read from the file, though not used.
83  getline(sline, cell, ',');
84  [[maybe_unused]] double true_amp = stod(cell);
85  getline(sline, cell, ',');
86  [[maybe_unused]] double true_t0 = stod(cell);
87  getline(sline, cell, ',');
88  [[maybe_unused]] double width = stod(cell);
89  getline(sline, cell, ',');
90  [[maybe_unused]] double noise = stod(cell);
91 
92  // normalized samples
93  apvSamples normedSamples;
94  for (size_t iSample = 0; iSample < nAPVSamples; ++iSample) {
95  getline(sline, cell, ',');
96  normedSamples[iSample] = stod(cell);
97  }
98 
99  // not needed
100  getline(sline, cell, ',');
101  getline(sline, cell, ',');
102  getline(sline, cell, ',');
103 
104  // probabilities
105  nnFitterBinData ProbsPy(nProbs);
106  for (size_t iSample = 0; iSample < nProbs; ++iSample) {
107  getline(sline, cell, ',');
108  ProbsPy[iSample] = stod(cell);
109  }
110 
111  // fit results
112  getline(sline, cell, ',');
113  double fitPy_amp = stod(cell);
114  getline(sline, cell, ',');
115  double fitPy_ampSigma = stod(cell);
116  getline(sline, cell, ',');
117  [[maybe_unused]] double fitPy_chi2 = stod(cell);
118  getline(sline, cell, ',');
119  double fitPy_t0 = stod(cell);
120  getline(sline, cell, ',');
121  double fitPy_t0Sigma = stod(cell);
122 
123  // now do the Cpp fit
124  const shared_ptr<nnFitterBinData> ProbsCpp = fitter.getFit(normedSamples, width);
125  for (size_t iBin = 0; iBin < nProbs; ++iBin)
126  EXPECT_NEAR((*ProbsCpp)[iBin], ProbsPy[iBin], 5.0e-3);
127 
128  double t0_cpp, t0_err_cpp;
129  tie(t0_cpp, t0_err_cpp) = fitTool.getTimeShift(*ProbsCpp);
130  EXPECT_NEAR(t0_cpp, fitPy_t0, 5);
131  EXPECT_NEAR(t0_err_cpp, fitPy_t0Sigma, 2);
132 
133  double amp_cpp, amp_err_cpp, chi2_cpp;
134  tie(amp_cpp, amp_err_cpp, chi2_cpp) = fitTool.getAmplitudeChi2(normedSamples, t0_cpp, width);
135  EXPECT_NEAR(amp_cpp, fitPy_amp, 1.0);
136  EXPECT_NEAR(amp_err_cpp, fitPy_ampSigma, 0.1);
137  // FIXME: This is calculated slightly differently in Python, and it shows.
138  // EXPECT_NEAR(chi2_cpp, fitPy_chi2, 1);
139  }
140  }

◆ TEST() [2/2]

Belle2::SVD::TEST ( NNTimeFitter  ,
DISABLED_CompareNetworkCoefficient   
)

Compare NN fitter parameter dump from Python with internal data representation in C++ to verify that the network coefficients were transferred without a significant loss of accuracy.

FIXME (Oct 12,2017: This test fails on buildbot, but ran successfully on all machines I tried.

Definition at line 37 of file NNFitterTest.cc.

◆ w_betaprime()

double Belle2::SVD::w_betaprime ( double  t)
inline

Beta-prime wave function, x^alpha/(1+x)^beta.

This is the function for general use.

Parameters
tProperly scaled time, (t - t0)/tau.
tauWaveform width
Returns
6x2 Eigen matrix, times in 1st column, signals in the 2nd.

Definition at line 89 of file SVDSimulationTools.h.

◆ w_expo()

double Belle2::SVD::w_expo ( double  t)
inline

Gamma waveform, x.exp(-x) This is only historically useful.

Use beta-prime instead.

Parameters
tproperly scaled time, (t-t0)/tau
Returns
Waveform value t * exp(1 - t) for t > 0, else 0

Definition at line 63 of file SVDSimulationTools.h.

◆ w_poly3()

double Belle2::SVD::w_poly3 ( double  t)
inline

Polynomial waveform, x.

(1-x)^2 This is used in signal calibration in SVD hardware tests. Do not use for signal simulation.

Parameters
tproperly scaled time, (t-t0)/tau
Returns
Waveform value 27/4 * t * (1 - t)^2 for t in <0,1>, else 0

Definition at line 75 of file SVDSimulationTools.h.

Variable Documentation

◆ apvTimeBase

const apvSamples apvTimeBase
Initial value:
=
{{ -dt_APV, 0.0, dt_APV, 2 * dt_APV, 3 * dt_APV, 4 * dt_APV}}

APV time base - times for the 6 signals.

Definition at line 44 of file SVDSimulationTools.h.

Belle2::SVD::apvSamples
std::array< apvSampleBaseType, nAPVSamples > apvSamples
vector od apvSample BaseType objects
Definition: SVDSimulationTools.h:41
Belle2::SVD::nAPVSamples
const std::size_t nAPVSamples
Number of APV samples.
Definition: SVDSimulationTools.h:34
Belle2::SVD::dt_APV
const double dt_APV
APV sampling time.
Definition: SVDSimulationTools.h:37
Belle2::SVD::nnFitterBinData
std::vector< double > nnFitterBinData
Vector of values defined for bins, such as bin times or bin probabilities.
Definition: NNWaveFitTool.h:32