Belle II Software development
CDCDedx1DCell Class Reference

dE/dx 1D cell correction calibration constants More...

#include <CDCDedx1DCell.h>

Inheritance diagram for CDCDedx1DCell:

Public Member Functions

 CDCDedx1DCell ()
 Default constructor.
 
 CDCDedx1DCell (short version, const std::vector< std::vector< double > > &groupGains, const std::vector< unsigned int > &layerToGroup)
 Constructor with grouped constants.
 
 ~CDCDedx1DCell ()
 Destructor.
 
CDCDedx1DCelloperator*= (CDCDedx1DCell const &rhs)
 Combine payloads.
 
short getVersion () const
 Get the version for the 1D cleanup.
 
unsigned int getNGroups () const
 Number of groups.
 
unsigned int getNLayers () const
 Number of layers.
 
unsigned int getGroup (unsigned int layer) const
 Get group index for layer.
 
unsigned int getNBins (unsigned int layer) const
 Get the number of bins for the entrance angle correction.
 
const std::vector< std::vector< double > > & getOneDCell () const
 Get the grouped calibration constants.
 
const std::vector< unsigned int > & getLayerMap () const
 Get the Layer-to-group map.
 
double getMean (unsigned int layer, unsigned int bin) const
 Return dE/dx mean value for the given bin.
 
void setMean (unsigned int layer, unsigned int bin, double value)
 Reset dE/dx mean value for the given bin.
 
double getMean (unsigned int layer, double enta) const
 Return dE/dx mean value for given entrance angle.
 

Private Member Functions

bool isValidGroupedPayload () const
 Payload validation.
 
 ClassDef (CDCDedx1DCell, 6)
 ClassDef.
 

Private Attributes

short m_version
 dE/dx cleanup correction versus entrance angle may be different for different layers, so store as a vector of vectors keep a version number to identify which layers are valid
 
std::vector< std::vector< double > > m_onedgains
 dE/dx means in entrance angle bins
 
std::vector< unsigned int > m_layerToGroup
 layer to group map
 

Detailed Description

dE/dx 1D cell correction calibration constants

Definition at line 26 of file CDCDedx1DCell.h.

Constructor & Destructor Documentation

◆ CDCDedx1DCell() [1/2]

CDCDedx1DCell ( )
inline

Default constructor.

Definition at line 33 of file CDCDedx1DCell.h.

33: m_version(0), m_onedgains(), m_layerToGroup() {};

◆ CDCDedx1DCell() [2/2]

CDCDedx1DCell ( short version,
const std::vector< std::vector< double > > & groupGains,
const std::vector< unsigned int > & layerToGroup )

Constructor with grouped constants.

Definition at line 14 of file CDCDedx1DCell.cc.

17 : m_version(version),
18 m_onedgains(groupGains),
19 m_layerToGroup(layerToGroup)
20{
21 // 1. groups exist
22 if (groupGains.empty()) {
23 B2ERROR("CDCDedx1DCell: groupGains is empty.");
24 return;
25 }
26
27 // 2. mapping exists
28 if (layerToGroup.empty()) {
29 B2ERROR("CDCDedx1DCell: layerToGroup is empty.");
30 return;
31 }
32
33 // 3. check groups not empty
34 for (size_t g = 0; g < groupGains.size(); ++g) {
35 if (groupGains[g].empty()) {
36 B2ERROR("CDCDedx1DCell: group " << g << " is empty.");
37 return;
38 }
39 }
40
41 // 4. check Layer -> group mapping
42 for (size_t layer = 0; layer < layerToGroup.size(); ++layer) {
43 if (layerToGroup[layer] >= groupGains.size()) {
44 B2ERROR("CDCDedx1DCell: layer " << layer
45 << " refers to invalid group "
46 << layerToGroup[layer]);
47 return;
48 }
49 }
50
51 m_onedgains = groupGains;
52 m_layerToGroup = layerToGroup;
53}
std::vector< unsigned int > m_layerToGroup
layer to group map
short m_version
dE/dx cleanup correction versus entrance angle may be different for different layers,...
std::vector< std::vector< double > > m_onedgains
dE/dx means in entrance angle bins

◆ ~CDCDedx1DCell()

~CDCDedx1DCell ( )
inline

Destructor.

Definition at line 43 of file CDCDedx1DCell.h.

43{};

Member Function Documentation

◆ getGroup()

unsigned int getGroup ( unsigned int layer) const
inline

Get group index for layer.

Definition at line 69 of file CDCDedx1DCell.h.

70 {
71 if (layer >= getNLayers()) {
72 B2ERROR("Layer out of range");
73 return std::numeric_limits<unsigned int>::max();
74 }
75
76 if (!m_layerToGroup.empty()) {
77 return m_layerToGroup[layer];
78 }
79
80 if (m_onedgains.size() == 2) {
81 return (layer < 8) ? 0 : 1;
82 }
83
84 B2ERROR("Invalid 1DCell payload state");
85 return std::numeric_limits<unsigned int>::max();
86 };

◆ getLayerMap()

const std::vector< unsigned int > & getLayerMap ( ) const
inline

Get the Layer-to-group map.

Returns
layer map

Definition at line 113 of file CDCDedx1DCell.h.

114 {
115 return m_layerToGroup;
116 }

◆ getMean() [1/2]

double getMean ( unsigned int layer,
double enta ) const

Return dE/dx mean value for given entrance angle.

Parameters
layercontinuous layer number
entaentrance angle (-pi/2 to pi/2)

Definition at line 113 of file CDCDedx1DCell.cc.

114{
115 const unsigned int group = getGroup(layer);
116
117 if (group >= m_onedgains.size()) return 1.0;
118 if (m_onedgains[group].empty()) return 1.0;
119
120 const double piby2 = M_PI / 2.0;
121
122 if (enta < -piby2) enta += piby2;
123 if (enta > piby2) enta -= piby2;
124
125 unsigned int nbins = m_onedgains[group].size();
126
127 double binsize = 2.0 * piby2 / nbins;
128
129 int bin = std::floor((enta + piby2) / binsize);
130
131 if (bin < 0 || static_cast<unsigned int>(bin) >= nbins) {
132 B2WARNING("Problem with CDC dE/dx 1D binning!");
133 return 1.0;
134 }
135
136 return m_onedgains[group][bin];
137}
unsigned int getGroup(unsigned int layer) const
Get group index for layer.

◆ getMean() [2/2]

double getMean ( unsigned int layer,
unsigned int bin ) const

Return dE/dx mean value for the given bin.

Parameters
layeris layer number between 0-55
binis enta bin number

Definition at line 91 of file CDCDedx1DCell.cc.

92{
93 const unsigned int group = getGroup(layer);
94 if (group >= m_onedgains.size()) return 1.0;
95
96 if (bin >= m_onedgains[group].size()) return 1.0;
97
98 return m_onedgains[group][bin];
99}

◆ getNBins()

unsigned int getNBins ( unsigned int layer) const
inline

Get the number of bins for the entrance angle correction.

Definition at line 90 of file CDCDedx1DCell.h.

91 {
92 const unsigned int group = getGroup(layer);
93
94 if (group >= m_onedgains.size()) return 0;
95
96 return m_onedgains[group].size();
97 };

◆ getNGroups()

unsigned int getNGroups ( ) const
inline

Number of groups.

Definition at line 56 of file CDCDedx1DCell.h.

56{return m_onedgains.size();};

◆ getNLayers()

unsigned int getNLayers ( ) const
inline

Number of layers.

Definition at line 59 of file CDCDedx1DCell.h.

60 {
61 if (!m_layerToGroup.empty()) return m_layerToGroup.size();
62
63 if (m_onedgains.size() == 2) return 56;
64
65 return 0;
66 };

◆ getOneDCell()

const std::vector< std::vector< double > > & getOneDCell ( ) const
inline

Get the grouped calibration constants.

Returns
grouped calibration constants

Definition at line 103 of file CDCDedx1DCell.h.

104 {
105 return m_onedgains;
106 }

◆ getVersion()

short getVersion ( ) const
inline

Get the version for the 1D cleanup.

Definition at line 53 of file CDCDedx1DCell.h.

53{ return m_version; };

◆ isValidGroupedPayload()

bool isValidGroupedPayload ( ) const
private

Payload validation.

Definition at line 55 of file CDCDedx1DCell.cc.

56{
57 if (m_onedgains.empty()) {
58 B2ERROR("CDCDedx1DCell: no gain groups");
59 return false;
60 }
61
62 for (unsigned int g = 0; g < m_onedgains.size(); ++g) {
63 if (m_onedgains[g].empty()) {
64 B2ERROR("CDCDedx1DCell: group " << g << " is empty");
65 return false;
66 }
67 }
68
69 // new-style payload
70 if (!m_layerToGroup.empty()) {
71
72 for (unsigned int layer = 0; layer < m_layerToGroup.size(); ++layer) {
73 if (m_layerToGroup[layer] >= m_onedgains.size()) {
74 B2ERROR("1DCell: invalid group index in layer map");
75 return false;
76 }
77 }
78
79 return true;
80 }
81
82 // old-style payload
83 if (m_onedgains.size() == 2) {
84 return true;
85 }
86
87 B2ERROR("CDCDedx1DCell: invalid legacy payload shape");
88 return false;
89}

◆ operator*=()

CDCDedx1DCell & operator*= ( CDCDedx1DCell const & rhs)

Combine payloads.

Definition at line 139 of file CDCDedx1DCell.cc.

140{
141 if (m_version != rhs.getVersion()) {
142 B2WARNING("1DCell versions do not match");
143 return *this;
144 }
145
146 if (!isValidGroupedPayload() || !rhs.isValidGroupedPayload()) {
147 B2WARNING("Invalid payload");
148 return *this;
149 }
150
151 if (m_layerToGroup != rhs.m_layerToGroup) {
152 B2WARNING("Layer mapping mismatch");
153 return *this;
154 }
155
156 if (m_onedgains.size() != rhs.m_onedgains.size()) {
157 B2WARNING("Group count mismatch");
158 return *this;
159 }
160
161 for (unsigned int group = 0; group < m_onedgains.size(); ++group) {
162
163 if (m_onedgains[group].size() != rhs.m_onedgains[group].size()) {
164 B2WARNING("Bin count mismatch");
165 return *this;
166 }
167
168 for (unsigned int bin = 0; bin < m_onedgains[group].size(); ++bin) {
169 m_onedgains[group][bin] *= rhs.m_onedgains[group][bin];
170 }
171 }
172
173 return *this;
174}
bool isValidGroupedPayload() const
Payload validation.

◆ setMean()

void setMean ( unsigned int layer,
unsigned int bin,
double value )

Reset dE/dx mean value for the given bin.

Parameters
layeris layer number between 0-55
binis enta bin number
valueis constant for requested entabin and layer

Definition at line 101 of file CDCDedx1DCell.cc.

104{
105 const unsigned int group = getGroup(layer);
106
107 if (group >= m_onedgains.size()) return;
108 if (bin >= m_onedgains[group].size()) return;
109
110 m_onedgains[group][bin] = value;
111}

Member Data Documentation

◆ m_layerToGroup

std::vector<unsigned int> m_layerToGroup
private

layer to group map

Definition at line 150 of file CDCDedx1DCell.h.

◆ m_onedgains

std::vector<std::vector<double> > m_onedgains
private

dE/dx means in entrance angle bins

Definition at line 149 of file CDCDedx1DCell.h.

◆ m_version

short m_version
private

dE/dx cleanup correction versus entrance angle may be different for different layers, so store as a vector of vectors keep a version number to identify which layers are valid

version number for 1D cleanup correction

Definition at line 148 of file CDCDedx1DCell.h.


The documentation for this class was generated from the following files: