forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecPoint.h
More file actions
137 lines (122 loc) · 4.84 KB
/
RecPoint.h
File metadata and controls
137 lines (122 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// 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 RecPoint.h
/// \brief Definition of the FDD RecPoint class
#ifndef ALICEO2_FDD_RECPOINT_H
#define ALICEO2_FDD_RECPOINT_H
#include "CommonDataFormat/InteractionRecord.h"
#include "CommonDataFormat/InteractionRecord.h"
#include "CommonDataFormat/TimeStamp.h"
#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 = 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)
{
mPMNumber = Channel;
mTime = Time;
mChargeADC = Charge;
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);
};
class RecPoint
{
public:
enum TimeTypeIndex : int { TimeA,
TimeC };
RecPoint() = default;
RecPoint(const std::array<int, 2>& collisiontime, int first, int ne,
o2::InteractionRecord iRec, o2::fdd::Triggers triggers)
: mCollisionTimePs(collisiontime)
{
mRef.setFirstEntry(first);
mRef.setEntries(ne);
mIntRecord = iRec;
mTriggers = triggers;
}
~RecPoint() = default;
float getCollisionTime(TimeTypeIndex type) const { return mCollisionTimePs[type]; }
float getCollisionTimeA() const { return getCollisionTime(TimeA); }
float getCollisionTimeC() const { return getCollisionTime(TimeC); }
bool isValidTime(TimeTypeIndex type) const { return getCollisionTime(type) < sDummyCollissionTime; }
void setCollisionTime(Float_t time, TimeTypeIndex type) { mCollisionTimePs[type] = time; }
const o2::fdd::Triggers getTrigger() const { return mTriggers; }
o2::InteractionRecord getInteractionRecord() const { return mIntRecord; };
gsl::span<const ChannelDataFloat> getBunchChannelData(const gsl::span<const ChannelDataFloat> tfdata) const
{
// extract the span of channel data for this bunch from the whole TF data
return mRef.getEntries() ? gsl::span<const ChannelDataFloat>(tfdata).subspan(mRef.getFirstEntry(), mRef.getEntries()) : gsl::span<const ChannelDataFloat>();
}
short static constexpr sDummyCollissionTime = 32767;
int getFirstEntry() const { return mRef.getFirstEntry(); }
int getEntriesInCurrentBC() const { return mRef.getEntries(); }
void print() const;
bool operator==(const RecPoint&) const = default;
private:
o2::dataformats::RangeReference<int, int> mRef;
o2::InteractionRecord mIntRecord;
o2::fdd::Triggers mTriggers; // pattern of triggers in this BC
std::array<int, 2> mCollisionTimePs = {sDummyCollissionTime, sDummyCollissionTime}; // in picoseconds
ClassDefNV(RecPoint, 3);
};
} // namespace fdd
} // namespace o2
#endif