diff --git a/Scintillator/ScintRecAlgs/CMakeLists.txt b/Scintillator/ScintRecAlgs/CMakeLists.txt index e4f81b4bb479b955c4d26d396527f1c0c29529a2..1cc6650e6e5c8dc724fe7cd929c781c3eb4192aa 100644 --- a/Scintillator/ScintRecAlgs/CMakeLists.txt +++ b/Scintillator/ScintRecAlgs/CMakeLists.txt @@ -9,7 +9,7 @@ atlas_subdir( ScintRecAlgs ) atlas_add_component( ScintRecAlgs src/*.cxx src/*.h src/components/*.cxx - LINK_LIBRARIES AthenaBaseComps StoreGateLib ScintRawEvent ScintRecEvent ScintRecToolsLib ) + LINK_LIBRARIES AthenaBaseComps StoreGateLib ScintRawEvent ScintRecEvent xAODFaserWaveform ScintRecToolsLib ) #atlas_install_python_modules( python/*.py ) diff --git a/Scintillator/ScintRecAlgs/src/ScintClockRecAlg.cxx b/Scintillator/ScintRecAlgs/src/ScintClockRecAlg.cxx index cbdb8521e650bc095856ec4e8f3ec824b0ff36bf..45ceaa30ba91d814072a02d312755d03d3bd1b85 100644 --- a/Scintillator/ScintRecAlgs/src/ScintClockRecAlg.cxx +++ b/Scintillator/ScintRecAlgs/src/ScintClockRecAlg.cxx @@ -53,8 +53,11 @@ ScintClockRecAlg::execute(const EventContext& ctx) const { } // Create the output clock container - SG::WriteHandle<WaveformClock> clockHandle(m_waveformClockKey, ctx); - ATH_CHECK( clockHandle.record( std::make_unique<WaveformClock>() ) ); + SG::WriteHandle<xAOD::WaveformClock> clockHandle(m_waveformClockKey, ctx); + //ATH_CHECK( clockHandle.record( std::make_unique<WaveformClock>() ) ); + ATH_CHECK( clockHandle.record( std::make_unique<xAOD::WaveformClock>(), + std::make_unique<xAOD::WaveformClockAuxInfo>() ) ); + auto clock = clockHandle.ptr(); // Reconstruct first element diff --git a/Scintillator/ScintRecAlgs/src/ScintClockRecAlg.h b/Scintillator/ScintRecAlgs/src/ScintClockRecAlg.h index ea0ac1db4336363892ed8e5b4b9ae96af7449ff5..8fb3555514a9711216fd35bef59859bfc42d97d5 100644 --- a/Scintillator/ScintRecAlgs/src/ScintClockRecAlg.h +++ b/Scintillator/ScintRecAlgs/src/ScintClockRecAlg.h @@ -8,8 +8,9 @@ #include "ScintRawEvent/ScintWaveformContainer.h" // Output data -#include "ScintRecEvent/WaveformClock.h" - +// #include "ScintRecEvent/WaveformClock.h" +#include "xAODFaserWaveform/WaveformClock.h" +#include "xAODFaserWaveform/WaveformClockAuxInfo.h" #include "ScintRecTools/IClockReconstructionTool.h" #include "StoreGate/ReadHandleKey.h" @@ -62,7 +63,7 @@ class ScintClockRecAlg : public AthReentrantAlgorithm { * @name Output data using SG::WriteHandleKey */ //@{ - SG::WriteHandleKey<WaveformClock> m_waveformClockKey + SG::WriteHandleKey<xAOD::WaveformClock> m_waveformClockKey {this, "WaveformClockKey", "LHCClockData"}; //@} diff --git a/Scintillator/ScintRecTools/CMakeLists.txt b/Scintillator/ScintRecTools/CMakeLists.txt index 7befc0e44e30e254232eb8f269f5663d3de7b15c..285298d61bfdf5ade63179faba730bab840b14d5 100644 --- a/Scintillator/ScintRecTools/CMakeLists.txt +++ b/Scintillator/ScintRecTools/CMakeLists.txt @@ -13,7 +13,7 @@ atlas_add_library( ScintRecToolsLib ScintRecTools/*.h src/*.cxx src/*.h PUBLIC_HEADERS ScintRecTools PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES AthenaBaseComps AthenaKernel GeoPrimitives ScintRawEvent ScintRecEvent + LINK_LIBRARIES AthenaBaseComps AthenaKernel GeoPrimitives ScintRawEvent ScintRecEvent xAODFaserWaveform PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} ) diff --git a/Scintillator/ScintRecTools/ScintRecTools/IClockReconstructionTool.h b/Scintillator/ScintRecTools/ScintRecTools/IClockReconstructionTool.h index 4ed97e93e23bb98876b7a0e6cf75eec4608b8432..46712a75ca41eceabf1331fd2ae1412d9f7f429b 100644 --- a/Scintillator/ScintRecTools/ScintRecTools/IClockReconstructionTool.h +++ b/Scintillator/ScintRecTools/ScintRecTools/IClockReconstructionTool.h @@ -16,8 +16,9 @@ #include "GaudiKernel/IAlgTool.h" #include "GaudiKernel/ToolHandle.h" +#include "xAODFaserWaveform/WaveformClock.h" + class ScintWaveform; -class WaveformClock; ///Interface for Clock reco algorithms class IClockReconstructionTool : virtual public IAlgTool @@ -31,7 +32,7 @@ class IClockReconstructionTool : virtual public IAlgTool // Reconstruct all peaks in a raw waveform virtual StatusCode reconstruct(const ScintWaveform& wave, - WaveformClock* clockdata) const = 0; + xAOD::WaveformClock* clockdata) const = 0; }; diff --git a/Scintillator/ScintRecTools/src/ClockReconstructionTool.cxx b/Scintillator/ScintRecTools/src/ClockReconstructionTool.cxx index 9e9743d9ef42c3eadbd7d70b3ac81e7b37295221..4c065eff5e21993315c65b4cc31202274fe7f3d7 100644 --- a/Scintillator/ScintRecTools/src/ClockReconstructionTool.cxx +++ b/Scintillator/ScintRecTools/src/ClockReconstructionTool.cxx @@ -31,7 +31,7 @@ ClockReconstructionTool::initialize() { // Reconstruction step StatusCode ClockReconstructionTool::reconstruct(const ScintWaveform& raw_wave, - WaveformClock* clockdata) const { + xAOD::WaveformClock* clockdata) const { ATH_MSG_DEBUG("Clock reconstruct called "); @@ -42,8 +42,8 @@ ClockReconstructionTool::reconstruct(const ScintWaveform& raw_wave, } // Set the trigger time - clockdata->setTriggerTime(raw_wave.trigger_time_tag()); - ATH_MSG_DEBUG("Trigger time: " << raw_wave.trigger_time_tag()); + //clockdata->setTriggerTime(raw_wave.trigger_time_tag()); + //ATH_MSG_DEBUG("Trigger time: " << raw_wave.trigger_time_tag()); // Digitized clock data, sampled at 500 MHz (2 ns) auto counts = raw_wave.adc_counts(); @@ -54,8 +54,8 @@ ClockReconstructionTool::reconstruct(const ScintWaveform& raw_wave, wave.assign(counts.begin(), counts.end()); ATH_MSG_DEBUG("Created double array with length " << wave.size() ); - ATH_MSG_DEBUG("First 20 elements:"); - for (unsigned int i=0; i< 20; i++) + ATH_MSG_DEBUG("First 10 elements:"); + for (unsigned int i=0; i< 10; i++) ATH_MSG_DEBUG(" " << i << " " << wave[i]); // delta_nu = 1/T where T is the total waveform length @@ -93,12 +93,11 @@ ClockReconstructionTool::reconstruct(const ScintWaveform& raw_wave, } // Store results - double avg = magnitude[0]; - double freq = imax * freqmult; - double amp = magnitude[imax]; - double phase = atan2(im_full[imax], re_full[imax]); - clockdata->setParams(avg, freq, amp, phase); - + clockdata->set_offset(magnitude[0]); + clockdata->set_frequency(imax * freqmult); + clockdata->set_amplitude(magnitude[imax]); + clockdata->set_phase(atan2(im_full[imax], re_full[imax])); + ATH_MSG_DEBUG("Before correcting for finite resolution:"); ATH_MSG_DEBUG(*clockdata); @@ -115,19 +114,19 @@ ClockReconstructionTool::reconstruct(const ScintWaveform& raw_wave, ATH_MSG_DEBUG("Found shift in frequency index: " << dm); // Improved values - freq = (imax+dm) * freqmult; - phase = atan2(im_full[imax], re_full[imax]) - dm * M_PI; + + double phase = atan2(im_full[imax], re_full[imax]) - dm * M_PI; // Fix any overflows if (phase < M_PI) phase += (2*M_PI); if (phase > M_PI) phase -= (2*M_PI); - amp = 2*M_PI*dm*magnitude[imax] / sin(M_PI * dm); - clockdata->setParams(avg, freq, amp, phase); + clockdata->set_frequency( (imax+dm) * freqmult ); + clockdata->set_phase (phase); + clockdata->set_amplitude( 2*M_PI*dm*magnitude[imax] / sin(M_PI * dm) ); ATH_MSG_DEBUG("After correcting for finite resolution:"); ATH_MSG_DEBUG(*clockdata); - delete fftr2c; return StatusCode::SUCCESS; diff --git a/Scintillator/ScintRecTools/src/ClockReconstructionTool.h b/Scintillator/ScintRecTools/src/ClockReconstructionTool.h index 3d04d5ef29d37e5875e87a48ff9f187921fae10e..c0f667524ec5767ec01e48c081b9da82d1e3de1d 100644 --- a/Scintillator/ScintRecTools/src/ClockReconstructionTool.h +++ b/Scintillator/ScintRecTools/src/ClockReconstructionTool.h @@ -14,7 +14,8 @@ #include "ScintRecTools/IClockReconstructionTool.h" #include "ScintRawEvent/ScintWaveform.h" -#include "ScintRecEvent/WaveformClock.h" +//#include "ScintRecEvent/WaveformClock.h" +#include "xAODFaserWaveform/WaveformClock.h" //Gaudi #include "GaudiKernel/ToolHandle.h" @@ -35,7 +36,7 @@ class ClockReconstructionTool: public extends<AthAlgTool, IClockReconstructionTo /// Reconstruct hits from clock virtual StatusCode reconstruct(const ScintWaveform& wave, - WaveformClock* clockdata) const; + xAOD::WaveformClock* clockdata) const; private: diff --git a/xAOD/xAODFaserWaveform/Root/WaveformClock_v1.cxx b/xAOD/xAODFaserWaveform/Root/WaveformClock_v1.cxx index 6a3128d028e883fb25d8b17a8fe012b064241828..b875b468fb2a648f88c754d19fd0c7d47df6927c 100644 --- a/xAOD/xAODFaserWaveform/Root/WaveformClock_v1.cxx +++ b/xAOD/xAODFaserWaveform/Root/WaveformClock_v1.cxx @@ -27,6 +27,9 @@ namespace xAOD { std::ostream& operator<<(std::ostream& s, const xAOD::WaveformClock_v1& clk) { s << "xAODWaveformClock: frequency=" << clk.frequency() + << " phase=" << clk.phase() + << " amplitude=" << clk.amplitude() + << " offset=" << clk.offset() << std::endl; return s; diff --git a/xAOD/xAODFaserWaveform/xAODFaserWaveform/versions/WaveformClock_v1.h b/xAOD/xAODFaserWaveform/xAODFaserWaveform/versions/WaveformClock_v1.h index 2d70b976d01ed425da8fa33c50ec04370a6e67e0..3fffe41c1feafe17cddb5195b3e4a727a355a4f9 100644 --- a/xAOD/xAODFaserWaveform/xAODFaserWaveform/versions/WaveformClock_v1.h +++ b/xAOD/xAODFaserWaveform/xAODFaserWaveform/versions/WaveformClock_v1.h @@ -46,7 +46,9 @@ namespace xAOD { }; // class WaveformClock_v1 -} + std::ostream& operator<<(std::ostream& s, const xAOD::WaveformClock_v1& clk); + +} // namespace xAOD // Declare the inheritance of the type: #include "xAODCore/BaseInfo.h" diff --git a/xAOD/xAODFaserWaveform/xAODFaserWaveform/xAODFaserWaveformDict.h b/xAOD/xAODFaserWaveform/xAODFaserWaveform/xAODFaserWaveformDict.h index 6ba4a1abdd1ecc915ad09292a8c0e975136a778e..5bb2eceb5665288f05ed3481de0d201d825989ff 100644 --- a/xAOD/xAODFaserWaveform/xAODFaserWaveform/xAODFaserWaveformDict.h +++ b/xAOD/xAODFaserWaveform/xAODFaserWaveform/xAODFaserWaveformDict.h @@ -27,7 +27,7 @@ namespace { struct GCCXML_DUMMY_INSTANTIATION_XAODFASERWAVEFORM { XAOD_INSTANTIATE_NS_CONTAINER_TYPES( xAOD, WaveformHitContainer_v1 ); XAOD_INSTANTIATE_NS_OBJECT_TYPES( xAOD, WaveformClock_v1 ); - } + }; } #endif // XAODFASERWAVEFORM_XAODFASERWAVEFORMDICT_H diff --git a/xAOD/xAODFaserWaveformAthenaPool/CMakeLists.txt b/xAOD/xAODFaserWaveformAthenaPool/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..3df3443af54cbf329ed56730645f27a44458d760 --- /dev/null +++ b/xAOD/xAODFaserWaveformAthenaPool/CMakeLists.txt @@ -0,0 +1,14 @@ +# Copyright (C) 2020 CERN for the benefit of the FASER collaboration + +# Declare the package name. +atlas_subdir( xAODFaserWaveformAthenaPool ) + +# Component(s) in the package: +atlas_add_poolcnv_library( xAODFaserWaveformAthenaPoolPoolCnv + src/*.h src/*.cxx + FILES xAODFaserWaveform/WaveformClock.h xAODFaserWaveform/WaveformClockAuxInfo.h + TYPES_WITH_NAMESPACE xAOD::WaveformClock xAOD::WaveformClockAuxInfo + CNV_PFX xAOD + LINK_LIBRARIES AthenaPoolCnvSvcLib AthenaPoolUtilities xAODFaserWaveform ) + + diff --git a/xAOD/xAODFaserWaveformAthenaPool/src/xAODWaveformClockAuxInfoCnv.cxx b/xAOD/xAODFaserWaveformAthenaPool/src/xAODWaveformClockAuxInfoCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2ae9467033ddabd5b6c0e0fab94a5fb20c9c99de --- /dev/null +++ b/xAOD/xAODFaserWaveformAthenaPool/src/xAODWaveformClockAuxInfoCnv.cxx @@ -0,0 +1,5 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +// Dummy source file so that cmake will know this is a custom converter. diff --git a/xAOD/xAODFaserWaveformAthenaPool/src/xAODWaveformClockAuxInfoCnv.h b/xAOD/xAODFaserWaveformAthenaPool/src/xAODWaveformClockAuxInfoCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..5ac8b4c0db48ff15f3647f71f37f072682e55fa8 --- /dev/null +++ b/xAOD/xAODFaserWaveformAthenaPool/src/xAODWaveformClockAuxInfoCnv.h @@ -0,0 +1,15 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERWAVEFORMATHENAPOOL_XAODWAVEFORMCLOCKAUXINFOCNV_H +#define XAODFASERWAVEFORMATHENAPOOL_XAODWAVEFORMCLOCKAUXINFOCNV_H + +#include "xAODFaserWaveform/WaveformClockAuxInfo.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolAuxContainerCnv.h" + +typedef T_AthenaPoolAuxContainerCnv<xAOD::WaveformClockAuxInfo> xAODWaveformClockAuxInfoCnv; + +#endif // XAODFASERWAVEFORMATHENAPOOL_XAODFASERWAVEFORMCLOCKAUXINFOCNV_H diff --git a/xAOD/xAODFaserWaveformAthenaPool/src/xAODWaveformClockCnv.cxx b/xAOD/xAODFaserWaveformAthenaPool/src/xAODWaveformClockCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2ae9467033ddabd5b6c0e0fab94a5fb20c9c99de --- /dev/null +++ b/xAOD/xAODFaserWaveformAthenaPool/src/xAODWaveformClockCnv.cxx @@ -0,0 +1,5 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +// Dummy source file so that cmake will know this is a custom converter. diff --git a/xAOD/xAODFaserWaveformAthenaPool/src/xAODWaveformClockCnv.h b/xAOD/xAODFaserWaveformAthenaPool/src/xAODWaveformClockCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..2f591d164011f6ec3c4e83b5a89d55b0fc725c68 --- /dev/null +++ b/xAOD/xAODFaserWaveformAthenaPool/src/xAODWaveformClockCnv.h @@ -0,0 +1,15 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERWAVEFORMATHENAPOOL_XAODWAVEFORMCLOCKCNV_H +#define XAODFASERWAVEFORMATHENAPOOL_XAODWAVEFORMCLOCKCNV_H + +#include "xAODFaserWaveform/WaveformClock.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolxAODCnv.h" + +typedef T_AthenaPoolxAODCnv<xAOD::WaveformClock> xAODWaveformClockCnv; + +#endif // XAODFASERWAVEFORMATHENAPOOL_XAODWAVEFORMCLOCKCNV_H