Project
Loading...
Searching...
No Matches
FT0EventsPerBcSpec.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 O2_CALIBRATION_FT0_EVENTS_PER_BC_CALIBRATOR_H
13#define O2_CALIBRATION_FT0_EVENTS_PER_BC_CALIBRATOR_H
14
21#include "Framework/Task.h"
24
27
28namespace o2::calibration
29{
31{
32 public:
33 FT0EventsPerBcProcessor(std::shared_ptr<o2::base::GRPGeomRequest> request) : mCCDBRequest(request) {}
34
36 {
38 if (ic.options().hasOption("slot-len-sec")) {
39 mSlotLenSec = ic.options().get<uint32_t>("slot-len-sec");
40 }
41 if (ic.options().hasOption("one-object-per-run")) {
42 mOneObjectPerRun = ic.options().get<bool>("one-object-per-run");
43 }
44 if (ic.options().hasOption("min-entries-number")) {
45 mMinNumberOfEntries = ic.options().get<uint32_t>("min-entries-number");
46 }
47 if (ic.options().hasOption("min-ampl-side-a")) {
48 mMinAmplitudeSideA = ic.options().get<int32_t>("min-ampl-side-a");
49 }
50 if (ic.options().hasOption("min-ampl-side-c")) {
51 mMinAmplitudeSideC = ic.options().get<int32_t>("min-ampl-side-c");
52 }
53 if (ic.options().hasOption("min-sum-of-ampl")) {
54 mMinSumOfAmplitude = ic.options().get<int32_t>("min-sum-of-ampl");
55 }
56
57 mCalibrator = std::make_unique<o2::ft0::EventsPerBcCalibrator>(mMinNumberOfEntries, mMinAmplitudeSideA, mMinAmplitudeSideC, mMinSumOfAmplitude);
58
59 if (mOneObjectPerRun) {
60 LOG(info) << "Only one object will be created at the end of run";
61 mCalibrator->setUpdateAtTheEndOfRunOnly();
62 }
63 if (mOneObjectPerRun == false) {
64 LOG(info) << "Defined slot interval to " << mSlotLenSec << " seconds";
65 mCalibrator->setSlotLengthInSeconds(mSlotLenSec);
66 }
67 }
68
73
75 {
77 auto digits = pc.inputs().get<gsl::span<o2::ft0::Digit>>("digits");
78 o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo());
79 if (digits.size() == 0) {
80 return;
81 }
82 mCalibrator->process(digits);
83 if (mOneObjectPerRun == false) {
84 sendOutput(pc.outputs());
85 }
86 }
87
89 {
90 LOG(info) << "Received end-of-stream, checking for slot to finalize...";
91 mCalibrator->checkSlotsToFinalize();
92 sendOutput(ec.outputs());
93 mCalibrator->initOutput();
94 }
95
97 {
99 const auto& tvxHists = mCalibrator->getTvxPerBc();
100 auto& infos = mCalibrator->getTvxPerBcCcdbInfo();
101 for (unsigned int idx = 0; idx < tvxHists.size(); idx++) {
102 auto& info = infos[idx];
103 const auto& payload = tvxHists[idx];
104
105 auto image = o2::ccdb::CcdbApi::createObjectImage(&payload, info.get());
106 LOG(info) << "Sending object " << info->getPath() << "/" << info->getFileName() << " of size " << image->size()
107 << " bytes, valid for " << info->getStartValidityTimestamp() << " : " << info->getEndValidityTimestamp();
108 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "EventsPerBc", idx}, *image.get());
109 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "EventsPerBc", idx}, *info.get());
110 }
111
112 if (tvxHists.size()) {
113 mCalibrator->initOutput();
114 }
115 }
116
117 private:
118 std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
119 std::unique_ptr<o2::ft0::EventsPerBcCalibrator> mCalibrator;
120 bool mOneObjectPerRun;
121 uint32_t mSlotLenSec;
122 uint32_t mMinNumberOfEntries;
123 int32_t mMinAmplitudeSideA;
124 int32_t mMinAmplitudeSideC;
125 int32_t mMinSumOfAmplitude;
126};
127} // namespace o2::calibration
128#endif
Utils and constants for calibration and related workflows.
Helper for geometry and GRP related CCDB requests.
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
void checkUpdates(o2::framework::ProcessingContext &pc)
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
void sendOutput(o2::framework::DataAllocator &output)
void init(o2::framework::InitContext &ic) final
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
void run(o2::framework::ProcessingContext &pc) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
FT0EventsPerBcProcessor(std::shared_ptr< o2::base::GRPGeomRequest > request)
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
Definition CcdbApi.h:103
GLeglImageOES image
Definition glcorearb.h:4021
static void fillTFIDInfo(o2::framework::ProcessingContext &pc, o2::dataformats::TFIDInfo &ti)
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
Definition Utils.h:44
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
Definition Utils.h:43
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits