Skip to content

Commit b9dffd6

Browse files
committed
FIT: implemented getters and setters in ChannelDataFloat for FT0,FV0 and FDD
1 parent 17da522 commit b9dffd6

File tree

4 files changed

+161
-12
lines changed

4 files changed

+161
-12
lines changed

DataFormats/Detectors/FIT/FDD/include/DataFormatsFDD/RecPoint.h

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,22 @@
2121
#include "DataFormatsFDD/ChannelData.h"
2222
#include "CommonDataFormat/RangeReference.h"
2323
#include "DataFormatsFDD/Digit.h"
24+
#include "DataFormat/Detectors/FIT/common/EEvebtDataBit.h"
2425

2526
namespace o2
2627
{
2728
namespace fdd
2829
{
2930
struct ChannelDataFloat {
31+
static constexpr int DUMMY_CHANNEL_ID = -1;
32+
static constexpr int DUMMY_CHAIN_QTC = -1;
33+
static constexpr double DUMMY_CFD_TIME = -20000;
34+
static constexpr double DUMMY_QTC_AMPL = -20000;
3035

31-
int mPMNumber = -1; // channel Id
32-
int adcId = -1; // QTC chain
33-
double mTime = -20000; // time in ps, 0 at the LHC clk center
34-
double mChargeADC = -20000; // charge [channels]
36+
int mPMNumber = DUMMY_CHANNEL_ID; // channel Id
37+
int adcId = DUMMY_CHAIN_QTC; // QTC chain
38+
double mTime = DUMMY_CFD_TIME; // time in ps, 0 at the LHC clk center
39+
double mChargeADC = DUMMY_QTC_AMPL; // charge [channels]
3540

3641
ChannelDataFloat() = default;
3742
ChannelDataFloat(int Channel, double Time, double Charge, int AdcId)
@@ -42,7 +47,41 @@ struct ChannelDataFloat {
4247
adcId = AdcId;
4348
}
4449

50+
static void setFlag(fit::EEventDataBit bitFlag, int& adcId)
51+
{
52+
adcId = uint8_t(adcId) | 1u << bitFlag;
53+
}
54+
static void clearFlag(fit::EEventDataBit bitFlag, int& adcId)
55+
{
56+
adcId = uint8_t(adcId) & ~(1u << bitFlag);
57+
}
58+
void setFlag(int flag)
59+
{
60+
adcId = flag;
61+
}
62+
void setFlag(fit::EEventDataBit bitFlag, bool value)
63+
{
64+
adcId = uint8_t(adcId) | uint8_t(value) << bitFlag;
65+
}
66+
bool getFlag(fit::EEventDataBit bitFlag) const
67+
{
68+
return bool(uint8_t(adcId) & (1u << bitFlag));
69+
}
70+
bool areAllFlagsGood() const
71+
{
72+
return (!getFlag(fit::EEventDataBit::kIsDoubleEvent) &&
73+
!getFlag(fit::EEventDataBit::kIsTimeInfoNOTvalid) &&
74+
getFlag(fit::EEventDataBit::kIsCFDinADCgate) &&
75+
!getFlag(fit::EEventDataBit::kIsTimeInfoLate) &&
76+
!getFlag(fit::EEventDataBit::kIsAmpHigh) &&
77+
getFlag(fit::EEventDataBit::kIsEventInTVDC) &&
78+
!getFlag(fit::EEventDataBit::kIsTimeInfoLost));
79+
}
80+
4581
void print() const;
82+
[[nodiscard]] int getChannelId() const { return mPMNumber; }
83+
[[nodiscard]] double getTime() const { return mTime; }
84+
[[nodiscard]] double getAmp() const { return mChargeADC; }
4685
bool operator==(const ChannelDataFloat&) const = default;
4786

4887
ClassDefNV(ChannelDataFloat, 1);

DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/RecPoints.h

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "DataFormatsFT0/ChannelData.h"
2121
#include "CommonDataFormat/RangeReference.h"
2222
#include "DataFormatsFT0/Digit.h"
23+
#include "DataFormat/Detectors/FIT/common/EEvebtDataBit.h"
2324
#include <array>
2425
#include "Rtypes.h"
2526
#include <TObject.h>
@@ -33,11 +34,15 @@ namespace ft0
3334
{
3435

3536
struct ChannelDataFloat {
37+
static constexpr int DUMMY_CHANNEL_ID = -1;
38+
static constexpr int DUMMY_CHAIN_QTC = -1;
39+
static constexpr float DUMMY_CFD_TIME = -20000;
40+
static constexpr float DUMMY_QTC_AMPL = -20000;
3641

37-
int ChId = -1; // channel Id
38-
int ChainQTC = -1; // QTC chain
39-
float CFDTime = -20000; // time in ps, 0 at the LHC clk center
40-
float QTCAmpl = -20000; // Amplitude mV
42+
int ChId = DUMMY_CHANNEL_ID; // channel Id
43+
int ChainQTC = DUMMY_CHAIN_QTC; // QTC chain
44+
float CFDTime = DUMMY_CFD_TIME; // time in ps, 0 at the LHC clk center
45+
float QTCAmpl = DUMMY_QTC_AMPL; // Amplitude mV
4146

4247
ChannelDataFloat() = default;
4348
ChannelDataFloat(int iPmt, float time, float charge, int chainQTC)
@@ -48,7 +53,42 @@ struct ChannelDataFloat {
4853
ChainQTC = chainQTC;
4954
}
5055

56+
static void setFlag(fit::EEventDataBit bitFlag, int& chainQTC)
57+
{
58+
ChainQTC = uint8_t(ChainQTC) | 1u << bitFlag;
59+
}
60+
static void clearFlag(fit::EEventDataBit bitFlag, int& chainQTC)
61+
{
62+
ChainQTC = uint8_t(ChainQTC) & ~(1u << bitFlag);
63+
}
64+
void setFlag(int flag)
65+
{
66+
ChainQTC = flag;
67+
}
68+
void setFlag(fit::EEventDataBit bitFlag, bool value)
69+
{
70+
ChainQTC = uint8_t(ChainQTC) | uint8_t(value) << bitFlag;
71+
}
72+
bool getFlag(fit::EEventDataBit bitFlag) const
73+
{
74+
return bool(uint8_t(ChainQTC) & (1u << bitFlag));
75+
}
76+
bool areAllFlagsGood() const
77+
{
78+
return (!getFlag(fit::EEventDataBit::kIsDoubleEvent) &&
79+
!getFlag(fit::EEventDataBit::kIsTimeInfoNOTvalid) &&
80+
getFlag(fit::EEventDataBit::kIsCFDinADCgate) &&
81+
!getFlag(fit::EEventDataBit::kIsTimeInfoLate) &&
82+
!getFlag(fit::EEventDataBit::kIsAmpHigh) &&
83+
getFlag(fit::EEventDataBit::kIsEventInTVDC) &&
84+
!getFlag(fit::EEventDataBit::kIsTimeInfoLost));
85+
}
86+
5187
void print() const;
88+
[[nodiscard]] int getChannelId() const { return ChId; }
89+
[[nodiscard]] float getTime() const { return CFDTime; }
90+
[[nodiscard]] float getAmp() const { return QTCAmpl; }
91+
5292
bool operator==(const ChannelDataFloat&) const = default;
5393

5494
ClassDefNV(ChannelDataFloat, 1);

DataFormats/Detectors/FIT/FV0/include/DataFormatsFV0/RecPoints.h

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "CommonDataFormat/InteractionRecord.h"
1919
#include "CommonDataFormat/RangeReference.h"
2020
#include "DataFormatsFV0/Digit.h"
21+
#include "DataFormat/Detectors/FIT/common/EEvebtDataBit.h"
2122
#include <array>
2223
#include <gsl/span>
2324

@@ -26,11 +27,15 @@ namespace o2
2627
namespace fv0
2728
{
2829
struct ChannelDataFloat {
30+
static constexpr int DUMMY_CHANNEL_ID = -1;
31+
static constexpr int DUMMY_CHAIN_QTC = -1;
32+
static constexpr double DUMMY_CFD_TIME = -20000.0;
33+
static constexpr double DUMMY_QTC_AMPL = -20000.0;
2934

30-
int channel = -1; // channel Id
31-
double time = -20000; // time in ns, 0 at the LHC clk center
32-
double charge = -20000; // charge [channels]
33-
int adcId = -1; // QTC chain
35+
int channel = DUMMY_CHANNEL_ID; // channel Id
36+
double time = DUMMY_CFD_TIME; // time in ns, 0 at the LHC clk center
37+
double charge = DUMMY_QTC_AMPL; // charge [channels]
38+
int adcId = DUMMY_CHAIN_QTC; // QTC chain
3439

3540
ChannelDataFloat() = default;
3641
ChannelDataFloat(int Channel, double Time, double Charge, int AdcId)
@@ -41,7 +46,37 @@ struct ChannelDataFloat {
4146
adcId = AdcId;
4247
}
4348

49+
static void setFlag(fit::EEventDataBit bitFlag, int& adcId)
50+
{
51+
adcId = uint8_t(adcId) | 1u << bitFlag;
52+
}
53+
static void clearFlag(fit::EEventDataBit bitFlag, int& adcId)
54+
{
55+
adcId = uint8_t(adcId) & ~(1u << bitFlag);
56+
}
57+
void setFlag(int flag)
58+
{
59+
adcId = flag;
60+
}
61+
bool getFlag(fit::EEventDataBit bitFlag)
62+
{
63+
return bool(uint8_t(adcId) & (1u << bitFlag));
64+
}
65+
bool areAllFlagsGood() const
66+
{
67+
return (!getFlag(fit::EEventDataBit::kIsDoubleEvent) &&
68+
!getFlag(fit::EEventDataBit::kIsTimeInfoNOTvalid) &&
69+
getFlag(fit::EEventDataBit::kIsCFDinADCgate) &&
70+
!getFlag(fit::EEventDataBit::kIsTimeInfoLate) &&
71+
!getFlag(fit::EEventDataBit::kIsAmpHigh) &&
72+
getFlag(fit::EEventDataBit::kIsEventInTVDC) &&
73+
!getFlag(fit::EEventDataBit::kIsTimeInfoLost));
74+
}
75+
4476
void print() const;
77+
[[nodiscard]] int getChannelId() const { return channel; }
78+
[[nodiscard]] int getTime() const { return time; }
79+
[[nodiscard]] int getAmp() const { return charge; }
4580
bool operator==(const ChannelDataFloat&) const = default;
4681

4782
ClassDefNV(ChannelDataFloat, 1);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
12+
/// \file EEventDataBit.h
13+
/// \brief Enum type describing bits in ChainQTC flag
14+
/// \author wiktor.pierozak@cern.ch
15+
16+
#ifndef O2_FIT_EEVENT_DATA_BIT_
17+
#define O2_FIT_EEVENT_DATA_BIT_
18+
19+
namespace o2
20+
{
21+
namespace fv0
22+
{
23+
enum class EEventDataBit { kNumberADC = 0,
24+
kIsDoubleEvent,
25+
kIsTimeInfoNOTvalid,
26+
kIsCFDinADCgate,
27+
kIsTimeInfoLate,
28+
kIsAmpHigh,
29+
kIsEventInTVDC,
30+
kIsTimeInfoLost
31+
};
32+
}
33+
} // namespace o2
34+
35+
#endif

0 commit comments

Comments
 (0)