Project
Loading...
Searching...
No Matches
MFTDCSConfigProcessorSpec.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_MFT_DCSCONFIGPROCESSOR_H
13#define O2_MFT_DCSCONFIGPROCESSOR_H
14
17
19
22#include "CCDB/CcdbObjectInfo.h"
23#include "CCDB/CcdbApi.h"
24
29#include "Framework/Task.h"
30#include "Framework/Logger.h"
31
32#include <chrono>
33
34using namespace o2::framework;
35
36using TFType = uint64_t;
37using HighResClock = std::chrono::high_resolution_clock;
38
39namespace o2
40{
41namespace mft
42{
43
45{
46
47 public:
49 {
50 mVerbose = ic.options().get<bool>("use-verbose-mode");
51 LOG(info) << " ************************* Verbose?" << mVerbose;
52 }
53
54 //---------------------------------------------------------
55
57 {
58 auto configBuff = pc.inputs().get<gsl::span<char>>("confFile");
59 auto configFileName = pc.inputs().get<std::string>("confFileName");
60
61 LOG(info) << "got input file " << configFileName << " of size " << configBuff.size();
62
63 mReader.init(mVerbose);
64 mReader.loadConfig(configBuff);
65
66 sendOutput(pc.outputs());
67
68 mReader.clear();
69 }
70
71 private:
72 void sendOutput(DataAllocator& output)
73 {
74
75 auto tf = std::chrono::duration_cast<std::chrono::milliseconds>(HighResClock::now().time_since_epoch()).count();
76
78
80 // Preparing the object for DCS Configuration
82
83 const auto& payloadConfigInfo = mReader.getConfigInfo();
84 auto clNameConfigInfo = o2::utils::MemFileHelper::getClassName(payloadConfigInfo);
85 auto flNameConfigInfo = o2::ccdb::CcdbApi::generateFileName(clNameConfigInfo);
86
87 std::map<std::string, std::string> mdConfigInfo;
88 mdConfigInfo.emplace("created_by", "dpl");
89
90 o2::ccdb::CcdbObjectInfo infoConfigInfo("MFT/Config/Params", clNameConfigInfo, flNameConfigInfo, mdConfigInfo, tf, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP);
91
92 auto imageConfigInfo = o2::ccdb::CcdbApi::createObjectImage(&payloadConfigInfo, &infoConfigInfo);
93
94 LOG(info) << "Sending object " << infoConfigInfo.getPath() << "/" << infoConfigInfo.getFileName() << " of size " << imageConfigInfo->size()
95 << " bytes, valid for " << infoConfigInfo.getStartValidityTimestamp() << " : " << infoConfigInfo.getEndValidityTimestamp();
96
97 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "DCS_CONFIG_FILE", 0}, *imageConfigInfo.get()); // vector<char>
98 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "DCS_CONFIG_FILE", 0}, infoConfigInfo); // root-serialized
99
101 // Preparing the object for Dead Map
103
104 const auto& payloadDeadMap = mReader.getNoiseMap();
105 auto clNameDeadMap = o2::utils::MemFileHelper::getClassName(payloadDeadMap);
106 auto flNameDeadMap = o2::ccdb::CcdbApi::generateFileName(clNameDeadMap);
107
108 std::map<std::string, std::string> mdDeadMap;
109 mdDeadMap.emplace("created_by", "dpl");
110
111 o2::ccdb::CcdbObjectInfo infoDeadMap("MFT/Calib/DeadMap", clNameDeadMap, flNameDeadMap, mdDeadMap, tf, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP);
112
113 auto imageDeadMap = o2::ccdb::CcdbApi::createObjectImage(&payloadDeadMap, &infoDeadMap);
114
115 LOG(info) << "Sending object " << infoDeadMap.getPath() << "/" << infoDeadMap.getFileName() << " of size " << imageDeadMap->size()
116 << " bytes, valid for " << infoDeadMap.getStartValidityTimestamp() << " : " << infoDeadMap.getEndValidityTimestamp();
117
118 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "DCS_CONFIG_FILE", 1}, *imageDeadMap.get()); // vector<char>
119 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "DCS_CONFIG_FILE", 1}, infoDeadMap); // root-serialized
120
122 // Preparing the object for Alpide Configuration
124
125 const auto& payloadAlpideInfo = mReader.getAlpideInfo();
126 auto clNameAlpideInfo = o2::utils::MemFileHelper::getClassName(payloadAlpideInfo);
127 auto flNameAlpideInfo = o2::ccdb::CcdbApi::generateFileName(clNameAlpideInfo);
128 std::map<std::string, std::string> mdAlpideInfo;
129 mdAlpideInfo.emplace("created_by", "dpl");
130
131 o2::ccdb::CcdbObjectInfo infoAlpideInfo("MFT/Config/AlpideParam", clNameAlpideInfo, flNameAlpideInfo, mdAlpideInfo, tf, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP);
132
133 auto imageAlpideInfo = o2::ccdb::CcdbApi::createObjectImage(&payloadAlpideInfo, &infoAlpideInfo);
134
135 LOG(info) << "Sending object " << infoAlpideInfo.getPath() << "/" << infoAlpideInfo.getFileName() << " of size " << imageAlpideInfo->size()
136 << " bytes, valid for " << infoAlpideInfo.getStartValidityTimestamp() << " : " << infoAlpideInfo.getEndValidityTimestamp();
137
138 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "DCS_CONFIG_FILE", 3}, *imageAlpideInfo.get()); // vector<char>
139 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "DCS_CONFIG_FILE", 3}, infoAlpideInfo); // root-serialized
140 }
141 //________________________________________________________________
142
143 DCSConfigReader mReader;
144 bool mVerbose = false; // to enable verbose mode
145
146}; // end class
147} // namespace mft
148
149namespace framework
150{
151
152DataProcessorSpec getMFTDCSConfigProcessorSpec()
153{
154
155 std::vector<OutputSpec> outputs;
156 outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "DCS_CONFIG_FILE"}, Lifetime::Sporadic);
157 outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "DCS_CONFIG_FILE"}, Lifetime::Sporadic);
158
159 std::string procName = "mft-dcs-config";
160
161 return DataProcessorSpec{
162 procName,
163 Inputs{{"confFile", ConcreteDataTypeMatcher{"MFT", "DCS_CONFIG_FILE"}, Lifetime::Sporadic},
164 {"confFileName", ConcreteDataTypeMatcher{"MFT", "DCS_CONFIG_NAME"}, Lifetime::Sporadic}},
165 Outputs{outputs},
166 AlgorithmSpec{adaptFromTask<o2::mft::MFTDCSConfigProcessor>()},
167 Options{{"use-verbose-mode", VariantType::Bool, false, {"Use verbose mode"}}}};
168}
169
170} // namespace framework
171} // namespace o2
172
173#endif
Utils and constants for calibration and related workflows.
std::chrono::high_resolution_clock HighResClock
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
uint64_t TFType
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
void loadConfig(gsl::span< const char > configBuf)
const std::vector< o2::mft::DCSConfigInfo > & getConfigInfo() const
const o2::itsmft::NoiseMap & getNoiseMap() const
const o2::itsmft::DPLAlpideParam< o2::detectors::DetID::MFT > & getAlpideInfo() const
void init(o2::framework::InitContext &ic) final
void run(o2::framework::ProcessingContext &pc) final
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::unique_ptr< GPUReconstructionTimeframe > tf
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"