Belle II Software development
VXDElectronDeposit.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 <algorithm>
12#include <cmath>
13
14namespace Belle2 {
31 public:
45
48 explicit VXDElectronDeposit(unsigned int packed): m_packed(packed) {}
49
55 VXDElectronDeposit(float fraction, float electrons)
56 {
57 const unsigned int intfrac = std::round(std::max(0.f, fraction) * static_cast<float>(c_MaxFraction));
58 const unsigned int intelec = std::round(std::max(0.f, electrons));
59 m_packed = std::min(intfrac, static_cast<unsigned int>(c_MaxFraction))
60 + (std::min(intelec, static_cast<unsigned int>(c_MaxElectrons)) << c_FractionBits);
61 }
62
63 float getFraction() const
64 {
65 return (m_packed & c_MaxFraction) * 1.0 / static_cast<float>(c_MaxFraction);
66 }
67
68 unsigned int getElectrons() const
69 {
71 }
72
73 unsigned int getPacked() const { return m_packed; }
75 operator unsigned int() const { return m_packed; }
76 private:
78 unsigned int m_packed: c_TotalBits;
79 };
80
82} //Belle2 namespace
unsigned int getElectrons() const
get the number of deposited electrons
EBits
Enum storing the bit information for the packed information.
@ c_TotalBits
Total number of bits needed for the packed structure.
@ c_MaxFraction
Maximum integer value allowed for the fraction part.
@ c_ElectronBits
Number of bits to encode the number of electrons.
@ c_FractionBits
Number of bits to encode the fraction along the path.
@ c_MaxElectrons
Maximum number of electrons allowed.
unsigned int m_packed
packed representation of the fraction and electron deposition
float getFraction() const
get the fraction along the path
VXDElectronDeposit(unsigned int packed)
Create a new instance from a packed value.
VXDElectronDeposit(float fraction, float electrons)
create a new instance from a fraction along the path and a number of electrons.
unsigned int getPacked() const
get the packed value
Abstract base class for different kinds of events.