|
| 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 | +#ifndef TOF_CALIB_COLLECTOR_H_ |
| 12 | +#define TOF_CALIB_COLLECTOR_H_ |
| 13 | + |
| 14 | +#include "DetectorsCalibration/TimeSlotCalibration.h" |
| 15 | +#include "DetectorsCalibration/TimeSlot.h" |
| 16 | +#include "DataFormatsTOF/CalibInfoTOF.h" |
| 17 | +#include "TOFBase/Geo.h" |
| 18 | +#include "DataFormatsTOF/CalibInfoTOFshort.h" |
| 19 | + |
| 20 | +#include <array> |
| 21 | + |
| 22 | +namespace o2 |
| 23 | +{ |
| 24 | +namespace tof |
| 25 | +{ |
| 26 | + |
| 27 | +class TOFCalibInfoSlot |
| 28 | +{ |
| 29 | + |
| 30 | + using Slot = o2::calibration::TimeSlot<o2::tof::TOFCalibInfoSlot>; |
| 31 | + using Geo = o2::tof::Geo; |
| 32 | + |
| 33 | + public: |
| 34 | + static constexpr int NCHANNELSXSECTOR = o2::tof::Geo::NCHANNELS / o2::tof::Geo::NSECTORS; |
| 35 | + |
| 36 | + TOFCalibInfoSlot() |
| 37 | + { |
| 38 | + for (int ch = 0; ch < Geo::NCHANNELS; ch++) { |
| 39 | + mEntriesSlot[ch] = 0; |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + ~TOFCalibInfoSlot() = default; |
| 44 | + |
| 45 | + void print() const; |
| 46 | + void printEntries() const; |
| 47 | + void fill(const gsl::span<const o2::dataformats::CalibInfoTOF> data); |
| 48 | + void merge(const TOFCalibInfoSlot* prev); |
| 49 | + |
| 50 | + auto& getEntriesPerChannel() const { return mEntriesSlot; } |
| 51 | + auto& getEntriesPerChannel() { return mEntriesSlot; } |
| 52 | + auto& getCollectedCalibInfoSlot() { return mTOFCollectedCalibInfoSlot; } |
| 53 | + auto& getCollectedCalibInfoSlot() const { return mTOFCollectedCalibInfoSlot; } |
| 54 | + |
| 55 | + private: |
| 56 | + std::array<int, Geo::NCHANNELS> mEntriesSlot; // vector containing number of entries per channel |
| 57 | + std::vector<o2::dataformats::CalibInfoTOFshort> mTOFCollectedCalibInfoSlot; ///< output TOF calibration info |
| 58 | + |
| 59 | + ClassDefNV(TOFCalibInfoSlot, 1); |
| 60 | +}; |
| 61 | + |
| 62 | +class TOFCalibCollector final : public o2::calibration::TimeSlotCalibration<o2::dataformats::CalibInfoTOF, o2::tof::TOFCalibInfoSlot> |
| 63 | +{ |
| 64 | + using TFType = uint64_t; |
| 65 | + using Slot = o2::calibration::TimeSlot<o2::tof::TOFCalibInfoSlot>; |
| 66 | + |
| 67 | + public: |
| 68 | + TOFCalibCollector(bool TFsendingPolicy, int maxNumOfHits, bool test = false) : mTFsendingPolicy(TFsendingPolicy), mMaxNumOfHits(maxNumOfHits), mTest(test){}; |
| 69 | + |
| 70 | + ~TOFCalibCollector() final = default; |
| 71 | + |
| 72 | + bool hasEnoughData(const Slot& slot) const final; |
| 73 | + void initOutput() final; |
| 74 | + void finalizeSlot(Slot& slot) final; |
| 75 | + Slot& emplaceNewSlot(bool front, TFType tstart, TFType tend) final; |
| 76 | + void isTest(bool istest) { mTest = istest; } |
| 77 | + auto& getCollectedCalibInfo() const { return mTOFCollectedCalibInfo; } |
| 78 | + auto& getEntriesPerChannel() const { return mEntries; } |
| 79 | + void isMaxNumberOfHitsAbsolute(bool absNumber) { mAbsMaxNumOfHits = absNumber; } |
| 80 | + |
| 81 | + private: |
| 82 | + bool mTFsendingPolicy = false; // whether we will send information at every TF or only when we have a certain statistics |
| 83 | + int mMaxNumOfHits = 500; // maximum number of hits for one single channel to trigger the sending of the information (if mTFsendingPolicy = false) |
| 84 | + bool mTest = false; // flag to say whether we are in test mode or not |
| 85 | + bool mAbsMaxNumOfHits = true; // to decide if the mMaxNumOfHits should be multiplied by the number of TOF channels |
| 86 | + std::array<int, Geo::NCHANNELS> mEntries; // vector containing number of entries per channel |
| 87 | + std::vector<o2::dataformats::CalibInfoTOFshort> mTOFCollectedCalibInfo; ///< output TOF calibration info |
| 88 | + |
| 89 | + ClassDefOverride(TOFCalibCollector, 1); |
| 90 | +}; |
| 91 | + |
| 92 | +} // end namespace tof |
| 93 | +} // end namespace o2 |
| 94 | + |
| 95 | +#endif /* TOF_CHANNEL_CALIBRATOR_H_ */ |
0 commit comments