forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriggers.h
More file actions
158 lines (141 loc) · 7.09 KB
/
Triggers.h
File metadata and controls
158 lines (141 loc) · 7.09 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
// 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 Triggers.h
/// \brief Class to describe triggers common for all FIT detectors
/// \author maciej.slupecki@cern.ch
#ifndef _FIT_TRIGGERS_H_
#define _FIT_TRIGGERS_H_
#include <Rtypes.h>
#include <tuple>
#include <iostream>
#include <string>
namespace o2
{
namespace fit
{
class Triggers
{
public:
template <typename... TrgBits>
constexpr static uint64_t word(TrgBits&&... trgBits)
{
return ((1ull << std::forward<TrgBits>(trgBits)) | ...);
}
enum { bitA = 0,
bitC = 1, // alias of bitAOut (FT0/FDD)
bitAOut = 1, // alias of bitC (FV0)
bitSCen = 2, // alias of bitTrgNchan (FT0/FDD)
bitTrgNchan = 2, // alias of bitSCen (FV0)
bitCen = 3, // alias of bitTrgCharge (FT0/FDD)
bitTrgCharge = 3, // alias of bitCen (FV0)
bitVertex = 4, // alias of bitAIn (FT0/FDD)
bitAIn = 4, // alias of bitVertex (FV0)
bitLaser = 5, // indicates the laser was triggered in this BC
bitOutputsAreBlocked = 6, // indicates that laser-induced pulses should arrive from detector to FEE in this BC (and trigger outputs are blocked)
bitDataIsValid = 7, // data is valid for processing
bitMinBias = 8 }; // extra calculated bit, vrt & (cern || semicent)
static const int16_t DEFAULT_TIME = -5000; // for average of one side (A or C)
static const int16_t DEFAULT_AMP = 0;
static const int16_t DEFAULT_ZERO = 0;
Triggers() = default;
Triggers(uint8_t signals, uint8_t chanA, uint8_t chanC, int32_t aamplA, int32_t aamplC, int16_t atimeA, int16_t atimeC)
{
triggersignals = signals;
nChanA = chanA;
nChanC = chanC;
amplA = aamplA;
amplC = aamplC;
timeA = atimeA;
timeC = atimeC;
}
inline static bool checkMinBiasFT0(uint64_t trgWord)
{
return static_cast<bool>(trgWord & word(bitVertex)) && static_cast<bool>(trgWord & word(bitSCen, bitCen));
}
static uint64_t makeExtendedTrgWord(uint64_t trgWord)
{
return trgWord | (static_cast<uint64_t>(checkMinBiasFT0(trgWord)) << bitMinBias);
}
static constexpr std::pair<uint8_t, uint8_t> parseDigitTriggerWord(uint8_t digitWord, bool shiftTechBitsToBegin = false)
{
const uint8_t techWordMask = word(bitLaser, bitOutputsAreBlocked, bitDataIsValid);
const uint8_t shiftTechWordPos = shiftTechBitsToBegin ? bitLaser : 0;
return {(digitWord & (~techWordMask)), (digitWord & techWordMask) >> shiftTechWordPos};
}
bool getOrA() const { return (triggersignals & (1 << bitA)) != 0; }
bool getOrC() const { return (triggersignals & (1 << bitC)) != 0; } // only used by FT0/FDD (same bit as OrAOut in FV0)
bool getOrAOut() const { return (triggersignals & (1 << bitAOut)) != 0; } // only used by FV0 (same bit as OrC in FT0/FDD)
bool getSCen() const { return (triggersignals & (1 << bitSCen)) != 0; } // only used by FT0/FDD (same bit as Nchan in FV0)
bool getTrgNChan() const { return (triggersignals & (1 << bitTrgNchan)) != 0; } // only used by FV0 (same bit as SCen in FT0/FDD)
bool getCen() const { return (triggersignals & (1 << bitCen)) != 0; } // only used by FT0/FDD (same bit as Charge in FV0)
bool getTrgCharge() const { return (triggersignals & (1 << bitTrgCharge)) != 0; } // only used by FV0 (same bit as Cen in FT0/FDD)
bool getVertex() const { return (triggersignals & (1 << bitVertex)) != 0; } // only used by FT0/FDD (same bit as OrAIn in FV0)
bool getOrAIn() const { return (triggersignals & (1 << bitAIn)) != 0; } // only used by FV0 (same bit as OrC in FT0/FDD)
bool getLaser() const { return (triggersignals & (1 << bitLaser)) != 0; }
bool getOutputsAreBlocked() const { return (triggersignals & (1 << bitOutputsAreBlocked)) != 0; }
bool getDataIsValid() const { return (triggersignals & (1 << bitDataIsValid)) != 0; }
bool getMinBiasFT0() const { return checkMinBiasFT0(static_cast<uint64_t>(triggersignals)); }
uint64_t getExtendedTrgWordFT0() const { return makeExtendedTrgWord(static_cast<uint64_t>(triggersignals)); }
uint8_t getTriggersignals() const { return triggersignals; }
uint8_t getNChanA() const { return nChanA; }
uint8_t getNChanC() const { return nChanC; }
int32_t getAmplA() const { return amplA; }
int32_t getAmplC() const { return amplC; }
int16_t getTimeA() const { return timeA; }
int16_t getTimeC() const { return timeC; }
void setTriggers(uint8_t trgsig, uint8_t chanA, uint8_t chanC, int32_t aamplA, int32_t aamplC, int16_t atimeA, int16_t atimeC)
{
triggersignals = trgsig;
nChanA = chanA;
nChanC = chanC;
amplA = aamplA;
amplC = aamplC;
timeA = atimeA;
timeC = atimeC;
}
void setTriggers(uint8_t trgsig)
{
triggersignals = trgsig;
}
void setTriggers(Bool_t isA, Bool_t isC, Bool_t isVrtx, Bool_t isCnt, Bool_t isSCnt, uint8_t chanA, uint8_t chanC, int32_t aamplA,
int32_t aamplC, int16_t atimeA, int16_t atimeC, Bool_t isLaser, Bool_t isOutputsAreBlocked, Bool_t isDataValid)
{
uint8_t trgsig = (isA << bitA) | (isC << bitC) | (isVrtx << bitVertex) | (isCnt << bitCen) | (isSCnt << bitSCen) | (isLaser << bitLaser) | (isOutputsAreBlocked << bitOutputsAreBlocked) | (isDataValid << bitDataIsValid);
setTriggers(trgsig, chanA, chanC, aamplA, aamplC, atimeA, atimeC);
}
void cleanTriggers()
{
triggersignals = DEFAULT_ZERO;
nChanA = nChanC = DEFAULT_ZERO;
amplA = amplC = DEFAULT_AMP;
timeA = timeC = DEFAULT_TIME;
}
bool operator==(Triggers const& other) const
{
return std::tie(triggersignals, nChanA, nChanC, amplA, amplC, timeA, timeC) ==
std::tie(other.triggersignals, other.nChanA, other.nChanC, other.amplA, other.amplC, other.timeA, other.timeC);
}
std::string print() const;
void print(std::ostream&) const;
void printLog() const;
private:
uint8_t triggersignals = DEFAULT_ZERO; // FIT trigger signals
uint8_t nChanA = DEFAULT_ZERO; // number of fired channels A side
uint8_t nChanC = DEFAULT_ZERO; // number of fired channels A side
int32_t amplA = DEFAULT_AMP; // sum amplitude A side
int32_t amplC = DEFAULT_AMP; // sum amplitude C side
int16_t timeA = DEFAULT_TIME; // average time A side (shouldn't be used if nChanA == 0)
int16_t timeC = DEFAULT_TIME; // average time C side (shouldn't be used if nChanC == 0)
ClassDefNV(Triggers, 7);
};
} // namespace fit
} // namespace o2
#endif