18#include "CoralBase/Blob.h"
19#include "CoolKernel/IObject.h"
31const unsigned int TOTAL_LHC_BCIDS = 3564;
46 return StatusCode::SUCCESS;
60 const std::vector<unsigned int>& luminousBunches,
62 std::vector<float>& rawLumiOut)
const
67 const uint8_t*
ATH_RESTRICT pchar =
static_cast<const uint8_t*
>(blob.startingAddress());
68 unsigned int bss = ((*pchar) % 100) / 10;
69 unsigned int smod = ((*pchar) % 10);
71 ATH_MSG_DEBUG(
"BunchRawInstLumi blob found with storage mode " << smod <<
" and byte storage size " << bss );
74 unsigned int bloblength = 0;
75 unsigned int nbcids = 0;
85 if (luminousBunches.empty()) {
87 return StatusCode::SUCCESS;
90 nbcids = luminousBunches.size();
91 bloblength = bss * nbcids + 1;
96 nbcids = TOTAL_LHC_BCIDS;
97 bloblength = bss * nbcids + 1;
104 bloblength = (2+bss)*nbcids + 3;
110 ATH_MSG_ERROR(
"BunchRawInstLumi blob found with unknown storage mode " << smod <<
"!" );
111 return StatusCode::FAILURE;
115 if (
static_cast<cool::UInt32
>(blob.size()) != bloblength) {
116 ATH_MSG_ERROR(
"BunchRawInstLumi blob found with length " << blob.size() <<
117 " in storage mode " << smod <<
" with size " << bss <<
118 ", expecting " << bloblength <<
"!" );
119 return StatusCode::FAILURE;
124 std::vector<float> rawLumi;
126 rawLumi.reserve (nbcids);
133 float scale = avgRawLumi / 100;
134 for (
unsigned int i=0; i<nbcids; i++) {
135 float val = (*pchar++) * scale;
136 rawLumi.push_back(val);
142 float scale = avgRawLumi / (100*100);
143 for (
unsigned int i=0; i<nbcids; i++) {
145 rawLumi.push_back(val);
151 for (
unsigned int i=0; i<nbcids; i++) {
157 for (
unsigned int i=0; i<nbcids; i++) {
163 ATH_MSG_ERROR(
"BunchRawInstLumi blob found with unknown byte storage size " << bss <<
"!" );
164 return StatusCode::FAILURE;
175 rawLumiOut.resize (TOTAL_LHC_BCIDS, 0);
176 for (
unsigned int i=0; i<nbcids; i++)
177 rawLumiOut[luminousBunches[i]] = rawLumi[i];
182 rawLumiOut = std::move (rawLumi);
187 rawLumiOut.resize (TOTAL_LHC_BCIDS, 0);
188 for (
unsigned int i=0; i<nbcids; i++) {
198 return StatusCode::SUCCESS;
210 auto lumis = std::make_unique<BunchLumisCondData>();
217 std::vector<unsigned int> luminousBunches;
221 luminousBunches = fillParams->luminousBunches();
222 EventIDRange fpRange;
224 range = EventIDRange::intersect (range, fpRange);
227 for (
const auto& p : *bunchLumisFolder.
retrieve()) {
228 unsigned int channel = p.first;
229 const coral::AttributeList& attrList = p.second;
231 if (attrList[
"BunchRawInstLum"].isNull()) {
232 ATH_MSG_ERROR(
"BunchRawInstLum blob not found for channel " << channel <<
"!" );
233 return StatusCode::FAILURE;
236 const coral::Blob& blob = attrList[
"BunchRawInstLum"].data<coral::Blob>();
237 if (blob.size() == 0) {
238 ATH_MSG_DEBUG(
"BunchRawInstLumi blob found with zero size for channel " << channel <<
"!" );
243 if (attrList[
"AverageRawInstLum"].isNull()) {
244 ATH_MSG_ERROR(
"AverageRawInstLum value not found for channel " << channel <<
"!" );
245 return StatusCode::FAILURE;
247 float avgRawLumi = attrList[
"AverageRawInstLum"].data<cool::Float>();
249 std::vector<float> rawLumis;
251 lumis->addChannel (channel, std::move (rawLumis));
257 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
Conditions algorithm to unpack raw luminosity data from COOL.
Helper to enable (more agressive) auto-vectorization.
#define ATH_ENABLE_TREE_VECTORIZATION
SG::ReadCondHandleKey< FillParamsCondData > m_fillParamsInputKey
Fill parameters needed for storage mode 0.
SG::WriteCondHandleKey< BunchLumisCondData > m_bunchLumisOutputKey
Output conditions object.
SG::ReadCondHandleKey< CondAttrListCollection > m_bunchLumisFolderInputKey
Input conditions object.
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm execute method.
virtual StatusCode initialize() override
Gaudi initialize method.
StatusCode unpackLumis(const coral::Blob &blob, const std::vector< unsigned int > &luminousBunches, float avgRawLumi, std::vector< float > &rawLumiOut) const
Unpack raw luminosity data for one channel.
const_pointer_type retrieve()
bool range(EventIDRange &r)
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Read little-endian values through possibly unaligned pointers.
double get_unaligned_double(const uint8_t *ATH_RESTRICT &p)
Read a little-endian double value from a possibly unaligned pointer.
uint16_t get_unaligned16(const uint8_t *ATH_RESTRICT &p)
Read a 2-byte little-endian value from a possibly unaligned pointer.
float get_unaligned_float(const uint8_t *ATH_RESTRICT &p)
Read a little-endian float value from a possibly unaligned pointer.
Macro wrapping the nonstandard restrict keyword.