|
| 1 | +// Copyright CERN and copyright holders of ALICE O2. This software is |
| 2 | +// distributed under the terms of the GNU General Public License v3 (GPL |
| 3 | +// Version 3), copied verbatim in the file "COPYING". |
| 4 | +// |
| 5 | +// See http://alice-o2.web.cern.ch/license for full licensing information. |
| 6 | +// |
| 7 | +// In applying this license CERN does not waive the privileges and immunities |
| 8 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 9 | +// or submit itself to any jurisdiction. |
| 10 | + |
| 11 | +/// \file MCHChannelCalibrator.h |
| 12 | +/// \brief Implementation of the MCH calibrator using pedestal data |
| 13 | +/// |
| 14 | +/// \author Andrea Ferrero, CEA-Saclay |
| 15 | + |
| 16 | +#ifndef MCH_CHANNEL_CALIBRATOR_H_ |
| 17 | +#define MCH_CHANNEL_CALIBRATOR_H_ |
| 18 | + |
| 19 | +#include "DataFormatsMCH/DsChannelGroup.h" |
| 20 | +#include "DetectorsCalibration/TimeSlotCalibration.h" |
| 21 | +#include "DetectorsCalibration/TimeSlot.h" |
| 22 | +#include "CCDB/CcdbObjectInfo.h" |
| 23 | +#include "MCHCalibration/PedestalDigit.h" |
| 24 | +#include "MCHCalibration/PedestalProcessor.h" |
| 25 | + |
| 26 | +#include <array> |
| 27 | + |
| 28 | +namespace o2 |
| 29 | +{ |
| 30 | +namespace mch |
| 31 | +{ |
| 32 | +namespace calibration |
| 33 | +{ |
| 34 | + |
| 35 | +/// Implementation of the processor that computes the mean and RMS of the channel-by-channel pedestals |
| 36 | +/// from the data corresponding to a time slot. |
| 37 | +/// In the MCH case the time slot has by default an infinite duration, therefore there is only a single |
| 38 | +/// set of pedestal values for each calibration run. |
| 39 | +class MCHChannelData |
| 40 | +{ |
| 41 | + using Slot = o2::calibration::TimeSlot<o2::mch::calibration::MCHChannelData>; |
| 42 | + |
| 43 | + public: |
| 44 | + MCHChannelData() = default; |
| 45 | + ~MCHChannelData() = default; |
| 46 | + |
| 47 | + void print() const; |
| 48 | + |
| 49 | + /// function to update the pedestal values from the data of a single TimeFrame |
| 50 | + void fill(const gsl::span<const o2::mch::calibration::PedestalDigit> data); |
| 51 | + void merge(const MCHChannelData* prev); |
| 52 | + |
| 53 | + /// function to access the table of computed pedestals for each readout channel |
| 54 | + const PedestalProcessor::PedestalsMap& getPedestals() { return mPedestalProcessor.getPedestals(); } |
| 55 | + |
| 56 | + private: |
| 57 | + /// helper class that performs the actual computation of the pedestals from the input digits |
| 58 | + PedestalProcessor mPedestalProcessor; |
| 59 | + |
| 60 | + ClassDefNV(MCHChannelData, 1); |
| 61 | +}; |
| 62 | + |
| 63 | +/// Implementation of a calibrator object that checks the computed mean and RMS of the pedestals and compares the |
| 64 | +/// values with user-supplied thresholds. |
| 65 | +/// The channels whose values exceed one of the thresholds are considered bad/noisy and they are stored into a |
| 66 | +/// "bad channels" list that is sent to the CDDB populator. |
| 67 | +class MCHChannelCalibrator final : public o2::calibration::TimeSlotCalibration<o2::mch::calibration::PedestalDigit, o2::mch::calibration::MCHChannelData> |
| 68 | +{ |
| 69 | + using TFType = uint64_t; |
| 70 | + using Slot = o2::calibration::TimeSlot<o2::mch::calibration::MCHChannelData>; |
| 71 | + using BadChannelsVector = o2::mch::DsChannelGroup; |
| 72 | + using CcdbObjectInfo = o2::ccdb::CcdbObjectInfo; |
| 73 | + |
| 74 | + public: |
| 75 | + struct ChannelPedestal { |
| 76 | + ChannelPedestal() = default; |
| 77 | + ChannelPedestal(o2::mch::DsChannelId chid, double mean, double rms) : mDsChId(chid), mPedMean(mean), mPedRms(rms) {} |
| 78 | + |
| 79 | + o2::mch::DsChannelId mDsChId; |
| 80 | + double mPedMean{0}; |
| 81 | + double mPedRms{0}; |
| 82 | + }; |
| 83 | + using PedestalsVector = std::vector<ChannelPedestal>; |
| 84 | + |
| 85 | + MCHChannelCalibrator(float pedThreshold, float noiseThreshold) : mPedestalThreshold(pedThreshold), mNoiseThreshold(noiseThreshold), mTFStart(0xffffffffffffffff){}; |
| 86 | + |
| 87 | + ~MCHChannelCalibrator() final = default; |
| 88 | + |
| 89 | + bool hasEnoughData(const Slot& slot) const final; |
| 90 | + void initOutput() final; |
| 91 | + void finalizeSlot(Slot& slot) final; |
| 92 | + Slot& emplaceNewSlot(bool front, TFType tstart, TFType tend) final; |
| 93 | + void endOfStream(); |
| 94 | + |
| 95 | + const BadChannelsVector& getBadChannelsVector() const { return mBadChannelsVector; } |
| 96 | + const CcdbObjectInfo& getBadChannelsInfo() const { return mBadChannelsInfo; } |
| 97 | + CcdbObjectInfo& getBadChannelsInfo() { return mBadChannelsInfo; } |
| 98 | + |
| 99 | + const PedestalsVector& getPedestalsVector() const { return mPedestalsVector; } |
| 100 | + |
| 101 | + private: |
| 102 | + float mNoiseThreshold; |
| 103 | + float mPedestalThreshold; |
| 104 | + |
| 105 | + TFType mTFStart; |
| 106 | + |
| 107 | + // output |
| 108 | + BadChannelsVector mBadChannelsVector; /// vector containing the unique IDs of the bad/noisy channels |
| 109 | + CcdbObjectInfo mBadChannelsInfo; /// vector of CCDB Infos , each element is filled with the CCDB description of the accompanying BadChannelsVector object |
| 110 | + PedestalsVector mPedestalsVector; |
| 111 | + |
| 112 | + ClassDefOverride(MCHChannelCalibrator, 1); |
| 113 | +}; |
| 114 | + |
| 115 | +} // end namespace calibration |
| 116 | +} // end namespace mch |
| 117 | +} // end namespace o2 |
| 118 | + |
| 119 | +#endif /* MCH_CHANNEL_CALIBRATOR_H_ */ |
0 commit comments