From b3d6f8023b9f1d38ec274e44fe34febae8c700e3 Mon Sep 17 00:00:00 2001 From: Eric Torrence <eric.torrence@cern.ch> Date: Tue, 17 Aug 2021 10:58:00 -0700 Subject: [PATCH] Revert "Fix up with upstream master" This reverts commit d7a73a649854dc7e065aad28a6fb237dd05e0ac9, reversing changes made to 6da05b79bf6855761eb8d362106c6ff4ec06e97f. --- .../src/RawWaveformDecoderTool.cxx | 106 ++++++++++++++---- .../src/RawWaveformDecoderTool.h | 53 ++++++++- .../src/RawWaveformCnv_p0.cxx | 7 +- 3 files changed, 138 insertions(+), 28 deletions(-) diff --git a/Waveform/WaveEventCnv/WaveByteStream/src/RawWaveformDecoderTool.cxx b/Waveform/WaveEventCnv/WaveByteStream/src/RawWaveformDecoderTool.cxx index 2081244c..ec7a6641 100644 --- a/Waveform/WaveEventCnv/WaveByteStream/src/RawWaveformDecoderTool.cxx +++ b/Waveform/WaveEventCnv/WaveByteStream/src/RawWaveformDecoderTool.cxx @@ -20,31 +20,16 @@ RawWaveformDecoderTool::RawWaveformDecoderTool(const std::string& type, { declareInterface<RawWaveformDecoderTool>(this); + // These must be configured by job options declareProperty("CaloChannels", m_caloChannels); - m_caloChannels.push_back(0); - m_caloChannels.push_back(1); - m_caloChannels.push_back(2); - m_caloChannels.push_back(3); - declareProperty("VetoChannels", m_vetoChannels); - m_vetoChannels.push_back(4); - m_vetoChannels.push_back(5); - m_vetoChannels.push_back(6); - m_vetoChannels.push_back(7); - declareProperty("TriggerChannels", m_triggerChannels); - m_triggerChannels.push_back(8); - m_triggerChannels.push_back(9); - m_triggerChannels.push_back(10); - m_triggerChannels.push_back(11); - declareProperty("PreshowerChannels", m_preshowerChannels); - m_preshowerChannels.push_back(12); - m_preshowerChannels.push_back(13); + // Test channels is provided for conveniene, not normally used declareProperty("TestChannels", m_testChannels); - m_testChannels.push_back(14); + // Clock should always be in channel 15 declareProperty("ClockChannels", m_clockChannels); m_clockChannels.push_back(15); @@ -58,6 +43,82 @@ StatusCode RawWaveformDecoderTool::initialize() { ATH_MSG_DEBUG("RawWaveformDecoderTool::initialize()"); + + // Set up helpers + ATH_CHECK(detStore()->retrieve(m_ecalID, "EcalID")); + ATH_CHECK(detStore()->retrieve(m_vetoID, "VetoID")); + ATH_CHECK(detStore()->retrieve(m_triggerID, "TriggerID")); + ATH_CHECK(detStore()->retrieve(m_preshowerID, "PreshowerID")); + + // Take each channel list and create identifiers + + // Loop through digitizer channel lists creating Identifiers + m_identifierMap.clear(); + + // First, calorimeter. Can either be 4 or 6 channels + // Bottom row first from left to right, then top row + int index=0; + int module=0; + int row=0; + int pmt=0; + + int max_modules = m_caloChannels.size() / 2; + for (auto const& chan : m_caloChannels) { + row = index / max_modules; + module = index % max_modules; + index++; + // Only store in map if digitizer channel is valid + if (chan < 0) continue; + m_identifierMap[chan] = m_ecalID->pmt_id(row, module, pmt); + ATH_MSG_DEBUG("Mapped digitizer channel " << chan << " to calo ID: " << m_identifierMap[chan]); + } + + // Next, veto detector. Have station and plate here. + int station=0; + int plate=0; + pmt=0; + index=0; + + int max_stations=m_vetoChannels.size() / 2; + for (auto const& chan : m_vetoChannels) { + station = index / max_stations; + plate = index % max_stations; + index++; + // Only store in map if digitizer channel is valid + if (chan < 0) continue; + m_identifierMap[chan] = m_vetoID->pmt_id(station, plate, pmt); + ATH_MSG_DEBUG("Mapped digitizer channel " << chan << " to veto ID: " << m_identifierMap[chan]); + } + + // Next, trigger detector. Have pmt and plate. + pmt=0; + station=0; + index=0; + int max_plates=m_triggerChannels.size() / 2; + for (auto const& chan : m_triggerChannels) { + plate = index / max_plates; + pmt = index % max_plates; + index++; + // Only store in map if digitizer channel is valid + if (chan < 0) continue; + m_identifierMap[chan] = m_triggerID->pmt_id(station, plate, pmt); + ATH_MSG_DEBUG("Mapped dititizer channel " << chan << " to trigger ID: " << m_identifierMap[chan]); + } + + // Finally, preshower detector. + pmt=0; + station=0; + plate=0; + index=0; + for (auto const& chan : m_preshowerChannels) { + plate = index; + index++; + // Only store in map if digitizer channel is valid + if (chan < 0) continue; + m_identifierMap[chan] = m_preshowerID->pmt_id(station, plate, pmt); + ATH_MSG_DEBUG("Mapped digitizer channel " << chan << " to preshower ID: " << m_identifierMap[chan]); + } + return StatusCode::SUCCESS; } @@ -111,7 +172,7 @@ RawWaveformDecoderTool::convert(const DAQFormats::EventFull* re, ATH_MSG_DEBUG("Found valid digitizer fragment"); } - std::vector<unsigned int>* channelList; + std::vector<int>* channelList; if (key == std::string("CaloWaveforms")) { channelList = &m_caloChannels; @@ -130,7 +191,7 @@ RawWaveformDecoderTool::convert(const DAQFormats::EventFull* re, return StatusCode::FAILURE; } - for (unsigned int channel: *channelList) { + for (int channel: *channelList) { ATH_MSG_DEBUG("Converting channel "+std::to_string(channel)+" for "+key); // Check if this has data @@ -161,6 +222,11 @@ RawWaveformDecoderTool::convert(const DAQFormats::EventFull* re, << *frag); } + // Set ID if one exists (clock, for instance, doesn't have an identifier) + if (m_identifierMap.count(channel) == 1) { + wfm->setIdentifier(m_identifierMap[channel]); + } + container->push_back(wfm); // Sanity check diff --git a/Waveform/WaveEventCnv/WaveByteStream/src/RawWaveformDecoderTool.h b/Waveform/WaveEventCnv/WaveByteStream/src/RawWaveformDecoderTool.h index 252698c5..e2852f13 100644 --- a/Waveform/WaveEventCnv/WaveByteStream/src/RawWaveformDecoderTool.h +++ b/Waveform/WaveEventCnv/WaveByteStream/src/RawWaveformDecoderTool.h @@ -13,6 +13,12 @@ #include "EventFormats/DAQFormats.hpp" #include "WaveRawEvent/RawWaveformContainer.h" +#include "Identifier/Identifier.h" +#include "FaserCaloIdentifier/EcalID.h" +#include "ScintIdentifier/VetoID.h" +#include "ScintIdentifier/TriggerID.h" +#include "ScintIdentifier/PreshowerID.h" + // This class provides conversion between bytestream and Waveform objects class RawWaveformDecoderTool : public AthAlgTool { @@ -32,13 +38,48 @@ class RawWaveformDecoderTool : public AthAlgTool { private: // List of channels to include in each container - std::vector<unsigned int> m_caloChannels; - std::vector<unsigned int> m_vetoChannels; - std::vector<unsigned int> m_triggerChannels; - std::vector<unsigned int> m_preshowerChannels; - std::vector<unsigned int> m_testChannels; - std::vector<unsigned int> m_clockChannels; + // List order must correspond to offline channel order + // All L/R designations refer to looking at the detector from + // the beam direction. + // + // In general, the ordering is layer (longitudinal), row (vertical), module (horizontal) + // Layers increase with longitudianl position downstream + // Rows increase from bottom to top + // Modules increase from right to left + // + // For all lists, use invalid channel (-1) to indicate detectors + // missing in sequence (i.e. 3 of 4 veto counters) + // + // TI12 detector: + // Calorimeter order: + // bottom right, bottom left, top right, top left + // Veto + // front to back. + // Trigger + // bottom right PMT, bottom left PMT, top right PMT, top left PMT + // Preshower + // front to back + // + // 2021 Testbeam detector: + // Calo order: + // bottom right, bottom center, bottom left, top R, top C, top L + // All others are just in order front to back + + std::vector<int> m_caloChannels; + std::vector<int> m_vetoChannels; + std::vector<int> m_triggerChannels; + std::vector<int> m_preshowerChannels; + std::vector<int> m_testChannels; + std::vector<int> m_clockChannels; + + // Identifiers keyed by digitizer channel + std::map<unsigned int, Identifier> m_identifierMap; + // ID helpers + const EcalID* m_ecalID{nullptr}; + const VetoID* m_vetoID{nullptr}; + const TriggerID* m_triggerID{nullptr}; + const PreshowerID* m_preshowerID{nullptr}; }; diff --git a/Waveform/WaveEventCnv/WaveEventAthenaPool/src/RawWaveformCnv_p0.cxx b/Waveform/WaveEventCnv/WaveEventAthenaPool/src/RawWaveformCnv_p0.cxx index d298c0ff..dedc71cb 100644 --- a/Waveform/WaveEventCnv/WaveEventAthenaPool/src/RawWaveformCnv_p0.cxx +++ b/Waveform/WaveEventCnv/WaveEventAthenaPool/src/RawWaveformCnv_p0.cxx @@ -9,7 +9,8 @@ RawWaveformCnv_p0::persToTrans(const RawWaveform_p0* persObj, RawWaveform* trans // Just fill available data here // Rest of it patched up in RawWaveformContainerCnv_p0 - transObj->setIdentifier(persObj->m_ID); + // Persistent object stores ID value, so instantiate Identifier here + transObj->setIdentifier(Identifier32(persObj->m_ID)); transObj->setChannel(persObj->m_channel); transObj->setCounts(persObj->m_adc_counts); @@ -23,7 +24,9 @@ RawWaveformCnv_p0::transToPers(const RawWaveform* transObj, RawWaveform_p0* pers // log << MSG::DEBUG << (*transObj) << endmsg; // log << MSG::DEBUG << "Persistent waveform (before):" << endmsg; // persObj->print(); - persObj->m_ID = transObj->identify(); + + // Save actual ID number + persObj->m_ID = transObj->identify32().get_compact(); persObj->m_channel = transObj->channel(); // Use copy here -- GitLab