Project
Loading...
Searching...
No Matches
PedestalCalibDevice.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
14#include "EMCALBase/Geometry.h"
20#include "EMCALCalib/CalibDB.h"
23
24#include <fairlogger/Logger.h>
25
26using namespace o2::emcal;
27
29{
30 LOG(debug) << "[EMCALPedestalCalibDevice - init] Initialize converter ";
31 if (!mGeometry) {
32 mGeometry = Geometry::GetInstanceFromRunNumber(300000);
33 }
34 if (!mGeometry) {
35 LOG(error) << "Failure accessing geometry";
36 }
37
39}
40
42{
43 if (!mRun) {
44 const auto& tinfo = ctx.services().get<o2::framework::TimingInfo>();
45 if (tinfo.runNumber != 0) {
46 mRun = tinfo.runNumber;
47 }
48 }
49
50 constexpr auto originEMC = o2::header::gDataOriginEMC;
52 LOG(debug) << "adding pedestal data";
53 mPedestalData += data;
54}
55
56//________________________________________________________________
58{
59 LOG(info) << "sending pedestal data";
60 constexpr auto originEMC = o2::header::gDataOriginEMC;
61
62 std::map<std::string, std::string> md;
64 auto flName = o2::ccdb::CcdbApi::generateFileName(clName);
66
68
71
72 // the following goes to the DCS ccdb
74 std::vector<char> vecPedData = helper.createPedestalInstruction(data, mAddRunNumber ? mRun : -1);
75 if (mDumpToFile) {
76 helper.dumpInstructions("EMCAL-Pedestals.txt", vecPedData);
77 }
78
79 auto clNameDCS = o2::utils::MemFileHelper::getClassName(vecPedData);
80 auto flNameDCS = o2::ccdb::CcdbApi::generateFileName(clNameDCS);
81 o2::ccdb::CcdbObjectInfo objInfoDCS("EMC/Calib/PDData", clNameDCS, flNameDCS, md, mStartTS, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP, true);
82 auto imageDCS = o2::ccdb::CcdbApi::createObjectImage(&vecPedData, &objInfoDCS);
83
84 ec.outputs().snapshot(o2::framework::Output{o2::calibration::Utils::gDataOriginCDBPayload, "EMC_PEDCALIBSTR", 1}, *imageDCS.get());
86}
87
88//________________________________________________________________
90{
91
92 Pedestal pedObj = mCalibExtractor.extractPedestals(mPedestalData);
93 sendData(ec, pedObj);
94 // reset Timestamp (probably not needed as program will probably be terminated)
96}
97
99{
100
101 std::vector<o2::framework::InputSpec> inputs;
102 inputs.emplace_back(o2::emcal::PedestalCalibDevice::getPedDataBinding(), o2::header::gDataOriginEMC, "PEDDATA", 0, o2::framework::Lifetime::Timeframe);
103 std::vector<o2::framework::OutputSpec> outputs;
104 outputs.emplace_back(o2::framework::ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "EMC_PEDCALIB"}, o2::framework::Lifetime::Sporadic);
105 outputs.emplace_back(o2::framework::ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "EMC_PEDCALIB"}, o2::framework::Lifetime::Sporadic);
106
107 outputs.emplace_back(o2::framework::ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "EMC_PEDCALIBSTR"}, o2::framework::Lifetime::Sporadic);
108 outputs.emplace_back(o2::framework::ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "EMC_PEDCALIBSTR"}, o2::framework::Lifetime::Sporadic);
109
111 "PedestalCalibrator",
112 inputs,
113 outputs,
114 o2::framework::AlgorithmSpec{o2::framework::adaptFromTask<o2::emcal::PedestalCalibDevice>(dumpToFile, addRunNum)},
116}
void dumpToFile(std::string fileName, const CathodeSegmentation &seg, const std::vector< Point > &points)
Utils and constants for calibration and related workflows.
std::ostringstream debug
static std::string generateFileName(const std::string &inp)
Definition CcdbApi.cxx:798
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
Definition CcdbApi.h:103
static constexpr long INFINITE_TIMESTAMP
static const char * getCDBPathChannelPedestals()
Get CCDB path for the pedestal data.
Definition CalibDB.h:370
Pedestal extractPedestals(PedestalProcessorData &obj)
Extract the pedestals from Stat Accumulators.
void dumpInstructions(const std::string_view filename, const gsl::span< char > &data)
print the vector produced by createInstructionString in a textfile
std::vector< char > createPedestalInstruction(const Pedestal &obj, const int runNum=-1)
Encodes the pedestal object into a string. This function fills fMeanPed which is then converted to a ...
static Geometry * GetInstanceFromRunNumber(Int_t runNumber, const std::string_view="", const std::string_view mcname="TGeant3", const std::string_view mctitle="")
Instanciate geometry depending on the run number. Mostly used in analysis and MC anchors.
Definition Geometry.cxx:219
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void init(framework::InitContext &ctx) final
static const char * getPedDataBinding()
void run(framework::ProcessingContext &ctx) final
void sendData(o2::framework::EndOfStreamContext &ec, const Pedestal &data) const
Exchange container between PedestalProcessorDevice and PedestalAggregatorDevice.
CCDB container for pedestal values.
Definition Pedestal.h:48
void snapshot(const Output &spec, T const &object)
decltype(auto) get(R binding, int part=0) const
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
GLeglImageOES image
Definition glcorearb.h:4021
GLboolean * data
Definition glcorearb.h:298
constexpr o2::header::DataOrigin gDataOriginEMC
Definition DataHeader.h:565
o2::framework::DataProcessorSpec getPedestalCalibDevice(bool dumpToFile, bool addRunNum)
std::vector< ConfigParamSpec > Options
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
Definition Utils.h:44
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
Definition Utils.h:43
static std::string getClassName(const T &obj)
get the class name of the object
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"