forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecPoints.h
More file actions
207 lines (184 loc) · 7.98 KB
/
RecPoints.h
File metadata and controls
207 lines (184 loc) · 7.98 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// 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 RecPoints.h
/// \brief Definition of the FIT RecPoints class
#ifndef ALICEO2_FT0_RECPOINTS_H
#define ALICEO2_FT0_RECPOINTS_H
#include "CommonDataFormat/InteractionRecord.h"
#include "CommonDataFormat/TimeStamp.h"
#include "DataFormatsFT0/ChannelData.h"
#include "CommonDataFormat/RangeReference.h"
#include "DataFormatsFT0/Digit.h"
#include "DataFormatsFIT/ChannelDataBit.h"
#include <array>
#include "Rtypes.h"
#include <TObject.h>
#include <gsl/span>
#include <string>
#include <utility>
#include <map>
namespace o2
{
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 = 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)
{
ChId = iPmt;
CFDTime = time;
QTCAmpl = charge;
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);
};
class RecPoints
{
public:
enum ETimeType { kTimeMean,
kTimeA,
kTimeC,
kTimeVertex };
// Enum for trigger nits specified in rec-points and AOD data
enum ETriggerBits { kOrA = 0, // OrA time-trigger signal
kOrC = 1, // OrC time-trigger signal
kSemiCentral = 2, // Semi-central amplitude-trigger signal
kCentral = 3, // Central amplitude-trigger signal
kVertex = 4, // Vertex time-trigger signal
kIsActiveSideA = 5, // Side-A has at least one channel active
kIsActiveSideC = 6, // Side-C has at least one channel active
kIsFlangeEvent = 7 // Flange event at Side-C, at least one channel has time which corresponds to -82 cm area
};
static const inline std::map<unsigned int, std::string> sMapTriggerBits = {
{ETriggerBits::kOrA, "OrA"},
{ETriggerBits::kOrC, "OrC"},
{ETriggerBits::kSemiCentral, "Semicentral"},
{ETriggerBits::kCentral, "Central"},
{ETriggerBits::kVertex, "Vertex"},
{ETriggerBits::kIsActiveSideA, "IsActiveSideA"},
{ETriggerBits::kIsActiveSideC, "IsActiveSideC"},
{ETriggerBits::kIsFlangeEvent, "IsFlangeEvent"}};
enum ETechnicalBits { kLaser = 0, // indicates the laser was triggered in this BC
kOutputsAreBlocked = 1, // indicates that laser-induced pulses should arrive from detector to FEE in this BC (and trigger outputs are blocked)
kDataIsValid = 2, // data is valid for processing
};
static const inline std::map<unsigned int, std::string> sMapTechnicalBits = {
{ETechnicalBits::kLaser, "Laser"},
{ETechnicalBits::kOutputsAreBlocked, "OutputsAreBlocked"},
{ETechnicalBits::kDataIsValid, "DataIsValid"}};
o2::dataformats::RangeReference<int, int> ref;
o2::InteractionRecord mIntRecord; // Interaction record (orbit, bc)
RecPoints() = default;
RecPoints(const std::array<short, 4>& collisiontime,
int first, int ne, o2::InteractionRecord iRec, o2::fit::Triggers chTrig)
: mCollisionTime(collisiontime)
{
ref.setFirstEntry(first);
ref.setEntries(ne);
mIntRecord = iRec;
mTriggers = chTrig;
}
RecPoints(int chDataFirstEntryPos,
int chDataNEntries,
const o2::InteractionRecord& ir,
const std::array<short, 4>& arrTimes,
const o2::fit::Triggers& digitTriggers,
uint8_t extraTriggerWord) : mIntRecord(ir), mCollisionTime(arrTimes), mTriggers(digitTriggers)
{
ref.setFirstEntry(chDataFirstEntryPos);
ref.setEntries(chDataNEntries);
initRecPointTriggers(digitTriggers, extraTriggerWord);
}
~RecPoints() = default;
short getCollisionTime(int side) const { return mCollisionTime[side]; }
short getCollisionTimeMean() const { return getCollisionTime(kTimeMean); }
short getCollisionTimeA() const { return getCollisionTime(kTimeA); }
short getCollisionTimeC() const { return getCollisionTime(kTimeC); }
bool isValidTime(int side) const { return getCollisionTime(side) < o2::InteractionRecord::DummyTime; }
void setCollisionTime(short time, int side) { mCollisionTime[side] = time; }
short getVertex() const { return getCollisionTime(kTimeVertex); }
void setVertex(short vertex) { mCollisionTime[kTimeVertex] = vertex; }
o2::fit::Triggers getTrigger() const { return mTriggers; }
void setTriggers(o2::fit::Triggers trig) { mTriggers = trig; }
uint8_t getTechnicalWord() const { return mTechnicalWord; }
static constexpr uint8_t makeExtraTrgWord(bool isActiveA = true, bool isActiveC = true, bool isFlangeEvent = true)
{
return (static_cast<uint8_t>(isActiveA) << kIsActiveSideA) |
(static_cast<uint8_t>(isActiveC) << kIsActiveSideC) |
(static_cast<uint8_t>(isFlangeEvent) << kIsFlangeEvent);
}
o2::InteractionRecord getInteractionRecord() const { return mIntRecord; };
gsl::span<const ChannelDataFloat> getBunchChannelData(const gsl::span<const ChannelDataFloat> tfdata) const;
short static constexpr sDummyCollissionTime = 32767;
void print() const;
bool operator==(const RecPoints&) const = default;
private:
void initRecPointTriggers(const o2::fit::Triggers& digitTriggers, uint8_t extraTrgWord = 0)
{
const auto digitTriggerWord = digitTriggers.getTriggersignals();
const auto trgAndTechWordPair = o2::fit::Triggers::parseDigitTriggerWord(digitTriggerWord, true);
mTriggers.setTriggers(trgAndTechWordPair.first | extraTrgWord);
mTechnicalWord = trgAndTechWordPair.second;
}
std::array<short, 4> mCollisionTime = {sDummyCollissionTime,
sDummyCollissionTime,
sDummyCollissionTime,
sDummyCollissionTime};
o2::fit::Triggers mTriggers; // pattern of triggers in this BC
uint8_t mTechnicalWord{0}; // field for keeping ETechnicalBits
ClassDefNV(RecPoints, 4);
};
} // namespace ft0
} // namespace o2
#endif