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

change to calo data decoder #15

Merged
merged 1 commit into from
Nov 13, 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
12 changes: 6 additions & 6 deletions artdaq-core-mu2e/Data/CalorimeterDataDecoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ CalorimeterDataDecoder::CalorimeterDataDecoder(std::vector<uint8_t> data)


// Get Calo Hit Data Packet
std::vector<std::pair<mu2e::CalorimeterDataDecoder::CalorimeterHitDataPacket, std::vector<uint16_t>>> mu2e::CalorimeterDataDecoder::GetCalorimeterHitData(size_t blockIndex) const
std::vector<std::pair<mu2e::CalorimeterDataDecoder::CalorimeterHitDataPacket, std::vector<uint16_t>>>* mu2e::CalorimeterDataDecoder::GetCalorimeterHitData(size_t blockIndex) const
{
// a pair is created mapping the data packet to set of hits (?)
std::vector<std::pair<mu2e::CalorimeterDataDecoder::CalorimeterHitDataPacket, std::vector<uint16_t>>> output;
std::vector<std::pair<mu2e::CalorimeterDataDecoder::CalorimeterHitDataPacket, std::vector<uint16_t>>> *output = new std::vector<std::pair<mu2e::CalorimeterDataDecoder::CalorimeterHitDataPacket, std::vector<uint16_t>>>();

// get data block at given index
auto dataPtr = dataAtBlockIndex(blockIndex);
Expand All @@ -55,19 +55,19 @@ std::vector<std::pair<mu2e::CalorimeterDataDecoder::CalorimeterHitDataPacket, st
while(count < dataPacket->NumberOfSamples){

// Reinterpret pos as a pointer to a hit readout header
output.emplace_back(mu2e::CalorimeterDataDecoder::CalorimeterHitDataPacket(*reinterpret_cast<mu2e::CalorimeterDataDecoder::CalorimeterHitDataPacket const*>(pos)), std::vector<uint16_t>()); //Construct and insert element at the end, Converts between types by reinterpreting the underlying bit pattern.
output->emplace_back(mu2e::CalorimeterDataDecoder::CalorimeterHitDataPacket(*reinterpret_cast<mu2e::CalorimeterDataDecoder::CalorimeterHitDataPacket const*>(pos)), std::vector<uint16_t>()); //Construct and insert element at the end, Converts between types by reinterpreting the underlying bit pattern.

// Step pos past the hit readout
pos += sizeof(mu2e::CalorimeterDataDecoder::CalorimeterHitDataPacket) / sizeof(uint16_t);

// Setup waveform storage
// find number of samples from output
auto nSamples = output.back().first.NumberOfSamples;
auto nSamples = output->back().first.NumberOfSamples;
// resize the vector part to nSamples
output.back().second.resize(nSamples);
output->back().second.resize(nSamples);

// Copy waveform into output
memcpy(output.back().second.data(), pos, sizeof(uint16_t) * nSamples);
memcpy(output->back().second.data(), pos, sizeof(uint16_t) * nSamples);

// Step pos past waveform
pos += nSamples;
Expand Down
2 changes: 1 addition & 1 deletion artdaq-core-mu2e/Data/CalorimeterDataDecoder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CalorimeterDataDecoder : public DTCDataDecoder

};

std::vector<std::pair<CalorimeterHitDataPacket, std::vector<uint16_t>>> GetCalorimeterHitData(size_t blockIndex) const;
std::vector<std::pair<CalorimeterHitDataPacket, std::vector<uint16_t>>>* GetCalorimeterHitData(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