@@ -75,8 +75,10 @@ void PedestalSpectrum::analyze()
7575 // -------------------------------------------------------------------------->
7676 // 0 10 ^ 20 30 ADC amplitude
7777 // tolerated gap
78+ //
7879 // we want to find all the peaks, determine their mean and rms
7980 // and mean and rms of all the distribution
81+ // pedestal is calculated from peak with most of statistics in it
8082 std::vector<uint16_t > peakLowEdge, peakHighEdge;
8183 peakLowEdge.push_back (mSpectrumContainer .begin ()->first );
8284 peakHighEdge.push_back ((--mSpectrumContainer .end ())->first );
@@ -94,7 +96,7 @@ void PedestalSpectrum::analyze()
9496 totalSumA += iAmpl->first * iAmpl->second ;
9597 totalSumA2 += (iAmpl->first * iAmpl->first ) * iAmpl->second ;
9698
97- if (iNextAmpl != mSpectrumContainer .end ()) { // is iAmpl not the last bin?
99+ if (iNextAmpl != mSpectrumContainer .end ()) { // is iAmpl not the last bin?
98100 if ((iNextAmpl->first - iAmpl->first ) > mToleratedGapWidth ) { // let's consider |bin1-bin2|<=5 belong to same peak
99101 // firts, save peak low and high edge (just for the future cases)
100102 peakHighEdge.push_back (iAmpl->first );
@@ -107,7 +109,7 @@ void PedestalSpectrum::analyze()
107109 peakSumA2 = 0 .;
108110 peakCounts = 0 ;
109111 }
110- } else { // this is last bin
112+ } else { // this is last bin
111113 peakHighEdge.push_back (iAmpl->first );
112114 mMeanOfPeaks .push_back (peakSumA / peakCounts);
113115 mRMSOfPeaks .push_back (sqrt (peakSumA2 / peakCounts - mMeanOfPeaks .back () * mMeanOfPeaks .back ()));
@@ -120,20 +122,19 @@ void PedestalSpectrum::analyze()
120122 mRMSOfPeaks .push_back (sqrt (totalSumA2 / totalCounts - mMeanOfPeaks .back () * mMeanOfPeaks .back ()));
121123 mPeakCounts .push_back (totalCounts);
122124
123- // final decision on pedestal value and RMS
124- if (mNPeaks == 1 ) { // everything seems to be good
125+ // final decision on pedestal value and RMS
126+ if (mNPeaks == 1 ) { // everything seems to be good
125127 mPedestalValue = mMeanOfPeaks .back ();
126128 mPedestalRMS = mRMSOfPeaks .back ();
127- if ((mPedestalRMS > mSuspiciousPedestalRMS ) && ((mPedestalValue + mPedestalRMS * mZSnSigmas ) < peakHighEdge.back ())) {
128- mPedestalRMS = (peakHighEdge.back () - mPedestalValue ) / mZSnSigmas ;
129- }
130- } else if (mNPeaks > 1 ) { // there are some problems with several pedestal peaks
131- mPedestalValue = mMeanOfPeaks .at (mNPeaks - 1 ); // mean of last peak
132- // mPedestalValue = mMeanOfPeaks.back();
133- mPedestalRMS = mRMSOfPeaks .back (); // total RMS of distribution
134- if ((mPedestalValue + mPedestalRMS * mZSnSigmas ) < peakHighEdge.back ()) {
135- mPedestalRMS = (peakHighEdge.back () - mPedestalValue ) / mZSnSigmas ;
129+ } else if (mNPeaks > 1 ) { // there are some problems with several pedestal peaks
130+ uint16_t iPeakWithMaxStat = 0 ;
131+ for (auto i = 0 ; i < mNPeaks ; i++) { // find peak with max statistics
132+ if (mPeakCounts [iPeakWithMaxStat] < mPeakCounts [i]) {
133+ iPeakWithMaxStat = i;
134+ }
136135 }
136+ mPedestalValue = mMeanOfPeaks [iPeakWithMaxStat]; // mean of peak with max statistics
137+ mPedestalRMS = mRMSOfPeaks [iPeakWithMaxStat]; // RMS of peak with max statistics
137138 }
138139 mIsAnalyzed = true ;
139140}
@@ -248,7 +249,7 @@ void PedestalCalibrator::finalizeSlot(PedestalTimeSlot& slot)
248249 LOG (info) << " PedestalCalibrator::finalizeSlot() : finalizing slot "
249250 << slot.getTFStart () << " <= TF <= " << slot.getTFEnd () << " with " << calibData->mNEvents << " events." ;
250251
251- // o2::cpv::Geometry geo; // CPV geometry object
252+ // o2::cpv::Geometry geo; // CPV geometry object
252253
253254 // o2::cpv::Pedestals - calibration object used at reconstruction
254255 // and efficiencies vector
@@ -298,6 +299,7 @@ void PedestalCalibrator::finalizeSlot(PedestalTimeSlot& slot)
298299 mPedEfficienciesVec .push_back (efficiencies);
299300 mDeadChannelsVec .push_back (deadChannels);
300301 mThresholdsFEEVec .push_back (thresholdsFEE);
302+ mThresholdsFEEVec .push_back (thresholdsFEE); // push same FEE thresholds 2 times so one of it goes to ccdb with subspec 0 and another with subspec 1 (for normal and DCS ccdb population)
301303 mHighPedChannelsVec .push_back (highPedChannels);
302304
303305 // metadata for o2::cpv::Pedestals
@@ -321,6 +323,8 @@ void PedestalCalibrator::finalizeSlot(PedestalTimeSlot& slot)
321323 className = o2::utils::MemFileHelper::getClassName (thresholdsFEE);
322324 fileName = o2::ccdb::CcdbApi::generateFileName (className);
323325 mCcdbInfoThresholdsFEEVec .emplace_back (" CPV/PedestalRun/FEEThresholds" , className, fileName, metaData, timeStamp, timeStamp + 31536000000 ); // one year validity time (in milliseconds!)
326+ // push same FEE thresholds 2 times so one of it goes to ccdb with subspec 0 and another with subspec 1 (for normal and DCS ccdb population)
327+ mCcdbInfoThresholdsFEEVec .emplace_back (" CPV/PedestalRun/FEEThresholds" , className, fileName, metaData, timeStamp, timeStamp + 31536000000 );
324328
325329 // metadata for high pedestal (> 511) channels
326330 className = o2::utils::MemFileHelper::getClassName (highPedChannels);
@@ -336,5 +340,5 @@ PedestalTimeSlot& PedestalCalibrator::emplaceNewSlot(bool front, TFType tstart,
336340 return slot;
337341}
338342// ___________________________________________________________________
339- } // end namespace cpv
340- } // end namespace o2
343+ } // end namespace cpv
344+ } // end namespace o2
0 commit comments