diff --git a/Calorimeter/CaloRecAlgs/CMakeLists.txt b/Calorimeter/CaloRecAlgs/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..219db92a3a8927ae9cc025bea46985387e072ce0 --- /dev/null +++ b/Calorimeter/CaloRecAlgs/CMakeLists.txt @@ -0,0 +1,15 @@ +################################################################################ +# Package: CaloRecAlgs +################################################################################ + +# Declare the package name: +atlas_subdir( CaloRecAlgs ) + +# Component(s) in the package: +atlas_add_component( CaloRecAlgs + src/*.cxx src/*.h + src/components/*.cxx + LINK_LIBRARIES AthenaBaseComps StoreGateLib xAODFaserCalorimeter xAODFaserWaveform) + +atlas_install_python_modules( python/*.py ) + diff --git a/Calorimeter/CaloRecAlgs/python/CaloRecAlgsConfig.py b/Calorimeter/CaloRecAlgs/python/CaloRecAlgsConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..034bf08b5b36a4620567f6716eca5d31338a1c04 --- /dev/null +++ b/Calorimeter/CaloRecAlgs/python/CaloRecAlgsConfig.py @@ -0,0 +1,41 @@ +""" Define methods used to instantiate configured Waveform reconstruction tools and algorithms + +Copyright (C) 2020 CERN for the benefit of the FASER collaboration +""" +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory + +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg + +#CalorimeterReconstructionTool = CompFactory.CalorimeterReconstructionTool + +# One stop shopping for normal FASER data +def CalorimeterReconstructionCfg(flags, **kwargs): + """ Return all algorithms and tools for Waveform reconstruction """ + acc = ComponentAccumulator() + + #tool = CalorimeterReconstructionTool(name="CaloRecTool", **kwargs) + + kwargs.setdefault("CaloWaveHitContainerKey", "CaloWaveformHits") + kwargs.setdefault("PreshowerWaveHitContainerKey", "PreshowerWaveformHits") + kwargs.setdefault("CaloHitContainerKey", "CaloHits") + #kwargs.setdefault("CalorimeterReconstructionTool", tool) + + recoAlg = CompFactory.CaloRecAlg("CaloRecAlg", **kwargs) + #recoAlg.CalorimeterReconstructionTool = tool + acc.addEventAlgo(recoAlg) + + return acc + +def CalorimeterReconstructionOutputCfg(flags, **kwargs): + """ Return ComponentAccumulator with output for Calorimeter Reco""" + acc = ComponentAccumulator() + ItemList = [ + "xAOD::CalorimeterHitContainer#*" + , "xAOD::CalorimeterHitAuxContainer#*" + ] + acc.merge(OutputStreamCfg(flags, "xAOD", ItemList)) + # ostream = acc.getEventAlgo("OutputStreamRDO") + # ostream.TakeItemsFromInput = True # Don't know what this does + return acc + diff --git a/Calorimeter/CaloRecAlgs/src/CaloRecAlg.cxx b/Calorimeter/CaloRecAlgs/src/CaloRecAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4b4d6f158f29478a60443381c5292d254d1c665f --- /dev/null +++ b/Calorimeter/CaloRecAlgs/src/CaloRecAlg.cxx @@ -0,0 +1,123 @@ +#include "CaloRecAlg.h" + +CaloRecAlg::CaloRecAlg(const std::string& name, + ISvcLocator* pSvcLocator) + : AthReentrantAlgorithm(name, pSvcLocator) { + +} + +StatusCode +CaloRecAlg::initialize() { + ATH_MSG_INFO(name() << "::initalize()" ); + + // Initalize tools + //ATH_CHECK( m_recoTool.retrieve() ); + + // Set key to read calo hits from + ATH_CHECK( m_caloWaveHitContainerKey.initialize() ); + + // Set key to read preshower hits from + ATH_CHECK( m_preshowerWaveHitContainerKey.initialize() ); + + // Set key to write container + ATH_CHECK( m_caloHitContainerKey.initialize() ); + + return StatusCode::SUCCESS; +} + +StatusCode +CaloRecAlg::finalize() { + ATH_MSG_INFO(name() << "::finalize()"); + + return StatusCode::SUCCESS; +} + +StatusCode +CaloRecAlg::execute(const EventContext& ctx) const { + ATH_MSG_DEBUG("Executing"); + + ATH_MSG_DEBUG("Run: " << ctx.eventID().run_number() + << " Event: " << ctx.eventID().event_number()); + + // Find the input waveform hit containers + SG::ReadHandle<xAOD::WaveformHitContainer> caloWaveHitHandle(m_caloWaveHitContainerKey, ctx); + + ATH_CHECK( caloWaveHitHandle.isValid() ); + ATH_MSG_DEBUG("Found ReadHandle for WaveformHitContainer " << m_caloWaveHitContainerKey); + + if (caloWaveHitHandle->size() == 0) { + ATH_MSG_DEBUG("Calorimeter Waveform Hit container found with zero length!"); + } + + SG::ReadHandle<xAOD::WaveformHitContainer> preshowerWaveHitHandle(m_preshowerWaveHitContainerKey, ctx); + + ATH_CHECK( preshowerWaveHitHandle.isValid() ); + ATH_MSG_DEBUG("Found ReadHandle for WaveformHitContainer " << m_preshowerWaveHitContainerKey); + + if (preshowerWaveHitHandle->size() == 0) { + ATH_MSG_DEBUG("Preshower Waveform Hit container found with zero length!"); + } + + // Find the output waveform container + SG::WriteHandle<xAOD::CalorimeterHitContainer> caloHitContainerHandle(m_caloHitContainerKey, ctx); + ATH_CHECK( caloHitContainerHandle.record( std::make_unique<xAOD::CalorimeterHitContainer>(), + std::make_unique<xAOD::CalorimeterHitAuxContainer>() ) ); + + ATH_MSG_DEBUG("WaveformsHitContainer '" << caloHitContainerHandle.name() << "' initialized"); + + // Reconstruct all waveforms + //CHECK( m_recoTool->reconstructAll(*waveformHandle, clockptr, hitContainerHandle.ptr()) ); + + // Find peak time (most significant hit) + const xAOD::WaveformHit* peakHit = findPeakHit(*caloWaveHitHandle); + if (peakHit == NULL) return StatusCode::SUCCESS; + + // Create a new calo hit + xAOD::CalorimeterHit* calo_hit = new xAOD::CalorimeterHit(); + caloHitContainerHandle->push_back(calo_hit); + + calo_hit->set_raw_energy(-1.); // Dummy value + + // Find closest hits in time per channel + std::map<int, const xAOD::WaveformHit*> hitMap; + for ( const auto& hit : *caloWaveHitHandle ) { + int channel = hit->channel(); + if (hitMap.count(channel) == 0) + hitMap[channel] = hit; + else { + if (abs(hitMap[channel]->localtime() - peakHit->localtime()) > + abs(hit->localtime() - peakHit->localtime())) + hitMap[channel] = hit; + } + } + + // For each hit found, insert these into the caloHit + // Clear before association + calo_hit->clearCaloWaveformLinks(); + for ( const auto& [chan, hit] : hitMap ) { + ATH_MSG_VERBOSE("Found hit " << *hit); + calo_hit->addCaloHit(caloWaveHitHandle.get(), hit); + } + + ATH_MSG_DEBUG("CaloHitContainer '" << caloHitContainerHandle.name() << "' filled with "<< caloHitContainerHandle->size() <<" items"); + + return StatusCode::SUCCESS; +} + +const xAOD::WaveformHit* +CaloRecAlg::findPeakHit(const xAOD::WaveformHitContainer& hitContainer) const { + + const xAOD::WaveformHit* peakHit = NULL; + for( const auto& hit : hitContainer ) { + if (peakHit == NULL) { + peakHit = hit; + } else { + if ( hit->peak() > peakHit->peak() ) peakHit = hit; + } + } + + // Didn't find anything? + if (peakHit == NULL) return NULL; + if (peakHit->status_bit(xAOD::WaveformStatus::THRESHOLD_FAILED)) return NULL; + return peakHit; +} diff --git a/Calorimeter/CaloRecAlgs/src/CaloRecAlg.h b/Calorimeter/CaloRecAlgs/src/CaloRecAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..bd98e9afd6b693b8cc4518ebd87ddd72207fddef --- /dev/null +++ b/Calorimeter/CaloRecAlgs/src/CaloRecAlg.h @@ -0,0 +1,83 @@ +#ifndef CALORECALGS_CALORECALG_H +#define CALORECALGS_CALORECALG_H + +// Base class +#include "AthenaBaseComps/AthReentrantAlgorithm.h" + +// Data classes +#include "xAODFaserWaveform/WaveformHitContainer.h" + +#include "xAODFaserCalorimeter/CalorimeterHit.h" +#include "xAODFaserCalorimeter/CalorimeterHitContainer.h" +#include "xAODFaserCalorimeter/CalorimeterHitAuxContainer.h" + +// Tool classes +//#include "CaloRecTools/ICalorimeterReconstructionTool.h" + +// Handles +#include "StoreGate/ReadHandleKey.h" +#include "StoreGate/WriteHandleKey.h" + +// Gaudi +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" + +// STL +#include <string> + +class CaloRecAlg : public AthReentrantAlgorithm { + + public: + // Constructor + CaloRecAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~CaloRecAlg() = default; + + /** @name Usual algorithm methods */ + //@{ + virtual StatusCode initialize() override; + virtual StatusCode execute(const EventContext& ctx) const override; + virtual StatusCode finalize() override; + //@} + + private: + + /** @name Disallow default instantiation, copy, assignment */ + //@{ + CaloRecAlg() = delete; + CaloRecAlg(const CaloRecAlg&) = delete; + CaloRecAlg &operator=(const CaloRecAlg&) = delete; + //@} + + /** + * @name Reconstruction tool + */ + //ToolHandle<ICalorimeterReconstructionTool> m_recoTool + //{this, "CalorimeterReconstructionTool", "CalorimeterReconstructionTool"}; + + /** + * @name Input raw waveform data using SG::ReadHandleKey + */ + //@{ + SG::ReadHandleKey<xAOD::WaveformHitContainer> m_caloWaveHitContainerKey + {this, "CaloWaveHitContainerKey", ""}; + //@} + + //@{ + SG::ReadHandleKey<xAOD::WaveformHitContainer> m_preshowerWaveHitContainerKey + {this, "PreshowerWaveHitContainerKey", ""}; + //@} + + /** + * @name Output data using SG::WriteHandleKey + */ + //@{ + SG::WriteHandleKey<xAOD::CalorimeterHitContainer> m_caloHitContainerKey + {this, "CaloHitContainerKey", ""}; + //@} + + const xAOD::WaveformHit* + findPeakHit(const xAOD::WaveformHitContainer& hitContainer) const; + +}; + +#endif // CALORECALGS_CALORECALG_H diff --git a/Calorimeter/CaloRecAlgs/src/components/CaloRecAlgs_entries.cxx b/Calorimeter/CaloRecAlgs/src/components/CaloRecAlgs_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..bf444d88011c857e2273ba392269cc2fb943c31a --- /dev/null +++ b/Calorimeter/CaloRecAlgs/src/components/CaloRecAlgs_entries.cxx @@ -0,0 +1,3 @@ +#include "../CaloRecAlg.h" + +DECLARE_COMPONENT( CaloRecAlg ) diff --git a/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py b/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py index 7671d13755f37e945b679796a15cb69f5d7aba98..7c1f662f4cfdad38026a90a7c01c82e834a0ef01 100755 --- a/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py +++ b/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py @@ -123,6 +123,10 @@ acc.merge(FaserGeometryCfg(ConfigFlags)) from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionCfg acc.merge(WaveformReconstructionCfg(ConfigFlags)) +# Not ready for primetime +# from CaloRecAlgs.CaloRecAlgsConfig import CalorimeterReconstructionCfg +# acc.merge(CalorimeterReconstructionCfg(ConfigFlags)) + # Tracker clusters from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) @@ -154,6 +158,10 @@ acc.merge(OutputStreamCfg(ConfigFlags, "xAOD", itemList)) from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionOutputCfg acc.merge(WaveformReconstructionOutputCfg(ConfigFlags)) +# Calorimeter reconstruction output +# from CaloRecAlgs.CaloRecAlgsConfig import CalorimeterReconstructionOutputCfg +# acc.merge(CalorimeterReconstructionOutputCfg(ConfigFlags)) + # Check what we have print( "Writing out xAOD objects:" ) print( acc.getEventAlgo("OutputStreamxAOD").ItemList ) diff --git a/Waveform/WaveRecTools/src/WaveformReconstructionTool.cxx b/Waveform/WaveRecTools/src/WaveformReconstructionTool.cxx index 69a1d2be1f1b4a9dae3f230bf9c9a4915d3b18fe..2198890dbc1a69e66a90ca0bc047980c41ba907b 100644 --- a/Waveform/WaveRecTools/src/WaveformReconstructionTool.cxx +++ b/Waveform/WaveRecTools/src/WaveformReconstructionTool.cxx @@ -658,7 +658,12 @@ WaveformReconstructionTool::findRawHitValues(const std::vector<float> time, cons rfit.integral = 2*tot; // Factor of 2 because at 500 MHz, dt = 2 ns rfit.time = rfit.mean; - ATH_MSG_DEBUG( "Initial Mean: " << rfit.mean << " RMS: " << rfit.sigma << " Peak: " << rfit.peak << " Integral: " << rfit.integral); + ATH_MSG_DEBUG( + "Initial Mean: " << rfit.mean + << " RMS: " << rfit.sigma + << " Peak: " << rfit.peak + << " Integral: " << rfit.integral + ); // Fix bad values if (isnan(rfit.sigma)) { @@ -666,6 +671,12 @@ WaveformReconstructionTool::findRawHitValues(const std::vector<float> time, cons rfit.sigma = 2.; } + if (rfit.mean < time.front() || rfit.mean > time.back()) { + rfit.mean = (3*time.front() + time.back())/4.; // Set time to 1/4 of way through window + ATH_MSG_DEBUG("Found mean: " << rfit.time << " out of range " << time.front() << "-" << time.back() << " Replace with " << rfit.mean); + rfit.time = rfit.mean; + } + return rfit; } diff --git a/Waveform/WaveRecTools/src/WaveformReconstructionTool.h b/Waveform/WaveRecTools/src/WaveformReconstructionTool.h index e7e61205f62af237aacaa2d7b8f803638856d7b0..7a39f883434051173099d3702e9643fb64cc9f51 100644 --- a/Waveform/WaveRecTools/src/WaveformReconstructionTool.h +++ b/Waveform/WaveRecTools/src/WaveformReconstructionTool.h @@ -84,8 +84,8 @@ class WaveformReconstructionTool: public extends<AthAlgTool, IWaveformReconstruc // // Window to define fitting range, in samples (2ns/sample) - IntegerProperty m_windowStart{this, "FitWindowStart", -10}; - IntegerProperty m_windowWidth{this, "FitWindowWidth", 50}; + IntegerProperty m_windowStart{this, "FitWindowStart", -15}; + IntegerProperty m_windowWidth{this, "FitWindowWidth", 60}; // // Remove overflow values from CB fit diff --git a/xAOD/xAODFaserCalorimeter/CMakeLists.txt b/xAOD/xAODFaserCalorimeter/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ec4c8c09788e92fb799c2e5119ad6c1a9a626454 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (C) 2020 CERN for the benefit of the FASER collaboration + +# Declare the package name. +atlas_subdir( xAODFaserCalorimeter ) + +# External dependencies. +find_package( xAODUtilities ) + +# Component(s) in the package. +atlas_add_library( xAODFaserCalorimeter + xAODFaserCalorimeter/*.h xAODFaserCalorimeter/versions/*.h Root/*.cxx + PUBLIC_HEADERS xAODFaserCalorimeter + LINK_LIBRARIES Identifier xAODCore xAODFaserWaveform ) + +atlas_add_xaod_smart_pointer_dicts( + INPUT xAODFaserCalorimeter/selection.xml + OUTPUT _selectionFile + CONTAINERS "xAOD::CalorimeterHitContainer_v1") + +atlas_add_dictionary( xAODFaserCalorimeterDict + xAODFaserCalorimeter/xAODFaserCalorimeterDict.h + ${_selectionFile} + LINK_LIBRARIES Identifier xAODCore xAODFaserCalorimeter + EXTRA_FILES Root/dict/*.cxx ) + diff --git a/xAOD/xAODFaserCalorimeter/README b/xAOD/xAODFaserCalorimeter/README new file mode 100644 index 0000000000000000000000000000000000000000..02dcfa45e9fafa3fa8edb77dbba4158f5ac09d59 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/README @@ -0,0 +1,2 @@ +ElementLinks added following DiTauJet example here: +https://gitlab.cern.ch/atlas/athena/-/tree/master/Event/xAOD/xAODTau \ No newline at end of file diff --git a/xAOD/xAODFaserCalorimeter/Root/CalorimeterHitAuxContainer_v1.cxx b/xAOD/xAODFaserCalorimeter/Root/CalorimeterHitAuxContainer_v1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6f6edf3e4c520dbf32bb816addb74f4ad3eae23f --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/Root/CalorimeterHitAuxContainer_v1.cxx @@ -0,0 +1,21 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +// Local include(s): +#include "xAODFaserCalorimeter/versions/CalorimeterHitAuxContainer_v1.h" + +namespace xAOD { + + CalorimeterHitAuxContainer_v1::CalorimeterHitAuxContainer_v1() + : AuxContainerBase() { + + AUX_VARIABLE(localtime); + AUX_VARIABLE(bcid_time); + AUX_VARIABLE(raw_energy); + + AUX_VARIABLE(caloLinks); + } + +} // namespace xAOD + diff --git a/xAOD/xAODFaserCalorimeter/Root/CalorimeterHit_v1.cxx b/xAOD/xAODFaserCalorimeter/Root/CalorimeterHit_v1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5e7a69ecc024dc3ecb70df95f1e623c4bc4e09fc --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/Root/CalorimeterHit_v1.cxx @@ -0,0 +1,67 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +// EDM include(s): +#include "xAODCore/AuxStoreAccessorMacros.h" + +// Local include(s): +#include "xAODFaserCalorimeter/versions/CalorimeterHit_v1.h" + +namespace xAOD { + + CalorimeterHit_v1::CalorimeterHit_v1() : SG::AuxElement() { + } + + AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( CalorimeterHit_v1, float, localtime, set_localtime ) + + AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( CalorimeterHit_v1, float, bcidtime, set_bcidtime ) + + AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( CalorimeterHit_v1, float, raw_energy, set_raw_energy ) + + // setters and getters for the Calo WaveformHit links + + AUXSTORE_OBJECT_SETTER_AND_GETTER( CalorimeterHit_v1, + CalorimeterHit_v1::WaveformHitLinks_t, + caloWaveformLinks, + setCaloWaveformLinks ) + + static const SG::AuxElement::Accessor< CalorimeterHit_v1::WaveformHitLinks_t > caloHitAcc( "caloWaveformLinks" ); + + const WaveformHit* CalorimeterHit_v1::caloHit( size_t i ) const { + return ( *caloHitAcc( *this )[ i ] ); + } + + size_t CalorimeterHit_v1::nCaloHits() const { + return caloHitAcc( *this ).size(); + } + + void CalorimeterHit_v1::addCaloHit( const xAOD::WaveformHitContainer* pWaveformHitContainer, + const xAOD::WaveformHit* pWaveformHit) { + ElementLink< xAOD::WaveformHitContainer > linkToWaveformHit; + linkToWaveformHit.toContainedElement(*pWaveformHitContainer, pWaveformHit); + + caloHitAcc( *this ).push_back( linkToWaveformHit ); + + return; + } + + void CalorimeterHit_v1::clearCaloWaveformLinks() { + caloHitAcc( *this ).clear(); + return; + } + +} // namespace xAOD + +namespace xAOD { + + std::ostream& operator<<(std::ostream& s, const xAOD::CalorimeterHit_v1& hit) { + s << "xAODCalorimeterHit:" + << " local time=" << hit.localtime() + << " raw_energy=" << hit.raw_energy() + << std::endl; + + return s; + } + +} // namespace xAOD diff --git a/xAOD/xAODFaserCalorimeter/Root/dict/ContainerProxies.cxx b/xAOD/xAODFaserCalorimeter/Root/dict/ContainerProxies.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8d2cc883ca49d230cc66fdfcab9dedf0112e30eb --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/Root/dict/ContainerProxies.cxx @@ -0,0 +1,8 @@ +// EDM include(s): +#include "xAODCore/AddDVProxy.h" + +// Local include(s): +#include "xAODFaserCalorimeter/CalorimeterHitContainer.h" + +// Set up the collection proxies: +ADD_NS_DV_PROXY( xAOD, CalorimeterHitContainer ); diff --git a/xAOD/xAODFaserCalorimeter/Root/xAODFaserCalorimeterCLIDs.cxx b/xAOD/xAODFaserCalorimeter/Root/xAODFaserCalorimeterCLIDs.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b98755185832080df8e8e60165c5f98c1e68bcf6 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/Root/xAODFaserCalorimeterCLIDs.cxx @@ -0,0 +1,8 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +//simple includes to force the CLASS_DEF etc to be encountered during compile + +#include "xAODFaserCalorimeter/CalorimeterHitContainer.h" +#include "xAODFaserCalorimeter/CalorimeterHitAuxContainer.h" diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHit.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHit.h new file mode 100644 index 0000000000000000000000000000000000000000..2a0fc9bac8f81a9e439a5426da3f28bf607d351a --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHit.h @@ -0,0 +1,22 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_CALORIMETERHIT_H +#define XAODFASERCALORIMETER_CALORIMETERHIT_H + +// Local include(s): +#include "xAODFaserCalorimeter/versions/CalorimeterHit_v1.h" + +namespace xAOD { + /// Declare the latest version of the class + typedef CalorimeterHit_v1 CalorimeterHit; +} + +// Set up a CLID for the container: +#include "xAODCore/CLASS_DEF.h" +CLASS_DEF( xAOD::CalorimeterHit, 195445226, 1 ) + +#endif // XAODFASERCALORIMETER_CALORIMETERHIT_H diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHitAuxContainer.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHitAuxContainer.h new file mode 100644 index 0000000000000000000000000000000000000000..d7c60f9fe782c7f3f817c8f285be1d0616b3e12b --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHitAuxContainer.h @@ -0,0 +1,22 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_CALORIMETERHITAUXCONTAINER_H +#define XAODFASERCALORIMETER_CALORIMETERHITAUXCONTAINER_H + +// Local include(s): +#include "xAODFaserCalorimeter/versions/CalorimeterHitAuxContainer_v1.h" + +namespace xAOD { + /// Declare the latest version of the class + typedef CalorimeterHitAuxContainer_v1 CalorimeterHitAuxContainer; +} + +// Set up a CLID for the container: +#include "xAODCore/CLASS_DEF.h" +CLASS_DEF( xAOD::CalorimeterHitAuxContainer, 1074912337, 1 ) + +#endif // XAODFASERCALORIMETER_CALORIMETERHITAUXCONTAINER_H diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHitContainer.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHitContainer.h new file mode 100644 index 0000000000000000000000000000000000000000..21f338983f67681cba5d3d505ca37ba5324b1f0c --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHitContainer.h @@ -0,0 +1,22 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_CALORIMETERHITCONTAINER_H +#define XAODFASERCALORIMETER_CALORIMETERHITCONTAINER_H + +// Local include(s): +#include "xAODFaserCalorimeter/versions/CalorimeterHitContainer_v1.h" + +namespace xAOD { + /// Declare the latest version of the class + typedef CalorimeterHitContainer_v1 CalorimeterHitContainer; +} + +// Set up a CLID for the container: +#include "xAODCore/CLASS_DEF.h" +CLASS_DEF( xAOD::CalorimeterHitContainer, 1147607550, 1 ) + +#endif // XAODFASERCALORIMETER_CALORIMETERHITCONTAINER_H diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/selection.xml b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/selection.xml new file mode 100644 index 0000000000000000000000000000000000000000..a07951d20534a62a96b9452c008b06bb23814eb8 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/selection.xml @@ -0,0 +1,16 @@ +<!-- Copyright (C) 2020 CERN for the benefit of the FASER collaboration --> +<lcgdict> + + <class name="xAOD::CalorimeterHit_v1" /> + <typedef name="xAOD::CalorimeterHit" /> + + <class name="xAOD::CalorimeterHitContainer_v1" + id="1172f311-f09a-4e3b-a946-68991c2c0646" /> + <typedef name="xAOD::CalorimeterHitContainer" /> + + <class name="xAOD::CalorimeterHitAuxContainer_v1" + id="755f71cf-2148-4736-b26e-3c007d627861" /> + <typedef name="xAOD::CalorimeterHitAuxContainer" /> + + +</lcgdict> diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHitAuxContainer_v1.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHitAuxContainer_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..7e61261eb4bd10f106d03b2a85f9918b82ce7944 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHitAuxContainer_v1.h @@ -0,0 +1,50 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_VERSIONS_CALORIMETERHITAUXCONTAINER_V1_H +#define XAODFASERCALORIMETER_VERSIONS_CALORIMETERHITAUXCONTAINER_V1_H + +// STL include(s): +#include <vector> + +// EDM include(s): +#include "xAODCore/AuxContainerBase.h" +#include "xAODFaserWaveform/WaveformHitContainer.h" + +namespace xAOD { + + /// Auxiliary container for CalorimeterHit containers + + class CalorimeterHitAuxContainer_v1 : public AuxContainerBase { + + public: + /// Default constructor + CalorimeterHitAuxContainer_v1(); + /// Destructor + ~CalorimeterHitAuxContainer_v1() {} + + private: + /// @name Basic variables + ///@ { + std::vector<float> localtime; + std::vector<float> bcid_time; + std::vector<float> raw_energy; + + typedef std::vector< ElementLink< WaveformHitContainer > > WaveformHitLink_t; + std::vector< WaveformHitLink_t > caloLinks; + std::vector< WaveformHitLink_t > preshowerLinks; + + ///@} + + }; // class CalorimeterHitAuxContainer_v1 + +} // namespace xAOD + +// Set up a CLID and StoreGate inheritance for the class: +#include "xAODCore/BaseInfo.h" +SG_BASE( xAOD::CalorimeterHitAuxContainer_v1, xAOD::AuxContainerBase ); + +#endif // XAODFASERCALORIMETER_VERSIONS_CALORIMETERHITAUXCONTAINER_V1_H diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHitContainer_v1.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHitContainer_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..84201189dcd86d08dd7bfa0083fe6bfb1c970b01 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHitContainer_v1.h @@ -0,0 +1,26 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_VERSIONS_CALORIMETERHITCONTAINER_V1_H +#define XAODFASERCALORIMETER_VERSIONS_CALORIMETERHITCONTAINER_V1_H + +// System include(s): +extern "C" { +# include "stdint.h" +} + +// EDM include(s): +#include "AthContainers/DataVector.h" + +// Local includes: +#include "xAODFaserCalorimeter/versions/CalorimeterHit_v1.h" + +namespace xAOD { + // Define the container as a simple DataVector + typedef DataVector<CalorimeterHit_v1> CalorimeterHitContainer_v1; +} + +#endif // XAODFASERCALORIMETER_VERSIONS_CALORIMETERHITCONTAINER_V1_H diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHit_v1.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHit_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..d9bb35047e6a75d6dac12dc0ba0eb47e3bceb684 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHit_v1.h @@ -0,0 +1,86 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_VERSIONS_CALORIMETERHIT_V1_H +#define XAODFASERCALORIMETER_VERSIONS_CALORIMETERHIT_V1_H + +// System include(s): +extern "C" { +# include "stdint.h" +} + +#include <vector> + +// Core EDM include(s): +#include "AthLinks/ElementLink.h" +#include "AthContainers/AuxElement.h" + +// xAOD include(s): +#include "xAODFaserWaveform/WaveformHit.h" +#include "xAODFaserWaveform/WaveformHitContainer.h" + +namespace xAOD { + + // Cllss describing pulses in the calorimeter digitizer + class CalorimeterHit_v1 : public SG::AuxElement { + + public: + /// Defaullt constructor + CalorimeterHit_v1(); + + /// @name Access CalorimeterHit elements + /// @{ + + /// Best results + float localtime() const; + void set_localtime(float value); + + float bcidtime() const; + void set_bcidtime(float value); + + float raw_energy() const; + void set_raw_energy(float value); + + // Waveform Hits + typedef std::vector< ElementLink< xAOD::WaveformHitContainer > > WaveformHitLinks_t; + + // Contributing Calorimeter Waveform Hits + const WaveformHitLinks_t& caloWaveformLinks() const; + void setCaloWaveformLinks( const WaveformHitLinks_t& caloWaveforms ); + // Remove all waveform hits + void clearCaloWaveformLinks(); + // Get the pointer to a given waveform hit + const WaveformHit* caloHit( size_t i ) const; + // Get the number of waveform hits + size_t nCaloHits() const; + // Add a waveform hit + void addCaloHit( const xAOD::WaveformHitContainer*, const xAOD::WaveformHit*); + + // // Contributing Preshower Waveform Hits + // const WaveformHitLinks_t& preshowerWaveformLinks() const; + // void setPreshowerWaveformLinks( const WaveformHitLinks_t& preshowerWaveforms ); + // // Remove all waveform hits + // void clearPreshowerWaveformLinks(); + // // Get the pointer to a given waveform hit + // const WaveformHit* preshowerHit( size_t i ) const; + // // Get the number of waveform hits + // size_t nPreshowerHits() const; + // // Add a waveform hit + // void addPreshowerHit( const xAOD::WaveformHitContainer*, const xAOD::WaveformHit*); + + /// @} + + }; // class CalorimeterHit_v1 + + std::ostream& operator<<(std::ostream& s, const xAOD::CalorimeterHit_v1& hit); +} + +// Declare the inheritance of the type: +#include "xAODCore/BaseInfo.h" +SG_BASE( xAOD::CalorimeterHit_v1, SG::AuxElement ); + + +#endif // XAODFASERCALORIMETER_VERSIONS_CALORIMETERHIT_V1_H diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/xAODFaserCalorimeterDict.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/xAODFaserCalorimeterDict.h new file mode 100644 index 0000000000000000000000000000000000000000..387eacb5e0c4e510a875a1ddfa4f8a5f0213ebdb --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/xAODFaserCalorimeterDict.h @@ -0,0 +1,26 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_XAODFASERCALORIMETERDICT_H +#define XAODFASERCALORIMETER_XAODFASERCALORIMETERDICT_H + +// Local includes +#include "xAODFaserCalorimeter/CalorimeterHit.h" +#include "xAODFaserCalorimeter/CalorimeterHitContainer.h" +#include "xAODFaserCalorimeter/CalorimeterHitAuxContainer.h" + +#include "xAODFaserCalorimeter/versions/CalorimeterHit_v1.h" +#include "xAODFaserCalorimeter/versions/CalorimeterHitContainer_v1.h" +#include "xAODFaserCalorimeter/versions/CalorimeterHitAuxContainer_v1.h" + +// EDM include(s). +#include "xAODCore/tools/DictHelpers.h" + +namespace { + struct GCCXML_DUMMY_INSTANTIATION_XAODFASERCALORIMETER { + XAOD_INSTANTIATE_NS_CONTAINER_TYPES( xAOD, CalorimeterHitContainer_v1 ); + }; +} + +#endif // XAODFASERCALORIMETER_XAODFASERCALORIMETERDICT_H diff --git a/xAOD/xAODFaserCalorimeterAthenaPool/CMakeLists.txt b/xAOD/xAODFaserCalorimeterAthenaPool/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..14c855eeff41534ed5a09a38b912a11dd1395a23 --- /dev/null +++ b/xAOD/xAODFaserCalorimeterAthenaPool/CMakeLists.txt @@ -0,0 +1,14 @@ +# Copyright (C) 2020 CERN for the benefit of the FASER collaboration + +# Declare the package name. +atlas_subdir( xAODFaserCalorimeterAthenaPool ) + +# Component(s) in the package: +atlas_add_poolcnv_library( xAODFaserCalorimeterAthenaPoolPoolCnv + src/*.h src/*.cxx + FILES xAODFaserCalorimeter/CalorimeterHitContainer.h xAODFaserCalorimeter/CalorimeterHitAuxContainer.h + TYPES_WITH_NAMESPACE xAOD::CalorimeterHitContainer xAOD::CalorimeterHitAuxContainer + CNV_PFX xAOD + LINK_LIBRARIES AthenaPoolCnvSvcLib AthenaPoolUtilities xAODFaserCalorimeter xAODFaserWaveform ) + + diff --git a/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitAuxContainerCnv.cxx b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitAuxContainerCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..783826faef6ddb70bf5806e935a364c7a9177d46 --- /dev/null +++ b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitAuxContainerCnv.cxx @@ -0,0 +1,6 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +// Dummy source file so that cmake will know this is a custom converter. +// xAODCalorimeterHitAuxContainerCnv.cxx diff --git a/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitAuxContainerCnv.h b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitAuxContainerCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..49acdb4f27d547ef553dfc82b2d9528978c1991c --- /dev/null +++ b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitAuxContainerCnv.h @@ -0,0 +1,15 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETERATHENAPOOL_XAODCALORIMETERHITAUXCONTAINERCNV_H +#define XAODFASERCALORIMETERATHENAPOOL_XAODCALORIMETERHITAUXCONTAINERCNV_H + +#include "xAODFaserCalorimeter/CalorimeterHitAuxContainer.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolAuxContainerCnv.h" + +typedef T_AthenaPoolAuxContainerCnv<xAOD::CalorimeterHitAuxContainer> xAODCalorimeterHitAuxContainerCnv; + +#endif // XAODFASERCALORIMETERATHENAPOOL_XAODFASERCALORIMETERHITAUXCONTAINERCNV_H diff --git a/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitContainerCnv.cxx b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitContainerCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..03aa7c9bedf108b7bf7cf9dec5bd010f4b6ecdc9 --- /dev/null +++ b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitContainerCnv.cxx @@ -0,0 +1,6 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +// Dummy source file so that cmake will know this is a custom converter. +// xAODCalorimeterHitContainerCnv.cxx diff --git a/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitContainerCnv.h b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitContainerCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..360e61266868e159e1e5d7f7b0929957ac052147 --- /dev/null +++ b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitContainerCnv.h @@ -0,0 +1,15 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETERATHENAPOOL_XAODCALORIMETERHITCONTAINERCNV_H +#define XAODFASERCALORIMETERATHENAPOOL_XAODCALORIMETERHITCONTAINERCNV_H + +#include "xAODFaserCalorimeter/CalorimeterHitContainer.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolxAODCnv.h" + +typedef T_AthenaPoolxAODCnv<xAOD::CalorimeterHitContainer> xAODCalorimeterHitContainerCnv; + +#endif // XAODFASERCALORIMETERATHENAPOOL_XAODCALORIMETERHITCONTAINERCNV_H diff --git a/xAOD/xAODFaserWaveform/Root/WaveformHit_v1.cxx b/xAOD/xAODFaserWaveform/Root/WaveformHit_v1.cxx index 8b26eebffaa1018193523608e0494ef5fcc29d44..df91c67cf77ef79b749934687ee910146ee3e309 100644 --- a/xAOD/xAODFaserWaveform/Root/WaveformHit_v1.cxx +++ b/xAOD/xAODFaserWaveform/Root/WaveformHit_v1.cxx @@ -55,6 +55,8 @@ namespace xAOD { s << "xAODWaveformHit: channel=" << hit.channel() << " local time=" << hit.localtime() << " peak=" << hit.peak() + << " start time=" << hit.time_vector().front() + << " end time=" << hit.time_vector().back() << std::endl; return s;