Project
Loading...
Searching...
No Matches
Digit.h
Go to the documentation of this file.
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#ifndef ALICEO2_TOF_DIGIT_H_
13#define ALICEO2_TOF_DIGIT_H_
14
15#include <iosfwd>
16#include "Rtypes.h"
17#include "TOFBase/Geo.h"
20#include <gsl/span>
21
22#include <boost/serialization/base_object.hpp> // for base_object
23
24namespace o2
25{
26namespace tof
27{
30class Digit
31{
32 public:
33 Digit() = default;
34
35 Digit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t label = -1, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0, float geanttime = 0, double t0 = 0);
36 Digit(Int_t channel, Int_t tdc, Int_t tot, uint32_t orbit, uint16_t bc, Int_t label = -1, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0, float geanttime = 0, double t0 = 0);
37 ~Digit() = default;
38
40 static ULong64_t getOrderingKey(Int_t channel, uint64_t bc, Int_t /*tdc*/)
41 {
42 return ((static_cast<ULong64_t>(bc) << 18) + channel); // channel in the least significant bits; then shift by 18 bits (which cover the total number of channels) to write the BC number
43 }
44 ULong64_t getOrderingKey()
45 {
46 return getOrderingKey(mChannel, mIR.toLong(), mTDC);
47 }
48
49 Int_t getChannel() const { return mChannel; }
50 void setChannel(Int_t channel) { mChannel = channel; }
51
52 uint16_t getTDC() const { return mTDC; }
53 void setTDC(uint16_t tdc) { mTDC = tdc; }
54
55 uint16_t getTOT() const { return mTOT; }
56 void setTOT(uint16_t tot) { mTOT = tot; }
57
58 uint64_t getBC() const { return mIR.toLong(); }
59 void setBC(uint64_t bc) { mIR.setFromLong(bc); }
60 void setIR(const InteractionRecord& ir) { mIR = ir; }
61
62 auto getIR() const { return mIR; }
63
64 Int_t getLabel() const { return mLabel; }
65 void setLabel(Int_t label) { mLabel = label; }
66
67 void printStream(std::ostream& stream) const;
68
69 bool merge(Int_t tdc, Int_t tot);
70
71 void getPhiAndEtaIndex(int& phi, int& eta) const;
72
73 Bool_t isUsedInCluster() const { return mIsUsedInCluster; }
74
75 void setIsUsedInCluster(bool val = true) { mIsUsedInCluster = val; }
76
77 Int_t getElectronicIndex() const { return mElectronIndex; }
78 void setElectronicIndex(Int_t ind) { mElectronIndex = ind; }
79 Int_t getElCrateIndex() const { return Geo::getCrateFromECH(mElectronIndex); } // to be derived from mElectronIndex
80 Int_t getElTRMIndex() const { return Geo::getTRMFromECH(mElectronIndex); } // to be derived from mElectronIndex
81 Int_t getElChainIndex() const { return Geo::getChainFromECH(mElectronIndex); } // to be derived from mElectronIndex
82 Int_t getElTDCIndex() const { return Geo::getTDCFromECH(mElectronIndex); } // to be derived from mElectronIndex
83 Int_t getElChIndex() const { return Geo::getTDCChFromECH(mElectronIndex); } // to be derived from mElectronIndex
84
85 void setCalibratedTime(Double_t time) { mCalibratedTime = time; }
86 double getCalibratedTime() const { return mCalibratedTime; }
87
88 void setIsProblematic(bool flag) { mIsProblematic = flag; }
89 bool isProblematic() const { return mIsProblematic; }
90
91 void setTriggerOrbit(uint32_t value) { mTriggerOrbit = value; }
92 uint32_t getTriggerOrbit() const { return mTriggerOrbit; }
93 void setTriggerBunch(uint16_t value) { mTriggerBunch = value; }
94 uint16_t getTriggerBunch() const { return mTriggerBunch; }
95
96 float getTgeant() const { return mTgeant; }
97 void setTgeant(float val) { mTgeant = val; }
98 double getT0true() const { return mT0true; }
99 void setT0true(double val) { mT0true = val; }
100
101 private:
103
104 Int_t mChannel;
105 uint16_t mTDC;
106 uint16_t mTOT;
107 InteractionRecord mIR{0, 0};
108 Int_t mLabel;
109 Double_t mCalibratedTime;
110 Int_t mElectronIndex;
111 uint32_t mTriggerOrbit = 0;
112 uint16_t mTriggerBunch = 0;
113 Bool_t mIsUsedInCluster;
114 Bool_t mIsProblematic = false;
115 float mTgeant = 0.0;
116 double mT0true = 0.0;
117
118 ClassDefNV(Digit, 5);
119};
120
121std::ostream& operator<<(std::ostream& stream, const Digit& dig);
122
124 // 1st entry and number of entries in the full vector of digits
125 // for given trigger (or BC or RO frame)
128
129 // crate info for diagnostic patterns
133
136
137 const InteractionRecord& getBCData() const { return mFirstIR; }
138
139 void setEmptyCrate(int crate) { mNdiaCrate[crate] = -1; }
140 bool isEmptyCrate(int crate) const { return (mNdiaCrate[crate] == -1); }
141 void addedDiagnostic(int crate) { mNdiaCrate[crate]++; }
142 void setDiagnosticInCrate(int crate, int val) { mNdiaCrate[crate] = val; }
143 int getDiagnosticInCrate(int crate) const
144 {
145 if (isEmptyCrate(crate)) {
146 return 0;
147 } else {
148 return mNdiaCrate[crate];
149 }
150 }
151
152 void setBCData(int orbit, int bc)
153 {
155 mFirstIR.bc = bc;
156 }
158 {
159 mFirstIR.orbit = src.orbit;
160 mFirstIR.bc = src.bc;
161 }
162 void SetBC(int bc) { mFirstIR.bc = bc; }
164
165 gsl::span<const Digit> getBunchChannelData(const gsl::span<const Digit> tfdata) const
166 {
167 // extract the span of channel data for this readout window from the whole TF data
168 return ref.getEntries() ? gsl::span<const Digit>(&tfdata[ref.getFirstEntry()], ref.getEntries()) : gsl::span<const Digit>();
169 }
170
171 ReadoutWindowData() = default;
173 {
174 ref.setFirstEntry(first);
175 ref.setEntries(ne);
176 refDiagnostic.setFirstEntry(0);
177 refDiagnostic.setEntries(0);
178 }
179
180 int first() const { return ref.getFirstEntry(); }
181 int size() const { return ref.getEntries(); }
182 int firstDia() const { return refDiagnostic.getFirstEntry(); }
183 int sizeDia() const { return refDiagnostic.getEntries(); }
184
185 void setFirstEntry(int first) { ref.setFirstEntry(first); }
186 void setNEntries(int ne) { ref.setEntries(ne); }
187 void setFirstEntryDia(int first) { refDiagnostic.setFirstEntry(first); }
188 void setNEntriesDia(int ne) { refDiagnostic.setEntries(ne); }
189
190 void setEventCounter(int ev) { mEventCounter = ev; }
191 void setDeltaEventCounterCrate(int crate, int ev) { mDeltaEventCounterCrate[crate] = ev; }
192 int getEventCounter() const { return mEventCounter; }
193 int getDeltaEventCounterCrate(int crate) const { return mDeltaEventCounterCrate[crate]; }
194 void setDeltaBCCrate(int crate, int bc) { mDeltaBCCrate[crate] = bc; }
195 int getDeltaBCCrate(int crate) const { return mDeltaBCCrate[crate]; }
196
198};
199
203 int mCountsRow = 0;
204
205 void clear()
206 {
207 memset(mCountsCrate, 0, Geo::kNCrate * 4);
208 memset(mNumberOfCrates, 0, (Geo::kNCrate + 1) * 4);
209 mCountsRow = 0;
210 }
212 void addRow() { mCountsRow++; }
213 int getNRow() const { return mCountsRow; }
214 void crateSeen(int crate) { mCountsCrate[crate]++; }
215 void numCratesSeen(int ncrates) { mNumberOfCrates[ncrates]++; }
216 int getCrateCounts(int crate) const { return mCountsCrate[crate]; }
217 int numCratesCounts(int ncrates) const { return mNumberOfCrates[ncrates]; }
218
220};
221
222} // namespace tof
223} // namespace o2
224#endif
uint64_t orbit
Definition RawEventData.h:6
uint64_t bc
Definition RawEventData.h:5
int16_t time
Definition RawEventData.h:4
unsigned short int uint16_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
Class to refer to the 1st entry and N elements of some group in the continuous container.
TOF digit implementation.
Definition Digit.h:31
void setTOT(uint16_t tot)
Definition Digit.h:56
uint64_t getBC() const
Definition Digit.h:58
void setTriggerOrbit(uint32_t value)
Definition Digit.h:91
void setTriggerBunch(uint16_t value)
Definition Digit.h:93
static ULong64_t getOrderingKey(Int_t channel, uint64_t bc, Int_t)
Get global ordering key made of.
Definition Digit.h:40
void printStream(std::ostream &stream) const
Definition Digit.cxx:32
ULong64_t getOrderingKey()
Definition Digit.h:44
Int_t getElChIndex() const
Definition Digit.h:83
Int_t getElTDCIndex() const
Definition Digit.h:82
Int_t getElChainIndex() const
Definition Digit.h:81
double getT0true() const
Definition Digit.h:98
~Digit()=default
Int_t getElTRMIndex() const
Definition Digit.h:80
void setBC(uint64_t bc)
Definition Digit.h:59
void setChannel(Int_t channel)
Definition Digit.h:50
Int_t getLabel() const
Definition Digit.h:64
uint16_t getTOT() const
Definition Digit.h:55
void setTgeant(float val)
Definition Digit.h:97
void setLabel(Int_t label)
Definition Digit.h:65
void setIR(const InteractionRecord &ir)
Definition Digit.h:60
bool isProblematic() const
Definition Digit.h:89
double getCalibratedTime() const
Definition Digit.h:86
void setElectronicIndex(Int_t ind)
Definition Digit.h:78
Int_t getChannel() const
Definition Digit.h:49
Digit()=default
void setIsUsedInCluster(bool val=true)
Definition Digit.h:75
void setTDC(uint16_t tdc)
Definition Digit.h:53
auto getIR() const
Definition Digit.h:62
bool merge(Int_t tdc, Int_t tot)
Definition Digit.cxx:47
void getPhiAndEtaIndex(int &phi, int &eta) const
Definition Digit.cxx:64
Int_t getElectronicIndex() const
Definition Digit.h:77
uint32_t getTriggerOrbit() const
Definition Digit.h:92
float getTgeant() const
Definition Digit.h:96
void setCalibratedTime(Double_t time)
Definition Digit.h:85
friend class boost::serialization::access
Definition Digit.h:102
void setIsProblematic(bool flag)
Definition Digit.h:88
Int_t getElCrateIndex() const
Definition Digit.h:79
uint16_t getTDC() const
Definition Digit.h:52
uint16_t getTriggerBunch() const
Definition Digit.h:94
void setT0true(double val)
Definition Digit.h:99
Bool_t isUsedInCluster() const
Definition Digit.h:73
static Int_t getTDCChFromECH(int ech)
Definition Geo.h:351
static Int_t getTDCFromECH(int ech)
Definition Geo.h:350
static Int_t getTRMFromECH(int ech)
Definition Geo.h:348
@ kNCrate
Definition Geo.h:97
static Int_t getCrateFromECH(int ech)
Definition Geo.h:347
static Int_t getChainFromECH(int ech)
Definition Geo.h:349
GLint first
Definition glcorearb.h:399
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
GLuint GLfloat * val
Definition glcorearb.h:1582
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition glcorearb.h:5034
GLuint GLuint stream
Definition glcorearb.h:1806
GLint ref
Definition glcorearb.h:291
std::ostream & operator<<(std::ostream &os, Cluster &c)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
uint32_t orbit
LHC orbit.
uint16_t bc
bunch crossing ID of interaction
void setFromLong(int64_t l)
ClassDefNV(DigitHeader, 2)
int mNumberOfCrates[Geo::kNCrate+1]
Definition Digit.h:202
int numCratesCounts(int ncrates) const
Definition Digit.h:217
int getNRow() const
Definition Digit.h:213
int getCrateCounts(int crate) const
Definition Digit.h:216
int mCountsCrate[Geo::kNCrate]
Definition Digit.h:201
void numCratesSeen(int ncrates)
Definition Digit.h:215
void crateSeen(int crate)
Definition Digit.h:214
void setEventCounter(int ev)
Definition Digit.h:190
int getDeltaEventCounterCrate(int crate) const
Definition Digit.h:193
void setDeltaEventCounterCrate(int crate, int ev)
Definition Digit.h:191
int mDeltaBCCrate[Geo::kNCrate]
Definition Digit.h:131
void SetOrbit(int orbit)
Definition Digit.h:163
void setEmptyCrate(int crate)
Definition Digit.h:139
void setBCData(int orbit, int bc)
Definition Digit.h:152
bool isEmptyCrate(int crate) const
Definition Digit.h:140
void setDeltaBCCrate(int crate, int bc)
Definition Digit.h:194
const InteractionRecord & getBCData() const
Definition Digit.h:137
void setNEntries(int ne)
Definition Digit.h:186
InteractionRecord mFirstIR
Definition Digit.h:134
void setDiagnosticInCrate(int crate, int val)
Definition Digit.h:142
int mDeltaEventCounterCrate[Geo::kNCrate]
Definition Digit.h:132
o2::dataformats::RangeReference< int, int > refDiagnostic
Definition Digit.h:127
int getDiagnosticInCrate(int crate) const
Definition Digit.h:143
int mNdiaCrate[Geo::kNCrate]
Definition Digit.h:130
o2::dataformats::RangeReference< int, int > ref
Definition Digit.h:126
void setBCData(InteractionRecord &src)
Definition Digit.h:157
gsl::span< const Digit > getBunchChannelData(const gsl::span< const Digit > tfdata) const
Definition Digit.h:165
void setFirstEntry(int first)
Definition Digit.h:185
ReadoutWindowData(int first, int ne)
Definition Digit.h:172
int getEventCounter() const
Definition Digit.h:192
void setFirstEntryDia(int first)
Definition Digit.h:187
void addedDiagnostic(int crate)
Definition Digit.h:141
void setNEntriesDia(int ne)
Definition Digit.h:188
int getDeltaBCCrate(int crate) const
Definition Digit.h:195
ClassDefNV(ReadoutWindowData, 4)
o2::InteractionRecord ir(0, 0)