Project
Loading...
Searching...
No Matches
RecEvent.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 _ZDC_RECEVENT_H_
13#define _ZDC_RECEVENT_H_
14
15#include "Framework/Logger.h"
22#include "ZDCBase/Constants.h"
23#include "MathUtils/Cartesian.h"
24#include <Rtypes.h>
25#include <array>
26#include <vector>
27#include <map>
28
32
33namespace o2
34{
35namespace zdc
36{
37struct RecEvent {
38 std::vector<o2::zdc::BCRecData> mRecBC;
39 std::vector<o2::zdc::ZDCEnergy> mEnergy;
40 std::vector<o2::zdc::ZDCTDCData> mTDCData;
41 std::vector<uint16_t> mInfo;
42 std::vector<o2::zdc::ZDCWaveform> mWaveform;
43
44 // Add new bunch crossing
45 inline void addBC(const RecEventAux& reca)
46 {
47#ifdef O2_ZDC_DEBUG
48 printf("addBC %u.%-4u En_start:%-2lu TDC_start:%-2lu Info_start:%-2lu ch=0x%08x tr=0x%08x\n", reca.ir.orbit, reca.ir.bc, mEnergy.size(), mTDCData.size(), mInfo.size(), reca.channels, reca.triggers);
49#endif
50 mRecBC.emplace_back(mEnergy.size(), mTDCData.size(), mInfo.size(), mWaveform.size(), reca.ir);
51 mRecBC.back().channels = reca.channels;
52 mRecBC.back().triggers = reca.triggers;
53 }
54
55 // Add energy
56 inline void addEnergy(uint8_t ch, float energy)
57 {
58#ifdef O2_ZDC_DEBUG
59 printf("ch:%-2u [%s] Energy %9.2f\n", ch, ChannelNames[ch].data(), energy);
60#endif
61 mEnergy.emplace_back(ch, energy);
62 mRecBC.back().addEnergy();
63 }
64
65 // Add TDC - int16_t
66 inline void addTDC(uint8_t ch, int16_t val, int16_t amp, bool isbeg = false, bool isend = false)
67 {
68#ifdef O2_ZDC_DEBUG
69 printf("ch:%-2u [%s] TDC %4d Amp. %4d%s%s\n", ch, ChannelNames[TDCSignal[ch]].data(), val, amp, isbeg ? " B" : "", isend ? " E" : "");
70#endif
71 mTDCData.emplace_back(ch, val, amp, isbeg, isend);
72 mRecBC.back().addTDC();
73 }
74
75 // Add TDC - float
76 inline void addTDC(uint8_t ch, float val, float amp, bool isbeg = false, bool isend = false)
77 {
78#ifdef O2_ZDC_DEBUG
79 printf("ch:%-2u [%s] TDC %6.0f Amp. %6.0f%s%s\n", ch, ChannelNames[TDCSignal[ch]].data(), val, amp, isbeg ? " B" : "", isend ? " E" : "");
80#endif
81 mTDCData.emplace_back(ch, val, amp, isbeg, isend);
82 mRecBC.back().addTDC();
83 }
84
85 // Add event information
86 inline void addInfo(uint16_t info)
87 {
88#ifdef O2_ZDC_DEBUG
89 printf("addInfo info=%u 0x%04x\n", info, info);
90#endif
91 mInfo.emplace_back(info);
92 mRecBC.back().addInfo();
93 }
94
95 inline void addInfo(uint8_t ch, uint16_t code)
96 {
97 if (ch >= NChannels && ch != 0x1f) {
98 LOGF(error, "Adding info (0x%x) for not existent channel %u", code, ch);
99 return;
100 }
101 uint16_t info = (code & 0x03ff) | ((ch & 0x1f) << 10);
102#ifdef O2_ZDC_DEBUG
103 printf("addInfo ch=%u code=%u \"%s\" info=%u 0x%04x\n", ch, code, MsgText[code].data(), info, info);
104#endif
105 mInfo.emplace_back(info);
106 mRecBC.back().addInfo();
107 }
108
109 uint32_t addInfo(const RecEventAux& reca, const std::array<bool, NChannels>& vec, const uint16_t code);
110 uint32_t addInfos(const RecEventAux& reca);
111
112 // Add waveform
113 inline void addWaveform(uint8_t ch, std::vector<float>& wave)
114 {
115#ifdef O2_ZDC_DEBUG
116 printf("ch:%-2u [%s] Waveform\n", ch, ChannelNames[ch].data());
117#endif
118 if (wave.size() == NIS) {
119 mWaveform.emplace_back(ch, wave.data());
120 mRecBC.back().addWaveform();
121 } else {
122 LOG(error) << __func__ << ": ch " << int(ch) << " inconsistent waveform size " << wave.size();
123 }
124 }
125
126 void print() const;
127 // TODO: remove persitency of this object (here for debugging)
129};
130
131} // namespace zdc
132} // namespace o2
133
134#endif
Class to refer to the reconstructed information.
Container class to store energy released in the ZDC.
Container class to store a TDC hit in a ZDC channel.
Container class to store the interpolated waveform of the ZDC.
GLboolean * data
Definition glcorearb.h:298
GLuint GLfloat * val
Definition glcorearb.h:1582
struct o2::upgrades_utils::@463 zdc
structure to keep FT0 information
const int TDCSignal[NTDCChannels]
Definition Constants.h:181
constexpr int NChannels
Definition Constants.h:65
constexpr std::string_view MsgText[]
Definition Constants.h:262
constexpr int NIS
Definition Constants.h:97
constexpr std::string_view ChannelNames[]
Definition Constants.h:147
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
o2::InteractionRecord ir
uint32_t triggers
pattern of decoded energies
uint32_t addInfos(const RecEventAux &reca)
Definition RecEvent.cxx:94
void addTDC(uint8_t ch, int16_t val, int16_t amp, bool isbeg=false, bool isend=false)
Definition RecEvent.h:66
void addInfo(uint16_t info)
Definition RecEvent.h:86
void addInfo(uint8_t ch, uint16_t code)
Definition RecEvent.h:95
std::vector< o2::zdc::ZDCWaveform > mWaveform
Event quality information.
Definition RecEvent.h:42
void addEnergy(uint8_t ch, float energy)
Definition RecEvent.h:56
ClassDefNV(RecEvent, 2)
void print() const
Definition RecEvent.cxx:16
void addWaveform(uint8_t ch, std::vector< float > &wave)
Definition RecEvent.h:113
std::vector< o2::zdc::ZDCEnergy > mEnergy
Interaction record and references to data.
Definition RecEvent.h:39
std::vector< uint16_t > mInfo
ZDC TDC.
Definition RecEvent.h:41
void addBC(const RecEventAux &reca)
ZDC waveform.
Definition RecEvent.h:45
void addTDC(uint8_t ch, float val, float amp, bool isbeg=false, bool isend=false)
Definition RecEvent.h:76
std::vector< o2::zdc::BCRecData > mRecBC
Definition RecEvent.h:38
std::vector< o2::zdc::ZDCTDCData > mTDCData
ZDC energy.
Definition RecEvent.h:40
std::vector< o2::ctf::BufferType > vec
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"