ATLAS Offline Software
Loading...
Searching...
No Matches
LArBadChanBlobUtils Namespace Reference

Typedefs

typedef std::pair< HWIdentifier, LArBadChannelBadChanEntry
typedef std::pair< HWIdentifier, LArBadFebBadFebEntry
typedef std::vector< BadChanEntryBadChanVec
typedef std::vector< BadFebEntryBadFebVec
typedef Identifier32::value_type Channel

Enumerations

enum  Endianness { LittleEndian , BigEndian }

Functions

int machineEndianness ()
template<class T>
void fillBlob (const std::vector< std::pair< HWIdentifier, T > > &vec, coral::Blob &blob)
 Creates a BLOB of the right size and copies the content of the vector of pair<HWIdentifier, LArBadChannel> into the blob.
void fillFebBlobV1 (const std::vector< HWIdentifier > &vec, coral::Blob &blob)
template<class T>
std::vector< std::pair< HWIdentifier, T > > decodeBlob (const coral::Blob *blobp, std::size_t chanSize, std::size_t stateSize, int endian, int version, MsgStream &log)
 Checks BLOB for differences in endian-ness and size of data types with respect to the architecture on which the code is executed and if the checks paass decodes the BLOB data into a vector of pair<HWIdentifier, LArBadChannel>.
std::vector< HWIdentifierdecodeFebBlobV1 (const coral::Blob *blobp, std::size_t chanSize, int endian, int version, MsgStream &log)
bool checkBlob (const coral::Blob *blobp, std::size_t chanSize, std::size_t stateSizeInBlob, int endian, int, std::size_t step, std::size_t currentStateSize, MsgStream &log)

Typedef Documentation

◆ BadChanEntry

Definition at line 20 of file LArBadChanBlobUtils.h.

◆ BadChanVec

Definition at line 22 of file LArBadChanBlobUtils.h.

◆ BadFebEntry

Definition at line 21 of file LArBadChanBlobUtils.h.

◆ BadFebVec

Definition at line 23 of file LArBadChanBlobUtils.h.

◆ Channel

Enumeration Type Documentation

◆ Endianness

Enumerator
LittleEndian 
BigEndian 

Definition at line 26 of file LArBadChanBlobUtils.h.

Function Documentation

◆ checkBlob()

bool LArBadChanBlobUtils::checkBlob ( const coral::Blob * blobp,
std::size_t chanSize,
std::size_t stateSizeInBlob,
int endian,
int ,
std::size_t step,
std::size_t currentStateSize,
MsgStream & log )

Definition at line 30 of file LArBadChanBlobUtils.cxx.

38 {
39 if ( endian != machineEndianness()) {
40 log << MSG::ERROR << "BLOB endian-ness and computer endian-ness differ."
41 << " This version cannot decode such BLOBs" << endmsg;
42 return false;
43 }
44 if ( chanSize != sizeof( Channel)) {
45 log << MSG::ERROR << "The word size for HWidentifier in the BLOB ("
46 << chanSize << ") diifers from the HWIdentifier::value_type size "
47 << sizeof( Channel) << endmsg;
48 log << MSG::ERROR << "This version cannot decode such BLOBs" << endmsg;
49 return false;
50 }
51 if ( stateSizeInBlob != 0 && stateSizeInBlob != currentStateSize) {
52 log << MSG::ERROR << "The word size for LArBadChannel or LArBadFeb in the BLOB ("
53 << stateSizeInBlob << ") diifers from the runtime BitWord size "
54 << currentStateSize << endmsg;
55 log << MSG::ERROR << "This version cannot decode such BLOBs" << endmsg;
56 return false;
57 }
58
59 if (blobp->size() % step != 0) {
60 log << MSG::ERROR << "BLOB size (" << blobp->size()
61 << ") is not an exact multiple of content size "
62 << step << endmsg;
63 log << MSG::ERROR << "The BLOB is probably corrupted." << endmsg;
64 return false;
65 }
66
67 // FIXME: add version check
68
69 return true;
70 }
#define endmsg
Identifier32::value_type Channel

◆ decodeBlob()

template<class T>
std::vector< std::pair< HWIdentifier, T > > LArBadChanBlobUtils::decodeBlob ( const coral::Blob * blobp,
std::size_t chanSize,
std::size_t stateSize,
int endian,
int version,
MsgStream & log )

Checks BLOB for differences in endian-ness and size of data types with respect to the architecture on which the code is executed and if the checks paass decodes the BLOB data into a vector of pair<HWIdentifier, LArBadChannel>.

If the checks fail returns an empty vector, and writes diagnostics on the MsgStream passed as an argument. The arguments chanSize, stateSize and endian must come from the database that provides the BLOB, and must be filled by the machine that created the BLOB.

◆ decodeFebBlobV1()

std::vector< HWIdentifier > LArBadChanBlobUtils::decodeFebBlobV1 ( const coral::Blob * blobp,
std::size_t chanSize,
int endian,
int version,
MsgStream & log )

Definition at line 72 of file LArBadChanBlobUtils.cxx.

77 {
78 std::vector<HWIdentifier> result;
79 std::size_t step;
80 if (version == 1) step = sizeof( Channel) ;
81 else step = sizeof( Channel) + sizeof( LArBadFeb::BitWord);
82
83 if (!checkBlob( blobp, chanSize, 0, endian, version, step, 0, log)) {
84 return result;
85 }
86 std::size_t vecSize = blobp->size() / step;
87 result.reserve( vecSize);
88 const void* adr = blobp->startingAddress();
89 for (std::size_t i=0; i< vecSize; i++) {
90 const Channel* ch = static_cast<const Channel*>( adr);
91 adr = static_cast<const void*>(ch+1);
92 result.emplace_back(Identifier32(*ch));
93 }
94 return result;
95 }
unsigned int BitWord
bool checkBlob(const coral::Blob *blobp, std::size_t chanSize, std::size_t stateSizeInBlob, int endian, int, std::size_t step, std::size_t currentStateSize, MsgStream &log)

◆ fillBlob()

template<class T>
void LArBadChanBlobUtils::fillBlob ( const std::vector< std::pair< HWIdentifier, T > > & vec,
coral::Blob & blob )

Creates a BLOB of the right size and copies the content of the vector of pair<HWIdentifier, LArBadChannel> into the blob.

Returns a pointer to the new blob, which has to be managed (and eventually released) by the caller

◆ fillFebBlobV1()

void LArBadChanBlobUtils::fillFebBlobV1 ( const std::vector< HWIdentifier > & vec,
coral::Blob & blob )

Definition at line 17 of file LArBadChanBlobUtils.cxx.

18 {
19 std::size_t nbytes = vec.size() * sizeof( Channel);
20 blob.resize(nbytes);
21 void* adr = blob.startingAddress();
22 for ( std::vector<HWIdentifier>::const_iterator i=vec.begin();
23 i != vec.end(); ++i) {
24 Channel* ch = static_cast<Channel*>( adr);
25 *ch = i->get_identifier32().get_compact(); // assign channel
26 adr = static_cast<void*>(ch+1); // points just after channel
27 }
28 }
std::vector< size_t > vec

◆ machineEndianness()

int LArBadChanBlobUtils::machineEndianness ( )

Definition at line 9 of file LArBadChanBlobUtils.cxx.

10 {
11 int i = 1;
12 char *p = reinterpret_cast<char *>(&i);
13 if (p[0] == 1) return LittleEndian; // Lowest address contains the least significant byte
14 else return BigEndian;
15 }