91 mod_ids.push_back((*map_it).first);
96 std::vector<unsigned int> mod_ids;
99 mod_ids.push_back((*map_it).first);
137 bool serialize_indivisible(uint32_t* output,
139 const std::vector<uint32_t>& indivisible,
140 unsigned int umax_size,
144 auto size_indivisible = indivisible.size();
145 auto size_needed = data_size + size_indivisible + (first ? 0 : 1);
150 if(truncating && size_needed > umax_size)
154 output[data_size++] = size_indivisible;
156 std::copy(std::begin(indivisible),
157 std::end(indivisible),
159 data_size += size_indivisible;
172 void serialize_collections(uint32_t * output,
174 const std::vector<uint32_t>& nav,
175 const std::vector<std::pair<unsigned, unsigned>>& boundaries)
177 const auto nav_begin = std::begin(nav);
178 for(
const auto& bpair : boundaries)
180 assert(bpair.first < nav.size());
181 assert(bpair.second >= bpair.first);
182 assert(bpair.second <= nav.size());
184 std::copy(nav_begin + bpair.first,
185 nav_begin + bpair.second,
187 data_size += bpair.second - bpair.first;
196 find_cuts(
const std::set<std::pair<CLID, std::string>>& collections,
197 const std::vector<std::pair<CLID, std::string>>& idname_include,
198 const std::vector<std::pair<CLID, std::string>>& idname_exclude,
199 std::vector<unsigned int> cuts,
200 std::vector<std::pair<unsigned int, unsigned int>>& out)
202 for(
const auto& coll : collections)
204 if(std::find(std::begin(idname_exclude),
205 std::end(idname_exclude),
206 coll) == std::end(idname_exclude))
208 auto it = std::find(std::begin(idname_include),
209 std::end(idname_include),
211 if(it != std::end(idname_include))
213 auto pos = std::distance(std::begin(idname_include), it);
214 out.emplace_back(
cuts.at(pos + 1),
226 unsigned add_collection_to_size(
unsigned current_size,
227 const std::pair<unsigned, unsigned>& pair)
229 return current_size + pair.second - pair.first;
237 calc_colls_size(
const std::vector<std::pair<unsigned, unsigned>>& boundaries)
239 return std::accumulate(std::begin(boundaries), std::end(boundaries), 0,
240 add_collection_to_size);
255 const auto& collections = modid_coll_it->second;
256 find_cuts(collections,
261 find_cuts(collections,
268 return std::make_pair(cuts_dsonly, cuts_reg);
274 static constexpr auto num_size_words = 3u;
280 unsigned int umax_size,
281 bool truncating)
const
283 auto calc_size_needed = [data_size](
unsigned int nav_size)
284 {
return nav_size + data_size + 1; };
287 auto is_within_size = [umax_size, &calc_size_needed](
unsigned int cut)
288 {
return calc_size_needed(cut) <= umax_size; };
292 if(
static_cast<unsigned int>(data_size) < umax_size)
295 auto cut_nav_size = tot_nav_size;
298 if(truncating && calc_size_needed(tot_nav_size) > umax_size)
304 endnav -= tot_nav_size - cut_nav_size;
311 output[data_size++] = cut_nav_size;
313 data_size += cut_nav_size;
324 unsigned int umax_size,
325 unsigned int nav_size,
327 bool truncating)
const
329 if(nav_size + data_size < umax_size)
331 output[data_size++] = nav_size;
332 auto index_for_size_in_nav_preamble = data_size + 1;
338 output[index_for_size_in_nav_preamble] = nav_size;
349 if(
static_cast<unsigned int>(data_size) < umax_size)
350 output[data_size++] = 0;
361 unsigned int estimated_size)
366 auto umax_size =
static_cast<unsigned int>(max_size);
367 output =
new uint32_t[std::min(umax_size, estimated_size)];
369 truncating = max_size >= 0 && estimated_size > umax_size;
373 return serialize_indivisible(output, data_size,
m_headerResult, umax_size,
380 unsigned int umax_size,
381 bool truncating)
const
383 return serialize_indivisible(output, data_size,
m_chainsResult, umax_size,
386 serialize_indivisible(output, data_size,
m_extras, umax_size,
392 unsigned int umax_size,
393 unsigned int nav_size,
395 bool truncating)
const
397 if(
static_cast<unsigned int>(data_size) < umax_size)
399 output[data_size++] = 0;
402 &&
static_cast<unsigned int>(data_size) < umax_size)
404 output[data_size++] = 0;
417 bool truncating{
false};
420 max_size, estim_size) &&
422 max_size, truncating);
432 bool truncating{
false};
434 auto navsize = calc_colls_size(dscuts.first) + calc_colls_size(dscuts.second);
449 const unsigned int mod_id)
451 uint32_t * aux =
nullptr;
454 auto ret =
serialize(aux, data_size, -1, mod_id);
455 auto uptr = std::unique_ptr<uint32_t[]>{aux};
457 output.reserve(data_size);
458 std::copy(aux, aux + data_size, std::back_inserter(output));
467 const unsigned int mod_id)
469 return mod_id ?
serialize_DS(output, data_size, max_size, mod_id)
489 if (data_size == 0 )
return false;
490 std::vector<uint32_t> rawResult(&source[0], &source[data_size]);
502 unsigned version = raw[0];
508 rawIndNumOfFixedBit = 12;
509 }
else if (version == 2 ) {
512 std::cerr <<
"HLTResult::unpackFromStorable has noticed a class version mismatch and does not know how to translate: raw data version " << raw[0] <<
" current class version " <<
m_HLTResultClassVersion << std::endl;
520 raw.begin()+rawIndNumOfFixedBit);
525 if ( raw.size() == rawIndNumOfFixedBit )
529 uint32_t offset = rawIndNumOfFixedBit;
530 uint32_t sizeOfChains = raw[offset];
533 uint32_t readEnd = offset + sizeOfChains;
534 bool truncation =
false;
536 if ( readEnd > raw.size() ){
537 readEnd = raw.size();
543 offset += sizeOfChains;
553 uint32_t sizeOfNavigation = raw[offset];
558 readEnd = offset + sizeOfNavigation;
559 if (readEnd > raw.size()) {
560 readEnd = raw.size();
565 if ( offset > readEnd )
569 raw.begin()+readEnd);
578 offset += sizeOfNavigation;
582 uint32_t sizeOfExtras = 0;
583 if (offset < raw.size()) {
584 sizeOfExtras = raw[offset++];
590 readEnd = offset + sizeOfExtras;
591 if (readEnd > raw.size()) {
592 readEnd = raw.size();
596 if ( offset > readEnd )
600 raw.begin()+readEnd);
618 std::vector<unsigned int> sizes;
HLT::HLTResult is sumarising result of trigger decision evaluation (online/offline) It contains basic...
void setCreatedOutsideHLT(bool created)
void setNumOfSatisfiedSigs(uint32_t sigs)
sget number of satisfied signatures
virtual uint32_t error_bits() const
bit flags to explain problems during processing
ErrorCode getLvlConverterStatus() const
overall hlt status: if StatusCode::isFailure(), event should be discarded from physics stream (and,...
HLTResult & operator=(HLTResult rhs)
unified assignement operator
std::vector< uint32_t > m_headerResult
the full payload, and sub-payloads
std::vector< std::pair< unsigned int, unsigned int > > CutPairs
std::vector< uint32_t > m_extras
extra storeage (which can be used to store some operational infos)
bool serialize_body_DS(uint32_t *output, int &data_size, unsigned int max_size, unsigned int nav_size, const CutPairVecs &dscuts, bool truncating) const
friend void swap(HLTResult &lhs, HLTResult &rhs)
void setLvl1Id(uint32_t id)
sets event number (Lvl1-id)
bool serialize(std::vector< uint32_t > &output, const unsigned int mod_id)
void setHLTLevel(HLTLevel hltLevel)
static unsigned int calc_total_size_DS(unsigned int ds_nav_size)
Calculate the size of a DS result, given the size of its navigation.
std::vector< unsigned int > listOfModIDs() const
return the rob module ID vector
uint32_t getConfigSuperMasterKey() const
gets the key of the menu which was used to trigger this event
bool serialize_bootstrap(uint32_t *&output, int &data_size, bool &truncating, int max_size, unsigned int estimated_size)
std::vector< std::pair< CLID, std::string > > m_id_name
void setConfigSuperMasterKey(uint32_t key)
sets the key of the menu which was used to trigger this event
void setHLTStatus(ErrorCode hltStatus)
std::map< unsigned int, std::set< std::pair< CLID, std::string > > > m_modID_id_name
std::vector< unsigned int > m_navigationResultCuts_DSonly
bool serialize_DS(uint32_t *&output, int &data_size, int max_size, unsigned int mod_id)
std::vector< std::pair< CLID, std::string > > m_id_name_DSonly
ErrorCode getHLTStatus() const
overall hlt status: if StatusCode::isFailure(), event should be discarded from physics stream (and,...
uint32_t getConfigPrescalesKey() const
gets the key of the prescales config which was used to trigger this event
unsigned int estimateSize() const
Estimate the size this HLTResult would ocuppy once serialized.
bool serialize_body_regular(uint32_t *output, int &data_size, unsigned int umax_size, bool truncating) const
virtual bool error() const
problems during processing
static const uint32_t m_HLTResultClassVersion
the version of this HLTResult class
std::vector< uint32_t > m_navigationResult
storage of navigation (serialized also)
HLTExtraData & getExtraData()
bool serialize_navigation_reg(uint32_t *output, int &data_size, unsigned int umax_size, bool truncating) const
bool isEmpty() const
true if result is empty
CutPairVecs findDSCuts(unsigned int) const
Find the pairs of cut points that mark the boundaries of DS collections for the given module id.
std::vector< uint32_t > m_navigationResult_DSonly
storage of navigation (serialized also) for DataScouting
bool serialize_regular(uint32_t *&output, int &data_size, int max_size)
HLTExtraData * m_extraData
object for m_extras deserialization (on demand)
unsigned int size() const
void setErrorCoordinates(unsigned int chainCounter=0, unsigned int step=0)
sets the information about the error, namely chain in which the error happened and the step
std::vector< unsigned int > partSizes() const
std::pair< CutPairs, CutPairs > CutPairVecs
bool serialize_navigation_DS(uint32_t *output, int &data_size, unsigned int umax_size, unsigned int nav_size, const CutPairVecs &dscuts, bool truncating) const
bool deserialize(const std::vector< uint32_t > &source)
GenericResult::deserialize( const std::vector<uint32_t>& source ).
std::vector< uint32_t > m_chainsResult
storege of serialized chains
@ IndHLTResultClassVersion
@ IndConfigPrescalesKey
configuration key for prescales
@ IndNumOfFixedBit
total number of fixed bits
@ IndConfigSuperMasterKey
configuration key for the menu
void setAccepted(bool acc)
sets HLT decision
bool isHLTResultTruncated() const
is serialized HLTResult truncated
void setLvlConverterStatus(ErrorCode status)
void setConfigPrescalesKey(uint32_t key)
sets the key of the prescales config which was used to trigger this event
void setHLTResultTruncated(bool truncated)
bool unpackFromStorable(const std::vector< uint32_t > &raw)
split the rawResult vector into rawPartialResult's
void setPassThrough(bool fa)
set passTrough flag
std::vector< unsigned int > m_navigationResultCuts
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
void swap(HLTExtraData &, HLTExtraData &)
static const ErrorCode FATAL(Action::ABORT_JOB, Reason::UNKNOWN)
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
@ ABORT_JOB
if things go really wrong, i.e.
@ CONTINUE
if all is OK the processing should be continued
@ ABORT_CHAIN
if things went wrong but it is not severe, other unrelated chains will continue
@ ABORT_EVENT
if things went wrong severely, event corruption suspected
@ NAV_ERROR
suspected Navigation error
@ TIMEOUT
the timeout occured
@ NO_LVL2_CHAINS
in the LVL2 result unpacked at EF no active LVL2 chains are present, that means no seeding informatio...
@ NO_LVL1_ITEMS
in the LVL1 result delivered to LVL2 none of LVL1 items are present, that means no seeding informatio...
@ WRONG_HLT_RESULT
error while unpacking HLT reult (happnes at EF when LVL2 result is unpacked)
@ NO_HLT_RESULT
no HLT result is present (means that LVL2 result was not delivered to EF)