Project
Loading...
Searching...
No Matches
CalibratorNoise.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
16
17using namespace o2::trd::constants;
18
19namespace o2::trd
20{
21
22void CalibratorNoise::process(const gsl::span<const Digit>& digits)
23{
24 for (const auto& digit : digits) {
25 int indexGlobal = HelperMethods::getGlobalChannelIndex(digit.getDetector(), digit.getROB(), digit.getMCM(), digit.getChannel());
26 auto& info = mChannelInfosDetailed[indexGlobal];
27 if (info.nEntries == 0) {
28 // the first time we see data from this channel we fill the detector information etc.
29 info.det = digit.getDetector();
30 info.sec = HelperMethods::getSector(digit.getDetector());
31 info.stack = HelperMethods::getStack(digit.getDetector());
32 info.layer = HelperMethods::getLayer(digit.getDetector());
33 info.row = digit.getPadRow();
34 info.col = digit.getPadCol();
35 info.isShared = digit.isSharedDigit();
36 info.channelGlb = HelperMethods::getChannelIndexInColumn(digit.getROB(), digit.getMCM(), digit.getChannel());
37 info.indexGlb = indexGlobal;
38 }
39 // the ADC information we always want to have
40 for (int i = 0; i < TIMEBINS; ++i) {
41 auto adc = digit.getADC()[i];
42 info.adcSum += adc;
43 info.adcSumSquared += adc * adc;
44 // mean and variance are calculated recursively
45 float meanCurrent = info.adcMean;
46 info.adcMean += (adc - meanCurrent) / (info.nEntries + 1);
47 info.variance += info.nEntries * (info.nEntries + 1) * (info.adcMean - meanCurrent) * (info.adcMean - meanCurrent);
48 info.nEntries += 1;
49 }
50 }
51 mNDigitsSeen += digits.size();
52 LOG(info) << "Processed " << digits.size() << " digits for this TF. Total number of processed digits: " << mNDigitsSeen;
53}
54
56{
57 for (const auto& channel : mChannelInfosDetailed) {
58 // create ChannelInfo object for array
59 if (channel.nEntries > 0) {
60 // we have seen data from this channel
61 auto& ch = mCCDBObject.getChannel(channel.indexGlb);
62 ch.setMean(channel.adcMean);
63 ch.setRMS(std::sqrt(channel.variance / channel.nEntries));
64 ch.setNentries(channel.nEntries);
65 }
66 }
67}
68
69} // namespace o2::trd
TRD pad calibration.
int32_t i
void process(const gsl::span< const Digit > &digits)
ChannelInfo & getChannel(int index)
void setMean(float mean)
constexpr int TIMEBINS
the number of time bins
Definition Constants.h:74
static int getGlobalChannelIndex(int det, int rob, int mcm, int channel)
static int getStack(int det)
static int getLayer(int det)
static int getSector(int det)
static int getChannelIndexInColumn(int rob, int mcm, int channel)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits
ArrayADC adc