diff --git a/DataFormats/Detectors/FIT/FDD/include/DataFormatsFDD/RecPoint.h b/DataFormats/Detectors/FIT/FDD/include/DataFormatsFDD/RecPoint.h index f784d99145728..226663dfa2319 100644 --- a/DataFormats/Detectors/FIT/FDD/include/DataFormatsFDD/RecPoint.h +++ b/DataFormats/Detectors/FIT/FDD/include/DataFormatsFDD/RecPoint.h @@ -21,17 +21,22 @@ #include "DataFormatsFDD/ChannelData.h" #include "CommonDataFormat/RangeReference.h" #include "DataFormatsFDD/Digit.h" +#include "DataFormatsFIT/ChannelDataBit.h" namespace o2 { namespace fdd { struct ChannelDataFloat { + static constexpr int DUMMY_CHANNEL_ID = -1; + static constexpr int DUMMY_CHAIN_QTC = -1; + static constexpr double DUMMY_CFD_TIME = -20000; + static constexpr double DUMMY_QTC_AMPL = -20000; - int mPMNumber = -1; // channel Id - int adcId = -1; // QTC chain - double mTime = -20000; // time in ps, 0 at the LHC clk center - double mChargeADC = -20000; // charge [channels] + int mPMNumber = DUMMY_CHANNEL_ID; ///< Channel ID + int adcId = DUMMY_CHAIN_QTC; ///< Channel data bits + double mTime = DUMMY_CFD_TIME; ///< Channel time (ns), 0 at the LHC clock center + double mChargeADC = DUMMY_QTC_AMPL; ///< Channel charge (ADC channels) ChannelDataFloat() = default; ChannelDataFloat(int Channel, double Time, double Charge, int AdcId) @@ -42,7 +47,41 @@ struct ChannelDataFloat { adcId = AdcId; } + static void setFlag(fit::ChannelDataBit bitFlag, int& adcId) + { + adcId = adcId | (1 << bitFlag); + } + static void clearFlag(fit::ChannelDataBit bitFlag, int& adcId) + { + adcId = adcId & ~(1 << bitFlag); + } + void setFlags(int flag) + { + adcId = flag; + } + void setFlag(fit::ChannelDataBit bitFlag, bool value = true) + { + adcId = (adcId & (~(1 << bitFlag))) | (int(value) << bitFlag); + } + bool getFlag(fit::ChannelDataBit bitFlag) const + { + return bool(adcId & (1 << bitFlag)); + } + bool areAllFlagsGood() const + { + return (!getFlag(fit::ChannelDataBit::kIsDoubleEvent) && + !getFlag(fit::ChannelDataBit::kIsTimeInfoNOTvalid) && + getFlag(fit::ChannelDataBit::kIsCFDinADCgate) && + !getFlag(fit::ChannelDataBit::kIsTimeInfoLate) && + !getFlag(fit::ChannelDataBit::kIsAmpHigh) && + getFlag(fit::ChannelDataBit::kIsEventInTVDC) && + !getFlag(fit::ChannelDataBit::kIsTimeInfoLost)); + } + void print() const; + int getChannelId() const { return mPMNumber; } + double getTime() const { return mTime; } + double getAmp() const { return mChargeADC; } bool operator==(const ChannelDataFloat&) const = default; ClassDefNV(ChannelDataFloat, 1); diff --git a/DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/RecPoints.h b/DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/RecPoints.h index 0503e4f39948f..218be2f63c0f4 100644 --- a/DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/RecPoints.h +++ b/DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/RecPoints.h @@ -20,6 +20,7 @@ #include "DataFormatsFT0/ChannelData.h" #include "CommonDataFormat/RangeReference.h" #include "DataFormatsFT0/Digit.h" +#include "DataFormatsFIT/ChannelDataBit.h" #include #include "Rtypes.h" #include @@ -33,11 +34,15 @@ namespace ft0 { struct ChannelDataFloat { + static constexpr int DUMMY_CHANNEL_ID = -1; + static constexpr int DUMMY_CHAIN_QTC = -1; + static constexpr float DUMMY_CFD_TIME = -20000; + static constexpr float DUMMY_QTC_AMPL = -20000; - int ChId = -1; // channel Id - int ChainQTC = -1; // QTC chain - float CFDTime = -20000; // time in ps, 0 at the LHC clk center - float QTCAmpl = -20000; // Amplitude mV + int ChId = DUMMY_CHANNEL_ID; ///< Channel ID + int ChainQTC = DUMMY_CHAIN_QTC; ///< Channel data bits + float CFDTime = DUMMY_CFD_TIME; ///< Channel time (ns), 0 at the LHC clock center + float QTCAmpl = DUMMY_QTC_AMPL; ///< Channel charge (ADC channels) ChannelDataFloat() = default; ChannelDataFloat(int iPmt, float time, float charge, int chainQTC) @@ -48,7 +53,42 @@ struct ChannelDataFloat { ChainQTC = chainQTC; } + static void setFlag(fit::ChannelDataBit bitFlag, int& chainQTC) + { + chainQTC = chainQTC | 1 << bitFlag; + } + static void clearFlag(fit::ChannelDataBit bitFlag, int& chainQTC) + { + chainQTC = chainQTC & (~(1 << bitFlag)); + } + void setFlags(int flag) + { + ChainQTC = flag; + } + void setFlag(fit::ChannelDataBit bitFlag, bool value = true) + { + ChainQTC = (ChainQTC & (~(1 << bitFlag))) | (int(value) << bitFlag); + } + bool getFlag(fit::ChannelDataBit bitFlag) const + { + return bool(ChainQTC & (1 << bitFlag)); + } + bool areAllFlagsGood() const + { + return (!getFlag(fit::ChannelDataBit::kIsDoubleEvent) && + !getFlag(fit::ChannelDataBit::kIsTimeInfoNOTvalid) && + getFlag(fit::ChannelDataBit::kIsCFDinADCgate) && + !getFlag(fit::ChannelDataBit::kIsTimeInfoLate) && + !getFlag(fit::ChannelDataBit::kIsAmpHigh) && + getFlag(fit::ChannelDataBit::kIsEventInTVDC) && + !getFlag(fit::ChannelDataBit::kIsTimeInfoLost)); + } + void print() const; + int getChannelId() const { return ChId; } + float getTime() const { return CFDTime; } + float getAmp() const { return QTCAmpl; } + bool operator==(const ChannelDataFloat&) const = default; ClassDefNV(ChannelDataFloat, 1); diff --git a/DataFormats/Detectors/FIT/FV0/include/DataFormatsFV0/RecPoints.h b/DataFormats/Detectors/FIT/FV0/include/DataFormatsFV0/RecPoints.h index b3527fdd049d2..d1e1aa837ba35 100644 --- a/DataFormats/Detectors/FIT/FV0/include/DataFormatsFV0/RecPoints.h +++ b/DataFormats/Detectors/FIT/FV0/include/DataFormatsFV0/RecPoints.h @@ -18,6 +18,7 @@ #include "CommonDataFormat/InteractionRecord.h" #include "CommonDataFormat/RangeReference.h" #include "DataFormatsFV0/Digit.h" +#include "DataFormatsFIT/ChannelDataBit.h" #include #include @@ -26,11 +27,15 @@ namespace o2 namespace fv0 { struct ChannelDataFloat { + static constexpr int DUMMY_CHANNEL_ID = -1; + static constexpr int DUMMY_CHAIN_QTC = -1; + static constexpr double DUMMY_CFD_TIME = -20000.0; + static constexpr double DUMMY_QTC_AMPL = -20000.0; - int channel = -1; // channel Id - double time = -20000; // time in ns, 0 at the LHC clk center - double charge = -20000; // charge [channels] - int adcId = -1; // QTC chain + int channel = DUMMY_CHANNEL_ID; ///< Channel ID + float time = DUMMY_CFD_TIME; ///< Channel time (ns), 0 at the LHC clock center + float charge = DUMMY_QTC_AMPL; ///< Channel charge (ADC channels) + int adcId = DUMMY_CHAIN_QTC; ///< Channel data bits ChannelDataFloat() = default; ChannelDataFloat(int Channel, double Time, double Charge, int AdcId) @@ -41,7 +46,41 @@ struct ChannelDataFloat { adcId = AdcId; } + static void setFlag(fit::ChannelDataBit bitFlag, int& adcId) + { + adcId = adcId | (1 << bitFlag); + } + static void clearFlag(fit::ChannelDataBit bitFlag, int& adcId) + { + adcId = adcId & (~(1 << bitFlag)); + } + void setFlags(int flag) + { + adcId = flag; + } + void setFlag(fit::ChannelDataBit bitFlag, bool value = true) + { + adcId = (adcId & (~(1 << bitFlag))) | (int(value) << bitFlag); + } + bool getFlag(fit::ChannelDataBit bitFlag) const + { + return bool(adcId & (1 << bitFlag)); + } + bool areAllFlagsGood() const + { + return (!getFlag(fit::ChannelDataBit::kIsDoubleEvent) && + !getFlag(fit::ChannelDataBit::kIsTimeInfoNOTvalid) && + getFlag(fit::ChannelDataBit::kIsCFDinADCgate) && + !getFlag(fit::ChannelDataBit::kIsTimeInfoLate) && + !getFlag(fit::ChannelDataBit::kIsAmpHigh) && + getFlag(fit::ChannelDataBit::kIsEventInTVDC) && + !getFlag(fit::ChannelDataBit::kIsTimeInfoLost)); + } + void print() const; + int getChannelId() const { return channel; } + double getTime() const { return time; } + double getAmp() const { return charge; } bool operator==(const ChannelDataFloat&) const = default; ClassDefNV(ChannelDataFloat, 1); diff --git a/DataFormats/Detectors/FIT/common/include/DataFormatsFIT/ChannelDataBit.h b/DataFormats/Detectors/FIT/common/include/DataFormatsFIT/ChannelDataBit.h new file mode 100644 index 0000000000000..3a90f5c4764b8 --- /dev/null +++ b/DataFormats/Detectors/FIT/common/include/DataFormatsFIT/ChannelDataBit.h @@ -0,0 +1,45 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file ChannelDataBit.h +/// \brief Enum type describing channel data bits +/// +/// \author wiktor.pierozak@cern.ch + +#ifndef O2_FIT_CHANNEL_DATA_BIT_ +#define O2_FIT_CHANNEL_DATA_BIT_ + +#include + +namespace o2 +{ +namespace fit +{ +enum class ChannelDataBit { kNumberADC = 0, + kIsDoubleEvent, + kIsTimeInfoNOTvalid, + kIsCFDinADCgate, + kIsTimeInfoLate, + kIsAmpHigh, + kIsEventInTVDC, + kIsTimeInfoLost +}; + +template + requires std::integral +IntegerType operator<<(IntegerType n, ChannelDataBit bitFlag) +{ + return n << static_cast(bitFlag); +} +} // namespace fit +} // namespace o2 + +#endif \ No newline at end of file diff --git a/Detectors/FIT/FV0/reconstruction/src/BaseRecoTask.cxx b/Detectors/FIT/FV0/reconstruction/src/BaseRecoTask.cxx index 8a217232592df..a108f0b906d47 100644 --- a/Detectors/FIT/FV0/reconstruction/src/BaseRecoTask.cxx +++ b/Detectors/FIT/FV0/reconstruction/src/BaseRecoTask.cxx @@ -51,15 +51,15 @@ RP BaseRecoTask::process(o2::fv0::Digit const& bcd, inChData[ich].ChainQTC}; // Conditions for reconstructing collision time (3 variants: first, average-relaxed and average-tight) - if (outChData[ich].charge > FV0DigParam::Instance().chargeThrForMeanTime) { - sideAtimeFirst = std::min(static_cast(sideAtimeFirst), outChData[ich].time); + if (outChData[ich].getAmp() > FV0DigParam::Instance().chargeThrForMeanTime) { + sideAtimeFirst = std::min(static_cast(sideAtimeFirst), outChData[ich].getTime()); if (inChData[ich].areAllFlagsGood()) { - if (std::abs(outChData[ich].time) < FV0DigParam::Instance().mTimeThresholdForReco) { - sideAtimeAvg += outChData[ich].time; + if (std::abs(outChData[ich].getTime()) < FV0DigParam::Instance().mTimeThresholdForReco) { + sideAtimeAvg += outChData[ich].getTime(); ndigitsA++; } - if (outChData[ich].charge > FV0DigParam::Instance().mAmpThresholdForReco && std::abs(outChData[ich].time) < FV0DigParam::Instance().mTimeThresholdForReco) { - sideAtimeAvgSelected += outChData[ich].time; + if (outChData[ich].getAmp() > FV0DigParam::Instance().mAmpThresholdForReco && std::abs(outChData[ich].getTime()) < FV0DigParam::Instance().mTimeThresholdForReco) { + sideAtimeAvgSelected += outChData[ich].getTime(); ndigitsASelected++; } }