Skip to content

Commit

Permalink
Merge pull request #3 from Mu2e/eflumerf/Mu2eArtdaqRework
Browse files Browse the repository at this point in the history
Add helper function to DTC_Event for use in DTCEventFragment.
  • Loading branch information
eflumerf authored Jun 13, 2023
2 parents 48f8a38 + 9f535cd commit 16506c0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cmake_minimum_required (VERSION 3.19 FATAL_ERROR)

find_package(cetmodules 3.19.02 REQUIRED)

project(mu2e_pcie_utils VERSION 2.08.04)
project(mu2e_pcie_utils VERSION 2.08.05)

include(CetCMakeEnv)
cet_cmake_env()
Expand Down
2 changes: 1 addition & 1 deletion dtcInterfaceLib/DTC_Packets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ bool DTCLib::DTC_DataHeaderPacket::Equals(const DTC_DataHeaderPacket& other) con
return ConvertToDataPacket() == other.ConvertToDataPacket();
}

DTCLib::DTC_SubEvent::DTC_SubEvent(const uint8_t*& ptr)
DTCLib::DTC_SubEvent::DTC_SubEvent(const uint8_t* ptr)
: header_(), data_blocks_()
{
memcpy(&header_, ptr, sizeof(header_));
Expand Down
24 changes: 20 additions & 4 deletions dtcInterfaceLib/DTC_Packets.h
Original file line number Diff line number Diff line change
Expand Up @@ -1081,12 +1081,12 @@ class DTC_SubEvent
/// Construct a DTC_SubEvent using a pointer to data. Flag will be set that the packet is read-only.
/// </summary>
/// <param name="ptr">Pointer to data</param>
explicit DTC_SubEvent(const uint8_t*& ptr);
explicit DTC_SubEvent(const uint8_t* ptr);

DTC_SubEvent()
: header_(), data_blocks_() {}

size_t GetSubEventByteCount() { return header_.inclusive_subevent_byte_count; }
size_t GetSubEventByteCount() const { return header_.inclusive_subevent_byte_count; }

DTC_EventWindowTag GetEventWindowTag() const;
void SetEventWindowTag(DTC_EventWindowTag const& tag);
Expand All @@ -1098,7 +1098,7 @@ class DTC_SubEvent
return data_blocks_;
}
size_t GetDataBlockCount() const { return data_blocks_.size(); }
DTC_DataBlock* GetDataBlock(size_t idx)
const DTC_DataBlock* GetDataBlock(size_t idx) const
{
if (idx >= data_blocks_.size()) throw std::out_of_range("Index " + std::to_string(idx) + " is out of range (max: " + std::to_string(data_blocks_.size() - 1) + ")");
return &data_blocks_[idx];
Expand All @@ -1111,11 +1111,14 @@ class DTC_SubEvent
}

DTC_Subsystem GetSubsystem() const { return static_cast<DTC_Subsystem>((header_.source_dtc_id & 0x70) >> 4); }
void SetDTCMAC(uint8_t mac) {
header_.dtc_mac = mac;
}
void SetSourceDTC(uint8_t id, DTC_Subsystem subsystem = DTC_Subsystem_Other)
{
header_.source_dtc_id = (id & 0xf) + ((static_cast<int>(subsystem) & 0x7) << 4);
}
DTC_SubEventHeader* GetHeader() { return &header_; }
const DTC_SubEventHeader* GetHeader() const { return &header_; }
void UpdateHeader();

private:
Expand Down Expand Up @@ -1218,6 +1221,7 @@ class DTC_Event
if (idx >= sub_events_.size()) throw std::out_of_range("Index " + std::to_string(idx) + " is out of range (max: " + std::to_string(sub_events_.size() - 1) + ")");
return &sub_events_[idx];
}

void AddSubEvent(DTC_SubEvent subEvt)
{
sub_events_.push_back(subEvt);
Expand All @@ -1234,6 +1238,18 @@ class DTC_Event
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) {
output.push_back(subevt);
}
}

return output;
}

DTC_EventHeader* GetHeader() { return &header_; }

void UpdateHeader();
Expand Down
9 changes: 3 additions & 6 deletions dtcInterfaceLib/mu2esim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,7 @@ void mu2esim::eventSimulator_(DTCLib::DTC_EventWindowTag ts)
for (auto ii = 0; ii < num_trk_dtcs; ++ii, ++DTCID)
{
TLOG(TLVL_EventSimulator) << "Generating Tracker data, DTCID " << DTCID << ", TRK DTC " << ii + 1 << "/" << num_trk_dtcs;
auto subEvtHdr = sub_event_->GetHeader();
subEvtHdr->dtc_mac = DTCID;
sub_event_->SetDTCMAC( DTCID);
sub_event_->SetSourceDTC(DTCID, DTCLib::DTC_Subsystem_Tracker);

for (auto link : DTCLib::DTC_Links)
Expand All @@ -645,8 +644,7 @@ void mu2esim::eventSimulator_(DTCLib::DTC_EventWindowTag ts)
for (auto ii = 0; ii < num_calo_dtcs; ++ii, ++DTCID)
{
TLOG(TLVL_EventSimulator) << "Generating Calorimeter data, DTCID " << DTCID << ", Calo DTC " << ii + 1 << "/" << num_calo_dtcs;
auto subEvtHdr = sub_event_->GetHeader();
subEvtHdr->dtc_mac = DTCID;
sub_event_->SetDTCMAC( DTCID);
sub_event_->SetSourceDTC(DTCID, DTCLib::DTC_Subsystem_Calorimeter);

for (auto link : DTCLib::DTC_Links)
Expand All @@ -660,8 +658,7 @@ void mu2esim::eventSimulator_(DTCLib::DTC_EventWindowTag ts)
for (auto ii = 0; ii < num_crv_dtcs; ++ii, ++DTCID)
{
TLOG(TLVL_EventSimulator) << "Generating CRV data, DTCID " << DTCID << ", CRV DTC " << ii + 1 << "/" << num_crv_dtcs;
auto subEvtHdr = sub_event_->GetHeader();
subEvtHdr->dtc_mac = DTCID;
sub_event_->SetDTCMAC( DTCID);
sub_event_->SetSourceDTC(DTCID, DTCLib::DTC_Subsystem_CRV);

for (auto link : DTCLib::DTC_Links)
Expand Down
4 changes: 3 additions & 1 deletion mcs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

add_subdirectory(basic_driver)

include_directories("${CMAKE_CURRENT_SOURCE_DIR}/basic_driver")

cet_make_exec( NAME mcs SOURCE mcs.cc LIBRARIES TRACE::TRACE)
Expand All @@ -8,4 +11,3 @@ cet_script( ALWAYS_COPY mcs.sh )
install_headers()
install_source()

add_subdirectory(basic_driver)
6 changes: 3 additions & 3 deletions tools/make_test_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

# DTC Config
export DTCLIB_SIM_ENABLE=E
export DTCLIB_NUM_TRACKER_BLOCKS=212
export DTCLIB_NUM_CALORIMETER_BLOCKS=60
export DTCLIB_NUM_TRACKER_BLOCKS=270
export DTCLIB_NUM_CALORIMETER_BLOCKS=134
export DTCLIB_NUM_CALORIMETER_HITS=10
export DTCLIB_NUM_CRV_BLOCKS=0

# Create file
mu2eUtil -Q -n 1000 --binary-file-mode DTC_packets.bin verify_stream
mu2eUtil -Q -n 10000 --binary-file-mode DTC_packets.bin buffer_test

0 comments on commit 16506c0

Please sign in to comment.