Project
Loading...
Searching...
No Matches
Digitizer.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_FT0_DIGITIZER_H
13#define ALICEO2_FT0_DIGITIZER_H
14
21#include "FT0Base/Geometry.h"
25#include "FT0Base/FT0DigParam.h"
27#include <array>
28#include <bitset>
29#include <vector>
30#include <deque>
31#include <optional>
32#include <set>
33
34namespace o2
35{
36namespace ft0
37{
39{
40 private:
42 typedef math_utils::RandomRing</*float_v::size()*/ 4 * DP::NOISE_RANDOM_RING_SIZE> NoiseRandomRingType;
43 static constexpr int NCHANNELS = o2::ft0::Geometry::Nchannels;
44
45 public:
46 Digitizer(Int_t mode = 0) : mMode(mode), mRndGaus(NoiseRandomRingType::RandomType::Gaus), mNumNoiseSamples(), mNoiseSamples(), mSincTable(), mSignalTable(), mSignalCache() { initParameters(); }
47 ~Digitizer() = default;
48
49 void process(const std::vector<o2::ft0::HitType>* hits, std::vector<o2::ft0::Digit>& digitsBC,
50 std::vector<o2::ft0::ChannelData>& digitsCh,
51 std::vector<o2::ft0::DetTrigInput>& digitsTrig,
53 void flush(std::vector<o2::ft0::Digit>& digitsBC,
54 std::vector<o2::ft0::ChannelData>& digitsCh,
55 std::vector<o2::ft0::DetTrigInput>& digitsTrig,
57 void flush_all(std::vector<o2::ft0::Digit>& digitsBC,
58 std::vector<o2::ft0::ChannelData>& digitsCh,
59 std::vector<o2::ft0::DetTrigInput>& digitsTrig,
61 void initParameters();
62 void printParameters() const;
63 void setEventID(Int_t id) { mEventID = id; }
64 void setSrcID(Int_t id) { mSrcID = id; }
65 const o2::InteractionRecord& getInteractionRecord() const { return mIntRecord; }
68 uint32_t getOrbit() const { return mIntRecord.orbit; }
69 uint16_t getBC() const { return mIntRecord.bc; }
70 int getEvent() const { return mEventID; }
71 double measure_amplitude(const std::vector<float>& times) const;
72 void init();
73 void finish();
74
76 caliboffsets) { mCalibOffset = caliboffsets; };
77 void setDeadChannelMap(o2::fit::DeadChannelMap const* deadChannelMap) { mDeadChannelMap = deadChannelMap; };
78 double getTimeOffsetWrtBC() const { return mIntRecord.getTimeOffsetWrtBC(); }
79
80 struct CFDOutput {
81 std::optional<double> particle;
82 double deadTime;
83 };
84 CFDOutput get_time(const std::vector<float>& times, float deadTime);
85
86 void setContinuous(bool v = true) { mIsContinuous = v; }
87 bool isContinuous() const { return mIsContinuous; }
88 struct BCCache {
89 struct particle {
90 int hit_ch;
91 double hit_time;
92 friend bool operator<(particle const& a, particle const& b)
93 {
94 return (a.hit_ch != b.hit_ch) ? (a.hit_ch < b.hit_ch) : (a.hit_time < b.hit_time);
95 }
96 };
97 std::vector<particle> hits;
98 std::set<ft0::MCLabel> labels;
99 };
104
105 protected:
106 inline float signalForm(float x) const
107 { // table lookup for the signal shape
108 if (x <= 0.0f) {
109 return 0.0f;
110 }
111 float const y = x / FT0DigParam::Instance().mBunchWidth * DP::SIGNAL_TABLE_SIZE;
112 int const index = std::floor(y);
113 if (index + 1 >= DP::SIGNAL_TABLE_SIZE) {
114 return mSignalTable.back();
115 }
116 float const rem = y - index;
117 return mSignalTable[index] + rem * (mSignalTable[index + 1] - mSignalTable[index]);
118 }
119
120 template <typename VcType>
121 inline VcType signalFormVc(VcType x) const
122 { // table lookup for the signal shape (SIMD version)
123 // implemented as template function, so that we don't need to include <Vc/Vc> here
124 auto const y = x / FT0DigParam::Instance().mBunchWidth * DP::SIGNAL_TABLE_SIZE;
125 typename VcType::IndexType const index = floor(y);
126 auto const rem = y - index;
127 VcType val(0);
128 for (size_t i = 0; i < VcType::size(); ++i) {
129 if (y[i] < 0.0f) {
130 continue;
131 }
132 if (index[i] + 1 < DP::SIGNAL_TABLE_SIZE) {
133 val[i] = mSignalTable[index[i]] + rem[i] * (mSignalTable[index[i] + 1] - mSignalTable[index[i]]);
134 } else {
135 val[i] = mSignalTable.back();
136 }
137 }
138 return val;
139 }
140
141 private:
142 // digit info
143 // parameters
144 Int_t mMode; // triggered or continuos
145 o2::InteractionTimeRecord mIntRecord; // Interaction record (orbit, bc)
146 Int_t mEventID;
147 Int_t mSrcID; // signal, background or QED
148 bool mIsContinuous = true; // continuous (self-triggered) or externally-triggered readout
149
150 o2::InteractionRecord firstBCinDeque = 0;
151 std::deque<BCCache> mCache;
152 std::array<GoodInteractionTimeRecord, NCHANNELS> mDeadTimes;
153
154 o2::ft0::Geometry mGeometry;
155
156 NoiseRandomRingType mRndGaus;
157 int mNumNoiseSamples; // number of noise samples in one BC
158 std::vector<float> mNoiseSamples;
159 std::array<std::vector<float>, DP::SINC_TABLE_SIZE> mSincTable;
160 std::array<float, DP::SIGNAL_TABLE_SIZE> mSignalTable;
161 std::vector<float> mSignalCache; // cached summed signal used by the CFD
162
163 void storeBC(BCCache& bc,
164 std::vector<o2::ft0::Digit>& digitsBC,
165 std::vector<o2::ft0::ChannelData>& digitsCh,
166 std::vector<o2::ft0::DetTrigInput>& digitsTrig,
168
169 o2::ft0::FT0ChannelTimeCalibrationObject const* mCalibOffset = nullptr;
170 o2::fit::DeadChannelMap const* mDeadChannelMap = nullptr;
171
172 ClassDefNV(Digitizer, 3);
173};
174
175} // namespace ft0
176} // namespace o2
177
178#endif
std::vector< unsigned long > times
Dead channel map for FIT.
Class to describe fired and stored channels for the BC and to refer to channel data.
Definition of the Detector class.
uint64_t bc
Definition RawEventData.h:5
Configurable digitization parameters.
unsigned short int uint16_t
int32_t i
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 process
std::vector< o2::MCCompLabel > labels
Definition of a container to keep Monte Carlo truth external to simulation objects.
A container to hold and manage MC truth information/labels.
void flush(std::vector< o2::ft0::Digit > &digitsBC, std::vector< o2::ft0::ChannelData > &digitsCh, std::vector< o2::ft0::DetTrigInput > &digitsTrig, o2::dataformats::MCTruthContainer< o2::ft0::MCLabel > &label)
uint32_t getOrbit() const
Definition Digitizer.h:68
void printParameters() const
Digitizer(Int_t mode=0)
Definition Digitizer.h:46
double getTimeOffsetWrtBC() const
Definition Digitizer.h:78
~Digitizer()=default
void setContinuous(bool v=true)
Definition Digitizer.h:86
void setDeadChannelMap(o2::fit::DeadChannelMap const *deadChannelMap)
Definition Digitizer.h:77
CFDOutput get_time(const std::vector< float > &times, float deadTime)
VcType signalFormVc(VcType x) const
Definition Digitizer.h:121
bool isContinuous() const
Definition Digitizer.h:87
void setInteractionRecord(const o2::InteractionTimeRecord &src)
Definition Digitizer.h:67
uint16_t getBC() const
Definition Digitizer.h:69
void setSrcID(Int_t id)
Definition Digitizer.h:64
const o2::InteractionRecord & getInteractionRecord() const
Definition Digitizer.h:65
void flush_all(std::vector< o2::ft0::Digit > &digitsBC, std::vector< o2::ft0::ChannelData > &digitsCh, std::vector< o2::ft0::DetTrigInput > &digitsTrig, o2::dataformats::MCTruthContainer< o2::ft0::MCLabel > &label)
void SetChannelOffset(o2::ft0::FT0ChannelTimeCalibrationObject const *caliboffsets)
Definition Digitizer.h:75
double measure_amplitude(const std::vector< float > &times) const
o2::InteractionRecord & getInteractionRecord(o2::InteractionRecord &src)
Definition Digitizer.h:66
int getEvent() const
Definition Digitizer.h:70
void setEventID(Int_t id)
Definition Digitizer.h:63
float signalForm(float x) const
Definition Digitizer.h:106
static constexpr int Nchannels
Definition Geometry.h:50
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
const GLdouble * v
Definition glcorearb.h:832
GLuint index
Definition glcorearb.h:781
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLint y
Definition glcorearb.h:270
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
GLuint GLfloat * val
Definition glcorearb.h:1582
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLuint id
Definition glcorearb.h:650
struct o2::upgrades_utils::@481 ft0
structure to keep V0C information
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
static constexpr int NOISE_RANDOM_RING_SIZE
friend bool operator<(particle const &a, particle const &b)
Definition Digitizer.h:92
std::set< ft0::MCLabel > labels
Definition Digitizer.h:98
std::vector< particle > hits
Definition Digitizer.h:97
std::optional< double > particle
Definition Digitizer.h:81