56 const bool enableZDCTDCCorr,
const bool enableZDCEnergyParam,
const bool enableZDCTowerParam,
const bool enableBaselineParam)
57 : mVerbosity(
verbosity), mDebugOut(debugOut), mEnableZDCTDCCorr(enableZDCTDCCorr), mEnableZDCEnergyParam(enableZDCEnergyParam), mEnableZDCTowerParam(enableZDCTowerParam), mEnableBaselineParam(enableBaselineParam)
67 LOG(warning) <<
"Limiting the number of waveforms in ourput to " << mMaxWave;
69 mRecoFraction = ic.
options().
get<
double>(
"tf-fraction");
70 if (mRecoFraction < 0 || mRecoFraction > 1) {
71 LOG(error) <<
"Unphysical reconstructed fraction " << mRecoFraction <<
" set to 1.0";
74 if (mRecoFraction < 1) {
75 LOG(warning) <<
"Target fraction for reconstructed TFs = " << mRecoFraction;
85 if (mEnableZDCTDCCorr) {
88 if (mEnableZDCEnergyParam) {
91 if (mEnableZDCTowerParam) {
94 if (mEnableBaselineParam) {
161 LOG(info) <<
"DigitRecoSpec::run initialization";
170 auto cput = mTimer.CpuTime();
173 auto bcdata = pc.
inputs().
get<gsl::span<o2::zdc::BCData>>(
"trig");
174 auto chans = pc.
inputs().
get<gsl::span<o2::zdc::ChannelData>>(
"chan");
175 auto peds = pc.
inputs().
get<gsl::span<o2::zdc::OrbitData>>(
"peds");
178 bool toProcess =
true;
179 if (mRecoFraction <= 0.) {
181 }
else if (mRecoFraction < 1.0) {
182 double frac = std::rand() / double(RAND_MAX);
183 if (frac > mRecoFraction) {
191 int rval = mWorker.
process(peds, bcdata, chans);
192 if (rval != 0 || mWorker.
inError()) {
193 LOG(warning) << bcdata.size() <<
" BC " << chans.size() <<
" CH " << peds.size() <<
" OD -> processing ended in ERROR @ line " << rval;
195 const std::vector<o2::zdc::RecEventAux>& recAux = mWorker.
getReco();
199 if (mVerbosity > 0 || fullinter) {
200 LOGF(info,
"BC processed during reconstruction %d%s", recAux.size(), (fullinter ?
" FullInterpolation" :
""));
202 uint32_t nte = 0, ntt = 0, nti = 0, ntw = 0;
203 for (
auto reca : recAux) {
205 int32_t ne = reca.ezdc.size();
209 for (int32_t ih = 0; ih < reca.ntdc[it]; ih++) {
211 recEvent.
addBC(reca);
215 recEvent.
addTDC(it, reca.TDCVal[it][ih], reca.TDCAmp[it][ih], reca.isBeg[it], reca.isEnd[it]);
221 if (reca.inter[isig].size() ==
NIS) {
223 recEvent.
addBC(reca);
231 if (mMaxWave > 0 && ntw >= mMaxWave) {
233 LOG(warning) <<
"Maximum number of output waveforms per TF reached: " << mMaxWave;
240 recEvent.
addBC(reca);
243 std::map<uint8_t, float>::iterator it;
244 for (it = reca.ezdc.begin(); it != reca.ezdc.end(); it++) {
245 recEvent.
addEnergy(it->first, it->second);
250 if (mVerbosity > 1 && (nt > 0 || ne > 0)) {
251 printf(
"Orbit %9u bc %4u ntdc %2d ne %2d channels=0x%08x\n", reca.ir.orbit, reca.ir.bc, nt, ne, reca.channels);
256 LOG(info) << bcdata.size() <<
" BC " << chans.size() <<
" CH " << peds.size() <<
" OD "
257 <<
"-> Reconstructed " << ntt <<
" signal TDCs and " << nte <<
" ZDC energies and "
258 << nti <<
" info messages in " << recEvent.
mRecBC.size() <<
"/" << recAux.size() <<
" b.c. and "
259 << ntw <<
" waveform chunks";
262 LOG(info) << bcdata.size() <<
" BC " << chans.size() <<
" CH " << peds.size() <<
" OD "
263 <<
"-> SKIPPED because of requested reconstruction fraction = " << mRecoFraction;
278 LOGF(info,
"ZDC Reconstruction total timing: Cpu: %.3e Real: %.3e s in %d slots", mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
283 std::vector<InputSpec> inputs;
284 inputs.emplace_back(
"trig",
"ZDC",
"DIGITSBC", 0, Lifetime::Timeframe);
285 inputs.emplace_back(
"chan",
"ZDC",
"DIGITSCH", 0, Lifetime::Timeframe);
286 inputs.emplace_back(
"peds",
"ZDC",
"DIGITSPD", 0, Lifetime::Timeframe);
290 if (enableZDCTDCCorr) {
293 LOG(warning) <<
"ZDCTDCCorr has been disabled - no correction is applied";
295 if (enableZDCEnergyParam) {
298 LOG(warning) <<
"ZDCEnergyParam has been disabled - no energy calibration is applied";
300 if (enableZDCTowerParam) {
303 LOG(warning) <<
"ZDCTowerParam has been disabled - no tower intercalibration";
305 if (enableBaselineParam) {
308 LOG(warning) <<
"BaselineParam has been disabled - no fallback in case orbit pedestals are missing";
311 std::vector<OutputSpec> outputs;
312 outputs.emplace_back(
"ZDC",
"BCREC", 0, Lifetime::Timeframe);
313 outputs.emplace_back(
"ZDC",
"ENERGY", 0, Lifetime::Timeframe);
314 outputs.emplace_back(
"ZDC",
"TDCDATA", 0, Lifetime::Timeframe);
315 outputs.emplace_back(
"ZDC",
"INFO", 0, Lifetime::Timeframe);
316 outputs.emplace_back(
"ZDC",
"WAVE", 0, Lifetime::Timeframe);
322 AlgorithmSpec{adaptFromTask<DigitRecoSpec>(
verbosity, enableDebugOut, enableZDCTDCCorr, enableZDCEnergyParam, enableZDCTowerParam, enableBaselineParam)},
Class to describe fired triggered and/or stored channels for the BC and to refer to channel data.
Baseline calibration data.
Run ZDC digits reconstruction.
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 TDC correction parameters.
Parameters to correct TDCs (produced by QA)
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
void setDebugOutput(bool state=true)
void setTowerParam(const ZDCTowerParam *param)
bool getFullInterpolation()
void setRecoConfigZDC(const RecoConfigZDC *cfg)
void setModuleConfig(const ModuleConfig *moduleConfig)
void setBaselineParam(const BaselineParam *param)
const std::vector< o2::zdc::RecEventAux > & getReco()
void setTDCParam(const ZDCTDCParam *param)
void setEnergyParam(const ZDCEnergyParam *param)
void setTDCCorr(const ZDCTDCCorr *param)
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)
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void init(o2::framework::InitContext &ic) final
void updateTimeDependentParams(o2::framework::ProcessingContext &pc)
void run(o2::framework::ProcessingContext &pc) final
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
Defining PrimaryVertex explicitly as messageable.
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
framework::DataProcessorSpec getDigitRecoSpec(const int verbosity, const bool enableDebugOut, const bool enableZDCTDCCorr, const bool enableZDCEnergyParam, const bool enableZDCTowerParam, const bool enableBaselineParam)
create a processor spec
const std::string CCDBPathTDCCorr
const std::string CCDBPathBaselineCalib
constexpr int NTDCChannels
const std::string CCDBPathRecoConfigZDC
const std::string CCDBPathEnergyCalib
const std::string CCDBPathTDCCalib
const std::string CCDBPathTowerCalib
const std::string CCDBPathConfigModule
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
void print(bool printall=true) const
uint32_t addInfos(const RecEventAux &reca)
void addTDC(uint8_t ch, int16_t val, int16_t amp, bool isbeg=false, bool isend=false)
std::vector< o2::zdc::ZDCWaveform > mWaveform
Event quality information.
void addEnergy(uint8_t ch, float energy)
void addWaveform(uint8_t ch, std::vector< float > &wave)
std::vector< o2::zdc::ZDCEnergy > mEnergy
Interaction record and references to data.
std::vector< uint16_t > mInfo
ZDC TDC.
void addBC(const RecEventAux &reca)
ZDC waveform.
std::vector< o2::zdc::BCRecData > mRecBC
std::vector< o2::zdc::ZDCTDCData > mTDCData
ZDC energy.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"