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 DETECTORS_ZDC_DIGITIZER_H_
13#define DETECTORS_ZDC_DIGITIZER_H_
14
15#include "DataFormatsZDC/Hit.h" // for the hit
23#include <vector>
24#include <array>
25#include <deque>
26#include <bitset>
27
28namespace o2
29{
30namespace zdc
31{
32
33class SimCondition;
34
36{
37 using ChannelBCDataF = std::array<float, NTimeBinsPerBC>;
38
39 public:
41 std::array<ChannelBCDataF, NChannels> data = {};
42 std::array<ChannelBCDataF, NDigiChannels> digi = {};
43 std::vector<o2::zdc::MCLabel> labels;
44 bool digitized = false;
45 bool triggerChecked = false;
46 uint32_t trigChanMask = 0; // mask of triggered channels
47 uint8_t extTrig = 0; // external trigger
48 static constexpr uint32_t AllChannelsMask = 0x80000000;
49
50 BCCache();
51
52 void clear()
53 {
54 digitized = false;
55 triggerChecked = false;
56 trigChanMask = 0;
57 for (auto& chan : data) {
58 chan.fill(0.);
59 }
60 }
61
67 void print() const;
68 };
69
71 int id = 0;
72 uint32_t readChannels = 0; // channels to read
73 uint32_t trigChannels = 0; // trigger channels
74 ModuleConfAux() = default;
75 ModuleConfAux(const Module& md);
76 };
77
78 void init();
79
80 // set event time
81 void setEventID(int eventID) { mEventID = eventID; }
82 void setSrcID(int sID) { mSrcID = sID; }
84 void setTimeStamp(long t) { mTimeStamp = t; }
85
87 {
88 // RS TODO: this method should be called e.g. from the steering DPL device in the triggered mode
89 if (mIRExternalTrigger.empty() || mIRExternalTrigger.back() != ir) {
90 mIRExternalTrigger.push_back(ir); // add new trigger if there was no already trigger in the same BC
91 }
92 }
93
94 void process(const std::vector<o2::zdc::Hit>& hits,
95 std::vector<o2::zdc::BCData>& digitsBC,
96 std::vector<o2::zdc::ChannelData>& digitsCh,
98
99 void flush(std::vector<o2::zdc::BCData>& digitsBC,
100 std::vector<o2::zdc::ChannelData>& digitsCh,
102
103 const SimCondition* getSimCondition() const { return mSimCondition; }
104 const ModuleConfig* getModuleConfig() const { return mModuleConfig; }
105 void setSimCondition(const SimCondition* cfg) { mSimCondition = cfg; }
106 void setModuleConfig(const ModuleConfig* cfg) { mModuleConfig = cfg; }
107
108 void setContinuous(bool v = true) { mIsContinuous = v; }
109 bool isContinuous() const { return mIsContinuous; }
111 void findEmptyBunches(const std::bitset<o2::constants::lhc::LHCMaxBunches>& bunchPattern);
112 int getNEmptyBunches() const { return mNEmptyBCs; }
113 void assignTriggerBits(uint32_t ibc, std::vector<BCData>& bcData); // Assign trigger bits for nearby bunch crossings
114 void Finalize(std::vector<BCData>& bcData, std::vector<o2::zdc::OrbitData>& pData); // Mask trigger bits for current bunch crossing
115 void setMaskTriggerBits(bool v = true) { mMaskTriggerBits = v; }
116 bool getMaskTriggerBits() { return mMaskTriggerBits; }
117 void setSkipMCLabels(bool v = true) { mSkipMCLabels = v; }
118 bool getSkipMCLabels() { return mSkipMCLabels; }
119
120 private:
121 static constexpr int BCCacheMin = -1, BCCacheMax = 5, NBC2Cache = 1 + BCCacheMax - BCCacheMin;
122
123 std::bitset<NChannels> chanPattern(uint32_t v) const
124 {
125 return std::bitset<NChannels>(v);
126 }
127 void phe2Sample(int nphe, int parID, double timeHit, std::array<o2::InteractionRecord, NBC2Cache> const& cachedIR, int nCachedIR, int channel);
128 BCCache& getCreateBCCache(const o2::InteractionRecord& ir);
129 BCCache* getBCCache(const o2::InteractionRecord& ir);
130 void setTriggerMask();
131 void setReadoutMask();
132 void generatePedestal();
133 void digitizeBC(BCCache& bc);
134 bool triggerBC(int ibc);
135 void storeBC(const BCCache& bc, uint32_t chan2Store,
136 std::vector<o2::zdc::BCData>& digitsBC, std::vector<o2::zdc::ChannelData>& digitsCh,
138
139 bool mIsContinuous = true; // continuous (self-triggered) or externally-triggered readout
140 int mEventID = 0;
141 int mSrcID = 0;
142 long mTimeStamp = 0; // TF (run) timestamp
144 std::deque<o2::InteractionRecord> mIRExternalTrigger; // IRs of externally provided triggered (at the moment MC sampled interactions)
145
146 std::deque<BCCache> mCache; // cached BCs data
147 std::array<std::vector<int16_t>, NChannels> mTrigChannelsData; // buffer for fast access to triggered channels data
148 int mTrigBinMin = 0xffff; // prefetched min and max
149 int mTrigBinMax = -0xffff; // bins to be checked for trigger
150 int mNBCAHead = 0; // when storing triggered BC, store also mNBCAHead BCs
151 uint32_t mTriggerMask = 0; // Trigger mask from ModuleConfig
152 uint32_t mReadoutMask = 0; // Readout mask from ModuleConfig
153 int32_t mNEmptyBCs = -1; // Number of clean empty bunches for pedestal evaluation
154 float mPedFactor = 1; // Pedestal scaling factor in digitization
155 bool mMaskTriggerBits = true; // Mask trigger bits with readout mask
156 bool mSkipMCLabels = false; // Skip MC labels in output
157
158 const SimCondition* mSimCondition = nullptr;
159 const ModuleConfig* mModuleConfig = nullptr;
160 std::vector<TriggerChannelConfig> mTriggerConfig;
161 uint32_t mTriggerableChanMask = 0;
162 std::vector<ModuleConfAux> mModConfAux;
163 std::vector<BCCache*> mFastCache;
164 std::vector<uint32_t> mStoreChanMask;
165 BCCache mDummyBC;
166 std::array<float, NChannels> mPedestalBLFluct;
167
168 // helper for inspection of bins in preceding or following BC: if we are at the cached BC = I and we need to
169 // inspect the bin = ib, we have to look in the binInSiftedBC of BC I-binHelper(ib,binInSiftedBC);
170 static constexpr int binHelper(int ib, int& binInSiftedBC)
171 {
172 if (ib < 0) {
173 binInSiftedBC = NTimeBinsPerBC - 1 + (1 + ib) % NTimeBinsPerBC;
174 return (ib - (NTimeBinsPerBC - 1)) / NTimeBinsPerBC;
175 } else {
176 binInSiftedBC = ib % NTimeBinsPerBC;
177 return ib / NTimeBinsPerBC;
178 }
179 }
180 ClassDefNV(Digitizer, 1);
181};
182} // namespace zdc
183} // namespace o2
184
185#endif /* DETECTORS_ZDC_DIGITIZER_H_ */
Class to describe fired triggered and/or stored channels for the BC and to refer to channel data.
Definition of the ZDC Hit class.
uint64_t bc
Definition RawEventData.h:5
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
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
std::vector< o2::MCCompLabel > labels
Definition of a container to keep Monte Carlo truth external to simulation objects.
Class to describe pedestal data accumulated over the orbit.
Container class to store NTimeBinsPerBC ADC values of single ZDC channel.
A container to hold and manage MC truth information/labels.
void updatePedestalReference(OrbitData &pdata)
void setContinuous(bool v=true)
Definition Digitizer.h:108
void flush(std::vector< o2::zdc::BCData > &digitsBC, std::vector< o2::zdc::ChannelData > &digitsCh, o2::dataformats::MCTruthContainer< o2::zdc::MCLabel > &labels)
void setEventID(int eventID)
Definition Digitizer.h:81
void addTriggeredBC(const o2::InteractionRecord &ir)
Definition Digitizer.h:86
void setInteractionRecord(const o2::InteractionTimeRecord &ir)
Definition Digitizer.h:83
void setSkipMCLabels(bool v=true)
Definition Digitizer.h:117
void setSrcID(int sID)
Definition Digitizer.h:82
const SimCondition * getSimCondition() const
Definition Digitizer.h:103
bool getMaskTriggerBits()
Definition Digitizer.h:116
void setTimeStamp(long t)
Definition Digitizer.h:84
void Finalize(std::vector< BCData > &bcData, std::vector< o2::zdc::OrbitData > &pData)
void assignTriggerBits(uint32_t ibc, std::vector< BCData > &bcData)
void setMaskTriggerBits(bool v=true)
Definition Digitizer.h:115
void setModuleConfig(const ModuleConfig *cfg)
Definition Digitizer.h:106
void setSimCondition(const SimCondition *cfg)
Definition Digitizer.h:105
int getNEmptyBunches() const
Definition Digitizer.h:112
const ModuleConfig * getModuleConfig() const
Definition Digitizer.h:104
void findEmptyBunches(const std::bitset< o2::constants::lhc::LHCMaxBunches > &bunchPattern)
bool isContinuous() const
Definition Digitizer.h:109
const GLdouble * v
Definition glcorearb.h:832
struct o2::upgrades_utils::@482 zdc
structure to keep FT0 information
constexpr int NTimeBinsPerBC
Definition Constants.h:53
constexpr int NChannels
Definition Constants.h:65
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
InteractionRecord & operator=(const InteractionRecord &src)=default
std::vector< o2::zdc::MCLabel > labels
Definition Digitizer.h:43
static constexpr uint32_t AllChannelsMask
Definition Digitizer.h:48
BCCache & operator=(const o2::InteractionRecord &ir)
Definition Digitizer.h:62
std::array< ChannelBCDataF, NChannels > data
Definition Digitizer.h:41
std::array< ChannelBCDataF, NDigiChannels > digi
Definition Digitizer.h:42
o2::InteractionRecord ir(0, 0)