7 #include "TGraphErrors.h"
13 for (
int i=0 ;
i<256; ++
i) vett[
i] = 0. ;
18 m_bestPedestal (bestPedestal) ,
21 LogDebug (
"EcalPedOffset") <<
"entering TPedValues ctor ..." ;
22 for(
int i=0;
i<1700;++
i)
29 LogDebug (
"EcalPedOffset") <<
"entering TPedValues copyctor ..." ;
33 for (
int gain = 0 ; gain < 3 ; ++gain)
34 for (
int crystal = 0 ; crystal < 1700 ; ++crystal)
35 for (
int DAC = 0 ; DAC < 256 ; ++DAC)
38 for(
int i=0;
i<1700;++
i)
51 const int endcapIndex)
55 if (gainId <= 0 || gainId >= 4)
57 edm::LogWarning (
"EcalPedOffset") <<
"WARNING : TPedValues : gainId " << gainId
58 <<
" does not exist, entry skipped" ;
63 if (crystal <= 0 || crystal > 1700)
65 edm::LogWarning (
"EcalPedOffset") <<
"WARNING : TPedValues : crystal " << crystal
66 <<
" does not exist, entry skipped" ;
71 if (DAC < 0 || DAC >= 256)
73 edm::LogWarning (
"EcalPedOffset") <<
"WARNING : TPedValues : DAC value " << DAC
74 <<
" is out range, entry skipped" ;
94 for (
int crystal = 0 ; crystal < 1700 ; ++crystal)
98 int dummyBestDAC = -1 ;
99 bool hasDigis =
false;
101 for (
int DAC = DACstart ; DAC < DACend ; ++DAC)
104 if (average == -1) continue ;
116 if ((dummyBestDAC == (DACend-1) || dummyBestDAC == -1) && hasDigis)
119 if (
gainId ==1) gainHuman =12;
120 else if (
gainId ==2) gainHuman =6;
121 else if (
gainId ==3) gainHuman =1;
124 <<
" TPedValues : cannot find best DAC value for channel: "
126 <<
" gain: " << gainHuman;
144 for (
int crystal = 0 ; crystal < 1700 ; ++crystal)
147 for (
int DAC = DACstart ; DAC < DACend ; ++DAC)
179 const double maxSlope,
const double minSlope,
const double maxChi2OverNDF)
const
183 if (!rootFile->cd (dirName.c_str ()))
185 rootFile->mkdir (dirName.c_str ()) ;
186 rootFile->cd (dirName.c_str ()) ;
190 for (
int xtl=0 ; xtl<1700 ; ++xtl)
193 for (
int gain=0 ; gain<3 ; ++gain)
195 vector<double> asseX;
196 vector<double> sigmaX;
197 vector<double> asseY;
198 vector<double> sigmaY;
204 for (
int dac=0 ; dac<256 ; ++dac)
210 asseX.push_back(dac);
212 asseY.push_back(average);
213 sigmaY.push_back(rms);
219 while(lastBin<(
int)asseX.size()-1 && asseY[lastBin+1]>0
220 && (asseY[lastBin+1]-asseY[lastBin+2])!=0)
223 int fitRangeEnd = (int)asseX[lastBin];
226 kinkPt = fitRangeEnd-4;
227 TGraphErrors
graph(asseX.size(),&(*asseX.begin()),&(*asseY.begin()),
228 &(*sigmaX.begin()),&(*sigmaY.begin()));
230 sprintf(funct,
"(x<%d)*([0]*x+[1])+(x>=%d)*([2]*x+[3])",kinkPt,kinkPt);
231 TF1 fitFunction(
"fitFunction",funct,asseX[0],fitRangeEnd);
232 fitFunction.SetLineColor(2);
236 if (gain ==0) gainHuman =12;
237 else if (gain ==1) gainHuman =6;
238 else if (gain ==2) gainHuman =1;
241 graph.GetXaxis()->SetTitle(
"DAC value");
242 graph.GetYaxis()->SetTitle(
"Average pedestal ADC");
243 graph.Fit(&fitFunction,
"RWQ");
246 double slope1 = fitFunction.GetParameter(0);
247 double slope2 = fitFunction.GetParameter(2);
249 if(fitFunction.GetChisquare()/fitFunction.GetNDF()>maxChi2OverNDF ||
250 fitFunction.GetChisquare()/fitFunction.GetNDF()<0 ||
251 slope1>0 || slope2>0 ||
252 ((slope1<-29 || slope1>-18) && slope1<0) ||
253 ((slope2<-29 || slope2>-18) && slope2<0))
255 edm::LogError(
"EcalPedOffset") <<
"TPedValues : TGraph for channel:" <<
257 " gain:" << gainHuman <<
" is not linear;" <<
" slope of line1:" <<
258 fitFunction.GetParameter(0) <<
" slope of line2:" <<
259 fitFunction.GetParameter(2) <<
" reduced chi-squared:" <<
260 fitFunction.GetChisquare()/fitFunction.GetNDF();
265 if((asseX.back()-asseX.front()+1)!=asseX.size())
266 edm::LogError(
"EcalPedOffset") <<
"TPedValues : Pedestal average not found " <<
268 <<
" gain:" << gainHuman;
TSinglePedEntry m_entries[3][1700][256]
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
Transient container Store all the pedestal values depending on the gain and pedestal offset $Date: $R...
TPedValues(double RMSmax=2, int bestPedestal=200)
ctor
double RMS() const
get the RMS of the inserted values
double average() const
get the average of the inserted values
TPedResult terminate(const int &DACstart=0, const int &DACend=256) const
calculate the offset values for all the containers
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
return(e1-e2)*(e1-e2)+dp *dp
int endcapCrystalNumbers[1700]
void insert(const int gainId, const int crystal, const int DAC, const int pedestal, const int endcapIndex)
add a single value
void reset(double vett[256])
void insert(const int &pedestal)
add a single value