Belle II Software development
SVDPulseShapeCalibrations.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#pragma once
10
11#include <vxd/dataobjects/VxdID.h>
12#include <svd/dbobjects/SVDCalibrationsBase.h>
13#include <svd/dbobjects/SVDCalibrationsVector.h>
14#include <svd/dbobjects/SVDStripCalAmp.h>
15#include <framework/database/DBObjPtr.h>
16#include <framework/logging/Logger.h>
17#include <string>
18
19
20#include <math.h>
21
22namespace Belle2 {
35 public:
36 static std::string calAmp_name;
43 {
44 m_calAmp_aDBObjPtr.addCallback([ this ](const std::string&) -> void {
45 B2DEBUG(20, "SVDPulseShapeCalibrations: from now on we are using " <<
46 this->m_calAmp_aDBObjPtr -> get_uniqueID()); });
47 }
48
61 inline double getChargeFromADC(
62 const Belle2::VxdID& sensorID,
63 const bool& isU, const unsigned short& strip,
64 const double& pulseADC
65 ) const
66 {
67 return pulseADC / getGain(sensorID, isU, strip);
68 }
69
85 inline long int getADCFromCharge(
86 const Belle2::VxdID& sensorID,
87 const bool& isU, const unsigned short& strip,
88 const double& charge) const
89 {
90 return roundl(charge * getGain(sensorID, isU, strip));
91 }
92
109 inline unsigned char getCappedADCFromCharge(
110 const Belle2::VxdID& sensorID,
111 const bool& isU, const unsigned short& strip,
112 const double& charge) const
113 {
114 auto chargeLongInt = getADCFromCharge(sensorID, isU, strip, charge);
115 if (chargeLongInt < 0)
116 return 0;
117 return chargeLongInt > 255 ? 255 : chargeLongInt;
118 }
119
130 inline float getPeakTime(const VxdID& sensorID, const bool& isU,
131 const unsigned short& strip) const
132 {
133 return m_calAmp_aDBObjPtr->getReference(sensorID.getLayerNumber(), sensorID.getLadderNumber(),
134 sensorID.getSensorNumber(), m_calAmp_aDBObjPtr->sideIndex(isU),
135 strip).peakTime;
136 }
137
154 inline float getWidth(const VxdID& sensorID, const bool& isU,
155 const unsigned short& strip) const
156 {
157 return m_calAmp_aDBObjPtr->getReference(sensorID.getLayerNumber(), sensorID.getLadderNumber(), sensorID.getSensorNumber(),
158 m_calAmp_aDBObjPtr->sideIndex(isU), strip).pulseWidth;
159
160 }
161
163 TString getUniqueID() { return m_calAmp_aDBObjPtr->get_uniqueID(); }
164
166 bool isValid()
167 {
168 return m_calAmp_aDBObjPtr.isValid();
169 }
170
171 private:
172
180 inline float getGain(const VxdID& sensorID, const bool& isU,
181 const unsigned short& strip) const
182 {
183 return m_calAmp_aDBObjPtr->getReference(sensorID.getLayerNumber(), sensorID.getLadderNumber(), sensorID.getSensorNumber(),
184 m_calAmp_aDBObjPtr->sideIndex(isU), strip).gain ;
185
186 }
187
188 private:
191 };
193}
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
base class for calibrations classes
This class defines the dbobject and the methods to access the SVD calibrations from the local runs pr...
static std::string calAmp_name
name of the SVDStripCalAmp payload
SVDCalibrationsBase< SVDCalibrationsVector< SVDStripCalAmp > > t_calAmp_payload
typedef of the SVDStripCalAmp payload of all SVD strips
DBObjPtr< t_calAmp_payload > m_calAmp_aDBObjPtr
SVDStripCalAmp payload.
float getGain(const VxdID &sensorID, const bool &isU, const unsigned short &strip) const
Return the channel gain.
long int getADCFromCharge(const Belle2::VxdID &sensorID, const bool &isU, const unsigned short &strip, const double &charge) const
Return a signed long integer corresponding to the ADC pulse height per strip, provided the charge [e]...
SVDPulseShapeCalibrations()
Constructor, no input argument is required.
unsigned char getCappedADCFromCharge(const Belle2::VxdID &sensorID, const bool &isU, const unsigned short &strip, const double &charge) const
Return an unsigned 8 bit integer corresponding to the ADC pulse height per strip, provided the charge...
double getChargeFromADC(const Belle2::VxdID &sensorID, const bool &isU, const unsigned short &strip, const double &pulseADC) const
Return the charge (number of electrons/holes) collected on a specific strip, given the number of ADC ...
float getPeakTime(const VxdID &sensorID, const bool &isU, const unsigned short &strip) const
Return the peaking time of the strip.
TString getUniqueID()
returns the unique ID of the payload
float getWidth(const VxdID &sensorID, const bool &isU, const unsigned short &strip) const
Return the width of the pulse shape for a given strip.
bool isValid()
returns true if the m_aDBObtPtr is valid in the requested IoV
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
baseType getSensorNumber() const
Get the sensor id.
Definition: VxdID.h:100
baseType getLadderNumber() const
Get the ladder id.
Definition: VxdID.h:98
baseType getLayerNumber() const
Get the layer id.
Definition: VxdID.h:96
Abstract base class for different kinds of events.