Belle II Software development
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  RawCluster
 Class representing a raw cluster candidate during clustering of the SVD. 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...
 
struct  StripInRawCluster
 structure containing the relevant informations of each strip of the raw cluster More...
 
class  SVDBackgroundModule
 SVD Background module. More...
 
class  SVDBeamBackHitFilterModule
 The SVDBeamBackHitFilter module. More...
 
class  SVDClusterCharge
 Abstract Class representing the SVD cluster charge. More...
 
class  SVDClusterizerDirectModule
 SVD Direct Clusterizer. More...
 
class  SVDClusterizerModule
 The SVD Clusterizer. More...
 
class  SVDClusterPosition
 Abstract Class representing the SVD cluster position. More...
 
class  SVDClusterTime
 Abstract Class representing the SVD cluster time. More...
 
class  SVDCoG3Time
 Derived Class representing the SVD cluster time computed with the CoG3 algorithm. More...
 
class  SVDCoG6Time
 Derived Class representing the SVD cluster time computed with the CoG6 algorithm. More...
 
class  SVDCoGOnlyPosition
 Derived Class representing the SVD cluster position computed with the CoGOnly algorithm. 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  SVDDQMDoseModule
 The SVD dose-monitoring DQM module. More...
 
class  SVDDQMInjectionModule
 The SVD Occupancy after Injection DQM module. More...
 
class  SVDELS3Charge
 Derived Class representing the SVD cluster charge computed with the ELS3 algorithm. More...
 
class  SVDELS3Time
 Derived Class representing the SVD cluster time computed with the ELS3 algorithm. More...
 
class  SVDMaxSampleCharge
 Derived Class representing the SVD cluster charge computed summing the max sample of each strip. More...
 
class  SVDMaxSumAlgorithm
 Class implementing the MaxSum algorithm. More...
 
class  SVDMissingAPVsClusterCreatorModule
 SVDMissingAPVsClusterCreatorModule: The SVD MissingAPVsClusterCreator. More...
 
class  SVDNNClusterizerModule
 SVD NN Clusterizer. More...
 
class  SVDNNShapeReconstructorModule
 The SVD NNShapeReconstructor. More...
 
class  SVDOldDefaultPosition
 Derived Class representing the SVD cluster position computed with the old algorithm (up to release-05). More...
 
class  SVDPackerModule
 SVDPackerModule: The SVD Raw Hits Creator. More...
 
class  SVDRecoChargeFactory
 Cluster Charge Factory Class. More...
 
class  SVDRecoDigitCreatorModule
 The SVD RecoDigit Creator. More...
 
class  SVDReconstructionBase
 Class to check whether the reconstruction algorithms are available or not. More...
 
class  SVDRecoPositionFactory
 Cluster Position Factory Class. More...
 
class  SVDRecoTimeFactory
 Cluster Time Factory Class. More...
 
class  SVDShaperDigitSorterModule
 The SVDShaperDigitSorter module. More...
 
class  SVDSimpleClusterizerModule
 SVDSimpleClusterizerModule: The SVD SimpleClusterizer. More...
 
class  SVDSumSamplesCharge
 Derived Class representing the SVD cluster charge computed summing the samples of each strip. More...
 
class  SVDUnpackerModule
 SVDUnpackerModule: The SVD Raw Hits Decoder. More...
 
class  SVDWaveform
 The SVD waveform class. 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 APV samples from waveform. More...
 

Typedefs

typedef std::map< short int, SVDWaveformStripWaveforms
 Map of all channels' waveforms in one sensor side.
 
typedef std::pair< StripWaveforms, StripWaveformsSensorWaveforms
 Waveforms of u- and v- channels in one sensor.
 
typedef std::map< VxdID, SensorWaveformsWaveforms
 Map of all waveforms 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)> WaveformShape
 WaveformShape type.
 

Functions

double w_expo (double t)
 Gamma waveform shape, x.exp(-x) This is only historically useful.
 
double w_poly3 (double t)
 Polynomial waveform shape, x.
 
double w_betaprime (double t)
 Beta-prime waveform shape, x^alpha/(1+x)^beta.
 
double w_adjacentU (double t)
 Adjacent-channel waveform U-side.
 
double w_adjacentV (double t)
 Adjacent-channel waveform V-side.
 
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.
 
 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.
 
 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.
 
 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 (SVDWaveform, Getters)
 Check object creation and simple object getters.
 
 TEST (SVDWaveform, Constructors)
 Check the different constructors.
 
 TEST (SVDWaveform, Assignment)
 Check assignment operators.
 
 TEST (SVDWaveform, Waveform)
 Check the waveform values and relations.
 
 TEST (SVDWaveform, 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.
 

Detailed Description

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

Typedef Documentation

◆ apvSampleBaseType

typedef double apvSampleBaseType

Vector of input samples in float form.

Definition at line 38 of file SVDSimulationTools.h.

◆ apvSamples

vector od apvSample BaseType objects

Definition at line 39 of file SVDSimulationTools.h.

◆ nnFitterBinData

typedef std::vector<double> nnFitterBinData

Vector of values defined for bins, such as bin times or bin probabilities.

Definition at line 30 of file NNWaveFitTool.h.

◆ nnFitterBins

typedef std::vector<double> nnFitterBins

Vector of bin edges, nnFitterBinData.size() + 1.

Definition at line 33 of file NNWaveFitTool.h.

◆ SensitiveDetector

The SVD Sensitive Detector class.

Definition at line 24 of file SensitiveDetector.h.

◆ SensorWaveforms

Waveforms of u- and v- channels in one sensor.

Definition at line 44 of file SVDDigitizerModule.h.

◆ StripWaveforms

typedef std::map<short int, SVDWaveform> StripWaveforms

Map of all channels' waveforms in one sensor side.

Definition at line 41 of file SVDDigitizerModule.h.

◆ Waveforms

typedef std::map<VxdID, SensorWaveforms> Waveforms

Map of all waveforms in all sensors.

Definition at line 47 of file SVDDigitizerModule.h.

◆ WaveformShape

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

WaveformShape type.

This is the type for a naked waveform 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 54 of file SVDSimulationTools.h.

Function Documentation

◆ pass3Samples()

bool pass3Samples ( const T &  a,
double  thr 
)
inline

pass 3-samples

Definition at line 193 of file SVDSimulationTools.h.

194 {
195 return (search_n(a.begin(), a.end(), 3, thr, std::greater<double>()) != a.end());
196 }

◆ tau_raw2real()

double 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 205 of file SVDSimulationTools.h.

205{ return 7.32313 * raw_tau; }

◆ TEST() [1/22]

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 53 of file NNFitterTest.cc.

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

◆ TEST() [2/22]

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 35 of file NNFitterTest.cc.

36 {
37 // Create an instance of the NN fitter
38 NNWaveFitter fitter("svd/data/SVDTimeNet.xml");
39 EXPECT_TRUE(fitter.checkCoefficients("svd/data/classifier.txt", 1.0e-6));
40 }

◆ TEST() [3/22]

TEST ( SVDModeByte  ,
Constructor   
)

Check that both constructors yield the same result.

Definition at line 23 of file SVDModeByte.cc.

24 {
25 // Default construct
26 SVDModeByte s0;
27 SVDModeByte s_def(151);
28 SVDModeByte s_en(SVDRunType::zero_suppressed, SVDEventType::global_run,
29 SVDDAQModeType::daq_6samples, uint8_t(7));
30 SVDModeByte s_num(2, 0, 2, 7);
31
32 EXPECT_EQ(s0, s_def);
33 EXPECT_EQ(s_def, s_en);
34 EXPECT_EQ(s_en, s_num);
35 // Empty
36 EXPECT_EQ(uint8_t(151), s0.getID());
37 EXPECT_EQ((string)s0, "0-suppr/global/6 samples/???");
38 // Malformed
39 s0.setTriggerBin(3);
40 EXPECT_EQ((string)s0, "0-suppr/global/6 samples/3");
41 s0.setDAQMode(1);
42 EXPECT_EQ((string)s0, "0-suppr/global/3 samples/3");
43 }
Class to store SVD mode information.
Definition: SVDModeByte.h:69
void setTriggerBin(baseType triggerBin)
Set the triggerBin id.
Definition: SVDModeByte.h:169
baseType getID() const
Get the unique id.
Definition: SVDModeByte.h:138
void setDAQMode(baseType daqMode)
Set the daqMode id.
Definition: SVDModeByte.h:172

◆ TEST() [4/22]

TEST ( SVDModeByte  ,
getters   
)

Check getters and setters.

Definition at line 46 of file SVDModeByte.cc.

47 {
48 // Construct
49 SVDModeByte s(3, 1, 1, 3);
50 EXPECT_EQ(s.getTriggerBin(), 3);
51 EXPECT_EQ(s.getDAQMode(), SVDDAQModeType::daq_3samples);
52 EXPECT_EQ(s.getEventType(), SVDEventType::local_run);
53 EXPECT_EQ(s.getRunType(), SVDRunType::zero_suppressed_timefit);
54 // Default
55 SVDModeByte s0;
56 EXPECT_EQ(s0.getTriggerBin(), 7);
57 EXPECT_EQ(s0.getDAQMode(), SVDDAQModeType::daq_6samples);
58 }
baseType getTriggerBin() const
Get the triggerBin id.
Definition: SVDModeByte.h:140
baseType getDAQMode() const
Get the daqMode id.
Definition: SVDModeByte.h:142

◆ TEST() [5/22]

TEST ( SVDRecoDigit  ,
ConstructEmpty   
)

Check empty object creation and data getters.

Definition at line 26 of file SVDRecoDigit.cc.

27 {
28 // Create an empty 6-digit
29 SVDRecoDigit digit;
30 // Test getters
31 EXPECT_EQ(VxdID{0}, digit.getSensorID());
32 EXPECT_TRUE(digit.isUStrip());
33 EXPECT_EQ(0, digit.getCellID());
34 EXPECT_EQ(0, digit.getAmplitude());
35 EXPECT_EQ(10, digit.getAmplitudeError());
36 EXPECT_EQ(0, digit.getTime());
37 EXPECT_EQ(100, digit.getTimeError());
39 for (auto prob : pdf)
40 EXPECT_EQ(SVDRecoDigit::OutputProbType(1.0), prob);
41 EXPECT_EQ(100.0, digit.getChi2Ndf());
42 }
The SVD RecoDigit class.
Definition: SVDRecoDigit.h:43
double OutputProbType
Type for output probability array.
Definition: SVDRecoDigit.h:56
OutputProbArray getProbabilities() const
Get signal time pdf.
Definition: SVDRecoDigit.h:144
float getTime() const
Get time estimate.
Definition: SVDRecoDigit.h:134
float getAmplitude() const
Get amplitude estimate.
Definition: SVDRecoDigit.h:119
float getChi2Ndf() const
Get waveform fit chi2/ndf.
Definition: SVDRecoDigit.h:163
VxdID getSensorID() const
Get the sensor ID.
Definition: SVDRecoDigit.h:98
float getAmplitudeError() const
Get amplitude error.
Definition: SVDRecoDigit.h:129
std::vector< OutputProbType > OutputProbArray
vector of OutProbType objects
Definition: SVDRecoDigit.h:57
short int getCellID() const
Get strip ID.
Definition: SVDRecoDigit.h:114
bool isUStrip() const
Get strip direction.
Definition: SVDRecoDigit.h:109
float getTimeError() const
Get time error.
Definition: SVDRecoDigit.h:139
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33

◆ TEST() [6/22]

TEST ( SVDRecoDigit  ,
ConstructFromContainer   
)

Check object creation and data getters using a stl container of probabilities.

Definition at line 47 of file SVDRecoDigit.cc.

48 {
49 // Create an arbitrary recodigit
50 VxdID sensorID(3, 4, 1);
51 short int cellID = 132;
52 float init_charge = 23456;
53 float init_chargeErr = 1234;
54 float init_time = -16;
55 float init_timeErr = 3.21;
56 float init_chi2 = 2.34;
57
58 std::vector<float> init_probs({0.0, 0.01, 0.10, 0.79, 0.06, 0.04});
59 SVDRecoDigit digit(sensorID, false, cellID, init_charge, init_chargeErr, init_time,
60 init_timeErr, init_probs, init_chi2);
61 // Test getters
62 EXPECT_EQ(sensorID, digit.getSensorID());
63 EXPECT_FALSE(digit.isUStrip());
64 EXPECT_EQ(cellID, digit.getCellID());
65 EXPECT_EQ(init_charge, digit.getCharge());
66 EXPECT_EQ(init_chargeErr, digit.getAmplitudeError());
67 EXPECT_EQ(init_time, digit.getTime());
68 EXPECT_EQ(init_timeErr, digit.getTimeError());
69 const SVDRecoDigit::OutputProbArray pdf = digit.getProbabilities();
70 for (size_t ip = 0; ip < pdf.size(); ++ip)
71 EXPECT_LE(fabs(static_cast<SVDRecoDigit::OutputProbType>(init_probs[ip]) - pdf[ip]), 1.0 / SVDRecoDigit::storedProbArrayNorm);
72 // Also, norm must be 1
73 float outputNorm = std::accumulate(pdf.begin(), pdf.end(), 0.0);
74 EXPECT_LE(fabs(1.0 - outputNorm), 1.0e-6);
75 EXPECT_EQ(init_chi2, digit.getChi2Ndf());
76
77 }

◆ TEST() [7/22]

TEST ( SVDRecoDigit  ,
ToString   
)

Check object creation and data getters using a stl container of probabilities.

Definition at line 81 of file SVDRecoDigit.cc.

82 {
83 // Create an arbitrary recodigit
84 VxdID sensorID(3, 4, 1);
85 short int cellID = 132;
86 float init_charge = 23456;
87 float init_chargeErr = 1234;
88 float init_time = -16;
89 float init_timeErr = 3.21;
90 float init_chi2 = 2.34;
91
92 std::vector<float> init_probs({0.0, 0.01, 0.10, 0.79, 0.06, 0.04});
93 SVDRecoDigit digit(sensorID, false, cellID, init_charge, init_chargeErr, init_time,
94 init_timeErr, init_probs, init_chi2);
95 // Test getters
96 std::string
97 digitString("VXDID : 25632 = 3.4.1 strip: V-132 Amplitude: 23456 +/- 1234 Time: -16 +/- 3.21\n probabilities: 0 655 6553 51772 3932 2621 Chi2/ndf: 2.34\n");
98 EXPECT_EQ(digitString, digit.toString());
99 }

◆ TEST() [8/22]

TEST ( SVDRecoTimeBase  ,
ConstructEmpty   
)

Check empty object creation and data getters.

Definition at line 25 of file SVDRecoTimeBase.cc.

26 {
27 // Create an empty time base
28 SVDRecoTimeBase timeBase;
29 // Test getters
30 EXPECT_EQ(VxdID{0}, timeBase.getSensorID());
31 EXPECT_TRUE(timeBase.isUStrip());
32 const SVDRecoTimeBase::BinEdgesArray bins = timeBase.getBins();
33 EXPECT_EQ(0, timeBase.getNBins());
34 for (auto bin : bins)
35 EXPECT_EQ(SVDRecoTimeBase::BinnedDataType(0.0), bin);
36 }
The SVD RecoTimeBase class.
std::size_t getNBins() const
Get number of bins.
const BinEdgesArray & getBins() const
Get the bins array.
float BinnedDataType
Types for bins array.
VxdID getSensorID() const
Get the sensor ID.
std::vector< BinnedDataType > BinEdgesArray
BinEdgesArray[i] is the left edge of bin i.
bool isUStrip() const
Get strip direction.

◆ TEST() [9/22]

TEST ( SVDRecoTimeBase  ,
ConstructFromContainer   
)

Check object creation and data getters.

Definition at line 41 of file SVDRecoTimeBase.cc.

42 {
43 // Create an arbitrary recotimeBase
44 VxdID sensorID(3, 4, 1);
45 std::vector<float> init_bins({ -5.0, -3.0, -1.0, 1.0, 3.0, 5.0});
46 SVDRecoTimeBase timeBase(sensorID, false, init_bins);
47 // Test getters
48 EXPECT_EQ(sensorID, timeBase.getSensorID());
49 EXPECT_FALSE(timeBase.isUStrip());
50 EXPECT_EQ(init_bins.size() - 1, timeBase.getNBins());
51 const SVDRecoTimeBase::BinEdgesArray& bins = timeBase.getBins();
52 for (size_t ib = 0; ib < bins.size(); ++ib)
53 EXPECT_EQ(init_bins[ib], bins[ib]);
54 }

◆ TEST() [10/22]

TEST ( SVDRecoTimeBase  ,
toString   
)

Check object printout.

Definition at line 58 of file SVDRecoTimeBase.cc.

59 {
60 // Create an arbitrary recotimeBase
61 VxdID sensorID(3, 4, 1);
62 std::vector<float> init_bins({ -5.0, -3.0, -1.0, 1.0, 3.0, 5.0});
63 SVDRecoTimeBase timeBase(sensorID, false, init_bins);
64 // Test toString method
65 EXPECT_EQ("VXDID : 25632 = 3.4.1 side: V bins: -5 -3 -1 1 3 5 ", timeBase.toString());
66 }

◆ TEST() [11/22]

TEST ( SVDShaperDigit  ,
ConstructDefaultTimeMode   
)

Check standard object creation without FADC time and mode information.

Definition at line 90 of file SVDShaperDigit.cc.

91 {
92 // Create an arbitrary 6-digit
93 VxdID sensorID(3, 4, 1);
94 short int cellID = 132;
95
96 double init_samples[6] = {0, 5, 10, 9, 6, 5};
97 SVDShaperDigit digit(sensorID, false, cellID, init_samples);
98 // Test that time and error are set correctly.
99 EXPECT_EQ(0.0, digit.getFADCTime());
100 }
The SVD ShaperDigit class.

◆ TEST() [12/22]

TEST ( SVDShaperDigit  ,
ConstructEmpty   
)

Check empty object creation and data getters.

Definition at line 26 of file SVDShaperDigit.cc.

27 {
28 // Create an empty 6-digit
29 SVDShaperDigit digit;
30 // Test getters
31 EXPECT_EQ(VxdID{0}, digit.getSensorID());
32 EXPECT_TRUE(digit.isUStrip());
33 EXPECT_EQ(0, digit.getCellID());
34 const SVDShaperDigit::APVFloatSamples& samples = digit.getSamples();
35 for (auto sample : samples)
36 EXPECT_EQ(SVDShaperDigit::APVFloatSampleType(0), sample);
37 EXPECT_EQ(0.0, digit.getFADCTime());
38 }
std::array< APVFloatSampleType, c_nAPVSamples > APVFloatSamples
array of APVFloatSampleType objects
float APVFloatSampleType
Types for array of samples for processing.
VxdID getSensorID() const
Get the sensor ID.
APVFloatSamples getSamples() const
Get array of samples.
short int getCellID() const
Get strip ID.
bool isUStrip() const
Get strip direction.
float getFADCTime() const
Get digit FADCTime estimate.

◆ TEST() [13/22]

TEST ( SVDShaperDigit  ,
ConstructFromCArray   
)

Check object creation and data getters using a c-array of samples.

Definition at line 66 of file SVDShaperDigit.cc.

67 {
68 // Create an arbitrary 6-digit
69 VxdID sensorID(3, 4, 1);
70 short int cellID = 132;
71 char digitFADCTime(-16);
72
73 // floats must work, too.
74 float init_samples[SVDShaperDigit::c_nAPVSamples] = {0, 5, 10, 9, 6, 5};
75 SVDShaperDigit digit(
76 sensorID, false, cellID, init_samples, digitFADCTime);
77 // Test getters
78 EXPECT_EQ(sensorID, digit.getSensorID());
79 EXPECT_FALSE(digit.isUStrip());
80 EXPECT_EQ(cellID, digit.getCellID());
81 const SVDShaperDigit::APVFloatSamples& samples = digit.getSamples();
82 for (size_t isample = 0; isample < SVDShaperDigit::c_nAPVSamples; ++isample)
83 EXPECT_EQ(static_cast<SVDShaperDigit::APVFloatSampleType>(init_samples[isample]),
84 samples[isample]);
85 EXPECT_EQ(static_cast<float>(digitFADCTime), digit.getFADCTime());
86 }

◆ TEST() [14/22]

TEST ( SVDShaperDigit  ,
ConstructFromContainer   
)

Check object creation and data getters using a stl container of samples.

Definition at line 43 of file SVDShaperDigit.cc.

44 {
45 // Create an arbitrary 6-digit
46 VxdID sensorID(3, 4, 1);
47 short int cellID = 132;
48 char digitFADCTime(-16);
49
50 std::vector<int> init_samples({0, 5, 10, 9, 6, 5});
51 SVDShaperDigit digit(sensorID, false, cellID, init_samples, digitFADCTime);
52 // Test getters
53 EXPECT_EQ(sensorID, digit.getSensorID());
54 EXPECT_FALSE(digit.isUStrip());
55 EXPECT_EQ(cellID, digit.getCellID());
56 const SVDShaperDigit::APVFloatSamples& samples = digit.getSamples();
57 for (size_t isample = 0; isample < SVDShaperDigit::c_nAPVSamples; ++isample)
58 EXPECT_EQ(static_cast<SVDShaperDigit::APVFloatSampleType>(init_samples[isample]),
59 samples[isample]);
60 EXPECT_EQ(static_cast<float>(digitFADCTime), digit.getFADCTime());
61 }

◆ TEST() [15/22]

TEST ( SVDShaperDigit  ,
SampleTrimming   
)

test sample trimming

Definition at line 103 of file SVDShaperDigit.cc.

104 {
105 // Create an arbitrary 6-digit
106 VxdID sensorID(3, 4, 1);
107 short int cellID = 132;
108
109 auto sampleMin =
110 static_cast<SVDShaperDigit::APVFloatSampleType>(std::numeric_limits<SVDShaperDigit::APVRawSampleType>::lowest());
111 auto sampleMax =
112 static_cast<SVDShaperDigit::APVFloatSampleType>(std::numeric_limits<SVDShaperDigit::APVRawSampleType>::max());
113
114 std::vector<float> init_samples({0, -10, 255, 256, 500, -1});
115 SVDShaperDigit digit(sensorID, false, cellID, init_samples);
116 const auto& samples = digit.getSamples();
117 for (size_t isample = 0; isample < SVDShaperDigit::c_nAPVSamples; ++isample) {
118 auto trimmedSample = std::max(sampleMin, std::min(sampleMax, init_samples[isample]));
119 EXPECT_EQ(trimmedSample, samples[isample]);
120 }
121 }

◆ TEST() [16/22]

TEST ( SVDShaperDigit  ,
TrimmingFunction   
)

test sample trimming

Definition at line 124 of file SVDShaperDigit.cc.

125 {
126
127 // Create an arbitrary 6-digit
128 auto sampleMin =
129 static_cast<SVDShaperDigit::APVFloatSampleType>(std::numeric_limits<SVDShaperDigit::APVRawSampleType>::lowest());
130 auto sampleMax =
131 static_cast<SVDShaperDigit::APVFloatSampleType>(std::numeric_limits<SVDShaperDigit::APVRawSampleType>::max());
132
133 std::vector<float> init_samples({0, -10, 255, 256, 500, -1});
134 for (size_t isample = 0; isample < SVDShaperDigit::c_nAPVSamples; ++isample) {
135 auto trimmedSample = std::max(sampleMin, std::min(sampleMax, init_samples[isample]));
136 EXPECT_EQ(trimmedSample, SVDShaperDigit::trimToSampleRange(init_samples[isample]));
137 }
138 }

◆ TEST() [17/22]

TEST ( SVDWaveform  ,
Assignment   
)

Check assignment operators.

Definition at line 94 of file SVDWaveform.cc.

95 {
96 // Create an artificial waveform and load it with data.
97 vector<double> charges;
98 charges.push_back(10);
99 charges.push_back(11);
100 charges.push_back(30);
101 vector<double> times;
102 for (int i = 0; i < 3; ++i) times.push_back(i * 15.0e-9);
103 vector<RelationElement::index_type> mcParticles;
104 for (int i = 0; i < 3; ++i) mcParticles.push_back(3 * i);
105 vector<RelationElement::index_type> trueHits;
106 for (int i = 0; i < 3; ++i) trueHits.push_back(7 * i);
107 const float tau = 25.0e-9;
108 SVDWaveform waveform;
109 for (int i = 0; i < 3; ++i) waveform.add(times.at(i), charges.at(i), tau, mcParticles.at(i), trueHits.at(i));
110 // Test the assignment operator
111 SVDWaveform waveform2 = waveform;
112 double totalcharge = 0;
113 for (int i = 0; i < 3; ++i) totalcharge += charges.at(i);
114 EXPECT_EQ(waveform2.getCharge(), totalcharge);
115 //Test SVDWaveform::getElementaryWaveforms()
117 for (int i = 0; i < 3; ++i) {
118 EXPECT_EQ(functions.at(i).m_initTime, times.at(i));
119 EXPECT_EQ(functions.at(i).m_charge, charges.at(i));
120 EXPECT_EQ(functions.at(i).m_tau, tau);
121 EXPECT_EQ(functions.at(i).m_particle, mcParticles.at(i));
122 EXPECT_EQ(functions.at(i).m_truehit, trueHits.at(i));
123 }
124 }
The SVD waveform class.
Definition: SVDWaveform.h:38
void add(double initTime, double charge, double tau, int particle=-1, int truehit=-1, WaveformShape wfun=w_betaprime)
Add a chargelet waveform to the total strip waveform.
Definition: SVDWaveform.h:106
std::deque< ElementaryWaveform > elementary_waveform_list
List of elementary waveforms.
Definition: SVDWaveform.h:77
double getCharge() const
Return the charge collected in the strip.
Definition: SVDWaveform.h:169
const elementary_waveform_list & getElementaryWaveforms() const
Return the list of waveform parameters.
Definition: SVDWaveform.h:174

◆ TEST() [18/22]

TEST ( SVDWaveform  ,
Constructors   
)

Check the different constructors.

Definition at line 59 of file SVDWaveform.cc.

60 {
61 // Create an artificial waveform and load it with data.
62 vector<double> charges;
63 charges.push_back(10);
64 charges.push_back(11);
65 charges.push_back(30);
66 vector<double> times;
67 for (int i = 0; i < 3; ++i) times.push_back(i * 15.0e-9);
68 vector<RelationElement::index_type> mcParticles;
69 for (int i = 0; i < 3; ++i) mcParticles.push_back(3 * i);
70 vector<RelationElement::index_type> trueHits;
71 for (int i = 0; i < 3; ++i) trueHits.push_back(7 * i);
72 const float tau = 25.0e-9;
73 SVDWaveform waveform;
74 for (int i = 0; i < 3; ++i) waveform.add(times.at(i), charges.at(i), tau, mcParticles.at(i), trueHits.at(i));
75 // Test the copy constructor
76 SVDWaveform waveform2(waveform);
77 double totalcharge = 0;
78 for (int i = 0; i < 3; ++i) totalcharge += charges.at(i);
79 EXPECT_EQ(waveform2.getCharge(), totalcharge);
80 //Test SVDWaveform::getElementaryWaveforms()
81 SVDWaveform::elementary_waveform_list functions = waveform2.getElementaryWaveforms();
82 size_t n = functions.size();
83 EXPECT_EQ(n, 3);
84 for (int i = 0; i < 3; ++i) {
85 EXPECT_EQ(functions.at(i).m_initTime, times.at(i));
86 EXPECT_EQ(functions.at(i).m_charge, charges.at(i));
87 EXPECT_EQ(functions.at(i).m_tau, tau);
88 EXPECT_EQ(functions.at(i).m_particle, mcParticles.at(i));
89 EXPECT_EQ(functions.at(i).m_truehit, trueHits.at(i));
90 }
91 }

◆ TEST() [19/22]

TEST ( SVDWaveform  ,
Getters   
)

Check object creation and simple object getters.

Definition at line 27 of file SVDWaveform.cc.

28 {
29 // First create an artificial waveform and load it with data.
30 vector<double> charges;
31 charges.push_back(10);
32 charges.push_back(11);
33 charges.push_back(30);
34 vector<double> times;
35 for (int i = 0; i < 3; ++i) times.push_back(i * 15.0e-9);
36 vector<RelationElement::index_type> mcParticles;
37 for (int i = 0; i < 3; ++i) mcParticles.push_back(3 * i);
38 vector<RelationElement::index_type> trueHits;
39 for (int i = 0; i < 3; ++i) trueHits.push_back(7 * i);
40 const float tau = 25.0e-9;
41 SVDWaveform waveform;
42 for (int i = 0; i < 3; ++i) waveform.add(times.at(i), charges.at(i), tau, mcParticles.at(i), trueHits.at(i));
43 // Test SVDWaveform::getCharge()
44 double totalcharge = 0;
45 for (int i = 0; i < 3; ++i) totalcharge += charges.at(i);
46 EXPECT_EQ(waveform.getCharge(), totalcharge);
47 //Test SVDWaveform::getElementaryWaveforms()
49 for (int i = 0; i < 3; ++i) {
50 EXPECT_EQ(functions.at(i).m_initTime, times.at(i));
51 EXPECT_EQ(functions.at(i).m_charge, charges.at(i));
52 EXPECT_EQ(functions.at(i).m_tau, tau);
53 EXPECT_EQ(functions.at(i).m_particle, mcParticles.at(i));
54 EXPECT_EQ(functions.at(i).m_truehit, trueHits.at(i));
55 }
56 }

◆ TEST() [20/22]

TEST ( SVDWaveform  ,
toString   
)

Check the waveform string representation.

Definition at line 156 of file SVDWaveform.cc.

157 {
158 // Create an artificial waveform and load it with data.
159 vector<double> charges;
160 charges.push_back(10);
161 charges.push_back(11);
162 charges.push_back(30);
163 vector<double> times;
164 for (int i = 0; i < 3; ++i) times.push_back(i * 15.0e-9);
165 vector<RelationElement::index_type> mcParticles;
166 for (int i = 0; i < 3; ++i) mcParticles.push_back(3 * i);
167 vector<RelationElement::index_type> trueHits;
168 for (int i = 0; i < 3; ++i) trueHits.push_back(7 * i);
169 const float tau = 50.0e-9; // 25 ns shaping time
170 SVDWaveform waveform;
171 for (int i = 0; i < 3; ++i) waveform.add(times.at(i), charges.at(i), tau, mcParticles.at(i), trueHits.at(i));
172 std::ostringstream os;
173 for (int i = 0; i < 3; ++i)
174 os << i + 1 << '\t' << times.at(i) << '\t' << charges.at(i) << '\t' << tau << std::endl;
175 EXPECT_EQ(waveform.toString(), os.str());
176 }
std::string toString() const
Produce a string representation of the object.
Definition: SVDWaveform.h:186

◆ TEST() [21/22]

TEST ( SVDWaveform  ,
Waveform   
)

Check the waveform values and relations.

Definition at line 127 of file SVDWaveform.cc.

128 {
129 // Create an artificial waveform and load it with data.
130 vector<double> charges;
131 charges.push_back(10);
132 charges.push_back(11);
133 charges.push_back(30);
134 vector<double> times;
135 for (int i = 0; i < 3; ++i) times.push_back(i * 15.0e-9);
136 vector<RelationElement::index_type> mcParticles;
137 for (int i = 0; i < 3; ++i) mcParticles.push_back(3 * i);
138 vector<RelationElement::index_type> trueHits;
139 for (int i = 0; i < 3; ++i) trueHits.push_back(7 * i);
140 const float tau = 25.0e-9; // 25 ns shaping time
141 SVDWaveform waveform;
142 for (int i = 0; i < 3; ++i) waveform.add(times.at(i), charges.at(i), tau, mcParticles.at(i), trueHits.at(i));
143 // Test operator()
144 double time = 40.0e-9; // 40 ns
145 // expected function value
146 double expected_value = 0;
148 double value = waveform.waveform(time, wave);
149 expected_value += value;
150 }
151 double function_value = waveform(time);
152 EXPECT_EQ(function_value, expected_value);
153 }
double waveform(double t, double initTime, double charge, double tau, WaveformShape wfun=w_betaprime) const
Waveform shape.
Definition: SVDWaveform.h:138
Type to store elementary waveform parameters.
Definition: SVDWaveform.h:48

◆ TEST() [22/22]

TEST ( TNiel  ,
output   
)

Check correct functioning of the class.

Definition at line 25 of file niel_fun.cc.

26 {
27 // First create a niel function and load it with data.
28 TNiel niel("vxd/tests/niel_test.csv");
29 // Value from within the range
30 EXPECT_EQ(niel.getNielFactor(3.0), 3.126E-2);
31 // Underflow value
32 EXPECT_EQ(niel.getNielFactor(0.0), 1.543E-2);
33 // Overflow value
34 EXPECT_EQ(niel.getNielFactor(20.0), 5.160E-2);
35 }
TNiel - the class providing values for NIEL factors.
Definition: niel_fun.h:17

◆ w_adjacentU()

double w_adjacentU ( double  t)
inline

Adjacent-channel waveform U-side.

The exact parametrisation is to be determined.

Parameters
tProperly scaled time, (t - t0)/tau.
Returns
Waveform value (TBD).

Definition at line 99 of file SVDSimulationTools.h.

100 {
101
102 double p[8];
103
104 // waveform parameters
105 p[0] = -7.379;
106 p[1] = -0.3594;
107 p[2] = 0.07564;
108 p[3] = 7.391;
109 p[4] = -0.08004;
110 p[5] = -2.139e-5;
111 p[6] = -1.781e-7;
112 p[7] = 0.01827;
113
114 if (t < 0.0)
115 return 0.0;
116 else
117 return (p[0] + p[1] * t) * exp(-p[2] * t) + (p[3] + p[4] * t + p[5] * pow(t, 2) + p[6] * pow(t, 3)) * exp(-p[7] * t);
118 }

◆ w_adjacentV()

double w_adjacentV ( double  t)
inline

Adjacent-channel waveform V-side.

The exact parametrisation is to be determined.

Parameters
tProperly scaled time, (t - t0)/tau.
Returns
Waveform value (TBD).

Definition at line 125 of file SVDSimulationTools.h.

126 {
127
128 double p[8];
129
130 // waveform parameters
131 p[0] = 0.2043;
132 p[1] = -0.0197;
133 p[2] = 0.01448;
134 p[3] = -0.2076;
135 p[4] = 0.0387;
136 p[5] = 0.01055;
137 p[6] = -4.03e-6;
138 p[7] = 0.07193;
139
140 if (t < 0.0)
141 return 0.0;
142 else
143 return (p[0] + p[1] * t) * exp(-p[2] * t) + (p[3] + p[4] * t + p[5] * pow(t, 2) + p[6] * pow(t, 3)) * exp(-p[7] * t);
144 }

◆ w_betaprime()

double w_betaprime ( double  t)
inline

Beta-prime waveform shape, x^alpha/(1+x)^beta.

This is the function for general use.

Parameters
tProperly scaled time, (t - t0)/tau.
Returns
Waveform value 149.012 * t^2 / (1+t)^10 for t > 0, else 0

Definition at line 86 of file SVDSimulationTools.h.

87 {
88 if (t < 0.0)
89 return 0.0;
90 else
91 return 149.012 * pow(t, 2) * pow(1.0 + t, -10);
92 }

◆ w_expo()

double w_expo ( double  t)
inline

Gamma waveform shape, 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 61 of file SVDSimulationTools.h.

62 {
63 if (t < 0.0) return 0.0;
64 else return t * exp(1.0 - t);
65 }

◆ w_poly3()

double w_poly3 ( double  t)
inline

Polynomial waveform shape, 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 73 of file SVDSimulationTools.h.

74 {
75 if (t < 0.0 || t > 1.0)
76 return 0.0;
77 else
78 return 6.75 * t * (1.0 - t) * (1.0 - t);
79 }

◆ zeroSuppress()

void zeroSuppress ( T &  a,
double  thr 
)
inline

pass zero suppression

Definition at line 182 of file SVDSimulationTools.h.

183 {
184 std::replace_if(a.begin(), a.end(), std::bind(std::less<double>(), std::placeholders::_1, thr), 0.0);
185 }

Variable Documentation

◆ apvTimeBase

const apvSamples apvTimeBase
Initial value:
=
{{ -dt_APV, 0.0, dt_APV, 2 * dt_APV, 3 * dt_APV, 4 * dt_APV}}
const double dt_APV
APV sampling time.

APV time base - times for the 6 signals.

Definition at line 42 of file SVDSimulationTools.h.

◆ dt_APV

const double dt_APV = 31.44 * Unit::ns

APV sampling time.

Definition at line 35 of file SVDSimulationTools.h.

◆ nAPVSamples

const std::size_t nAPVSamples = 6

Number of APV samples.

Definition at line 32 of file SVDSimulationTools.h.