11 #include <framework/logging/Logger.h>
12 #include <pxd/calibration/PXDCalibrationUtilities.h>
13 #include <vxd/dataobjects/VxdID.h>
22 #include <boost/format.hpp>
37 void getNumberOfBins(
const std::shared_ptr<TH1I>& histo_ptr,
unsigned short& nBinsU,
unsigned short& nBinsV)
39 set<unsigned short> uBinSet;
40 set<unsigned short> vBinSet;
43 for (
auto histoBin = 1; histoBin <= histo_ptr->GetXaxis()->GetNbins(); histoBin++) {
45 string label = histo_ptr->GetXaxis()->GetBinLabel(histoBin);
48 istringstream stream(label);
50 getline(stream, token,
'_');
51 getline(stream, token,
'_');
52 unsigned short uBin = std::stoi(token);
54 getline(stream, token,
'_');
55 unsigned short vBin = std::stoi(token);
61 if (uBinSet.empty() || vBinSet.empty()) {
62 B2FATAL(
"Not able to determine the grid size. Something is wrong with collected data.");
64 nBinsU = *uBinSet.rbegin() + 1;
65 nBinsV = *vBinSet.rbegin() + 1;
72 set<unsigned short> sensorSet;
75 for (
auto histoBin = 1; histoBin <= histo_ptr->GetXaxis()->GetNbins(); histoBin++) {
77 string label = histo_ptr->GetXaxis()->GetBinLabel(histoBin);
80 istringstream stream(label);
82 getline(stream, token,
'_');
83 VxdID sensorID(token);
84 sensorSet.insert(sensorID.
getID());
86 return sensorSet.size();
92 auto size = signals.size();
96 }
else if (size <= 100) {
98 sort(signals.begin(), signals.end());
100 return (signals[size / 2 - 1] + signals[size / 2]) / 2;
102 return signals[size / 2];
108 nth_element(signals.begin(), signals.begin() + n, signals.end());
109 auto med = signals[n];
111 auto max_it = max_element(signals.begin(), signals.begin() + n);
112 med = (*max_it + med) / 2.0;
121 double probSums[1] = {0.5};
122 hist->GetQuantiles(1, quantiles, probSums);
129 auto size = hist->GetEntries();
130 if (size == 0)
return 0.0;
132 int max = hist->GetBinLowEdge(hist->GetNbinsX() + 1);
133 int min = hist->GetBinLowEdge(1);
136 TF1* landau =
new TF1(
"landau",
"TMath::Landau(x,[0],[1])*[2]", min, max);
137 landau->SetParNames(
"MPV",
"sigma",
"scale");
138 landau->SetParameters(1., 0.1, 1000);
139 landau->SetParLimits(0, 0., 3.);
141 Int_t status = hist->Fit(
"landau",
"Lq",
"", min, max);
142 double MPV = landau->GetParameter(
"MPV");
144 B2INFO(
"Fit result: " << status <<
" MPV " << MPV <<
" sigma " << landau->GetParameter(
"sigma")
145 <<
" scale " << landau->GetParameter(
"scale") <<
" chi2 " << landau->GetChisquare());
151 if (status == 0)
return MPV;
153 B2WARNING(
"Fit failed!. using default value.");
161 auto size = signals.size();
162 if (size == 0)
return 0.0;
165 double max = *max_element(signals.begin(), signals.end());
166 double min = *min_element(signals.begin(), signals.end());
169 TH1D* hist_signals =
new TH1D(
"",
"", max - min, min, max);
170 for (
auto it = signals.begin(); it != signals.end(); ++it) {
171 hist_signals->Fill(*it);