Project
Loading...
Searching...
No Matches
DigiReco.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#include <map>
13#include <deque>
14#include <gsl/span>
15#include <TFile.h>
16#include <TTree.h>
17#include "Framework/Logger.h"
18#include "ZDCBase/Constants.h"
34
35#ifndef ALICEO2_ZDC_DIGI_RECO_H
36#define ALICEO2_ZDC_DIGI_RECO_H
37
38//#define ALICEO2_ZDC_DIGI_RECO_DEBUG
39#ifdef O2_ZDC_DEBUG
40#ifndef ALICEO2_ZDC_DIGI_RECO_DEBUG
41#define ALICEO2_ZDC_DIGI_RECO_DEBUG
42#endif
43#endif
44
45namespace o2
46{
47namespace zdc
48{
49using O2_ZDC_DIGIRECO_FLT = float;
50
52 DigiRecoTDC(uint16_t myval, uint16_t myamp, o2::InteractionRecord myir)
53 {
54 val = myval;
55 amp = myamp;
56 ir = myir;
57 }
58 uint16_t val;
59 uint16_t amp;
61};
62
64{
65 public:
66 DigiReco() = default;
67 ~DigiReco() = default;
68 void init();
70 int process(const gsl::span<const o2::zdc::OrbitData>& orbitdata,
71 const gsl::span<const o2::zdc::BCData>& bcdata,
72 const gsl::span<const o2::zdc::ChannelData>& chdata);
73 int write();
74 void setVerbosity(int v)
75 {
76 mVerbosity = v;
77 }
78 int getVerbosity() const { return mVerbosity; }
79 void setDebugOutput(bool state = true)
80 {
81 mTreeDbg = state;
82 }
83 void eor();
84 uint8_t getTriggerCondition() { return mTriggerCondition; }
85 void setTripleTrigger() { mTriggerCondition = 0x7; }
86 void setDoubleTrigger() { mTriggerCondition = 0x3; }
87 void setSingleTrigger() { mTriggerCondition = 0x1; }
88
89 void setAlpha(double v) { mAlpha = v; };
90 double getAlpha() { return mAlpha; };
91
92 void setModuleConfig(const ModuleConfig* moduleConfig) { mModuleConfig = moduleConfig; };
93 const ModuleConfig* getModuleConfig() { return mModuleConfig; };
94 void setTDCParam(const ZDCTDCParam* param) { mTDCParam = param; };
95 const ZDCTDCParam* getTDCParam() { return mTDCParam; };
96 void setTDCCorr(const ZDCTDCCorr* param) { mTDCCorr = param; };
97 const ZDCTDCCorr* getTDCCorr() { return mTDCCorr; };
98 void setEnergyParam(const ZDCEnergyParam* param) { mEnergyParam = param; };
99 const ZDCEnergyParam* getEnergyParam() { return mEnergyParam; };
100 void setTowerParam(const ZDCTowerParam* param) { mTowerParam = param; };
101 const ZDCTowerParam* getTowerParam() { return mTowerParam; };
102 void setBaselineParam(const BaselineParam* param) { mPedParam = param; };
103 const BaselineParam* getBaselineParam() { return mPedParam; };
104 void setRecoConfigZDC(const RecoConfigZDC* cfg) { mRecoConfigZDC = cfg; };
105 const RecoConfigZDC* getRecoConfigZDC() { return mRecoConfigZDC; };
106 // Enable or disable low pass filtering
107 void setLowPassFilter(bool val = true)
108 {
109 mLowPassFilter = val;
110 mLowPassFilterSet = true;
111 LOG(warn) << __func__ << " Configuration of low pass filtering: " << (mLowPassFilter ? "enabled" : "disabled");
112 };
113 bool getLowPassFilter() { return mLowPassFilter; };
114 void setFullInterpolation(bool val = true)
115 {
116 mFullInterpolation = val;
117 mFullInterpolationSet = true;
118 LOG(warn) << __func__ << " Full waveform interpolation: " << (mFullInterpolation ? "enabled" : "disabled");
119 };
120 bool getFullInterpolation() { return mFullInterpolation; };
121 // Enable or disable TDC corrections
122 void setCorrSignal(bool val = true)
123 {
124 mCorrSignal = val;
125 mCorrSignalSet = true;
126 LOG(warn) << __func__ << " Configuration of TDC signal correction: " << (mCorrSignal ? "enabled" : "disabled");
127 };
128 bool getCorrSignal() { return mCorrSignal; };
129 void setCorrBackground(bool val = true)
130 {
131 mCorrBackground = val;
132 mCorrBackgroundSet = true;
133 LOG(warn) << __func__ << " Configuration of TDC pile-up correction: " << (mCorrBackground ? "enabled" : "disabled");
134 };
135 bool getCorrBackground() { return mCorrBackground; };
136 bool inError()
137 {
138 return mInError;
139 }
140
141 const uint32_t* getTDCMask() const { return mTDCMask; }
142 const uint32_t* getChMask() const { return mChMask; }
143 const std::vector<o2::zdc::RecEventAux>& getReco() { return mReco; }
144
145 private:
146 const ModuleConfig* mModuleConfig = nullptr;
147 void updateOffsets(int ibun);
148 void lowPassFilter();
149 int reconstructTDC(int seq_beg, int seq_end);
150 int reconstruct(int seq_beg, int seq_end);
151 int processTrigger(int itdc, int ibeg, int iend);
152 int processTriggerExtended(int itdc, int ibeg, int iend);
153 int interpolate(int itdc, int ibeg, int iend);
154 int fullInterpolation(int itdc, int ibeg, int iend);
155 void correctTDCPile();
156 bool mLowPassFilter = true;
157 bool mLowPassFilterSet = false;
158 bool mFullInterpolation = false;
159 bool mFullInterpolationSet = false;
160 int mFullInterpolationMinLength = 2;
161 int mInterpolationStep = 25;
162 bool mCorrSignal = true;
163 bool mCorrSignalSet = false;
164 bool mCorrBackground = true;
165 bool mCorrBackgroundSet = false;
166 bool mInError = false;
167 int mAssignedTDC[NTDCChannels] = {0};
168
169 int correctTDCSignal(int itdc, int16_t TDCVal, float TDCAmp, float& fTDCVal, float& fTDCAmp, bool isbeg, bool isend);
170 int correctTDCBackground(int ibc, int itdc, std::deque<DigiRecoTDC>& tdc);
171
172 O2_ZDC_DIGIRECO_FLT getPoint(int itdc, int ibeg, int iend, int i);
173 void setPoint(int itdc, int ibeg, int iend, int i);
174
175 void assignTDC(int ibun, int ibeg, int iend, int itdc, int tdc, float amp);
176 void findSignals(int ibeg, int iend);
177 const RecoParamZDC* mRopt = nullptr;
178 bool mIsContinuous = true;
179 uint8_t mTriggerCondition = 0x3;
180 int mNBCAHead = 0;
181 const ZDCTDCParam* mTDCParam = nullptr;
182 const ZDCTDCCorr* mTDCCorr = nullptr;
183 const ZDCEnergyParam* mEnergyParam = nullptr;
184 const ZDCTowerParam* mTowerParam = nullptr;
185 const BaselineParam* mPedParam = nullptr;
186 uint32_t mTriggerMask = 0;
187 uint32_t mTDCMask[NTDCChannels] = {0};
188 uint32_t mChMask[NChannels] = {0};
189 const RecoConfigZDC* mRecoConfigZDC = nullptr;
190 int32_t mVerbosity = DbgMinimal;
192 bool mTreeDbg = false;
193 std::unique_ptr<TFile> mDbg = nullptr;
194 std::unique_ptr<TTree> mTDbg = nullptr;
195 gsl::span<const o2::zdc::OrbitData> mOrbitData;
196 gsl::span<const o2::zdc::BCData> mBCData;
197 gsl::span<const o2::zdc::ChannelData> mChData;
198 std::vector<o2::zdc::RecEventAux> mReco;
199 std::map<uint32_t, int> mOrbit;
200 float mOffset[NChannels];
201 uint32_t mOffsetOrbit = 0xffffffff;
202 uint8_t mSource[NChannels];
203 static constexpr int mNSB = TSN * NTimeBinsPerBC;
204 RecEventAux mRec;
205 int mNBC = 0;
206 int mNLonely = 0;
207 int mLonely[o2::constants::lhc::LHCMaxBunches] = {0};
208 int mLonelyTrig[o2::constants::lhc::LHCMaxBunches] = {0};
209 uint32_t mMissingPed[NChannels] = {0};
210 int16_t tdc_shift[NTDCChannels] = {0};
211 float tdc_calib[NTDCChannels] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
212 float tdc_offset[NTDCChannels] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
213 constexpr static uint16_t mMask[NTimeBinsPerBC] = {0x0001, 0x002, 0x004, 0x008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800};
214 O2_ZDC_DIGIRECO_FLT mAlpha = 3; // Parameter of interpolation function
215 // Configuration of interpolation for current TDC
216 int mNbun; // Number of adjacent bunches
217 int mNsam; // Number of acquired samples
218 int mNtot; // Total number of points in the interpolated arrays
219 int mIlast; // Index of last acquired sample
220 int mNint; // Total points in the interpolation region (-1)
221 O2_ZDC_DIGIRECO_FLT mFirstSample;
222 O2_ZDC_DIGIRECO_FLT mLastSample;
223};
224} // namespace zdc
225} // namespace o2
226#endif
Class to describe fired triggered and/or stored channels for the BC and to refer to channel data.
Baseline calibration data.
benchmark::State & state
int32_t i
Class to describe pedestal data accumulated over the orbit.
Class to describe reconstructed ZDC event (single BC with signal in one of detectors)
ZDC reconstruction parameters.
ZDC reconstruction parameters.
ZDC Energy calibration.
ZDC TDC correction parameters.
Parameters to correct TDCs (produced by QA)
ZDC Tower calibration.
Container class to store NTimeBinsPerBC ADC values of single ZDC channel.
const ZDCTDCCorr * getTDCCorr()
Definition DigiReco.h:97
void setFullInterpolation(bool val=true)
Definition DigiReco.h:114
void setAlpha(double v)
Definition DigiReco.h:89
void setDebugOutput(bool state=true)
Definition DigiReco.h:79
void setTowerParam(const ZDCTowerParam *param)
Definition DigiReco.h:100
void setCorrBackground(bool val=true)
Definition DigiReco.h:129
void setCorrSignal(bool val=true)
Definition DigiReco.h:122
const BaselineParam * getBaselineParam()
Definition DigiReco.h:103
uint8_t getTriggerCondition()
Definition DigiReco.h:84
double getAlpha()
Definition DigiReco.h:90
bool getFullInterpolation()
Definition DigiReco.h:120
~DigiReco()=default
const ModuleConfig * getModuleConfig()
Definition DigiReco.h:93
void setRecoConfigZDC(const RecoConfigZDC *cfg)
Definition DigiReco.h:104
void setModuleConfig(const ModuleConfig *moduleConfig)
Definition DigiReco.h:92
int getVerbosity() const
Definition DigiReco.h:78
const RecoConfigZDC * getRecoConfigZDC()
Definition DigiReco.h:105
void prepareInterpolation()
Definition DigiReco.cxx:463
DigiReco()=default
void setTripleTrigger()
Definition DigiReco.h:85
bool getCorrSignal()
Definition DigiReco.h:128
const uint32_t * getChMask() const
Definition DigiReco.h:142
bool getCorrBackground()
Definition DigiReco.h:135
const uint32_t * getTDCMask() const
Definition DigiReco.h:141
void setSingleTrigger()
Definition DigiReco.h:87
const ZDCTowerParam * getTowerParam()
Definition DigiReco.h:101
void setBaselineParam(const BaselineParam *param)
Definition DigiReco.h:102
const std::vector< o2::zdc::RecEventAux > & getReco()
Definition DigiReco.h:143
void setDoubleTrigger()
Definition DigiReco.h:86
void setTDCParam(const ZDCTDCParam *param)
Definition DigiReco.h:94
void setLowPassFilter(bool val=true)
Definition DigiReco.h:107
const ZDCTDCParam * getTDCParam()
Definition DigiReco.h:95
void setVerbosity(int v)
Definition DigiReco.h:74
void setEnergyParam(const ZDCEnergyParam *param)
Definition DigiReco.h:98
void setTDCCorr(const ZDCTDCCorr *param)
Definition DigiReco.h:96
const ZDCEnergyParam * getEnergyParam()
Definition DigiReco.h:99
bool getLowPassFilter()
Definition DigiReco.h:113
const GLdouble * v
Definition glcorearb.h:832
GLuint GLfloat * val
Definition glcorearb.h:1582
GLenum GLfloat param
Definition glcorearb.h:271
uint8_t itsSharedClusterMap uint8_t
constexpr int LHCMaxBunches
struct o2::upgrades_utils::@463 zdc
structure to keep FT0 information
float O2_ZDC_DIGIRECO_FLT
Definition DigiReco.h:49
constexpr int NTimeBinsPerBC
Definition Constants.h:53
constexpr int NTDCChannels
Definition Constants.h:90
constexpr int NChannels
Definition Constants.h:65
constexpr int TSN
Definition Constants.h:94
constexpr int NTS
Definition Constants.h:96
constexpr int DbgMinimal
Definition Constants.h:208
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
o2::InteractionRecord ir
Definition DigiReco.h:60
DigiRecoTDC(uint16_t myval, uint16_t myamp, o2::InteractionRecord myir)
Definition DigiReco.h:52
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"