Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add utility returning hashed version of firmware-uuid of a L1T menu #41633

Merged
merged 1 commit into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}