Belle II Software development
CDCDedx1DCell.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 CDCDedx1DCell: public TObject {
27
28 public:
29
34
38 CDCDedx1DCell(short version, const std::vector<std::vector<double>>& onedgains): m_version(version), m_onedgains(onedgains) {};
39
44
49 {
50 if (m_version != rhs.getVersion()) {
51 B2WARNING("1D cell gain parameters do not match, cannot merge!");
52 return *this;
53 }
54 for (unsigned int layer = 0; layer < getSize(); ++layer) {
55 double tempLayer = -1; //out of bound layer
56 if (getSize() == 2)tempLayer = layer * 20; // 20 to make <8 and >=8 difference
57 else if (getSize() == 56)tempLayer = layer;
58 else B2ERROR("ERROR! Wrong # of constants vector array");
59 for (unsigned int bin = 0; bin < getNBins(layer); ++bin) {
60 m_onedgains[layer][bin] *= rhs.getMean(tempLayer, bin);
61 }
62 }
63 return *this;
64 }
65
68 short getVersion() const { return m_version; };
69
72 unsigned int getSize() const { return m_onedgains.size(); };
73
76 unsigned int getNBins(unsigned int layer) const
77 {
78 if (m_onedgains.size() == 0) {
79 B2ERROR("ERROR!");
80 return 0;
81 }
82
83 if (m_onedgains.size() == 2) {
84 if (layer == 0) return m_onedgains[0].size();
85 else if (layer == 1) return m_onedgains[1].size();
86 else {
87 B2ERROR("ERROR! const vector not found");
88 return 0;
89 }
90 } else if (m_onedgains.size() == 56) {
91 if (layer < m_onedgains.size()) return m_onedgains[layer].size();
92 } else {
93 B2ERROR("ERROR! Wrong # of constants vector array: getNBins()");
94 return 0;
95 }
96 return 0;
97 };
98
103 double getMean(unsigned int layer, unsigned int bin) const
104 {
105 unsigned int mylayer = 0;
106 if (layer >= 8 && m_onedgains.size() == 2) mylayer = 1;
107 else if (m_onedgains.size() == 56) mylayer = layer;
108
109 if (mylayer < m_onedgains.size() and bin < m_onedgains[mylayer].size()) return m_onedgains[mylayer][bin];
110
111 return 1.0;
112 };
113
119 void setMean(unsigned int layer, unsigned int bin, double value)
120 {
121 unsigned int mylayer = 0;
122 if (layer >= 8 && m_onedgains.size() == 2) mylayer = 1;
123 else if (m_onedgains.size() == 56) mylayer = layer;
124
125 if (mylayer < m_onedgains.size() and bin < m_onedgains[mylayer].size()) m_onedgains[mylayer][bin] = value;
126 };
127
132 double getMean(unsigned int layer, double enta) const
133 {
134 if (layer > 56) {
135 B2ERROR("No such layer!");
136 return 0;
137 }
138
139 unsigned int mylayer = 0;
140 if (layer >= 8 && m_onedgains.size() == 2) mylayer = 1;
141 else if (m_onedgains.size() == 56) mylayer = layer;
142
143 if (mylayer >= m_onedgains.size()) return 1.0;
144
145 double piby2 = M_PI / 2.0;
146 // assume rotational symmetry
147 if (enta < -piby2) enta += piby2;
148 if (enta > piby2) enta -= piby2;
149
150 double binsize = (m_onedgains[mylayer].size() != 0) ? 2.0 * piby2 / m_onedgains[mylayer].size() : 0.0;
151 int bin = (binsize != 0.0) ? std::floor((enta + piby2) / binsize) : -1;
152 if (bin < 0 || (unsigned)bin >= m_onedgains[mylayer].size()) {
153 B2WARNING("Problem with CDC dE/dx 1D binning!");
154 return 1.0;
155 }
156
157 return m_onedgains[mylayer][bin];
158 };
159
160 private:
164 short m_version;
165 std::vector<std::vector<double>> m_onedgains;
166
168 };
169
170} // end namespace Belle2
ClassDef(CDCDedx1DCell, 5)
ClassDef.
short m_version
dE/dx cleanup correction versus entrance angle may be different for different layers,...
CDCDedx1DCell(short version, const std::vector< std::vector< double > > &onedgains)
Constructor.
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.
double getMean(unsigned int layer, double enta) const
Return dE/dx mean value for given entrance angle.
~CDCDedx1DCell()
Destructor.
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.
CDCDedx1DCell()
Default constructor.
unsigned int getNBins(unsigned int layer) const
Get the number of bins for the entrance angle correction.
short getVersion() const
Get the version for the 1D cleanup.
unsigned int getSize() const
Get the number of bins for the entrance angle correction.
Abstract base class for different kinds of events.