Project
Loading...
Searching...
No Matches
TPCFactorizeSACSpec.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
16
17#ifndef O2_TPCFACTORIZESACSPEC_H
18#define O2_TPCFACTORIZESACSPEC_H
19
20#include <vector>
21#include <fmt/format.h>
22#include "Framework/Task.h"
24#include "Framework/Logger.h"
27#include "Headers/DataHeader.h"
29#include "CCDB/CcdbApi.h"
35
36using namespace o2::framework;
38using namespace o2::tpc;
39
40namespace o2::tpc
41{
42
44{
45 public:
46 TPCFactorizeSACSpec(const unsigned int timeframes, const SACFactorization::SACDeltaCompression compression, const bool debug, const int lane) : mSACFactorization{timeframes}, mCompressionDeltaSAC{compression}, mDebug{debug}, mLaneId{lane} {};
47
49 {
50 int countStacks = 0;
51 mCCDBTimeStamp = pc.inputs().get<uint64_t>("sacccdb");
52 for (auto& ref : InputRecordWalker(pc.inputs(), mFilter)) {
53 auto const* tpcStackHeader = o2::framework::DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
54 const int stack = tpcStackHeader->subSpecification;
55 mSACFactorization.setSACs(pc.inputs().get<std::vector<int32_t>>(ref), stack);
56 ++countStacks;
57 }
58
59 if (countStacks != GEMSTACKS) {
60 LOGP(warning, "Received only {} out of {}", countStacks, GEMSTACKS);
61 }
62
63 mSACFactorization.factorizeSACs();
64
65 if (mDebug) {
66 LOGP(info, "dumping aggregated and factorized SACs to file");
67 const auto currTF = processing_helpers::getCurrentTF(pc);
68 mSACFactorization.dumpToFile(fmt::format("SACFactorized_{:02}.root", currTF).data());
69 }
70
71 // storing to CCDB
72 sendOutput(pc.outputs());
73 }
74
76 {
77 ec.services().get<ControlService>().readyToQuit(QuitRequest::Me);
78 }
79
83
84 // for CCDB
85 static constexpr header::DataDescription getDataDescriptionCCDBSAC() { return header::DataDescription{"TPC_CalibSAC"}; }
86
87 private:
88 SACFactorization mSACFactorization;
89 const SACFactorization::SACDeltaCompression mCompressionDeltaSAC{};
90 const bool mDebug{false};
91 const int mLaneId{0};
92 uint64_t mCCDBTimeStamp{0};
93 const std::vector<InputSpec> mFilter = {{"sac", ConcreteDataTypeMatcher{gDataOriginTPC, TPCDistributeSACSpec::getDataDescriptionSACVec(mLaneId)}, Lifetime::Sporadic}};
94
95 void sendOutput(DataAllocator& output)
96 {
97 const uint64_t timeStampStart = mCCDBTimeStamp;
98 const uint64_t timeStampEnd = timeStampStart + o2::ccdb::CcdbObjectInfo::DAY;
99
100 // do check if received data is empty
101 if (timeStampStart != 0) {
104 output.snapshot(Output{gDataOriginTPC, getDataDescriptionTimeStamp()}, std::vector<uint64_t>{timeStampStart, timeStampEnd});
105 output.snapshot(Output{gDataOriginTPC, getDataDescriptionLane()}, mLaneId);
106
107 o2::ccdb::CcdbObjectInfo ccdbInfoSAC(CDBTypeMap.at(CDBType::CalSAC), std::string{}, std::string{}, std::map<std::string, std::string>{}, timeStampStart, timeStampEnd);
108
109 std::unique_ptr<std::vector<char>> imageSACDelta{};
110 switch (mCompressionDeltaSAC) {
111 case SACFactorization::SACDeltaCompression::MEDIUM:
112 default: {
113 SAC<unsigned short> sacContainer{mSACFactorization.getSACZero(), mSACFactorization.getSACOne(), mSACFactorization.getSACDeltaMediumCompressed()};
114 imageSACDelta = o2::ccdb::CcdbApi::createObjectImage(&sacContainer, &ccdbInfoSAC);
115 break;
116 }
117 case SACFactorization::SACDeltaCompression::HIGH: {
118 SAC<unsigned char> sacContainer{mSACFactorization.getSACZero(), mSACFactorization.getSACOne(), mSACFactorization.getSACDeltaHighCompressed()};
119 imageSACDelta = o2::ccdb::CcdbApi::createObjectImage(&sacContainer, &ccdbInfoSAC);
120 break;
121 }
122 case SACFactorization::SACDeltaCompression::NO:
123 SAC<float> sacContainer{mSACFactorization.getSACZero(), mSACFactorization.getSACOne(), std::move(mSACFactorization).getSACDeltaUncompressed()};
124 imageSACDelta = o2::ccdb::CcdbApi::createObjectImage(&sacContainer, &ccdbInfoSAC);
125 break;
126 }
127
128 LOGP(info, "Sending object {} / {} of size {} bytes, valid for {} : {} ", ccdbInfoSAC.getPath(), ccdbInfoSAC.getFileName(), imageSACDelta->size(), ccdbInfoSAC.getStartValidityTimestamp(), ccdbInfoSAC.getEndValidityTimestamp());
131 } else {
132 LOGP(warning, "Received empty data for SACs! SACs will not be stored for the current aggregation interval!");
133 }
134
135 mSACFactorization.reset();
136 }
137};
138
139DataProcessorSpec getTPCFactorizeSACSpec(const int lane, const unsigned int timeframes, const SACFactorization::SACFactorization::SACDeltaCompression compression, const bool debug)
140{
141 std::vector<OutputSpec> outputSpecs;
144
145 outputSpecs.emplace_back(ConcreteDataMatcher{gDataOriginTPC, TPCFactorizeSACSpec::getDataDescriptionSAC1(), header::DataHeader::SubSpecificationType{Side::A}}, Lifetime::Sporadic);
146 outputSpecs.emplace_back(ConcreteDataMatcher{gDataOriginTPC, TPCFactorizeSACSpec::getDataDescriptionSAC1(), header::DataHeader::SubSpecificationType{Side::C}}, Lifetime::Sporadic);
147 outputSpecs.emplace_back(ConcreteDataMatcher{gDataOriginTPC, TPCFactorizeSACSpec::getDataDescriptionTimeStamp(), header::DataHeader::SubSpecificationType{0}}, Lifetime::Sporadic);
148 outputSpecs.emplace_back(ConcreteDataMatcher{gDataOriginTPC, TPCFactorizeSACSpec::getDataDescriptionLane(), header::DataHeader::SubSpecificationType{0}}, Lifetime::Sporadic);
149
150 std::vector<InputSpec> inputSpecs;
151 inputSpecs.emplace_back(InputSpec{"sac", ConcreteDataTypeMatcher{gDataOriginTPC, TPCDistributeSACSpec::getDataDescriptionSACVec(lane)}, Lifetime::Sporadic});
152 inputSpecs.emplace_back(InputSpec{"sacccdb", ConcreteDataTypeMatcher{gDataOriginTPC, TPCDistributeSACSpec::getDataDescriptionSACCCDB()}, Lifetime::Sporadic});
153
155 fmt::format("tpc-factorize-sac-{:02}", lane).data(),
156 inputSpecs,
157 outputSpecs,
158 AlgorithmSpec{adaptFromTask<TPCFactorizeSACSpec>(timeframes, compression, debug, lane)}};
159 spec.rank = lane;
160 return spec;
161}
162
163} // namespace o2::tpc
164
165#endif
Simple interface to the CDB manager.
Utils and constants for calibration and related workflows.
std::ostringstream debug
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
A helper class to iteratate over all parts of all input routes.
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
uint32_t stack
Definition RawData.h:1
TPC factorization of SACs.
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
Definition CcdbApi.h:109
static constexpr long DAY
A helper class to iteratate over all parts of all input routes.
const std::vector< float > & getSACZero(const o2::tpc::Side side) const
void reset()
resetting aggregated SACs
void setSACs(std::vector< int32_t > &&SACs, const unsigned int stack)
auto getSACDeltaMediumCompressed() const
const std::vector< float > & getSACOne(const o2::tpc::Side side) const
void dumpToFile(const char *outFileName="SACFactorized.root", const char *outName="SACFactorized") const
static header::DataDescription getDataDescriptionSACVec(const int lane)
return data description for aggregated SACs for given lane
static constexpr header::DataDescription getDataDescriptionSACCCDB()
static constexpr header::DataDescription getDataDescriptionSAC1()
static constexpr header::DataDescription getDataDescriptionLane()
static constexpr header::DataDescription getDataDescriptionTimeStamp()
static constexpr header::DataDescription getDataDescriptionCCDBSAC()
TPCFactorizeSACSpec(const unsigned int timeframes, const SACFactorization::SACDeltaCompression compression, const bool debug, const int lane)
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void run(o2::framework::ProcessingContext &pc) final
GLint ref
Definition glcorearb.h:291
constexpr o2::header::DataOrigin gDataOriginTPC
Definition DataHeader.h:579
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
uint32_t getCurrentTF(o2::framework::ProcessingContext &pc)
Global TPC definitions and constants.
DataProcessorSpec getTPCFactorizeSACSpec(const int lane, const unsigned int timeframes, const SACFactorization::SACFactorization::SACDeltaCompression compression, const bool debug)
const std::unordered_map< CDBType, const std::string > CDBTypeMap
Storage name in CCDB for each calibration and parameter type.
Definition CDBTypes.h:98
@ A
Definition Defs.h:37
@ C
Definition Defs.h:38
IDCDeltaCompression
IDC Delta IDC Compression types.
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
Definition Utils.h:44
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
Definition Utils.h:43
container to be written to CCDB