25 if (ifirst > 0 || ilast < 0 || ilast < ifirst) {
26 LOGF(fatal,
"WaveformCalibQueue configure error with ifirst=%d ilast=%d", ifirst, ilast);
30 mN = ilast - ifirst + 1;
34 for (int32_t isig = 0; isig <
NChannels; isig++) {
47 if (
mIR.size() == 0) {
52 auto& last =
mIR.back();
54 if (toadd.differenceInBC(last) > 1) {
55#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
56 LOG(info) <<
"WaveformCalibQueue::" << __func__ <<
" gap detected. Clearing " <<
mIR.size() <<
" bc";
61 while (
mIR.size() >=
mN) {
66 if (
mIR.size() ==
mN) {
67#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
68 LOG(info) <<
"WaveformCalibQueue::" << __func__ <<
" processing " <<
mIR.size() <<
" bcs";
74 for (
int i = 0;
i <
mN;
i++) {
81 auto tdca =
mTDCA[itdc].at(
i);
82 auto tdcv =
mTDCP[itdc].at(
i);
83 if (tdca < mCfg->cutLow[itdc] || tdca >
mCfg->
cutHigh[itdc] || tdcv < mCfg->cutTimeLow[itdc] || tdcv >
mCfg->
cutTimeHigh[itdc]) {
110#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
111 LOGF(info,
"WaveformCalibQueue::%s %u.%04u", __func__, ev.
ir.
orbit, ev.
ir.
bc);
113 mIR.push_back(ev.
ir);
123 for (
int isig = 0; isig <
NChannels; isig++) {
129 for (uint16_t info : decodedInfo) {
130 uint8_t ch = (info >> 10) & 0x1f;
131 uint16_t code = info & 0x03ff;
142 int nhit = ev.
NtdcV(itdc);
143 if (ev.
NtdcA(itdc) != nhit) {
144 LOGF(error,
"Mismatch in TDC %d data Val=%d Amp=%d\n", itdc, ev.
NtdcV(itdc), ev.
NtdcA(ich));
145 mNTDC[itdc].push_back(0);
146 mTDCA[itdc].push_back(0);
147 mTDCP[itdc].push_back(0);
148 }
else if (nhit == 0) {
149 mNTDC[itdc].push_back(0);
150 mTDCA[itdc].push_back(0);
151 mTDCP[itdc].push_back(0);
154 mNTDC[itdc].push_back(nhit);
165 float min = std::numeric_limits<float>::infinity();
166 for (
int ib = 0; ib <
mN; ib++) {
168#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
169 LOG(info) <<
"WaveformCalibQueue::" << __func__ <<
" mNW[" << ib <<
"] = " <<
mNW[ib] <<
" mFirstW = " <<
mFirstW[ib];
171 for (
int iw = 0; iw <
mNW[ib]; iw++) {
172 auto& mywave = wave[iw +
mFirstW[ib]];
173 if (mywave.ch() == isig) {
175 for (
int ip = 0; ip <
NIS; ip++) {
176 if (mywave.inter[ip] <
min) {
179 min = mywave.inter[ip];
193#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
194 LOG(info) <<
"WaveformCalibQueue::" << __func__ <<
" isig = " << isig <<
" ipkb " << ipkb <<
" ipk " << ipk <<
" min " <<
min;
204#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
209 float min = std::numeric_limits<float>::infinity();
210 float max = -std::numeric_limits<float>::infinity();
211 bool hasInfos =
false;
212 for (
int ib = 0; ib <
mN; ib++) {
218#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
223 for (
int iw = 0; iw <
mNW[ib]; iw++) {
227 auto& mywave = wave[iw +
mFirstW[ib]];
228 if (mywave.ch() == isig) {
230 for (
int ip = 0; ip <
NIS; ip++) {
231 if (mywave.inter[ip] <
min) {
234 min = mywave.inter[ip];
236 if (mywave.inter[ip] >
max) {
237 max = mywave.inter[ip];
242#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
243 LOG(info) <<
" isig=" << isig <<
" mNW[" << ib <<
"] = " <<
mNW[ib] <<
" mFirstW = " <<
mFirstW[ib] <<
" ifound=" << ifound <<
" hasInfos=" << hasInfos;
246 if (!ifound || hasInfos) {
251#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
252 LOG(info) <<
" isig = " << isig <<
" ipkb " << ipkb <<
" != mPk " <<
mPk <<
" SKIP";
256#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
257 LOG(info) <<
" isig = " << isig <<
" ADDING DATA";
259 int ppos =
NIS * ipkb + ipk;
264 if (amp < mCfg->cutLow[isig] || amp >
mCfg->
cutHigh[isig]) {
266#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
267 LOG(info) <<
" isig = " << isig <<
" amplitude " << amp <<
" not in range " <<
mCfg->
cutLow[isig] <<
" : " <<
mCfg->
cutHigh[isig];
279 int ipos =
mPeak - ppos;
282 data.setFirstValid(isig, ipos);
284 for (
int ib = 0; ib <
mN; ib++) {
285 for (
int iw = 0; iw <
mNW[ib]; iw++) {
286 auto& mywave = wave[iw +
mFirstW[ib]];
287 if (mywave.ch() == isig) {
288 for (
int ip = 0; ip <
NIS; ip++) {
289 if (ipos >= 0 && ipos <
mNP) {
291 data.mWave[isig].mData[ipos] += mywave.inter[ip];
300 data.setLastValid(isig, ipos);
301#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
302 LOG(info) <<
"WaveformCalibQueue::" << __func__ <<
" isig = " << isig <<
" ipkb " << ipkb <<
" ipk " << ipk <<
" min " <<
min <<
" range=[" <<
data.getFirstValid(isig) <<
":" << ppos <<
":" <<
data.getLastValid(isig) <<
"]";
311 printf(
"WaveformCalibQueue::print() %d consecutive bunches\n",
n);
312 for (
int i = 0;
i <
n;
i++) {
314 bool printed =
false;
318 printf(
"mHasInfos:");
347 printf(
" %2d=%6.1f",
j,
mTDCA[
j][
i]);
360 printf(
" %2d=%6.1f",
j,
mTDCP[
j][
i]);
371 LOG(info) <<
"WaveformCalibQueue::" << __func__;
373 for (
int isig = 0; isig <
NChannels; isig++) {
struct o2::upgrades_utils::@463 zdc
structure to keep FT0 information
const int TDCSignal[NTDCChannels]
constexpr int NTimeBinsPerBC
constexpr int NTDCChannels
const int SignalTDC[NChannels]
constexpr std::string_view ChannelNames[]
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
uint16_t bc
bunch crossing ID of interaction
void getRefW(int &firstw, int &nw)
int NtdcV(uint8_t ich) const
float tdcV(uint8_t ich, uint64_t ipos) const
float tdcA(uint8_t ich, uint64_t ipos) const
int NtdcA(uint8_t ich) const
const std::vector< uint16_t > & getDecodedInfo()
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"