From 801c1e3046846c5974f8af8c355035ad0c68d810 Mon Sep 17 00:00:00 2001 From: Eric Torrence <eric.torrence@cern.ch> Date: Fri, 11 Sep 2020 12:04:36 -0700 Subject: [PATCH 1/2] Create waveform POOL converter, update to latest waveform channel mappings --- .../src/ScintWaveformAccess.cxx | 5 ++ .../src/ScintWaveformAccess.h | 2 + .../python/FaserByteStreamCnvSvcBaseConfig.py | 1 + .../src/ScintWaveformDecoderTool.cxx | 23 +++++++-- .../src/ScintWaveformDecoderTool.h | 1 + .../ScintEventAthenaPool/CMakeLists.txt | 28 ++++++++++ .../ScintEventAthenaPoolCnvDict.h | 11 ++++ .../ScintWaveformContainer_p0.h | 39 ++++++++++++++ .../ScintEventAthenaPool/ScintWaveform_p0.h | 42 +++++++++++++++ .../ScintEventAthenaPool/selection.xml | 4 ++ .../src/ScintWaveformCnv_p0.cxx | 33 ++++++++++++ .../src/ScintWaveformCnv_p0.h | 27 ++++++++++ .../src/ScintWaveformContainerCnv.cxx | 42 +++++++++++++++ .../src/ScintWaveformContainerCnv.h | 33 ++++++++++++ .../src/ScintWaveformContainerCnv_p0.cxx | 51 +++++++++++++++++++ .../src/ScintWaveformContainerCnv_p0.h | 28 ++++++++++ .../src/ScintWaveformContainer_p0.cxx | 1 + 17 files changed, 367 insertions(+), 4 deletions(-) create mode 100644 Scintillator/ScintEventCnv/ScintEventAthenaPool/CMakeLists.txt create mode 100644 Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintEventAthenaPoolCnvDict.h create mode 100644 Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintWaveformContainer_p0.h create mode 100644 Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintWaveform_p0.h create mode 100644 Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/selection.xml create mode 100644 Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformCnv_p0.cxx create mode 100644 Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformCnv_p0.h create mode 100644 Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv.cxx create mode 100644 Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv.h create mode 100644 Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv_p0.cxx create mode 100644 Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv_p0.h create mode 100644 Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainer_p0.cxx diff --git a/Control/CalypsoExample/WaveformDataAccessExample/src/ScintWaveformAccess.cxx b/Control/CalypsoExample/WaveformDataAccessExample/src/ScintWaveformAccess.cxx index 4dc33c5f..d3de51d5 100644 --- a/Control/CalypsoExample/WaveformDataAccessExample/src/ScintWaveformAccess.cxx +++ b/Control/CalypsoExample/WaveformDataAccessExample/src/ScintWaveformAccess.cxx @@ -32,6 +32,7 @@ ScintWaveformAccess::initialize() ATH_CHECK( m_TriggerWaveformContainer.initialize() ); ATH_CHECK( m_PreshowerWaveformContainer.initialize() ); ATH_CHECK( m_TestWaveformContainer.initialize() ); + ATH_CHECK( m_ClockWaveformContainer.initialize() ); return StatusCode::SUCCESS; } @@ -70,5 +71,9 @@ ScintWaveformAccess::execute(const EventContext& ctx) const ATH_MSG_INFO("Found ReadHandle for TestWaveforms"); ATH_MSG_INFO(*testHandle); + SG::ReadHandle<ScintWaveformContainer> clockHandle(m_ClockWaveformContainer, ctx); + ATH_MSG_INFO("Found ReadHandle for ClockWaveforms"); + ATH_MSG_INFO(*clockHandle); + return StatusCode::SUCCESS; } diff --git a/Control/CalypsoExample/WaveformDataAccessExample/src/ScintWaveformAccess.h b/Control/CalypsoExample/WaveformDataAccessExample/src/ScintWaveformAccess.h index bea751f2..ac73b688 100644 --- a/Control/CalypsoExample/WaveformDataAccessExample/src/ScintWaveformAccess.h +++ b/Control/CalypsoExample/WaveformDataAccessExample/src/ScintWaveformAccess.h @@ -40,6 +40,8 @@ class ScintWaveformAccess: public AthReentrantAlgorithm { this, "PreshowerWaveformContainerKey", "PreshowerWaveforms", "ReadHandleKey for PreshowerWaveforms Container"}; SG::ReadHandleKey<ScintWaveformContainer> m_TestWaveformContainer { this, "TestWaveformContainerKey", "TestWaveforms", "ReadHandleKey for TestWaveforms Container"}; + SG::ReadHandleKey<ScintWaveformContainer> m_ClockWaveformContainer + { this, "ClockWaveformContainerKey", "ClockWaveforms", "ReadHandleKey for ClockWaveforms Container"}; }; #endif /* WAVEFORMDATAACCESSEXAMPLE_SCINTWAVEFORMACCESS_H */ diff --git a/Event/FaserByteStreamCnvSvcBase/python/FaserByteStreamCnvSvcBaseConfig.py b/Event/FaserByteStreamCnvSvcBase/python/FaserByteStreamCnvSvcBaseConfig.py index 63c95b01..3346c0fd 100644 --- a/Event/FaserByteStreamCnvSvcBase/python/FaserByteStreamCnvSvcBaseConfig.py +++ b/Event/FaserByteStreamCnvSvcBase/python/FaserByteStreamCnvSvcBaseConfig.py @@ -17,6 +17,7 @@ def FaserByteStreamCnvSvcBaseCfg(flags, **kwargs): "ScintWaveformContainer/VetoWaveforms", "ScintWaveformContainer/TriggerWaveforms", "ScintWaveformContainer/PreshowerWaveforms", + "ScintWaveformContainer/ClockWaveforms", "ScintWaveformContainer/TestWaveforms" ] diff --git a/Scintillator/ScintEventCnv/ScintByteStream/src/ScintWaveformDecoderTool.cxx b/Scintillator/ScintEventCnv/ScintByteStream/src/ScintWaveformDecoderTool.cxx index 8cb9a344..de415ef2 100644 --- a/Scintillator/ScintEventCnv/ScintByteStream/src/ScintWaveformDecoderTool.cxx +++ b/Scintillator/ScintEventCnv/ScintByteStream/src/ScintWaveformDecoderTool.cxx @@ -22,18 +22,31 @@ ScintWaveformDecoderTool::ScintWaveformDecoderTool(const std::string& type, 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(1); + 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(2); + 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(3); + m_preshowerChannels.push_back(12); + m_preshowerChannels.push_back(13); declareProperty("TestChannels", m_testChannels); - m_testChannels.push_back(4); + m_testChannels.push_back(14); + + declareProperty("ClockChannels", m_clockChannels); + m_clockChannels.push_back(15); } @@ -104,6 +117,8 @@ ScintWaveformDecoderTool::convert(const DAQFormats::EventFull* re, channelList = &m_preshowerChannels; } else if (key == std::string("TestWaveforms")) { channelList = &m_testChannels; + } else if (key == std::string("ClockWaveforms")) { + channelList = &m_clockChannels; } else { ATH_MSG_ERROR("Unknown key " << key); return StatusCode::FAILURE; diff --git a/Scintillator/ScintEventCnv/ScintByteStream/src/ScintWaveformDecoderTool.h b/Scintillator/ScintEventCnv/ScintByteStream/src/ScintWaveformDecoderTool.h index 0c43dc02..a5e7bd98 100644 --- a/Scintillator/ScintEventCnv/ScintByteStream/src/ScintWaveformDecoderTool.h +++ b/Scintillator/ScintEventCnv/ScintByteStream/src/ScintWaveformDecoderTool.h @@ -37,6 +37,7 @@ private: std::vector<unsigned int> m_triggerChannels; std::vector<unsigned int> m_preshowerChannels; std::vector<unsigned int> m_testChannels; + std::vector<unsigned int> m_clockChannels; }; diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/CMakeLists.txt b/Scintillator/ScintEventCnv/ScintEventAthenaPool/CMakeLists.txt new file mode 100644 index 00000000..b68ac1d6 --- /dev/null +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/CMakeLists.txt @@ -0,0 +1,28 @@ +# $Id: CMakeLists.txt 749562 2016-05-25 04:45:43Z krasznaa $ +################################################################################ +# Package: ScintEventAthenaPool +################################################################################ + +# Declare the package name: +atlas_subdir( ScintEventAthenaPool ) + +# Component(s) in the package: +atlas_add_poolcnv_library( ScintEventAthenaPoolPoolCnv + ScintEventAthenaPool/*.h src/*.h src/*.cxx + FILES ScintRawEvent/ScintWaveform.h + ScintRawEvent/ScintWaveformContainer.h + LINK_LIBRARIES Identifier GeneratorObjectsTPCnv AthAllocators AthContainers + AthenaBaseComps AthenaKernel SGTools StoreGateLib AthenaPoolCnvSvcLib + AthenaPoolUtilities AtlasSealCLHEP GaudiKernel ScintRawEvent + ) + +atlas_add_dictionary( ScintEventAthenaPoolCnvDict + ScintEventAthenaPool/ScintEventAthenaPoolCnvDict.h + ScintEventAthenaPool/selection.xml + LINK_LIBRARIES Identifier GeneratorObjectsTPCnv ) + +# Install files from the package: +atlas_install_headers( ScintEventAthenaPool ) + + + diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintEventAthenaPoolCnvDict.h b/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintEventAthenaPoolCnvDict.h new file mode 100644 index 00000000..ddf45c64 --- /dev/null +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintEventAthenaPoolCnvDict.h @@ -0,0 +1,11 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef SCINTEVENTATHENAPOOLCNVDICT_H +#define SCINTEVENTATHENAPOOLCNVDICT_H + +#include "ScintEventAthenaPool/ScintWaveform_p0.h" +#include "ScintEventAthenaPool/ScintWaveformContainer_p0.h" + +#endif diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintWaveformContainer_p0.h b/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintWaveformContainer_p0.h new file mode 100644 index 00000000..1c7b327d --- /dev/null +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintWaveformContainer_p0.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef SCINTWAVEFORMCONTAINER_P0_H +#define SCINTWAVEFORMCONTAINER_P0_H + +// Persistent represenation of a ScintWaveformContainer. + +#include <vector> +#include "ScintEventAthenaPool/ScintWaveform_p0.h" + +class ScintWaveformContainer_p0 { + public: + ScintWaveformContainer_p0(); + friend class ScintWaveformContainerCnv_p0; + private: + bool m_board_fail_flag; + unsigned int m_board_id; + unsigned int m_pattern_trig_options; + unsigned int m_channel_mask; + unsigned int m_event_counter; + unsigned int m_trigger_time_tag; + unsigned int m_samples; + std::vector<ScintWaveform_p0> m_waveforms; +}; + +inline +ScintWaveformContainer_p0::ScintWaveformContainer_p0() : m_board_fail_flag(0), + m_board_id(0), + m_pattern_trig_options(0), + m_channel_mask(0), + m_event_counter(0), + m_trigger_time_tag(0), + m_samples(0) { + m_waveforms.clear(); +} + +#endif diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintWaveform_p0.h b/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintWaveform_p0.h new file mode 100644 index 00000000..b37fe284 --- /dev/null +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintWaveform_p0.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef SCINTWAVEFORM_P0_H +#define SCINTWAVEFORM_P0_H + +#include <vector> +#include <iostream> +#include <iomanip> + +class ScintWaveform_p0 { + public: + ScintWaveform_p0(); + +// List of Cnv classes that convert this into Rdo objects + friend class ScintWaveformCnv_p0; + + private: + unsigned int m_channel; + std::vector<unsigned int> m_adc_counts; + + public: + void print() const { + std::cout << "Persistent Waveform data:" << std::endl + << std::setw(30) << " channel: "<<std::setfill(' ')<<std::setw(32)<<std::dec<<m_channel<<std::setfill(' ')<<std::endl + << std::setw(30) << " length: "<<std::setfill(' ')<<std::setw(32)<<std::dec<<m_adc_counts.size()<<std::setfill(' ')<<std::endl; + } +}; + +inline +ScintWaveform_p0::ScintWaveform_p0() : m_channel(0) { + m_adc_counts.clear(); +} + +// Stream operator for debugging +//std::ostream +//&operator<<(std::ostream &out, const ScintWaveform_p0 &wfm) { +// return wfm.print(out); +//} + +#endif diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/selection.xml b/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/selection.xml new file mode 100644 index 00000000..5c52a4cc --- /dev/null +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/selection.xml @@ -0,0 +1,4 @@ +<lcgdict> + <class name="ScintWaveform_p0" /> + <class name="ScintWaveformContainer_p0" id="344d904d-6338-41f1-94ee-ea609ea4ae44" /> +</lcgdict> diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformCnv_p0.cxx b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformCnv_p0.cxx new file mode 100644 index 00000000..b245674d --- /dev/null +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformCnv_p0.cxx @@ -0,0 +1,33 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#include "ScintWaveformCnv_p0.h" + +void +ScintWaveformCnv_p0::persToTrans(const ScintWaveform_p0* persObj, ScintWaveform* transObj, MsgStream& log) { + + transObj = 0; + log << MSG::WARNING << "ScintWaveformCnv_p0::persToTrans not implemented!" << endmsg; + +} + +void +ScintWaveformCnv_p0::transToPers(const ScintWaveform* transObj, ScintWaveform_p0* persObj, MsgStream& log) { + + // log << MSG::DEBUG << "ScintWaveformCnv_p0::transToPers called" << endmsg; + // log << MSG::DEBUG << "Transient waveform:" << endmsg; + // log << MSG::DEBUG << (*transObj) << endmsg; + // log << MSG::DEBUG << "Persistent waveform (before):" << endmsg; + // persObj->print(); + + persObj->m_channel = transObj->channel(); + + // Use copy here + persObj->m_adc_counts = transObj->adc_counts(); + + // log << MSG::DEBUG << "Persistent waveform (after):" << endmsg; + // persObj->print(); + // log << MSG::DEBUG << "ScintWaveformCnv_p0::transToPers done" << endmsg; + +} diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformCnv_p0.h b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformCnv_p0.h new file mode 100644 index 00000000..41bb1530 --- /dev/null +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformCnv_p0.h @@ -0,0 +1,27 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef SCINTWAVEFORMCNV_P0_H +#define SCINTWAVEFORMCNV_P0_H + +#include "ScintRawEvent/ScintWaveform.h" +#include "ScintEventAthenaPool/ScintWaveform_p0.h" + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" + +class ScintWaveformCnv_p0 : public T_AthenaPoolTPCnvBase<ScintWaveform, ScintWaveform_p0> { + public: + ScintWaveformCnv_p0() {}; + + virtual void persToTrans(const ScintWaveform_p0* persObj, + ScintWaveform* transObj, + MsgStream& log); + + virtual void transToPers(const ScintWaveform* transObj, + ScintWaveform_p0* persObj, + MsgStream& log); + private: +}; + +#endif diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv.cxx b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv.cxx new file mode 100644 index 00000000..afea1cac --- /dev/null +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv.cxx @@ -0,0 +1,42 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#include "ScintWaveformContainerCnv.h" + +ScintWaveformContainer_PERS* +ScintWaveformContainerCnv::createPersistent (ScintWaveformContainer* transCont) { + ATH_MSG_DEBUG("ScintWaveformContainerCnv::createPersistent()"); + + ScintWaveformContainerCnv_PERS converter; + + ScintWaveformContainer_PERS* persObj(nullptr); + persObj = converter.createPersistent( transCont, msg() ); + return persObj; +} + +ScintWaveformContainer* +ScintWaveformContainerCnv::createTransient() { + ATH_MSG_DEBUG("ScintWaveformContainerCnv::createTransient()"); + + static const pool::Guid p0_guid("344d904d-6338-41f1-94ee-ea609ea4ae44"); + ScintWaveformContainer* trans(0); + + // Check for GUID of each persistent type + if ( compareClassGuid(p0_guid) ) { + std::unique_ptr< ScintWaveformContainer_p0 > col_vect( poolReadObject< ScintWaveformContainer_p0 >() ); + + ScintWaveformContainerCnv_p0 converter_p0; + trans = converter_p0.createTransient( col_vect.get(), msg() ); + + } else { + + // Didn't find a known type + throw std::runtime_error("Unsupported persistent version of ScintWaveformContainer"); + } + + return trans; + +} + + diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv.h b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv.h new file mode 100644 index 00000000..c0160c8e --- /dev/null +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv.h @@ -0,0 +1,33 @@ +/* + Copyright 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef SCINTWAVEFORMCONTAINERCNV_H +#define SCINTWAVEFORMCONTAINERCNV_H + +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" + +#include "ScintWaveformContainerCnv_p0.h" + +#include "ScintRawEvent/ScintWaveformContainer.h" +#include "ScintEventAthenaPool/ScintWaveformContainer_p0.h" + +// The latest persistent representation +typedef ScintWaveformContainer_p0 ScintWaveformContainer_PERS; +typedef ScintWaveformContainerCnv_p0 ScintWaveformContainerCnv_PERS; + +typedef T_AthenaPoolCustomCnv< ScintWaveformContainer, ScintWaveformContainer_PERS > ScintWaveformContainerCnvBase; + +class ScintWaveformContainerCnv : public ScintWaveformContainerCnvBase { + friend class CnvFactory<ScintWaveformContainerCnv>; + + public: + ScintWaveformContainerCnv (ISvcLocator* svcloc) : ScintWaveformContainerCnvBase(svcloc) {} + + protected: + virtual ScintWaveformContainer_PERS* createPersistent (ScintWaveformContainer* transCont); + virtual ScintWaveformContainer* createTransient (); + +}; + +#endif diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv_p0.cxx b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv_p0.cxx new file mode 100644 index 00000000..f808f108 --- /dev/null +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv_p0.cxx @@ -0,0 +1,51 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#include "ScintWaveformContainerCnv_p0.h" +#include "ScintWaveformCnv_p0.h" + +void +ScintWaveformContainerCnv_p0::persToTrans(const ScintWaveformContainer_p0* persCont, ScintWaveformContainer* transCont, MsgStream& log) { + + transCont = 0; + log << MSG::WARNING << "ScintWaveformContainerCnv_p0::persToTrans not implemented!" << endmsg; + + +} + +void +ScintWaveformContainerCnv_p0::transToPers(const ScintWaveformContainer* transCont,ScintWaveformContainer_p0* persCont, MsgStream& log) { + + log << MSG::DEBUG << "ScintWaveformContainerCnv_p0::transToPers preparing " << transCont->size() << " waveforms" << endmsg; + + ScintWaveformCnv_p0 waveformCnv; + + typedef ScintWaveformContainer TRANS; + TRANS::const_iterator it_Cont = transCont->begin(); + TRANS::const_iterator it_ContEnd = transCont->end(); + + // Fill common information + const ScintWaveform* transObj = (*it_Cont); + persCont->m_board_fail_flag = transObj->board_fail_flag(); + persCont->m_board_id = transObj->board_id(); + persCont->m_pattern_trig_options = transObj->pattern_trig_options(); + persCont->m_channel_mask = transObj->channel_mask(); + persCont->m_event_counter = transObj->event_counter(); + persCont->m_trigger_time_tag = transObj->trigger_time_tag(); + persCont->m_samples = transObj->n_samples(); + + // Loop over each waveform and convert those as well + persCont->m_waveforms.resize(transCont->size()); + + for (int index=0; it_Cont != it_ContEnd; it_Cont++, index++) { + // Add new collection + log << MSG::DEBUG << "Converting waveform " << index << endmsg; + const ScintWaveform* data = (*it_Cont); + ScintWaveform_p0* pdata = &(persCont->m_waveforms.at(index)); + waveformCnv.transToPers(data, pdata, log); + } + + log << MSG::DEBUG << "ScintWaveformContainerCnv_p0::transToPers finished" << endmsg; + +} diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv_p0.h b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv_p0.h new file mode 100644 index 00000000..6792e2a2 --- /dev/null +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv_p0.h @@ -0,0 +1,28 @@ +/* + Copyright 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef SCINTWAVEFORMCONTAINERCNV_P0_H +#define SCINTWAVEFORMCONTAINERCNV_P0_H + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" + +#include "ScintRawEvent/ScintWaveformContainer.h" +#include "ScintEventAthenaPool/ScintWaveformContainer_p0.h" + +class ScintWaveformContainerCnv_p0 : public T_AthenaPoolTPCnvBase<ScintWaveformContainer, ScintWaveformContainer_p0> { + + public: + ScintWaveformContainerCnv_p0() {}; + + virtual void persToTrans(const ScintWaveformContainer_p0* persCont, + ScintWaveformContainer* transCont, + MsgStream& log); + + virtual void transToPers(const ScintWaveformContainer* transCont, + ScintWaveformContainer_p0* persCont, + MsgStream& log); + +}; + +#endif diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainer_p0.cxx b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainer_p0.cxx new file mode 100644 index 00000000..7d047238 --- /dev/null +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainer_p0.cxx @@ -0,0 +1 @@ +// Dummy source file so that cmake can find this -- GitLab From 188bb23b3b7efc02da8441c78210ef034593e575 Mon Sep 17 00:00:00 2001 From: Eric Torrence <eric.torrence@cern.ch> Date: Fri, 11 Sep 2020 14:08:49 -0700 Subject: [PATCH 2/2] Add P->T conversion --- .../ScintEventAthenaPool/ScintWaveform_p0.h | 1 + .../src/ScintWaveformCnv_p0.cxx | 9 ++++--- .../src/ScintWaveformContainerCnv_p0.cxx | 24 +++++++++++++++++-- .../ScintRawEvent/ScintWaveform.h | 11 +++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintWaveform_p0.h b/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintWaveform_p0.h index b37fe284..e91c8811 100644 --- a/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintWaveform_p0.h +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/ScintEventAthenaPool/ScintWaveform_p0.h @@ -17,6 +17,7 @@ class ScintWaveform_p0 { friend class ScintWaveformCnv_p0; private: + unsigned int m_ID; unsigned int m_channel; std::vector<unsigned int> m_adc_counts; diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformCnv_p0.cxx b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformCnv_p0.cxx index b245674d..ffc6f0d8 100644 --- a/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformCnv_p0.cxx +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformCnv_p0.cxx @@ -7,8 +7,11 @@ void ScintWaveformCnv_p0::persToTrans(const ScintWaveform_p0* persObj, ScintWaveform* transObj, MsgStream& log) { - transObj = 0; - log << MSG::WARNING << "ScintWaveformCnv_p0::persToTrans not implemented!" << endmsg; + // Just fill available data here + // Rest of it patched up in ScintWaveformContainerCnv_p0 + transObj->setIdentifier(persObj->m_ID); + transObj->setChannel(persObj->m_channel); + transObj->setCounts(persObj->m_adc_counts); } @@ -20,7 +23,7 @@ ScintWaveformCnv_p0::transToPers(const ScintWaveform* transObj, ScintWaveform_p0 // log << MSG::DEBUG << (*transObj) << endmsg; // log << MSG::DEBUG << "Persistent waveform (before):" << endmsg; // persObj->print(); - + persObj->m_ID = transObj->identify(); persObj->m_channel = transObj->channel(); // Use copy here diff --git a/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv_p0.cxx b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv_p0.cxx index f808f108..4312a030 100644 --- a/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv_p0.cxx +++ b/Scintillator/ScintEventCnv/ScintEventAthenaPool/src/ScintWaveformContainerCnv_p0.cxx @@ -8,10 +8,30 @@ void ScintWaveformContainerCnv_p0::persToTrans(const ScintWaveformContainer_p0* persCont, ScintWaveformContainer* transCont, MsgStream& log) { - transCont = 0; - log << MSG::WARNING << "ScintWaveformContainerCnv_p0::persToTrans not implemented!" << endmsg; + log << MSG::DEBUG << "ScintWaveformContainerCnv_p0::persToTrans called" << endmsg; + ScintWaveformCnv_p0 waveformCnv; + + // Clear this, transient container is DataVector, which stores pointers + // Create them below and push back to fill + transCont->clear(); + for (unsigned int index = 0; index < persCont->m_waveforms.size(); ++index) { + std::unique_ptr<ScintWaveform> data = std::make_unique<ScintWaveform>(); + const ScintWaveform_p0* pdata = &persCont->m_waveforms.at(index); + waveformCnv.persToTrans(pdata, data.get(), log); + + // Fill other values held by container in persistent class + data->setBoardFailFlag(persCont->m_board_fail_flag); + data->setBoardId(persCont->m_board_id); + data->setPatternTrigOptions(persCont->m_pattern_trig_options); + data->setChannelMask(persCont->m_channel_mask); + data->setEventCounter(persCont->m_event_counter); + data->setTriggerTime(persCont->m_trigger_time_tag); + data->setSamples(persCont->m_samples); + + transCont->push_back(data.release()); + } } void diff --git a/Scintillator/ScintRawEvent/ScintRawEvent/ScintWaveform.h b/Scintillator/ScintRawEvent/ScintRawEvent/ScintWaveform.h index 0c211be6..c7598d44 100644 --- a/Scintillator/ScintRawEvent/ScintRawEvent/ScintWaveform.h +++ b/Scintillator/ScintRawEvent/ScintRawEvent/ScintWaveform.h @@ -73,6 +73,17 @@ public: void setHeader (const DigitizerDataFragment* frag); void setWaveform (unsigned int channel, const std::vector<uint16_t> waveform); + // Set functions for P->T conversion + void setBoardId(unsigned int id) {m_board_id = id;} + void setBoardFailFlag(bool flag) {m_board_fail_flag = flag;} + void setPatternTrigOptions(unsigned int pattern) {m_pattern_trig_options = pattern;} + void setChannelMask(unsigned int mask) {m_channel_mask = mask;} + void setEventCounter(unsigned int counter) {m_event_counter = counter;} + void setTriggerTime(unsigned int tag) {m_trigger_time_tag = tag;} + void setChannel(unsigned int chan) {m_channel = chan;} + void setSamples(unsigned int samp) {m_samples = samp;} + void setCounts(const std::vector<unsigned int>& counts) {m_adc_counts = counts;} + /////////////////////////////////////////////////////////////////// // Private data: /////////////////////////////////////////////////////////////////// -- GitLab