14 #include <framework/logging/Logger.h>
30 class CDCDedxADCNonLinearity:
public TObject {
53 unsigned int getSize(
int layer,
int axis)
const
57 if (layer < 0 || layer > 55) {
58 B2ERROR(
"CDCDedxADCNonLinearity:CDC layer out of range, choose between 0-55");
61 if (layer >= 8) mylayer = 2;
64 if (axis < 0 || axis > 1) {
65 B2ERROR(
"CDCDedxADCNonLinearity:Problem with X/Y axis: choose 0/1 for X/Y");
68 mylayer = mylayer + axis;
83 if (layer < 0 || layer > 55) {
84 B2WARNING(
"CDCDedxADCNonLinearity:returning uncorrected ADC as input layer is out of range: must be 0-55");
87 if (layer >= 8) mylayer = 2;
90 std::vector<double> tempX =
m_nonlADC[mylayer];
91 std::vector<double> tempY =
m_nonlADC[mylayer + 1];
93 if (tempX.size() != tempY.size()) {
94 B2WARNING(
"CDCDedxADCNonLinearity:returning uncorrected ADC as parameters range don't match: X=Y in bins");
99 unsigned int ibin = TMath::BinarySearch(tempY.size(), tempY.data(),
double(ADC));
101 if (ibin >= tempY.size() - 1)ibin = tempY.size() - 2;
102 if (ibin >= tempY.size() - 1) {
103 B2WARNING(
"CDCDedxADCNonLinearity:returning uncorrected ADC as bins are not in range");
107 double slope = (tempY[ibin + 1] - tempY[ibin]) / (tempX[ibin + 1] - tempX[ibin]);
108 return std::round(tempX[ibin] + (ADC - tempY[ibin]) / slope);
120 if (layer < 0 || layer > 55) {
121 B2ERROR(
"CDCDedxADCNonLinearity:CDC layer out of range, choose between 0-55");
124 if (layer >= 8) mylayer = 2;
127 if (axis < 0 || axis > 1) {
128 B2ERROR(
"CDCDedxADCNonLinearity:Problem with X/Y axis: choose 0/1 for X/Y");
131 mylayer = mylayer + axis;
135 B2ERROR(
"CDCDedxADCNonLinearity:Problem with par index: choose 0 and " <<
m_nonlADC[mylayer].size());
150 if (layer < 0 || layer > 55) {
151 B2ERROR(
"CDCDedxADCNonLinearity:CDC layer out of range, choose between 0-55");
154 if (layer >= 8) mylayer = 2;
157 if (axis < 0 || axis > 1) {
158 B2ERROR(
"CDCDedxADCNonLinearity:Problem with X/Y axis: choose 0/1 for X/Y");
161 mylayer = mylayer + axis;
164 B2INFO(
"Printing parameters for layer: " << layer <<
", axis: " << axis <<
", nPars:" <<
m_nonlADC[mylayer].size());
165 for (
unsigned int iPar = 0; iPar <
m_nonlADC[mylayer].size(); iPar++)
166 std::cout <<
"Par # " << iPar <<
": " <<
m_nonlADC[mylayer][iPar] << std::endl;
176 void setNonLinearityPar(
unsigned int layer,
unsigned int axis,
unsigned int par,
double value)
180 B2ERROR(
"CDCDedxADCNonLinearity:CDC layer out of range, choose between 0-55");
183 if (layer >= 8) mylayer = 2;
187 B2ERROR(
"CDCDedxADCNonLinearity:Problem with X/Y axis: choose 0/1 for X/Y");
190 mylayer = mylayer + axis;
194 B2ERROR(
"CDCDedxADCNonLinearity:Problem with par index: choose 0 and " <<
m_nonlADC[mylayer].size());
204 std::vector<std::vector<double>>
m_nonlADC;