diff --git a/Calorimeter/CaloDigiAlgs/src/CaloWaveformDigiAlg.cxx b/Calorimeter/CaloDigiAlgs/src/CaloWaveformDigiAlg.cxx index 4d122f2e8ec6844496c4bff025779fca9045da1c..12f5ee5eed4a08a8ce0d3119f0bfe6a8430cb4d9 100644 --- a/Calorimeter/CaloDigiAlgs/src/CaloWaveformDigiAlg.cxx +++ b/Calorimeter/CaloDigiAlgs/src/CaloWaveformDigiAlg.cxx @@ -98,11 +98,18 @@ CaloWaveformDigiAlg::execute(const EventContext& ctx) const { // Loop over wavefrom vectors to make and store waveform unsigned int digitizer_samples = m_digiTool->digitizer_samples(); for (const auto& w : waveforms) { - RawWaveform* wfm = new RawWaveform(); + RawWaveform* wfm = new RawWaveform(); wfm->setWaveform(0, w.second); wfm->setIdentifier(w.first); - wfm->setChannel(m_mappingTool->getChannelMapping(w.first)); wfm->setSamples(digitizer_samples); + // Don't write out waveforms with no channel defined + // Causes problems in downstream reco (not known in cable map + int channel = m_mappingTool->getChannelMapping(w.first); + if (channel < 0) { + ATH_MSG_DEBUG("Skipping waveform with unknown channel!"); + continue; + } + wfm->setChannel(channel); waveformContainerHandle->push_back(wfm); } diff --git a/Calorimeter/CaloRecAlgs/src/CaloRecAlg.cxx b/Calorimeter/CaloRecAlgs/src/CaloRecAlg.cxx index c8844946d2f8b1242c22ec0540a07d23ff2c7ada..5b132d2f9ce057254aedf9937f0359eea0303196 100644 --- a/Calorimeter/CaloRecAlgs/src/CaloRecAlg.cxx +++ b/Calorimeter/CaloRecAlgs/src/CaloRecAlg.cxx @@ -51,14 +51,7 @@ StatusCode CaloRecAlg::execute(const EventContext& ctx) const { } SG::ReadHandle<xAOD::WaveformHitContainer> calo2WaveHitHandle(m_calo2WaveHitContainerKey, ctx); - - ATH_CHECK( calo2WaveHitHandle.isValid() ); - ATH_MSG_DEBUG("Found ReadHandle for WaveformHitContainer " << m_calo2WaveHitContainerKey); - - if (calo2WaveHitHandle->size() == 0) { - ATH_MSG_DEBUG("Calorimeter 2 Waveform Hit container found with zero length!"); - } - + SG::ReadHandle<xAOD::WaveformHitContainer> preshowerWaveHitHandle(m_preshowerWaveHitContainerKey, ctx); ATH_CHECK( preshowerWaveHitHandle.isValid() ); @@ -87,21 +80,6 @@ StatusCode CaloRecAlg::execute(const EventContext& ctx) const { } ATH_MSG_DEBUG("CaloHitContainer '" << caloHitContainerHandle.name() << "' filled with "<< caloHitContainerHandle->size() <<" items"); - // Reconstruct high-gain calorimeter hits - SG::WriteHandle<xAOD::CalorimeterHitContainer> calo2HitContainerHandle(m_calo2HitContainerKey, ctx); - ATH_CHECK( calo2HitContainerHandle.record( std::make_unique<xAOD::CalorimeterHitContainer>(), - std::make_unique<xAOD::CalorimeterHitAuxContainer>() ) ); - ATH_MSG_DEBUG("WaveformsHitContainer '" << calo2HitContainerHandle.name() << "' initialized"); - - for( const auto& hit : *calo2WaveHitHandle ) { - if (hit->status_bit(xAOD::WaveformStatus::SECONDARY)) continue; - xAOD::CalorimeterHit* calo_hit = new xAOD::CalorimeterHit(); - calo2HitContainerHandle->push_back(calo_hit); - calo_hit->addHit(calo2WaveHitHandle.get(), hit); - m_recoCalibTool->reconstruct(ctx, calo_hit, correct_gain=false); - } - ATH_MSG_DEBUG("Calo2HitContainer '" << calo2HitContainerHandle.name() << "' filled with "<< calo2HitContainerHandle->size() <<" items"); - // Reconstruct preshower hits SG::WriteHandle<xAOD::CalorimeterHitContainer> preshowerHitContainerHandle(m_preshowerHitContainerKey, ctx); ATH_CHECK( preshowerHitContainerHandle.record( std::make_unique<xAOD::CalorimeterHitContainer>(), @@ -117,6 +95,35 @@ StatusCode CaloRecAlg::execute(const EventContext& ctx) const { } ATH_MSG_DEBUG("PreshowerHitContainer '" << preshowerHitContainerHandle.name() << "' filled with "<< preshowerHitContainerHandle->size() <<" items"); + + // High-gain calo isn't guaranteed to exist + if ( calo2WaveHitHandle.isValid() ) { + ATH_MSG_DEBUG("Found ReadHandle for WaveformHitContainer " << m_calo2WaveHitContainerKey); + + if (calo2WaveHitHandle->size() == 0) { + ATH_MSG_DEBUG("Calorimeter 2 Waveform Hit container found with zero length!"); + } + + // Reconstruct high-gain calorimeter hits + SG::WriteHandle<xAOD::CalorimeterHitContainer> calo2HitContainerHandle(m_calo2HitContainerKey, ctx); + ATH_CHECK( calo2HitContainerHandle.record( std::make_unique<xAOD::CalorimeterHitContainer>(), + std::make_unique<xAOD::CalorimeterHitAuxContainer>() ) ); + ATH_MSG_DEBUG("WaveformsHitContainer '" << calo2HitContainerHandle.name() << "' initialized"); + + for( const auto& hit : *calo2WaveHitHandle ) { + if (hit->status_bit(xAOD::WaveformStatus::SECONDARY)) continue; + xAOD::CalorimeterHit* calo_hit = new xAOD::CalorimeterHit(); + calo2HitContainerHandle->push_back(calo_hit); + calo_hit->addHit(calo2WaveHitHandle.get(), hit); + m_recoCalibTool->reconstruct(ctx, calo_hit, correct_gain=false); + } + ATH_MSG_DEBUG("Calo2HitContainer '" << calo2HitContainerHandle.name() << "' filled with "<< calo2HitContainerHandle->size() <<" items"); + + } else { + ATH_MSG_DEBUG("No ReadHandle for WaveformHitContainer " << m_calo2WaveHitContainerKey); + } + + return StatusCode::SUCCESS; } diff --git a/Waveform/WaveRecAlgs/python/WaveRecAlgsConfig.py b/Waveform/WaveRecAlgs/python/WaveRecAlgsConfig.py index 6af8ed0e1c78771a1121bce792b4d69105dc46e1..8600247ed919a34df3f81dfb6d059eb8fba28b87 100644 --- a/Waveform/WaveRecAlgs/python/WaveRecAlgsConfig.py +++ b/Waveform/WaveRecAlgs/python/WaveRecAlgsConfig.py @@ -16,7 +16,9 @@ def WaveformReconstructionCfg(flags): """ Return all algorithms and tools for Waveform reconstruction """ acc = ComponentAccumulator() - if not flags.Input.isMC: + if flags.Input.isMC: + print("ClockRecAlg diabled for MC in WaveformReconstructionCfg!") + else: acc.merge(WaveformClockRecCfg(flags, "ClockRecAlg")) if "TB" in flags.GeoModel.FaserVersion: @@ -28,7 +30,10 @@ def WaveformReconstructionCfg(flags): else: acc.merge(WaveformHitRecCfg(flags, "CaloWaveformRecAlg", "Calo")) - acc.merge(WaveformHitRecCfg(flags, "Calo2WaveformRecAlg", "Calo2")) + if flags.Input.isMC: + print("Calo2WaveformRecAlg diabled for MC in WaveformReconstructionCfg!") + else: + acc.merge(WaveformHitRecCfg(flags, "Calo2WaveformRecAlg", "Calo2")) # Make preshower window 200 ns wide (value in digitizer clock ticks) acc.merge(WaveformHitRecCfg(flags, "VetoWaveformRecAlg", "Veto", FitWindowWidth=100 ))