Project
Loading...
Searching...
No Matches
InterCalibEPNSpec.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 "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}
64
66{
67 // we call these methods just to trigger finaliseCCDB callback
68 pc.inputs().get<o2::zdc::InterCalibConfig*>("intercalibconfig");
69}
70
72{
73 if (matcher == ConcreteDataMatcher("ZDC", "INTERCALIBCONFIG", 0)) {
74 auto* config = (const o2::zdc::InterCalibConfig*)obj;
75 if (mVerbosity > DbgZero) {
76 config->print();
77 }
78 mWorker.setInterCalibConfig(config);
79 }
80}
81
83{
84 if (!mInitialized) {
85 mInitialized = true;
87 mTimer.Stop();
88 mTimer.Reset();
89 mTimer.Start(false);
90 }
91
92 auto creationTime = pc.services().get<o2::framework::TimingInfo>().creation; // approximate time in ms
93 mWorker.getData().setCreationTime(creationTime);
94
95 auto bcrec = pc.inputs().get<gsl::span<o2::zdc::BCRecData>>("bcrec");
96 auto energy = pc.inputs().get<gsl::span<o2::zdc::ZDCEnergy>>("energy");
97 auto tdc = pc.inputs().get<gsl::span<o2::zdc::ZDCTDCData>>("tdc");
98 auto info = pc.inputs().get<gsl::span<uint16_t>>("info");
99
100 // Process reconstructed data
101 mWorker.process(bcrec, energy, tdc, info);
102
103 // Send intermediate calibration data and histograms
104 o2::framework::Output output("ZDC", "INTERCALIBDATA", 0);
105 pc.outputs().snapshot(output, mWorker.mData);
106 for (int ih = 0; ih < (2 * InterCalibData::NH); ih++) {
107 if (mWorker.mH[ih] != nullptr) {
108 o2::framework::Output output("ZDC", "INTER_1DH", ih);
109 pc.outputs().snapshot(output, mWorker.mH[ih]->getBase());
110 }
111 }
112 for (int ih = 0; ih < InterCalibData::NH; ih++) {
113 o2::framework::Output output("ZDC", "INTER_2DH", ih);
114 pc.outputs().snapshot(output, mWorker.mC[ih]->getBase());
115 }
116}
117
119{
120 mWorker.endOfRun();
121 mTimer.Stop();
122 LOGF(info, "ZDC EPN Intercalibration total timing: Cpu: %.3e Real: %.3e s in %d slots", mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
123}
124
126{
127 std::vector<InputSpec> inputs;
128 inputs.emplace_back("bcrec", "ZDC", "BCREC", 0, Lifetime::Timeframe);
129 inputs.emplace_back("energy", "ZDC", "ENERGY", 0, Lifetime::Timeframe);
130 inputs.emplace_back("tdc", "ZDC", "TDCDATA", 0, Lifetime::Timeframe);
131 inputs.emplace_back("info", "ZDC", "INFO", 0, Lifetime::Timeframe);
132 inputs.emplace_back("intercalibconfig", "ZDC", "INTERCALIBCONFIG", 0, Lifetime::Condition, o2::framework::ccdbParamSpec(o2::zdc::CCDBPathInterCalibConfig.data()));
133
134 std::vector<OutputSpec> outputs;
135 outputs.emplace_back("ZDC", "INTERCALIBDATA", 0, Lifetime::Timeframe);
136 for (int ih = 0; ih < (2 * InterCalibData::NH); ih++) {
137 outputs.emplace_back("ZDC", "INTER_1DH", ih, Lifetime::Timeframe);
138 }
139 for (int ih = 0; ih < InterCalibData::NH; ih++) {
140 outputs.emplace_back("ZDC", "INTER_2DH", ih, Lifetime::Timeframe);
141 }
142 return DataProcessorSpec{
143 "zdc-intercalib-epn",
144 inputs,
145 outputs,
146 AlgorithmSpec{adaptFromTask<InterCalibEPNSpec>()},
147 Options{{"verbosity-level", o2::framework::VariantType::Int, 0, {"Verbosity level"}}}};
148}
149
150} // namespace zdc
151} // namespace o2
#define verbosity
Class to describe fired triggered and/or stored channels for the BC and to refer to channel data.
ZDC intercalibration pre-processing on EPN.
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
Definition of the Names Generator class.
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 Energy calibration.
ZDC Tower calibration.
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 run(o2::framework::ProcessingContext &pc) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void updateTimeDependentParams(o2::framework::ProcessingContext &pc)
void init(o2::framework::InitContext &ic) final
void setInterCalibConfig(const InterCalibConfig *param)
std::array< o2::dataformats::FlatHisto2D< float > *, NH > mC
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)
InterCalibData & getData()
void setVerbosity(int val)
std::array< o2::dataformats::FlatHisto1D< float > *, 2 *NH > 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 DbgZero
Definition Constants.h:207
framework::DataProcessorSpec getInterCalibEPNSpec()
const std::string CCDBPathInterCalibConfig
Definition Constants.h:226
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static constexpr int NH
Dimension of matrix (1 + 4 coefficients + offset)
void setCreationTime(uint64_t ctime)