Project
Loading...
Searching...
No Matches
NoiseCalibEPNSpec.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
15
16#include <iostream>
17#include <vector>
18#include <string>
21#include "CCDB/CcdbApi.h"
22#include "Framework/Logger.h"
39
40using namespace o2::framework;
41
42namespace o2
43{
44namespace zdc
45{
46
48{
49 mTimer.Stop();
50 mTimer.Reset();
51}
52
54{
55 mTimer.Stop();
56 mTimer.Reset();
57}
58
60{
61 mVerbosity = ic.options().get<int>("verbosity-level");
62 mWorker.setVerbosity(mVerbosity);
63 const auto& opt = CalibParamZDC::Instance();
64 mModTF = opt.modTF;
65 if (mVerbosity >= DbgZero) {
66 LOG(info) << "Sending calibration data to aggregator every mModTF = " << mModTF << " TF";
67 }
68}
69
71{
72 // we call these methods just to trigger finaliseCCDB callback
73 pc.inputs().get<o2::zdc::ModuleConfig*>("moduleconfig");
74}
75
77{
78 if (matcher == ConcreteDataMatcher("ZDC", "MODULECONFIG", 0)) {
79 auto* config = (const o2::zdc::ModuleConfig*)obj;
80 if (mVerbosity > DbgMinimal) {
81 LOG(info) << "Loaded ModuleConfig configuration object";
82 config->print();
83 }
84 mWorker.setModuleConfig(config);
85 }
86}
87
89{
90 if (!mInitialized) {
91 mInitialized = true;
93 mTimer.Stop();
94 mTimer.Reset();
95 mTimer.Start(false);
96 }
97
98 auto creationTime = pc.services().get<o2::framework::TimingInfo>().creation; // approximate time in ms
99 mWorker.getData().mergeCreationTime(creationTime);
100 mWorker.getDataSum().mergeCreationTime(creationTime);
101
102 auto trig = pc.inputs().get<gsl::span<o2::zdc::BCData>>("trig");
103 auto chan = pc.inputs().get<gsl::span<o2::zdc::ChannelData>>("chan");
104 auto peds = pc.inputs().get<gsl::span<o2::zdc::OrbitData>>("peds");
105
106 // Process digits
107 mWorker.process(peds, trig, chan);
108 mProcessed++;
109
110 if (mProcessed >= mModTF) {
111 auto& summary = mWorker.mData.getSummary();
112 // Send intermediate calibration data and histograms
113 if (mVerbosity > DbgMedium && mModTF > 0) {
114 LOG(info) << "Send intermediate calibration data mProcessed=" << mProcessed << " >= mModTF=" << mModTF;
115 }
116 o2::framework::Output outputData("ZDC", "NOISECALIBDATA", 0);
117 pc.outputs().snapshot(outputData, summary);
118 for (int ih = 0; ih < NChannels; ih++) {
119 {
120 o2::framework::Output output("ZDC", "NOISE_1DH", ih);
121 pc.outputs().snapshot(output, mWorker.mH[0][ih]->getBase());
122 }
123 {
124 o2::framework::Output output("ZDC", "NOISE_1DH_S", ih);
125 pc.outputs().snapshot(output, mWorker.mH[1][ih]->getBase());
126 }
127 {
128 o2::framework::Output output("ZDC", "NOISE_1DH_D", ih);
129 pc.outputs().snapshot(output, mWorker.mH[2][ih]->getBase());
130 }
131 }
132 mWorker.clear();
133 mProcessed = 0;
134 }
135}
136
138{
139 mWorker.endOfRun();
140 mTimer.Stop();
141 LOGF(info, "ZDC EPN Noise calibration total timing: Cpu: %.3e Real: %.3e s in %d slots", mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
142}
143
145{
146 std::vector<InputSpec> inputs;
147 inputs.emplace_back("trig", "ZDC", "DIGITSBC", 0, Lifetime::Timeframe);
148 inputs.emplace_back("chan", "ZDC", "DIGITSCH", 0, Lifetime::Timeframe);
149 inputs.emplace_back("peds", "ZDC", "DIGITSPD", 0, Lifetime::Timeframe);
150 inputs.emplace_back("moduleconfig", "ZDC", "MODULECONFIG", 0, Lifetime::Condition, o2::framework::ccdbParamSpec(o2::zdc::CCDBPathConfigModule.data()));
151
152 std::vector<OutputSpec> outputs;
153 outputs.emplace_back("ZDC", "NOISECALIBDATA", 0, Lifetime::Sporadic);
154 for (int ih = 0; ih < NChannels; ih++) {
155 outputs.emplace_back("ZDC", "NOISE_1DH", ih, Lifetime::Sporadic);
156 outputs.emplace_back("ZDC", "NOISE_1DH_S", ih, Lifetime::Sporadic);
157 outputs.emplace_back("ZDC", "NOISE_1DH_D", ih, Lifetime::Sporadic);
158 }
159 return DataProcessorSpec{
160 "zdc-calib-noise-epn",
161 inputs,
162 outputs,
163 AlgorithmSpec{adaptFromTask<NoiseCalibEPNSpec>()},
164 Options{{"verbosity-level", o2::framework::VariantType::Int, 0, {"Verbosity level"}}}};
165}
166
167} // namespace zdc
168} // namespace o2
#define verbosity
Class to describe fired triggered and/or stored channels for the BC and to refer to channel data.
ZDC calibration common parameters.
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
Definition of the Names Generator class.
Format of noise calibration intermediate data.
Class to describe pedestal data accumulated over the orbit.
Class to describe reconstructed ZDC event (single BC with signal in one of detectors)
Container class to store NTimeBinsPerBC ADC values of single ZDC channel.
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
Definition InitContext.h:33
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
void updateTimeDependentParams(o2::framework::ProcessingContext &pc)
void run(o2::framework::ProcessingContext &pc) final
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void init(o2::framework::InitContext &ic) final
void setVerbosity(int val)
NoiseCalibData & getDataSum()
void setModuleConfig(const ModuleConfig *moduleConfig)
int process(const gsl::span< const o2::zdc::OrbitData > &orbitdata, const gsl::span< const o2::zdc::BCData > &bcdata, const gsl::span< const o2::zdc::ChannelData > &chdata)
NoiseCalibData & getData()
std::array< std::array< o2::dataformats::FlatHisto1D< double > *, NChannels >, NoiseCalibData::NHA > mH
GLboolean * data
Definition glcorearb.h:298
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
struct o2::upgrades_utils::@463 zdc
structure to keep FT0 information
constexpr int NChannels
Definition Constants.h:65
framework::DataProcessorSpec getNoiseCalibEPNSpec()
constexpr int DbgMinimal
Definition Constants.h:208
constexpr int DbgZero
Definition Constants.h:207
const std::string CCDBPathConfigModule
Definition Constants.h:219
constexpr int DbgMedium
Definition Constants.h:209
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
NoiseCalibSummaryData & getSummary()
void mergeCreationTime(uint64_t ctime)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"