9#include <cdc/dbobjects/CDCDedx1DCell.h>
15 const std::vector<std::vector<double>>& groupGains,
16 const std::vector<unsigned int>& layerToGroup)
22 if (groupGains.empty()) {
23 B2ERROR(
"CDCDedx1DCell: groupGains is empty.");
28 if (layerToGroup.empty()) {
29 B2ERROR(
"CDCDedx1DCell: layerToGroup is empty.");
34 for (
size_t g = 0; g < groupGains.size(); ++g) {
35 if (groupGains[g].empty()) {
36 B2ERROR(
"CDCDedx1DCell: group " << g <<
" is empty.");
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]);
58 B2ERROR(
"CDCDedx1DCell: no gain groups");
62 for (
unsigned int g = 0; g <
m_onedgains.size(); ++g) {
64 B2ERROR(
"CDCDedx1DCell: group " << g <<
" is empty");
72 for (
unsigned int layer = 0; layer <
m_layerToGroup.size(); ++layer) {
74 B2ERROR(
"1DCell: invalid group index in layer map");
87 B2ERROR(
"CDCDedx1DCell: invalid legacy payload shape");
93 const unsigned int group =
getGroup(layer);
105 const unsigned int group =
getGroup(layer);
115 const unsigned int group =
getGroup(layer);
120 const double piby2 = M_PI / 2.0;
122 if (enta < -piby2) enta += piby2;
123 if (enta > piby2) enta -= piby2;
127 double binsize = 2.0 * piby2 / nbins;
129 int bin = std::floor((enta + piby2) / binsize);
131 if (bin < 0 ||
static_cast<unsigned int>(bin) >= nbins) {
132 B2WARNING(
"Problem with CDC dE/dx 1D binning!");
142 B2WARNING(
"1DCell versions do not match");
147 B2WARNING(
"Invalid payload");
152 B2WARNING(
"Layer mapping mismatch");
157 B2WARNING(
"Group count mismatch");
161 for (
unsigned int group = 0; group <
m_onedgains.size(); ++group) {
164 B2WARNING(
"Bin count mismatch");
168 for (
unsigned int bin = 0; bin <
m_onedgains[group].size(); ++bin) {
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,...
double getMean(unsigned int layer, unsigned int bin) const
Return dE/dx mean value for the given bin.
CDCDedx1DCell & operator*=(CDCDedx1DCell const &rhs)
Combine payloads.
std::vector< std::vector< double > > m_onedgains
dE/dx means in entrance angle bins
void setMean(unsigned int layer, unsigned int bin, double value)
Reset dE/dx mean value for the given bin.
bool isValidGroupedPayload() const
Payload validation.
CDCDedx1DCell()
Default constructor.
unsigned int getGroup(unsigned int layer) const
Get group index for layer.
short getVersion() const
Get the version for the 1D cleanup.
Abstract base class for different kinds of events.