25 printBits(
unsigned char c)
28 for (
int i = 7;
i >= 0; --
i) {
29 int bit = ((c >>
i) & 1);
30 std::cout <<
" " << bit;
35 packIntoString(std::vector<unsigned char>
const& source,
36 std::vector<unsigned char>& package)
38 unsigned int const packInOneByte{4};
40 std::size_t
const sizeOfPackage{
41 source.empty() ? 0u : 1u + ((source.size() - 1) / packInOneByte)};
42 package.resize(sizeOfPackage);
43 memset(&package[0], 0x00, sizeOfPackage);
44 for (
unsigned int i = 0;
i != source.size(); ++
i) {
45 unsigned int whichByte =
i / packInOneByte;
46 unsigned int indexWithinByte =
i % packInOneByte;
48 package[whichByte] | (source[
i] << (indexWithinByte * 2));
52 std::cout << std::endl;
83 void endJob()
override;
86 std::vector<unsigned char> hltbits_{};
105 Event const ev{ep, mc};
129 <<
"\narttest::TestBitsOutput::write\n" 130 <<
"Expected there to be no TriggerResults object but we found one" 139 assert(prod.provenance()->parents().empty());
140 std::vector<unsigned char> vHltState;
143 std::vector<std::string>
const& hlts =
145 unsigned int hltSize = hlts.size();
146 for (
unsigned int i = 0;
i != hltSize; ++
i) {
147 vHltState.push_back(prod->at(
i).state());
150 packIntoString(vHltState,
hltbits_);
151 std::cout <<
"Size of hltbits:" <<
hltbits_.size() << std::endl;
152 auto intp =
reinterpret_cast<char*
>(&
bitMask_);
155 std::cout << std::endl <<
"Current Bits Mask byte:";
157 auto tmp =
static_cast<unsigned char>(*(intp +
i));
158 std::cout << std::endl <<
"Original Byte:";
160 std::cout << std::endl;
166 if (!matched && hltSize > 0) {
167 std::cerr <<
"\ncfg bitMask is different from event..aborting." 171 std::cout <<
"\nSUCCESS: Found Matching Bits" << std::endl;
void write(art::EventPrincipal &e) override
void writeSubRun(art::SubRunPrincipal &) override
art::ModuleDescription moduleDescription_
Handle< TriggerResults > getTriggerResults(Event const &e) const
auto const & get_PSet() const
bool expectTriggerResults_
#define DEFINE_ART_MODULE(klass)
TestBitsOutput(Parameters const &)
fhicl::TableFragment< art::OutputModule::Config > omConfig
void writeRun(art::RunPrincipal &) override
static Globals * instance()
std::vector< unsigned char > hltbits_
std::vector< std::string > const & triggerPathNames() const
cet::coded_exception< error, detail::translate > exception