ATLAS Offline Software
TrigPassBitsCnv_p1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <cmath>
7 #include <iostream>
10 
11 
12 
13 void store_bits(const std::vector<bool>& bits, std::vector<uint32_t>& store ){
14  const unsigned word_count = store.size();
15  const unsigned bits_count = bits.size();
16 
17  for ( unsigned word = 0; word < word_count; ++word) {
18  uint32_t& temp(store[word]);
19 
20  for ( unsigned bit = 0; bit < 32; ++bit) {
21  const unsigned position = word*32+bit;
22  if (position >= bits_count )
23  return;
24  if (bits[position])
25  temp |= (1 << bit);
26  }
27  }
28 }
29 
30 void restore_bits(std::vector<bool>& bits, const std::vector<uint32_t>& store) {
31  const unsigned word_count = store.size();
32  const unsigned bits_count = bits.size();
33 
34 
35  for ( unsigned word = 0; word < word_count; ++word) {
36  const uint32_t& temp(store[word]);
37 
38  for ( unsigned bit = 0; bit < 32; ++bit) {
39  const unsigned position = word*32+bit;
40  if (position >= bits_count )
41  return;
42 
43  if (temp & (1 << bit))
44  bits[position] = true;
45  else
46  bits[position] = false;
47  }
48  }
49 }
50 
51 
52 unsigned necessary_words(unsigned size) {
53  return (size ? 1 : 0) + size/32;
54 }
55 
56 
57 
59  TrigPassBits* transObj,
60  MsgStream &log)
61 {
62  log << MSG::DEBUG << "TrigPassBitsCnv_p1::persToTrans called " << endmsg;
63 
64  transObj->m_decisions.resize(persObj->m_size, false); // reserve space and set defaults to 0
65 
66  restore_bits(transObj->m_decisions, persObj->m_serialized); // get back the bits
67 
68 }
69 
70 
72  TrigPassBits_p1* persObj,
73  MsgStream &log)
74 {
75  log << MSG::DEBUG << "TrigPassBitsCnv_p1::transToPers called " << endmsg;
76  persObj->m_size = transObj->m_decisions.size();
77 
78  persObj->m_serialized.resize(necessary_words(persObj->m_size), 0); // reserve the space and set the content to 0
79 
80  store_bits(transObj->m_decisions, persObj->m_serialized); // pack the bits
81 }
SGTest::store
TestStore store
Definition: TestStore.cxx:23
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
restore_bits
void restore_bits(std::vector< bool > &bits, const std::vector< uint32_t > &store)
Definition: TrigPassBitsCnv_p1.cxx:30
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TrigPassBits_p1
Definition: TrigPassBits_p1.h:21
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TrigPassBits_p1::m_size
unsigned int m_size
Definition: TrigPassBits_p1.h:38
TrigPassBits_p1::m_serialized
std::vector< uint32_t > m_serialized
Definition: TrigPassBits_p1.h:39
TrigPassBits_p1.h
necessary_words
unsigned necessary_words(unsigned size)
Definition: TrigPassBitsCnv_p1.cxx:52
TrigPassBits
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/TrigPassBits.h:17
TrigPassBitsCnv_p1.h
store_bits
void store_bits(const std::vector< bool > &bits, std::vector< uint32_t > &store)
Definition: TrigPassBitsCnv_p1.cxx:13
TrigPassBits::m_decisions
std::vector< bool > m_decisions
trainsient bits storage (STL docu assures that this is efficient)
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/TrigPassBits.h:49
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TrigPassBits.h
TrigPassBitsCnv_p1::transToPers
virtual void transToPers(const TrigPassBits *transObj, TrigPassBits_p1 *persObj, MsgStream &log)
Definition: TrigPassBitsCnv_p1.cxx:71
TrigPassBitsCnv_p1::persToTrans
virtual void persToTrans(const TrigPassBits_p1 *persObj, TrigPassBits *transObj, MsgStream &log)
Definition: TrigPassBitsCnv_p1.cxx:58