Belle II Software development
SVDRecoDigit.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#ifndef SVD_RECODIGIT_H
10#define SVD_RECODIGIT_H
11
12#include <vxd/dataobjects/VxdID.h>
13#include <framework/datastore/RelationsObject.h>
14
15#include <vector>
16#include <cstdint>
17#include <sstream>
18#include <string>
19#include <algorithm>
20#include <numeric>
21
22namespace Belle2 {
44
45 public:
46
49 typedef uint16_t StoredProbType;
50 typedef std::vector<StoredProbType> StoredProbArray;
51 static const uint16_t storedProbArrayNorm = UINT16_MAX;
56 typedef double OutputProbType;
57 typedef std::vector<OutputProbType> OutputProbArray;
70 template<typename T>
71 SVDRecoDigit(VxdID sensorID, bool isU, short cellID, float fittedAmplitude,
72 float fittedAmplitudeError, float fittedTime, float fittedTimeError,
73 const T& probabilities, float chi2):
74 m_sensorID(sensorID), m_isU(isU), m_cellID(cellID),
75 m_fittedAmplitude(fittedAmplitude), m_fittedAmplitudeError(fittedAmplitudeError),
76 m_fittedTime(fittedTime), m_fittedTimeError(fittedTimeError), m_fitChi2Ndf(chi2)
77 {
78 // Expecting input array normalized to 1, but don't rely on it.
79 double inputNorm = std::accumulate(probabilities.begin(), probabilities.end(), 0.0);
80 if (inputNorm < 0.1) inputNorm = 1.0;
81 double normCoef = static_cast<double>(storedProbArrayNorm) / inputNorm;
82 std::transform(probabilities.begin(), probabilities.end(),
83 std::back_inserter(m_probabilities),
84 [normCoef](typename T::value_type x)->StoredProbType
85 { return static_cast<StoredProbType>(normCoef * x); }
86 );
87 }
88
91 0, true, 0, 0.0, 10.0, 0.0, 100.0, std::vector<double>({1.0}), 100.0
92 )
93 { }
94
98 VxdID getSensorID() const { return m_sensorID; }
99
105
109 bool isUStrip() const { return m_isU; }
110
114 short int getCellID() const { return m_cellID; }
115
119 float getAmplitude() const { return m_fittedAmplitude; }
120
124 float getCharge() const { return m_fittedAmplitude; }
125
130
134 float getTime() const { return m_fittedTime; }
135
139 float getTimeError() const { return m_fittedTimeError; }
140
145 {
146 OutputProbArray outputPdf;
147 // We need to get the norm, may be different
148 int storeNorm = std::accumulate(m_probabilities.begin(), m_probabilities.end(), 0.0,
149 [](int x, StoredProbType y) -> int { return x + y; });
150 double normCoef = static_cast<double>(1.0 / storeNorm);
151 if (normCoef < 1.0e-15) normCoef = 1.0;
152 std::transform(m_probabilities.begin(), m_probabilities.end(),
153 std::back_inserter(outputPdf),
154 [normCoef](StoredProbType x)-> OutputProbType
155 { return static_cast<OutputProbType>(normCoef * x); }
156 );
157 return outputPdf;
158 }
159
163 float getChi2Ndf() const { return m_fitChi2Ndf; }
164
166 std::string toString() const
167 {
168 VxdID thisSensorID(m_sensorID);
169
170 std::ostringstream os;
171 os << "VXDID : " << m_sensorID << " = " << std::string(thisSensorID) << " strip: "
172 << ((m_isU) ? "U-" : "V-") << m_cellID
173 << " Amplitude: " << m_fittedAmplitude << " +/- " << m_fittedAmplitudeError
174 << " Time: " << m_fittedTime << " +/- " << m_fittedTimeError << std::endl
175 << " probabilities: ";
176 std::copy(m_probabilities.begin(), m_probabilities.end(),
177 std::ostream_iterator<StoredProbType>(os, " "));
178 os << "Chi2/ndf: " << m_fitChi2Ndf << std::endl;
179 return os.str();
180 }
181
182 private:
183
185 bool m_isU;
186 short m_cellID;
187 // float m_stripNoise; /**< Noise of the strip, from calibration. */
196
197 }; // class SVDRecoDigit
198
200} // end namespace Belle2
201
202#endif // SVD_RECODIGIT_H
Defines interface for accessing relations of objects in StoreArray.
ClassDef(RelationsInterface, 0)
defines interface for accessing relations of objects in StoreArray.
The SVD RecoDigit class.
Definition: SVDRecoDigit.h:43
SVDRecoDigit()
Default constructor for the ROOT IO.
Definition: SVDRecoDigit.h:90
double OutputProbType
Type for output probability array.
Definition: SVDRecoDigit.h:56
OutputProbArray getProbabilities() const
Get signal time pdf.
Definition: SVDRecoDigit.h:144
StoredProbArray m_probabilities
pdf of the time estimate.
Definition: SVDRecoDigit.h:192
float m_fitChi2Ndf
Standardized chi2 of the fit.
Definition: SVDRecoDigit.h:193
bool m_isU
True if U, false if V.
Definition: SVDRecoDigit.h:185
std::string toString() const
Display main parameters in this object.
Definition: SVDRecoDigit.h:166
float getTime() const
Get time estimate.
Definition: SVDRecoDigit.h:134
VxdID::baseType m_sensorID
Compressed sensor identifier.
Definition: SVDRecoDigit.h:184
float getAmplitude() const
Get amplitude estimate.
Definition: SVDRecoDigit.h:119
SVDRecoDigit(VxdID sensorID, bool isU, short cellID, float fittedAmplitude, float fittedAmplitudeError, float fittedTime, float fittedTimeError, const T &probabilities, float chi2)
Constructor using a stl container of time bin probabilities.
Definition: SVDRecoDigit.h:71
VxdID::baseType getRawSensorID() const
Get raw sensor ID.
Definition: SVDRecoDigit.h:104
uint16_t StoredProbType
Types for internal storage of probability array.
Definition: SVDRecoDigit.h:49
std::vector< StoredProbType > StoredProbArray
vector of StoreProbType objects
Definition: SVDRecoDigit.h:50
float m_fittedAmplitude
Fitted amplitude of the signal ("charge")
Definition: SVDRecoDigit.h:188
float m_fittedTime
Fitted arrival time of the signal.
Definition: SVDRecoDigit.h:190
float getCharge() const
Get amplitude estimate, alternate getter name.
Definition: SVDRecoDigit.h:124
float getChi2Ndf() const
Get waveform fit chi2/ndf.
Definition: SVDRecoDigit.h:163
short m_cellID
Strip coordinate in pitch units.
Definition: SVDRecoDigit.h:186
VxdID getSensorID() const
Get the sensor ID.
Definition: SVDRecoDigit.h:98
static const uint16_t storedProbArrayNorm
some constant
Definition: SVDRecoDigit.h:51
float m_fittedTimeError
Error estimate of time fit.
Definition: SVDRecoDigit.h:191
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
float m_fittedAmplitudeError
Error estimate of amplitude fit.
Definition: SVDRecoDigit.h:189
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
unsigned short baseType
The base integer type for VxdID.
Definition: VxdID.h:36
Abstract base class for different kinds of events.
STL namespace.