Belle II Software  release-05-02-19
SVDPulseShapeCalibrations.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Laura Zani *
7  * *
8  * This software is provided "as is" without any warranty. *
9  * WARNING: Do not try to fry it with water. Use only olive oil. *
10  **************************************************************************/
11 
12 #pragma once
13 
14 #include <vxd/dataobjects/VxdID.h>
15 #include <svd/dbobjects/SVDCalibrationsBase.h>
16 #include <svd/dbobjects/SVDCalibrationsVector.h>
17 #include <svd/dbobjects/SVDStripCalAmp.h>
18 #include <framework/database/DBObjPtr.h>
19 #include <framework/logging/Logger.h>
20 #include <string>
21 
22 
23 #include <math.h>
24 
25 namespace Belle2 {
37  class SVDPulseShapeCalibrations {
38  public:
39  static std::string calAmp_name;
40  typedef SVDCalibrationsBase< SVDCalibrationsVector< SVDStripCalAmp > >
46  {
47  m_calAmp_aDBObjPtr.addCallback([ this ](const std::string&) -> void {
48  B2INFO("SVDPulseShapeCalibrations: from now on we are using " <<
49  this->m_calAmp_aDBObjPtr -> get_uniqueID()); });
50  }
51 
65  inline double getChargeFromADC(
66  const Belle2::VxdID& sensorID,
67  const bool& isU, const unsigned short& strip,
68  const double& pulseADC
69  ) const
70  {
71  return pulseADC / getGain(sensorID, isU, strip);
72  }
73 
90  inline long int getADCFromCharge(
91  const Belle2::VxdID& sensorID,
92  const bool& isU, const unsigned short& strip,
93  const double& charge) const
94  {
95  return roundl(charge * getGain(sensorID, isU, strip));
96  }
97 
115  inline unsigned char getCappedADCFromCharge(
116  const Belle2::VxdID& sensorID,
117  const bool& isU, const unsigned short& strip,
118  const double& charge) const
119  {
120  auto chargeLongInt = getADCFromCharge(sensorID, isU, strip, charge);
121  if (chargeLongInt < 0)
122  return 0;
123  return chargeLongInt > 255 ? 255 : chargeLongInt;
124  }
125 
137  inline float getPeakTime(const VxdID& sensorID, const bool& isU,
138  const unsigned short& strip) const
139  {
140  return m_calAmp_aDBObjPtr->getReference(sensorID.getLayerNumber(), sensorID.getLadderNumber(),
141  sensorID.getSensorNumber(), m_calAmp_aDBObjPtr->sideIndex(isU),
142  strip).peakTime;
143  }
144 
161  inline float getWidth(const VxdID& sensorID, const bool& isU,
162  const unsigned short& strip) const
163  {
164  return m_calAmp_aDBObjPtr->getReference(sensorID.getLayerNumber(), sensorID.getLadderNumber(), sensorID.getSensorNumber(),
165  m_calAmp_aDBObjPtr->sideIndex(isU), strip).pulseWidth;
166 
167  }
168 
170  TString getUniqueID() { return m_calAmp_aDBObjPtr->get_uniqueID(); }
171 
173  bool isValid()
174  {
175  return m_calAmp_aDBObjPtr.isValid();
176  }
177 
178  private:
179 
187  inline float getGain(const VxdID& sensorID, const bool& isU,
188  const unsigned short& strip) const
189  {
190  return m_calAmp_aDBObjPtr->getReference(sensorID.getLayerNumber(), sensorID.getLadderNumber(), sensorID.getSensorNumber(),
191  m_calAmp_aDBObjPtr->sideIndex(isU), strip).gain ;
192 
193  }
194 
195  private:
198  };
200 }
Belle2::SVDPulseShapeCalibrations::getWidth
float getWidth(const VxdID &sensorID, const bool &isU, const unsigned short &strip) const
Return the width of the pulse shape for a given strip.
Definition: SVDPulseShapeCalibrations.h:170
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::SVDPulseShapeCalibrations::isValid
bool isValid()
returns true if the m_aDBObtPtr is valid in the requested IoV
Definition: SVDPulseShapeCalibrations.h:182
Belle2::VxdID::getLadderNumber
baseType getLadderNumber() const
Get the ladder id.
Definition: VxdID.h:108
Belle2::SVDPulseShapeCalibrations::getUniqueID
TString getUniqueID()
returns the unique ID of the payload
Definition: SVDPulseShapeCalibrations.h:179
Belle2::SVDPulseShapeCalibrations::getPeakTime
float getPeakTime(const VxdID &sensorID, const bool &isU, const unsigned short &strip) const
Return the peaking time of the strip.
Definition: SVDPulseShapeCalibrations.h:146
Belle2::SVDPulseShapeCalibrations::getChargeFromADC
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 ...
Definition: SVDPulseShapeCalibrations.h:74
Belle2::DBObjPtr
Class for accessing objects in the database.
Definition: DBObjPtr.h:31
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SVDPulseShapeCalibrations::t_calAmp_payload
SVDCalibrationsBase< SVDCalibrationsVector< SVDStripCalAmp > > t_calAmp_payload
typedef of the SVDStripCalAmp payload of all SVD strips
Definition: SVDPulseShapeCalibrations.h:50
Belle2::SVDPulseShapeCalibrations::SVDPulseShapeCalibrations
SVDPulseShapeCalibrations()
Constructor, no input argument is required.
Definition: SVDPulseShapeCalibrations.h:53
Belle2::SVDPulseShapeCalibrations::getGain
float getGain(const VxdID &sensorID, const bool &isU, const unsigned short &strip) const
Return the channel gain.
Definition: SVDPulseShapeCalibrations.h:196
Belle2::SVDPulseShapeCalibrations::m_calAmp_aDBObjPtr
DBObjPtr< t_calAmp_payload > m_calAmp_aDBObjPtr
SVDStripCalAmp payload.
Definition: SVDPulseShapeCalibrations.h:205
Belle2::VxdID::getSensorNumber
baseType getSensorNumber() const
Get the sensor id.
Definition: VxdID.h:110
Belle2::VxdID::getLayerNumber
baseType getLayerNumber() const
Get the layer id.
Definition: VxdID.h:106
Belle2::SVDPulseShapeCalibrations::getCappedADCFromCharge
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...
Definition: SVDPulseShapeCalibrations.h:124
Belle2::SVDPulseShapeCalibrations::calAmp_name
static std::string calAmp_name
name of the SVDStripCalAmp payload
Definition: SVDPulseShapeCalibrations.h:48
Belle2::SVDPulseShapeCalibrations::getADCFromCharge
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]...
Definition: SVDPulseShapeCalibrations.h:99