Skip to content

Commit

Permalink
Merge pull request #41633 from missirol/devel_l1tMenuFirmwareUUIDHashed
Browse files Browse the repository at this point in the history
add utility returning hashed version of firmware-uuid of a L1T menu
  • Loading branch information
cmsbuild authored May 15, 2023
2 parents a1e01af + afbd0d9 commit e2d3811
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CondTools/L1Trigger/bin/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<bin name="l1tHashMenuFirmwareUUID" file="l1tHashMenuFirmwareUUID.cpp">
<use name="CondFormats/L1TObjects"/>
</bin>
50 changes: 50 additions & 0 deletions CondTools/L1Trigger/bin/l1tHashMenuFirmwareUUID.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <iostream>
#include <string>

#include "CondFormats/L1TObjects/interface/L1TUtmTriggerMenu.h"

void showHelpMessage() {
std::cout << "---------------------------------------------------------------\n";
std::cout << "=== l1tHashMenuFirmwareUUID ===\n";
std::cout << "=== compute 32-bit hashed version of L1T-menu firmware UUID ===\n";
std::cout << "---------------------------------------------------------------\n";
std::cout << "\n"
<< "Purpose:\n"
<< " return 32-bit hashed version (type: int) of the firmware-UUID of a L1T menu\n\n"
<< "Input:\n"
<< " firmware-UUID of a L1T menu, i.e. value of the field \"uuid-firmware\""
<< " in the .xml file containing the L1T menu;\n"
<< " given a database payload XYZ, the .xml file can be obtained via \"conddb dump XYZ > tmp.xml\"\n"
<< " (if \"-h\" or \"--help\" are specified, this help message is shown)\n\n"
<< "Exit code:\n"
<< " 1 if no command-line arguments are specified, 0 otherwise\n\n"
<< "Example:\n"
<< " > l1tHashMenuFirmwareUUID 7a1a9c0b-5e34-4c25-804f-2ae8094c4832\n\n";
}

int main(int argc, char** argv) {
if (argc < 2) {
std::cerr << "ERROR: no L1T-menu firmware UUID specified (hint: specify --help for more info).\n";
return 1;
} else {
for (int idx = 1; idx < argc; ++idx) {
std::string const argv_i = argv[idx];
if (argv_i == "-h" or argv_i == "--help") {
showHelpMessage();
return 0;
}
}

if (argc > 2) {
std::cerr << "WARNING: specified " << argc - 1 << " command-line arguments,"
<< " but only the first one will be used (" << argv[1] << ").\n";
}
}

L1TUtmTriggerMenu foo;
foo.setFirmwareUuid(argv[1]);

std::cout << int(foo.getFirmwareUuidHashed()) << std::endl;

return 0;
}

0 comments on commit e2d3811

Please sign in to comment.