Belle II Software development
CDCDedxCosineCor.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 <framework/logging/Logger.h>
12
13#include <TObject.h>
14#include <cmath>
15
16namespace Belle2 {
21
25
26 class CDCDedxCosineCor: public TObject {
27
28 public:
29
34
39 explicit CDCDedxCosineCor(const std::vector<double>& cosgains): m_cosgains(cosgains), m_groupCosgains(),
40 m_layerToGroup() {};
41
48
49 CDCDedxCosineCor(const std::vector<std::vector<double>>& groupCosgains,
50 const std::vector<unsigned int>& layerToGroup);
51
56
61
66 bool isGrouped() const
67 {
68 return !m_groupCosgains.empty();
69 }
70
75 unsigned int getNGroups() const
76 {
77 if (isGrouped()) return m_groupCosgains.size();
78 return (m_cosgains.empty() ? 0 : 1);
79 }
80
82 unsigned int getNLayers() const
83 {
84 if (!m_layerToGroup.empty()) return m_layerToGroup.size();
85
86 return 0;
87 };
88
90 unsigned int getGroup(unsigned int layer) const
91 {
92 if (layer >= getNLayers()) {
93 B2ERROR("Layer out of range");
94 return std::numeric_limits<unsigned int>::max();
95 }
96
97 if (!m_layerToGroup.empty()) {
98 return m_layerToGroup[layer];
99 }
100
101 B2INFO("Invalid cosine correction payload state");
102 return std::numeric_limits<unsigned int>::max();
103 };
104
109 unsigned int getSize(unsigned int layer) const
110 {
111 if (isGrouped()) {
112 const unsigned int group = getGroup(layer);
113 return m_groupCosgains[group].size();
114 }
115
116 return m_cosgains.size();
117 }
118
123 const std::vector<double>& getCosCor() const
124 {
125 return m_cosgains;
126 }
127
132 const std::vector<std::vector<double>>& getGroupCosCor() const
133 {
134 return m_groupCosgains;
135 }
136
141 const std::vector<unsigned int>& getLayerMap() const
142 {
143 return m_layerToGroup;
144 }
145
151 void setCosCor(unsigned int bin, double value);
152
159 void setCosCor(unsigned int group, unsigned int bin, double value);
160
166 double getMean(unsigned int bin) const;
167
173 double getMean(double costh) const;
174
181 double getMean(unsigned int layer, unsigned int bin) const;
182
189 double getMean(unsigned int layer, double costh) const;
190
191 private:
192
199 double getMeanFromVector(const std::vector<double>& gains, double costh) const;
200
205 bool isValidGroupedPayload() const;
206
212 bool multiplyGains(std::vector<double>& lhs, const std::vector<double>& rhs) const;
213
214 std::vector<double> m_cosgains;
215 std::vector<std::vector<double>> m_groupCosgains;
216 std::vector<unsigned int> m_layerToGroup;
217
219 };
220
221} // end namespace Belle2
dE/dx cosine gain calibration constants
unsigned int getNGroups() const
Get number of groups in grouped mode.
std::vector< std::vector< double > > m_groupCosgains
grouped dE/dx gains [group][bin]
unsigned int getSize(unsigned int layer) const
Get the number of bins.
std::vector< unsigned int > m_layerToGroup
map from layer index to group index
ClassDef(CDCDedxCosineCor, 9)
ClassDef.
CDCDedxCosineCor()
Default constructor.
void setCosCor(unsigned int bin, double value)
Set old-style cosine correction.
double getMeanFromVector(const std::vector< double > &gains, double costh) const
Helper to interpolate/extrapolate from one vector of gains.
bool multiplyGains(std::vector< double > &lhs, const std::vector< double > &rhs) const
Multiply lhs by rhs with possible rebinning.
bool isGrouped() const
Check whether grouped mode is used.
CDCDedxCosineCor(const std::vector< double > &cosgains)
Old payloads Constructor.
const std::vector< std::vector< double > > & getGroupCosCor() const
Get the grouped calibration constants.
CDCDedxCosineCor & operator*=(const CDCDedxCosineCor &rhs)
Combine payloads.
std::vector< double > m_cosgains
old-style dE/dx gains in cos(theta) bins
bool isValidGroupedPayload() const
Validate grouped payload content.
const std::vector< double > & getCosCor() const
Get the old-style calibration constants.
const std::vector< unsigned int > & getLayerMap() const
Get the Layer-to-group map.
unsigned int getNLayers() const
Number of layers.
double getMean(unsigned int bin) const
Return dE/dx mean value for the given bin in old mode.
unsigned int getGroup(unsigned int layer) const
Get group index for layer.
Abstract base class for different kinds of events.