Project
Loading...
Searching...
No Matches
WaveformCalibEPN.cxx
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 <TROOT.h>
13#include <TFile.h>
14#include <TH1.h>
15#include <TString.h>
16#include <TStyle.h>
17#include <TDirectory.h>
20#include "Framework/Logger.h"
21
22using namespace o2::zdc;
23
25{
26 if (mConfig == nullptr) {
27 LOG(fatal) << "o2::zdc::WaveformCalibEPN: missing configuration object";
28 return -1;
29 }
30
31 auto* cfg = mConfig;
32 if (mVerbosity > DbgZero) {
33 mConfig->print();
34 }
35
36 // Inspect reconstruction parameters
37 const auto& opt = CalibParamZDC::Instance();
38 opt.print();
39
40 if (opt.rootOutput == true) {
42 }
43
44 if (opt.dumpCalib == true) {
46 }
47
48 mQueue.configure(cfg);
49 if (mVerbosity > DbgZero) {
50 mQueue.printConf();
51 }
52 mQueue.mVerbosity = mVerbosity;
53
54 // number of bins
55 mNBin = cfg->nbun * TSN * NTimeBinsPerBC;
56 mFirst = cfg->ibeg;
57 mLast = cfg->iend;
58 mData.setN(cfg->nbun);
59 mData.mPeak = mQueue.mPeak;
60 LOGF(info, "o2::zdc::WaveformCalibEPN::%s mNBin=%d mFirst=%d mLast=%d mN=%d mPeak=%d", __func__, mNBin, mFirst, mLast, cfg->nbun, mData.mPeak);
61 mInitDone = true;
62 return 0;
63}
64
66{
67#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
68 LOG(info) << "o2::zdc::WaveformCalibEPN::" << __func__;
69#endif
70 // mQueue.clear();
72 mData.setN(mN);
73}
74
75//______________________________________________________________________________
76int WaveformCalibEPN::process(const gsl::span<const o2::zdc::BCRecData>& RecBC,
77 const gsl::span<const o2::zdc::ZDCEnergy>& Energy,
78 const gsl::span<const o2::zdc::ZDCTDCData>& TDCData,
79 const gsl::span<const uint16_t>& Info,
80 const gsl::span<const o2::zdc::ZDCWaveform>& wave)
81{
82 if (!mInitDone) {
83 init();
84 }
86 ev.init(RecBC, Energy, TDCData, Info);
87 auto nen = ev.getEntries();
88 std::vector<o2::InteractionRecord> ir;
89 while (int ientry = ev.next()) {
90 uint32_t mask = mQueue.append(ev);
91#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
92 LOGF(info, "WaveformCalibEPN::%s mask=0x%04x %s %s %s %s %s %s %s %s %s %s", __func__, mask,
93 (mask & 0x001) ? ChannelNames[TDCSignal[0]] : " ",
94 (mask & 0x002) ? ChannelNames[TDCSignal[1]] : " ",
95 (mask & 0x004) ? ChannelNames[TDCSignal[2]] : " ",
96 (mask & 0x008) ? ChannelNames[TDCSignal[3]] : " ",
97 (mask & 0x010) ? ChannelNames[TDCSignal[4]] : " ",
98 (mask & 0x020) ? ChannelNames[TDCSignal[5]] : " ",
99 (mask & 0x040) ? ChannelNames[TDCSignal[6]] : " ",
100 (mask & 0x080) ? ChannelNames[TDCSignal[7]] : " ",
101 (mask & 0x100) ? ChannelNames[TDCSignal[8]] : " ",
102 (mask & 0x200) ? ChannelNames[TDCSignal[9]] : " ");
103#endif
104 if (mask != 0) {
105#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
106 // Print last recorded event. Not the event at peak position
107 ev.print();
109 mQueue.print();
110#endif
111 // Analyze signals that refer to the TDC channels that satisfy condition
112 for (int isig = 0; isig < NChannels; isig++) {
113 int itdc = SignalTDC[isig];
114 if ((mask & (0x1 << itdc)) != 0) {
115 // Check which channels have consecutive data
116 mQueue.addData(isig, wave, mData);
117 }
118 }
119 }
120 }
121 return 0;
122}
123
124//______________________________________________________________________________
126{
127 if (mVerbosity > DbgZero) {
128 LOGF(info, "WaveformCalibEPN::endOfRun ts (%llu:%llu)", mData.mCTimeBeg, mData.mCTimeEnd);
129 for (int is = 0; is < NChannels; is++) {
130 int itdc = SignalTDC[is];
131 if (mData.getEntries(is) > 0) {
132 LOGF(info, "Waveform %2d %s with %10d events and cuts AMP:(%g:%g) TDC:%d:(%g:%g) Valid:[%d:%d:%d]", is, ChannelNames[is].data(),
133 mData.getEntries(is), mConfig->cutLow[is], mConfig->cutHigh[is],
134 itdc, mConfig->cutTimeLow[itdc], mConfig->cutTimeHigh[itdc],
136 } else {
137 LOGF(info, "Waveform %2d %s with %10d events and cuts AMP:(%g:%g) TDC:%d:(%g:%g)", is, ChannelNames[is].data(),
138 mData.getEntries(is), mConfig->cutLow[is], mConfig->cutHigh[is],
139 itdc, mConfig->cutTimeLow[itdc], mConfig->cutTimeHigh[itdc]);
140 }
141 }
142 }
143 const auto& opt = CalibParamZDC::Instance();
144 if (mSaveDebugHistos) {
145 saveDebugHistos(opt.outputDir + "ZDCWaveformCalibEPN.root");
146 }
147 if (mDumpCalib) {
148 dumpCalib(opt.outputDir + "ZDCWaveformCalibEPNDump.root");
149 }
150 return 0;
151}
152
153//______________________________________________________________________________
154int WaveformCalibEPN::saveDebugHistos(const std::string fn)
155{
156 return mData.saveDebugHistos(fn);
157}
158
159//______________________________________________________________________________
160int WaveformCalibEPN::dumpCalib(const std::string fn)
161{
162 return mData.dumpCalib(fn);
163}
ZDC calibration common parameters.
int dumpCalib(const std::string fn="ZDCWaveformCalibEPNDump.root")
int saveDebugHistos(const std::string fn="ZDCWaveformCalibEPN.root")
int process(const gsl::span< const o2::zdc::BCRecData > &bcrec, const gsl::span< const o2::zdc::ZDCEnergy > &energy, const gsl::span< const o2::zdc::ZDCTDCData > &tdc, const gsl::span< const uint16_t > &info, const gsl::span< const o2::zdc::ZDCWaveform > &wave)
GLboolean * data
Definition glcorearb.h:298
GLint GLuint mask
Definition glcorearb.h:291
const int TDCSignal[NTDCChannels]
Definition Constants.h:181
constexpr int NTimeBinsPerBC
Definition Constants.h:53
const int SignalTDC[NChannels]
Definition Constants.h:195
constexpr int NChannels
Definition Constants.h:65
constexpr int TSN
Definition Constants.h:94
constexpr int DbgZero
Definition Constants.h:207
constexpr std::string_view ChannelNames[]
Definition Constants.h:147
void printDecodedMessages() const
void init(const std::vector< o2::zdc::BCRecData > *RecBC, const std::vector< o2::zdc::ZDCEnergy > *Energy, const std::vector< o2::zdc::ZDCTDCData > *TDCData, const std::vector< uint16_t > *Info)
Trigger mask for printout.
double cutTimeHigh[NTDCChannels]
TDC cut low.
double cutHigh[NChannels]
Amplitude cut low.
double cutTimeLow[NTDCChannels]
Minimum entries to compute waveform.
int mPeak
Number of bunches in waveform.
int dumpCalib(const std::string fn)
uint64_t mCTimeEnd
Time of processed time frame.
int saveDebugHistos(const std::string fn)
int addData(int isig, const gsl::span< const o2::zdc::ZDCWaveform > &wave, WaveformCalibData &data)
int mVerbosity
Cut on position difference high.
uint32_t append(RecEventFlat &ev)
void configure(const WaveformCalibConfig *cfg)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
o2::InteractionRecord ir(0, 0)