6 #include "TGraphErrors.h"
12 for (
int i = 0;
i < 256; ++
i)
17 LogDebug(
"EcalPedOffset") <<
"entering TPedValues ctor ...";
18 for (
int i = 0;
i < 1700; ++
i)
23 LogDebug(
"EcalPedOffset") <<
"entering TPedValues copyctor ...";
28 for (
int crystal = 0; crystal < 1700; ++crystal)
29 for (
int DAC = 0; DAC < 256; ++DAC)
32 for (
int i = 0;
i < 1700; ++
i)
41 if (gainId <= 0 || gainId >= 4) {
42 edm::LogWarning(
"EcalPedOffset") <<
"WARNING : TPedValues : gainId " <<
gainId <<
" does not exist, entry skipped";
47 if (crystal <= 0 || crystal > 1700) {
48 edm::LogWarning(
"EcalPedOffset") <<
"WARNING : TPedValues : crystal " << crystal
49 <<
" does not exist, entry skipped";
54 if (DAC < 0 || DAC >= 256) {
55 edm::LogWarning(
"EcalPedOffset") <<
"WARNING : TPedValues : DAC value " << DAC <<
" is out range, entry skipped";
72 for (
int crystal = 0; crystal < 1700; ++crystal) {
75 int dummyBestDAC = -1;
76 bool hasDigis =
false;
78 for (
int DAC = DACstart; DAC < DACend; ++DAC) {
93 if ((dummyBestDAC == (DACend - 1) || dummyBestDAC == -1) && hasDigis) {
103 edm::LogError(
"EcalPedOffset") <<
" TPedValues : cannot find best DAC value for channel: "
119 for (
int crystal = 0; crystal < 1700; ++crystal) {
121 for (
int DAC = DACstart; DAC < DACend; ++DAC) {
153 const double maxSlope,
154 const double minSlope,
155 const double maxChi2OverNDF)
const {
164 for (
int xtl = 0; xtl < 1700; ++xtl) {
167 vector<double> asseX;
169 vector<double> asseY;
176 for (
int dac = 0; dac < 256; ++dac) {
180 asseX.push_back(dac);
186 if (!asseX.empty()) {
188 while (lastBin < (
int)asseX.size() - 1 && asseY[lastBin + 1] > 0 &&
189 (asseY[lastBin + 1] - asseY[lastBin + 2]) != 0)
192 int fitRangeEnd = (
int)asseX[lastBin];
194 if (fitRangeEnd < 66)
195 kinkPt = fitRangeEnd - 4;
196 TGraphErrors graph(asseX.size(), &(*asseX.begin()), &(*asseY.begin()), &(*
sigmaX.begin()), &(*
sigmaY.begin()));
198 sprintf(
funct,
"(x<%d)*([0]*x+[1])+(x>=%d)*([2]*x+[3])", kinkPt, kinkPt);
199 TF1 fitFunction(
"fitFunction",
funct, asseX[0], fitRangeEnd);
200 fitFunction.SetLineColor(2);
213 graph.GetXaxis()->SetTitle(
"DAC value");
214 graph.GetYaxis()->SetTitle(
"Average pedestal ADC");
215 graph.Fit(&fitFunction,
"RWQ");
218 double slope1 = fitFunction.GetParameter(0);
219 double slope2 = fitFunction.GetParameter(2);
221 if (fitFunction.GetChisquare() / fitFunction.GetNDF() > maxChi2OverNDF ||
222 fitFunction.GetChisquare() / fitFunction.GetNDF() < 0 || slope1 > 0 || slope2 > 0 ||
223 ((slope1 < -29 || slope1 > -18) && slope1 < 0) || ((slope2 < -29 || slope2 > -18) && slope2 < 0)) {
225 <<
" gain:" << gainHuman <<
" is not linear;"
226 <<
" slope of line1:" << fitFunction.GetParameter(0)
227 <<
" slope of line2:" << fitFunction.GetParameter(2) <<
" reduced chi-squared:"
228 << fitFunction.GetChisquare() / fitFunction.GetNDF();
235 if ((asseX.back() - asseX.front() + 1) != asseX.size())
236 edm::LogError(
"EcalPedOffset") <<
"TPedValues : Pedestal average not found "
238 <<
" gain:" << gainHuman;