Skip to content

Updated overlay classes to accomodate the new link subsystem ids #46

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

Merged
merged 6 commits into from
Feb 5, 2025
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
46 changes: 46 additions & 0 deletions artdaq-core-mu2e/Data/CalorimeterDataDecoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ namespace mu2e {
return output;
}

if(dataBlock->GetHeader()->GetSubsystem() != DTCLib::DTC_Subsystem_Calorimeter) {
TLOG(TLVL_DEBUG) << "CalorimeterDataDecoder::GetCalorimeterHitTestData : this block is from different subsystem: " << dataBlock->GetHeader()->GetSubsystem();
return output;
}

DTCLib::DTC_DataHeaderPacket* blockHeader = dataBlock->GetHeader().get();
size_t blockSize = dataBlock->byteSize;
size_t nPackets = blockHeader->GetPacketCount();
Expand Down Expand Up @@ -329,4 +334,45 @@ namespace mu2e {
return output;
}


// Get EmulatedROC Counters Data Packet
std::vector<std::pair<mu2e::CalorimeterDataDecoder::CalorimeterCountersDataPacket, std::vector<uint32_t>>>* mu2e::CalorimeterDataDecoder::GetEmulatedCountersData(size_t blockIndex) const
{
std::vector<std::pair<mu2e::CalorimeterDataDecoder::CalorimeterCountersDataPacket, std::vector<uint32_t>>> *output = new std::vector<std::pair<mu2e::CalorimeterDataDecoder::CalorimeterCountersDataPacket, std::vector<uint32_t>>>();

// get data block at given index
DTCLib::DTC_DataBlock const * dataBlock = dataAtBlockIndex(blockIndex);
if (dataBlock == nullptr) return output;

DTCLib::DTC_DataHeaderPacket* blockHeader = dataBlock->GetHeader().get();
size_t blockSize = dataBlock->byteSize;
size_t nPackets = blockHeader->GetPacketCount();
size_t dataSize = blockSize - 16;

auto blockDataPtr = dataBlock->GetData();

if (nPackets == 0){ //Empty packet
TLOG(TLVL_DEBUG) << "CalorimeterDataDecoder::GetEmulatedCountersData : no packets -- disabled ROC?";
return output;
}

if (dataSize%4 != 0){ //Data not multiple of 32-bit words
TLOG(TLVL_WARNING) << "CalorimeterDataDecoder::GetEmulatedCountersData : data size (" << dataSize << ") is not multiple of 32-bit";
return output;
}

uint16_t nCounters = dataSize / 4;
//Create output
output->emplace_back(mu2e::CalorimeterDataDecoder::CalorimeterCountersDataPacket(), std::vector<uint32_t>(nCounters));
output->back().first.numberOfCounters = nCounters;

//Get data in 32-bit words
auto data32bitPtr = reinterpret_cast<const uint32_t *>(blockDataPtr);
for (uint word=0; word<nCounters; word++){
output->back().second[word] = (*(data32bitPtr + word));
}

return output;
}

} // namespace mu2e
1 change: 1 addition & 0 deletions artdaq-core-mu2e/Data/CalorimeterDataDecoder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ namespace mu2e {
std::vector<std::pair<CalorimeterHitDataPacket, std::vector<uint16_t>>>* GetCalorimeterHitData(size_t blockIndex) const;
std::vector<std::pair<CalorimeterHitTestDataPacket, std::vector<uint16_t>>>* GetCalorimeterHitTestData(size_t blockIndex) const;
std::vector<std::pair<CalorimeterCountersDataPacket, std::vector<uint32_t>>>* GetCalorimeterCountersData(size_t blockIndex) const;
std::vector<std::pair<CalorimeterCountersDataPacket, std::vector<uint32_t>>>* GetEmulatedCountersData(size_t blockIndex) const;
std::unique_ptr<CalorimeterFooterPacket> GetCalorimeterFooter(size_t blockIndex) const;
std::vector<std::pair<CalorimeterHitDataPacket, uint16_t>> GetCalorimeterHitsForTrigger(size_t blockIndex) const;
};
Expand Down
4 changes: 2 additions & 2 deletions artdaq-core-mu2e/Data/DTCDataDecoder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ struct mu2e::DTCDataDecoder

auto ptr = data_.data();
event_ = DTCLib::DTC_SubEvent(ptr);
event_.SetupSubEvent();
event_.SetupSubEvent();
setup_ = true;
}

void setup_event() const {
auto ptr = data_.data();
event_ = DTCLib::DTC_SubEvent(ptr);
event_.SetupSubEvent();
event_.SetupSubEvent();
setup_ = true;
}

Expand Down
18 changes: 15 additions & 3 deletions artdaq-core-mu2e/Overlays/DTC_Packets/DTC_Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,32 @@ class DTC_Event
for (size_t ii = 0; ii < sub_events_.size(); ++ii)
{
if (sub_events_[ii].GetDTCID() == dtc && sub_events_[ii].GetSubsystem() == static_cast<uint8_t>(subsys))
return &sub_events_[ii];
return &sub_events_[ii];
}
return nullptr;
}

std::vector<DTC_SubEvent> GetSubsystemData(DTC_Subsystem subsys) const {
std::vector<DTC_SubEvent> output;

for(auto& subevt : sub_events_) {
if(subevt.GetSubsystem() == subsys) {
if(subevt.HasSubsystem(subsys)) {
output.push_back(subevt);
}
}
return output;
}

std::vector<DTC_DataBlock> GetSubsystemBlocks(DTC_Subsystem subsys) const {
std::vector<DTC_DataBlock> output;
for(auto& subevt : sub_events_) {
if(subevt.HasSubsystem(subsys)) {
for(auto& datablock : subevt.GetDataBlocks()) {
if(datablock.GetHeader()->GetSubsystem() == subsys) {
output.push_back(datablock);
}
}
}
}
return output;
}

Expand Down
37 changes: 33 additions & 4 deletions artdaq-core-mu2e/Overlays/DTC_Packets/DTC_SubEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <cstdint>
#include <vector>
#include <array>

namespace DTCLib {

Expand Down Expand Up @@ -61,14 +62,42 @@ class DTC_SubEvent
UpdateHeader();
}

DTC_Subsystem GetSubsystem() const { return static_cast<DTC_Subsystem>(header_.source_subsystem); }
DTC_Subsystem GetSubsystem(DTC_Link_ID link = DTC_Link_0) const {
switch(link){
case DTC_Link_0: return static_cast<DTC_Subsystem>(header_.link0_subsystem); break;
case DTC_Link_1: return static_cast<DTC_Subsystem>(header_.link1_subsystem); break;
case DTC_Link_2: return static_cast<DTC_Subsystem>(header_.link2_subsystem); break;
case DTC_Link_3: return static_cast<DTC_Subsystem>(header_.link3_subsystem); break;
case DTC_Link_4: return static_cast<DTC_Subsystem>(header_.link4_subsystem); break;
case DTC_Link_5: return static_cast<DTC_Subsystem>(header_.link5_subsystem); break;
default: return static_cast<DTC_Subsystem>(0);
}
}
bool HasSubsystem(DTC_Subsystem subsys) const {
if (static_cast<DTC_Subsystem>(header_.link0_subsystem) == subsys) return true;
if (static_cast<DTC_Subsystem>(header_.link1_subsystem) == subsys) return true;
if (static_cast<DTC_Subsystem>(header_.link2_subsystem) == subsys) return true;
if (static_cast<DTC_Subsystem>(header_.link3_subsystem) == subsys) return true;
if (static_cast<DTC_Subsystem>(header_.link4_subsystem) == subsys) return true;
if (static_cast<DTC_Subsystem>(header_.link5_subsystem) == subsys) return true;
return false;
}
void SetDTCMAC(uint8_t mac) {
header_.dtc_mac = mac;
}
void SetSourceDTC(uint8_t id, DTC_Subsystem subsystem = DTC_Subsystem_Other)
{
void SetSourceDTC(uint8_t id, DTC_Subsystem subsystem = DTC_Subsystem_Other){
std::array<DTC_Subsystem, 6> subsystems;
subsystems.fill(subsystem); //Use same subsystem for all six links
SetSourceDTC(id,subsystems);
}
void SetSourceDTC(uint8_t id, std::array<DTC_Subsystem, 6> subsystems){
header_.source_dtc_id = id;
header_.source_subsystem = static_cast<uint8_t>(subsystem);
header_.link0_subsystem = static_cast<uint8_t>(subsystems[0]);
header_.link1_subsystem = static_cast<uint8_t>(subsystems[1]);
header_.link2_subsystem = static_cast<uint8_t>(subsystems[2]);
header_.link3_subsystem = static_cast<uint8_t>(subsystems[3]);
header_.link4_subsystem = static_cast<uint8_t>(subsystems[4]);
header_.link5_subsystem = static_cast<uint8_t>(subsystems[5]);
}
const DTC_SubEventHeader* GetHeader() const { return &header_; }
void UpdateHeader();
Expand Down
22 changes: 20 additions & 2 deletions artdaq-core-mu2e/Overlays/DTC_Packets/DTC_SubEventHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ struct DTC_SubEventHeader
uint64_t partition_id : 8;
uint64_t evb_mode : 8;
uint64_t source_dtc_id : 8;
uint64_t source_subsystem : 3;
uint64_t reserved2 : 29;

uint64_t link0_subsystem : 3;
uint64_t link1_subsystem : 3;
uint64_t link2_subsystem : 3;
uint64_t link3_subsystem : 3;
uint64_t link4_subsystem : 3;
uint64_t link5_subsystem : 3;
uint64_t reserved2 : 14;

uint64_t link0_status : 8;
uint64_t link1_status : 8;
Expand Down Expand Up @@ -57,6 +63,12 @@ struct DTC_SubEventHeader
, partition_id(0)
, evb_mode(0)
, source_dtc_id(0)
, link0_subsystem(0)
, link1_subsystem(0)
, link2_subsystem(0)
, link3_subsystem(0)
, link4_subsystem(0)
, link5_subsystem(0)
, reserved2(0)
, link0_status(0)
, link1_status(0)
Expand Down Expand Up @@ -89,6 +101,12 @@ struct DTC_SubEventHeader
oss << ",\n\t\"partition_id\": " << partition_id;
oss << ",\n\t\"evb_mode\": " << evb_mode;
oss << ",\n\t\"source_dtc_id\": " << source_dtc_id;
oss << ",\n\t\"link0_subsystem\": " << link0_subsystem;
oss << ",\n\t\"link1_subsystem\": " << link1_subsystem;
oss << ",\n\t\"link2_subsystem\": " << link2_subsystem;
oss << ",\n\t\"link3_subsystem\": " << link3_subsystem;
oss << ",\n\t\"link4_subsystem\": " << link4_subsystem;
oss << ",\n\t\"link5_subsystem\": " << link5_subsystem;
oss << ",\n\t\"link0_status\": " << link0_status;
oss << ",\n\t\"link1_status\": " << link1_status;
oss << ",\n\t\"link2_status\": " << link2_status;
Expand Down
Loading