Belle II Software  release-05-01-25
SVDRecoDigit.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Peter Kvasnicka *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef SVD_RECODIGIT_H
12 #define SVD_RECODIGIT_H
13 
14 #include <vxd/dataobjects/VxdID.h>
15 #include <svd/dataobjects/SVDModeByte.h>
16 #include <framework/datastore/RelationsObject.h>
17 
18 #include <vector>
19 #include <cstdint>
20 #include <sstream>
21 #include <string>
22 #include <algorithm>
23 #include <numeric>
24 
25 namespace Belle2 {
46  class SVDRecoDigit : public RelationsObject {
47 
48  public:
49 
52  typedef uint16_t StoredProbType;
53  typedef std::vector<StoredProbType> StoredProbArray;
54  static const uint16_t storedProbArrayNorm = UINT16_MAX;
59  typedef double OutputProbType;
60  typedef std::vector<OutputProbType> OutputProbArray;
75  template<typename T>
76  SVDRecoDigit(VxdID sensorID, bool isU, short cellID, float fittedAmplitude,
77  float fittedAmplitudeError, float fittedTime, float fittedTimeError,
78  const T& probabilities, float chi2, SVDModeByte mode = SVDModeByte()):
79  m_sensorID(sensorID), m_isU(isU), m_cellID(cellID),
80  m_fittedAmplitude(fittedAmplitude), m_fittedAmplitudeError(fittedAmplitudeError),
81  m_fittedTime(fittedTime), m_fittedTimeError(fittedTimeError), m_fitChi2Ndf(chi2),
82  m_mode(mode.getID())
83  {
84  // Expecting input array normalized to 1, but don't rely on it.
85  double inputNorm = std::accumulate(probabilities.begin(), probabilities.end(), 0.0);
86  if (inputNorm < 0.1) inputNorm = 1.0;
87  double normCoef = static_cast<double>(storedProbArrayNorm) / inputNorm;
88  std::transform(probabilities.begin(), probabilities.end(),
89  std::back_inserter(m_probabilities),
90  [normCoef](typename T::value_type x)->StoredProbType
91  { return static_cast<StoredProbType>(normCoef * x); }
92  );
93  }
94 
97  0, true, 0, 0.0, 10.0, 0.0, 100.0, std::vector<double>( {1.0}), 100.0
98  )
99  { }
100 
104  VxdID getSensorID() const { return m_sensorID; }
105 
110  VxdID::baseType getRawSensorID() const { return m_sensorID; }
111 
115  bool isUStrip() const { return m_isU; }
116 
120  short int getCellID() const { return m_cellID; }
121 
125  float getAmplitude() const { return m_fittedAmplitude; }
126 
130  float getCharge() const { return m_fittedAmplitude; }
131 
135  float getAmplitudeError() const { return m_fittedAmplitudeError; }
136 
140  float getTime() const { return m_fittedTime; }
141 
145  float getTimeError() const { return m_fittedTimeError; }
146 
151  {
152  OutputProbArray outputPdf;
153  // We need to get the norm, may be different
154  int storeNorm = std::accumulate(m_probabilities.begin(), m_probabilities.end(), 0.0,
155  [](int x, StoredProbType y) -> int { return x + y; });
156  double normCoef = static_cast<double>(1.0 / storeNorm);
157  if (normCoef < 1.0e-15) normCoef = 1.0;
158  std::transform(m_probabilities.begin(), m_probabilities.end(),
159  std::back_inserter(outputPdf),
160  [normCoef](StoredProbType x)-> OutputProbType
161  { return static_cast<OutputProbType>(normCoef * x); }
162  );
163  return outputPdf;
164  }
165 
169  float getChi2Ndf() const { return m_fitChi2Ndf; }
170 
174  SVDModeByte getModeByte() const
175  { return m_mode; }
176 
178  std::string toString() const
179  {
180  VxdID thisSensorID(m_sensorID);
181  SVDModeByte thisMode(m_mode);
182 
183  std::ostringstream os;
184  os << "VXDID : " << m_sensorID << " = " << std::string(thisSensorID) << " strip: "
185  << ((m_isU) ? "U-" : "V-") << m_cellID
186  << " Amplitude: " << m_fittedAmplitude << " +/- " << m_fittedAmplitudeError
187  << " Time: " << m_fittedTime << " +/- " << m_fittedTimeError << std::endl
188  << " probabilities: ";
189  std::copy(m_probabilities.begin(), m_probabilities.end(),
190  std::ostream_iterator<StoredProbType>(os, " "));
191  os << "Chi2/ndf: " << m_fitChi2Ndf << " " << thisMode << std::endl;
192  return os.str();
193  }
194 
195  private:
196 
198  bool m_isU;
199  short m_cellID;
200  // float m_stripNoise; /**< Noise of the strip, from calibration. */
201  float m_fittedAmplitude;
202  float m_fittedAmplitudeError;
203  float m_fittedTime;
204  float m_fittedTimeError;
206  float m_fitChi2Ndf;
210 
211  }; // class SVDRecoDigit
212 
214 } // end namespace Belle2
215 
216 #endif // SVD_RECODIGIT_H
Belle2::SVDRecoDigit::getProbabilities
OutputProbArray getProbabilities() const
Get signal time pdf.
Definition: SVDRecoDigit.h:158
Belle2::SVDRecoDigit::m_fittedAmplitude
float m_fittedAmplitude
Fitted amplitude of the signal ("charge")
Definition: SVDRecoDigit.h:209
Belle2::SVDRecoDigit::m_cellID
short m_cellID
Strip coordinate in pitch units.
Definition: SVDRecoDigit.h:207
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::SVDRecoDigit::getChi2Ndf
float getChi2Ndf() const
Get waveform fit chi2/ndf.
Definition: SVDRecoDigit.h:177
Belle2::SVDRecoDigit::StoredProbType
uint16_t StoredProbType
Types for internal storage of probability array.
Definition: SVDRecoDigit.h:60
Belle2::SVDRecoDigit::getTime
float getTime() const
Get time estimate @returm fitted signal arrival time.
Definition: SVDRecoDigit.h:148
Belle2::SVDRecoDigit::storedProbArrayNorm
static const uint16_t storedProbArrayNorm
some constant
Definition: SVDRecoDigit.h:62
Belle2::SVDRecoDigit::isUStrip
bool isUStrip() const
Get strip direction.
Definition: SVDRecoDigit.h:123
Belle2::getID
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
Definition: calibTools.h:71
Belle2::RelationsInterface::ClassDef
ClassDef(RelationsInterface, 0)
defines interface for accessing relations of objects in StoreArray.
Belle2::SVDRecoDigit::m_sensorID
VxdID::baseType m_sensorID
Compressed sensor identifier.
Definition: SVDRecoDigit.h:205
Belle2::SVDModeByte
Class to store SVD mode information.
Definition: SVDModeByte.h:79
Belle2::SVDRecoDigit::m_fitChi2Ndf
float m_fitChi2Ndf
Standardized chi2 of the fit.
Definition: SVDRecoDigit.h:214
Belle2::SVDRecoDigit::SVDRecoDigit
SVDRecoDigit()
Default constructor for the ROOT IO.
Definition: SVDRecoDigit.h:104
Belle2::SVDRecoDigit::getRawSensorID
VxdID::baseType getRawSensorID() const
Get raw sensor ID.
Definition: SVDRecoDigit.h:118
Belle2::SVDRecoDigit::toString
std::string toString() const
Display main parameters in this object.
Definition: SVDRecoDigit.h:186
Belle2::SVDRecoDigit::OutputProbType
double OutputProbType
Type for output probability array.
Definition: SVDRecoDigit.h:67
Belle2::SVDRecoDigit::m_fittedAmplitudeError
float m_fittedAmplitudeError
Error estimate of amplitude fit.
Definition: SVDRecoDigit.h:210
Belle2::VxdID::baseType
unsigned short baseType
The base integer type for VxdID.
Definition: VxdID.h:46
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SVDModeByte::baseType
uint8_t baseType
The base integer type for SVDModeByte.
Definition: SVDModeByte.h:82
Belle2::SVDRecoDigit::getAmplitude
float getAmplitude() const
Get amplitude estimate.
Definition: SVDRecoDigit.h:133
Belle2::SVDRecoDigit::getSensorID
VxdID getSensorID() const
Get the sensor ID.
Definition: SVDRecoDigit.h:112
Belle2::SVDRecoDigit::getCellID
short int getCellID() const
Get strip ID.
Definition: SVDRecoDigit.h:128
Belle2::SVDRecoDigit::getTimeError
float getTimeError() const
Get time error.
Definition: SVDRecoDigit.h:153
Belle2::SVDRecoDigit::m_probabilities
StoredProbArray m_probabilities
pdf of the time estimate.
Definition: SVDRecoDigit.h:213
Belle2::RelationsObject
RelationsInterface< TObject > RelationsObject
Provides interface for getting/adding relations to objects in StoreArrays.
Definition: RelationsObject.h:443
Belle2::SVDRecoDigit::m_fittedTimeError
float m_fittedTimeError
Error estimate of time fit.
Definition: SVDRecoDigit.h:212
Belle2::SVDRecoDigit::getModeByte
SVDModeByte getModeByte() const
Get the SVDMOdeByte object containing information on trigger FADCTime and DAQ mode.
Definition: SVDRecoDigit.h:182
Belle2::SVDRecoDigit::m_mode
SVDModeByte::baseType m_mode
Mode byte, trigger FADCTime + DAQ mode.
Definition: SVDRecoDigit.h:215
Belle2::SVDRecoDigit::getCharge
float getCharge() const
Get amplitude estimate, alternate getter name.
Definition: SVDRecoDigit.h:138
Belle2::SVDRecoDigit::m_isU
bool m_isU
True if U, false if V.
Definition: SVDRecoDigit.h:206
Belle2::SVDRecoDigit
The SVD RecoDigit class.
Definition: SVDRecoDigit.h:54
Belle2::SVDRecoDigit::StoredProbArray
std::vector< StoredProbType > StoredProbArray
vector of StoreProbType objects
Definition: SVDRecoDigit.h:61
Belle2::SVDRecoDigit::OutputProbArray
std::vector< OutputProbType > OutputProbArray
vector of OutProbType objects
Definition: SVDRecoDigit.h:68
Belle2::SVDRecoDigit::m_fittedTime
float m_fittedTime
Fitted arrival time of the signal.
Definition: SVDRecoDigit.h:211
Belle2::SVDRecoDigit::getAmplitudeError
float getAmplitudeError() const
Get amplitude error.
Definition: SVDRecoDigit.h:143