-
Notifications
You must be signed in to change notification settings - Fork 1
Jcampos/add channel status #49
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
Changes from 12 commits
a0acf33
3d703aa
751012a
426e4da
1a9855d
c7c75e2
019e9e7
3d33780
d0949d3
0cc0aaf
d6f48c9
7ef7f2e
39c4454
eb4ed03
cca443e
9fc9a2b
58f34f4
b0ccb32
cf9a6d9
c8fb0f0
31621c9
5dd8b4c
cd1036d
ec0e7a8
9297f32
ac0a29d
bd25651
a21a6cc
36a3f1d
921a82c
e9205ca
07ea18d
5cc0c5f
e941230
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| add_subdirectory(FEInterfaces) | ||
| add_subdirectory(Generators) | ||
| add_subdirectory(ArtModules) | ||
| add_subdirectory(TablePlugins) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,12 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| include(otsdaq::table) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cet_build_plugin(SubsystemCalorimeterParametersTable otsdaq::table LIBRARIES REG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| otsdaq::SlowControlsTableBase | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| otsdaq::XDAQContextTable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| include(otsdaq::table) | |
| cet_build_plugin(SubsystemCalorimeterParametersTable otsdaq::table LIBRARIES REG | |
| otsdaq::SlowControlsTableBase | |
| otsdaq::XDAQContextTable | |
| ) | |
| include(otsdaq::table) | |
| cet_build_plugin(SubsystemCalorimeterParametersTable otsdaq::table LIBRARIES REG | |
| otsdaq::SlowControlsTableBase | |
| otsdaq::XDAQContextTable | |
| ) |
Outdated
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line contains trailing whitespace, which may violate project coding standards. Consider removing it.
| include(otsdaq::table) | |
| cet_build_plugin(SubsystemCalorimeterParametersTable otsdaq::table LIBRARIES REG | |
| otsdaq::SlowControlsTableBase | |
| otsdaq::XDAQContextTable | |
| ) | |
| include(otsdaq::table) | |
| cet_build_plugin(SubsystemCalorimeterParametersTable otsdaq::table LIBRARIES REG | |
| otsdaq::SlowControlsTableBase | |
| otsdaq::XDAQContextTable | |
| ) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,71 @@ | ||||||
| #ifndef _ots_SubsystemCalorimeterParametersTable_h_ | ||||||
| #define _ots_SubsystemCalorimeterParametersTable_h_ | ||||||
|
|
||||||
| #include "otsdaq/ConfigurationInterface/ConfigurationManager.h" | ||||||
| #include "otsdaq/TableCore/TableBase.h" | ||||||
|
|
||||||
| namespace ots { | ||||||
| class SubsystemCalorimeterParametersTable : public TableBase { | ||||||
| // clang-format off | ||||||
|
|
||||||
| public: | ||||||
| SubsystemCalorimeterParametersTable (void); | ||||||
| virtual ~SubsystemCalorimeterParametersTable (void); | ||||||
|
|
||||||
| // Methods | ||||||
| void init (ConfigurationManager* configManager) override; | ||||||
|
|
||||||
| virtual std::string getStructureAsJSON (const ConfigurationManager* configManager) override; | ||||||
|
|
||||||
| virtual std::string getChannelMapAndCSVFormat (const ConfigurationManager* configManager, const std::string& OfflineCxxClassName); | ||||||
|
|
||||||
| virtual std::string getStatusTableInCSVFormat (const ConfigurationManager* configManager, const std::string& OfflineCxxClassName); | ||||||
|
|
||||||
| void generateOfflineTableMap (const ConfigurationManager* configManager); | ||||||
|
|
||||||
| void loadNominalChannelMap (); | ||||||
giro94 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| bool isFirstAppInContext_ = false; | ||||||
|
|
||||||
rrivera747 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| private: | ||||||
|
|
||||||
| const static std::string PATH_TO_TRIGGER_OFFLINE_DB; | ||||||
| const static std::string CHANNEL_STATUS_TABLE; | ||||||
| const static std::string CHANNEL_MAP_TABLE; | ||||||
| const static uint32_t CHANNELS_PER_BOARD = 20; | ||||||
|
||||||
|
|
||||||
| std::map<std::string, std::string> mapOfflineTables_; | ||||||
| std::map<uint16_t, uint16_t> mapChannels_; | ||||||
|
|
||||||
| // Column names | ||||||
| struct ColParameters // Calorimeter subsystem top level | ||||||
| { | ||||||
| // Incomplete list | ||||||
| std::string const colLinkToFETypeTable = "LinkToChannelStatusTableInfo"; | ||||||
| std::string const colLinkToSlowControlsChannelTable_ = "LinkToChannelThresholdTableInfo"; | ||||||
| } ColParameters; | ||||||
|
|
||||||
| struct ColChannelMap // LinkToChannelMapTableInfo | ||||||
| { | ||||||
| std::string const offlineId_ = "offID"; | ||||||
| std::string const onlineId_ = "FEEchan"; | ||||||
| } ColChannelMap; | ||||||
|
|
||||||
| struct ColChannelStatus // LinkToChannelStatusTableInfo | ||||||
| { | ||||||
| std::string const colBoardId_ = "BoardID"; | ||||||
| std::string const colStatus_ = "Status"; | ||||||
| } ColChannelStatus; | ||||||
|
|
||||||
| struct ColChannelThreshold // LinkToChannelThresholdTableInfo | ||||||
| { | ||||||
| std::string const colStatus_ = "BoardID"; | ||||||
|
||||||
| std::string const colStatus_ = "BoardID"; | |
| std::string const colStatus_ = "Status"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot change to colBoardId_ = "BoardID";
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| #include "otsdaq-mu2e-calorimeter/TablePlugins/SubsystemCalorimeterParametersTable.h" | ||
| #include "otsdaq/Macros/TablePluginMacros.h" //for DEFINE_OTS_TABLE | ||
|
|
||
| #include "otsdaq/TablePlugins/XDAQContextTable/XDAQContextTable.h" | ||
|
|
||
rrivera747 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #include <sys/stat.h> //for mkdir | ||
rrivera747 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #include <fstream> | ||
| #include <iostream> | ||
|
|
||
| using namespace ots; | ||
|
|
||
| const std::string SubsystemCalorimeterParametersTable::PATH_TO_TRIGGER_OFFLINE_DB = getenv("PATH_TO_TRIGGER_OFFLINE_DB") ? getenv("PATH_TO_TRIGGER_OFFLINE_DB") : ""; | ||
rrivera747 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const std::string SubsystemCalorimeterParametersTable::CHANNEL_MAP_TABLE = "SubsystemCalorimeterMapTable"; | ||
| const std::string SubsystemCalorimeterParametersTable::CHANNEL_STATUS_TABLE = "SubsystemCalorimeterStatusTable"; | ||
|
|
||
| //============================================================================== | ||
| SubsystemCalorimeterParametersTable::SubsystemCalorimeterParametersTable(void) : TableBase("SubsystemCalorimeterParametersTable") {} | ||
|
|
||
| //============================================================================== | ||
| SubsystemCalorimeterParametersTable::~SubsystemCalorimeterParametersTable(void) {} | ||
|
|
||
| //============================================================================== | ||
| /// init | ||
| /// generate calo specific files needed by the online trigger and save them in the filesystem 'offline' db | ||
| void SubsystemCalorimeterParametersTable::init(ConfigurationManager* configManager) { | ||
| // use isFirstAppInContext to only run once per context, for example to avoid | ||
| // generating files on local disk multiple times. | ||
| bool isFirstAppInContext_ = configManager->isOwnerFirstAppInContext(); | ||
|
|
||
| __COUTV__(isFirstAppInContext_); | ||
| if(!isFirstAppInContext_) | ||
| return; | ||
|
|
||
| __COUTV__(SubsystemCalorimeterParametersTable::PATH_TO_TRIGGER_OFFLINE_DB); | ||
| if(SubsystemCalorimeterParametersTable::PATH_TO_TRIGGER_OFFLINE_DB.size() == 0) | ||
| return; | ||
|
|
||
| __COUT__ << "*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << __E__; | ||
| __COUT__ << configManager->__SELF_NODE__ << __E__; | ||
|
|
||
| generateOfflineTableMap(configManager); | ||
|
|
||
| for(const auto& offlineTable : mapOfflineTables_) { | ||
| std::string offlineTableFileName = PATH_TO_TRIGGER_OFFLINE_DB + "/" + offlineTable.first + ".txt"; | ||
|
|
||
| try { | ||
| std::ofstream out(offlineTableFileName); | ||
| if(!out) { | ||
| __COUTT__ << "Failed to open file: " << offlineTableFileName; | ||
| return; | ||
rrivera747 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| out << offlineTable.second; | ||
| out.close(); | ||
| } catch(const std::exception& e) { | ||
| __COUT__ << "Failed to write offline table " << offlineTable.first << " to file."; | ||
| __COUT__ << e.what() << __E__; | ||
rrivera747 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| } // end init() | ||
|
|
||
| //============================================================================== | ||
| void SubsystemCalorimeterParametersTable::generateOfflineTableMap(const ConfigurationManager* configManager) { | ||
| mapOfflineTables_.clear(); | ||
| mapOfflineTables_["CalChannelMap"] = getChannelMapAndCSVFormat(configManager, "CalChannelMap"); | ||
| __COUTT__ << mapOfflineTables_["CalChannelMap"] << __E__; | ||
| mapOfflineTables_["CalChannelStatus"] = getStatusTableInCSVFormat(configManager, "CalChannelStatus"); | ||
| __COUTT__ << mapOfflineTables_["CalChannelStatus"] << __E__; | ||
| } // end generateOfflineTableMap() | ||
|
|
||
| //============================================================================== | ||
| std::string SubsystemCalorimeterParametersTable::getChannelMapAndCSVFormat(const ConfigurationManager* configManager, const std::string& OfflineCxxClassName) { | ||
| mapChannels_.clear(); | ||
|
|
||
| std::stringstream OfflineTable; | ||
| OfflineTable << "TABLE " << OfflineCxxClassName << __E__; | ||
| std::vector<std::pair<std::string, ConfigurationTree>> channelMapRecords = configManager->getNode(SubsystemCalorimeterParametersTable::CHANNEL_MAP_TABLE).getChildren(); | ||
|
|
||
| // start main fe/DTC record loop | ||
| for(auto& channelMapPair : channelMapRecords) { | ||
| uint16_t onlineID = channelMapPair.second.getNode(ColChannelMap.onlineId_).getValue<uint16_t>(); | ||
| uint16_t offlineID = channelMapPair.second.getNode(ColChannelMap.offlineId_).getValue<uint16_t>(); | ||
| mapChannels_[onlineID] = offlineID; | ||
|
|
||
| OfflineTable << onlineID << "," << offlineID << "\n"; | ||
| } | ||
| return OfflineTable.str(); | ||
| } // end getChannelMapAndCSVFormat() | ||
|
|
||
| //============================================================================== | ||
| std::string SubsystemCalorimeterParametersTable::getStatusTableInCSVFormat(const ConfigurationManager* configManager, const std::string& OfflineCxxClassName) { | ||
| std::stringstream OfflineTable; | ||
| OfflineTable << "TABLE " << OfflineCxxClassName << __E__; | ||
| std::vector<std::pair<std::string, ConfigurationTree>> channelStatusRecords = configManager->getNode(SubsystemCalorimeterParametersTable::CHANNEL_STATUS_TABLE).getChildren(); | ||
|
|
||
| // start main fe/DTC record loop | ||
| for(auto& channelStatusPair : channelStatusRecords) { | ||
| uint32_t boardID = channelStatusPair.second.getNode(ColChannelStatus.colBoardId_).getValue<uint32_t>(); | ||
giro94 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ConfigurationTree::BitMap<std::string> bitmap = channelStatusPair.second.getNode(ColChannelStatus.colStatus_).getValueAsBitMap(); | ||
|
|
||
| // assume data is 1-dimensional | ||
| for(uint32_t j = 0; j < bitmap.numberOfColumns(0); j++) { | ||
| OfflineTable << mapChannels_.at(boardID * CHANNELS_PER_BOARD + j) << ", "; | ||
| OfflineTable << ((bitmap.get(0, j).size() == 0) ? "0" : bitmap.get(0, j)); | ||
| OfflineTable << ((j + 1 == bitmap.numberOfColumns(0)) ? "" : "\n"); | ||
rrivera747 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
rrivera747 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| return OfflineTable.str(); | ||
| } // end getStatusTableInCSVFormat() | ||
|
|
||
| //============================================================================== | ||
| // return status structures | ||
| std::string SubsystemCalorimeterParametersTable::getStructureAsJSON(const ConfigurationManager* cfgMgr) { | ||
| // Don't generate maps if done already in init() | ||
| if(mapOfflineTables_.size() == 0) | ||
| generateOfflineTableMap(cfgMgr); | ||
|
|
||
| std::vector<std::pair<std::string, ConfigurationTree>> channelStatusRecords = cfgMgr->getNode(SubsystemCalorimeterParametersTable::CHANNEL_STATUS_TABLE).getChildren(); | ||
|
|
||
| std::stringstream outstream; | ||
|
|
||
| outstream << "{"; | ||
|
|
||
| // Write all cat-3 tables converted from MongoDB | ||
| outstream << "\t\"cat3\": {" << __E__; | ||
| std::map<std::string, std::string>::iterator it; | ||
| for(it = mapOfflineTables_.begin(); it != mapOfflineTables_.end(); ++it) { | ||
| outstream << "\"" << it->first << "\":" << it->second; | ||
| outstream << (std::next(it) == mapOfflineTables_.end() ? "" : ","); | ||
| } | ||
| outstream << "},"; | ||
|
|
||
| // Write any desired table in a custom format for user-friendly quick reading | ||
| outstream << "\t\"custom\": "; | ||
| outstream << "{" << __E__; | ||
| outstream << "\t\"Number of rows\": " << channelStatusRecords.size() << "," << __E__; | ||
| outstream << "\t[" << __E__; | ||
rrivera747 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| uint16_t statusPairIdx = 0; | ||
| for(auto& channelStatusPair : channelStatusRecords) { | ||
| uint16_t boardID = channelStatusPair.second.getNode(ColChannelStatus.colBoardId_).getValue<uint16_t>(); | ||
| ConfigurationTree::BitMap<std::string> bitmap = channelStatusPair.second.getNode(ColChannelStatus.colStatus_).getValueAsBitMap(); | ||
| statusPairIdx++; | ||
|
|
||
| outstream << "\t\t{" << __E__; | ||
| outstream << "\t\t\"BoardID\": " << boardID << "," << __E__; | ||
| outstream << "\t\t\"Rows\": " << bitmap.numberOfRows() << "," << __E__; | ||
| outstream << "\t\t\"BitMap\": ["; | ||
|
|
||
| // assume data is 1-dimensional | ||
| for(uint32_t j = 0; j < bitmap.numberOfColumns(0); j++) { | ||
| outstream << ((bitmap.get(0, j).size() == 0) ? "0" : bitmap.get(0, j)); | ||
| outstream << ((j + 1 == bitmap.numberOfColumns(0)) ? "" : ", "); | ||
| } | ||
| outstream << "]" << __E__; | ||
| outstream << "\t\t}" << (statusPairIdx == channelStatusRecords.size() ? "" : ",") << __E__; | ||
| } | ||
|
|
||
| outstream << "\t]" << __E__; | ||
| outstream << "}"; // close custom blob | ||
| outstream << "}"; // close full blob | ||
| return outstream.str(); | ||
| } // end getStructureAsJSON() | ||
|
|
||
| DEFINE_OTS_TABLE(SubsystemCalorimeterParametersTable) | ||
Uh oh!
There was an error while loading. Please reload this page.