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,
158 if (!rootFile->cd(
dirName.c_str())) {
159 rootFile->mkdir(
dirName.c_str());
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);
213 graph.GetXaxis()->SetTitle(
"DAC value");
214 graph.GetYaxis()->SetTitle(
"Average pedestal ADC");
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:" 235 if ((asseX.back() - asseX.front() + 1) != asseX.size())
236 edm::LogError(
"EcalPedOffset") <<
"TPedValues : Pedestal average not found " 238 <<
" gain:" << gainHuman;
double RMS() const
get the RMS of the inserted values
TSinglePedEntry m_entries[3][1700][256]
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
double fitFunction(double *x, double *par)
Log< level::Error, false > LogError
Transient container Store all the pedestal values depending on the gain and pedestal offset $Date: $R...
TPedResult terminate(const int &DACstart=0, const int &DACend=256) const
calculate the offset values for all the containers
TPedValues(double RMSmax=2, int bestPedestal=200)
ctor
int getCrystalNumber(int xtal) const
return the index from the table
int checkEntries(const int &DACstart=0, const int &DACend=256) const
check whether the scan was complete in the range
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
int makePlots(TFile *rootFile, const std::string &dirName, const double maxSlopeAllowed, const double minSlopeAllowed, const double maxChi2OverNDF) const
create a plot of the DAC pedestal trend
int endcapCrystalNumbers[1700]
void insert(const int gainId, const int crystal, const int DAC, const int pedestal, const int endcapIndex)
add a single value
double average() const
get the average of the inserted values
Log< level::Warning, false > LogWarning
void reset(double vett[256])
void insert(const int &pedestal)
add a single value