diff --git a/src/algorithms/calorimetry/CalorimeterClusterMerger.h b/src/algorithms/calorimetry/CalorimeterClusterMerger.h index a97c60dd61..f38ad7c4a2 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterMerger.h +++ b/src/algorithms/calorimetry/CalorimeterClusterMerger.h @@ -26,10 +26,9 @@ class CalorimeterClusterMerger { public: CalorimeterClusterMerger() = default; - ~CalorimeterClusterMerger(){} // better to use smart pointer? - virtual void AlgorithmInit(std::shared_ptr& logger); - virtual void AlgorithmChangeRun() ; - virtual void AlgorithmProcess() ; + void AlgorithmInit(std::shared_ptr& logger); + void AlgorithmChangeRun() ; + void AlgorithmProcess() ; //-------- Configuration Parameters ------------ diff --git a/src/algorithms/calorimetry/CalorimeterHitDigi.cc b/src/algorithms/calorimetry/CalorimeterHitDigi.cc index 8a0f51a36d..b363a8800a 100644 --- a/src/algorithms/calorimetry/CalorimeterHitDigi.cc +++ b/src/algorithms/calorimetry/CalorimeterHitDigi.cc @@ -14,7 +14,6 @@ #include "CalorimeterHitDigi.h" #include -#include #include #include using namespace dd4hep; @@ -116,29 +115,21 @@ void CalorimeterHitDigi::AlgorithmChangeRun() { //------------------------ // AlgorithmProcess //------------------------ -void CalorimeterHitDigi::AlgorithmProcess() { - - // Delete any output objects left from last event. - // (Should already have been done for us, but just to be bullet-proof.) - for( auto h : rawhits ) delete h; - rawhits.clear(); - +std::unique_ptr CalorimeterHitDigi::AlgorithmProcess(const edm4hep::SimCalorimeterHitCollection &simhits) { if (merge_hits) { - signal_sum_digi(); + return std::move(signal_sum_digi(simhits)); } else { - single_hits_digi(); + return std::move(single_hits_digi(simhits)); } } -//------------------------ -// single_hits_digi -//------------------------ -void CalorimeterHitDigi::single_hits_digi(){ +std::unique_ptr CalorimeterHitDigi::single_hits_digi(const edm4hep::SimCalorimeterHitCollection &simhits) { + std::unique_ptr rawhits { std::make_unique() }; // Create output collections - for ( auto ahit : simhits ) { + for (const auto &ahit : simhits) { // Note: juggler internal unit of energy is dd4hep::GeV - const double eDep = ahit->getEnergy(); + const double eDep = ahit.getEnergy(); // apply additional calorimeter noise to corrected energy deposit const double eResRel = (eDep > m_threshold) @@ -157,7 +148,7 @@ void CalorimeterHitDigi::single_hits_digi(){ const long long adc = std::llround(ped + eDep * (m_corrMeanScale + eResRel) / m_dyRangeADC * m_capADC); double time = std::numeric_limits::max(); - for (const auto& c : ahit->getContributions()) { + for (const auto& c : ahit.getContributions()) { if (c.getTime() <= time) { time = c.getTime(); } @@ -166,64 +157,60 @@ void CalorimeterHitDigi::single_hits_digi(){ const long long tdc = std::llround((time + m_normDist(generator) * tRes) * stepTDC); - if (eDep> 1.e-3) m_log->trace("E sim {} \t adc: {} \t time: {}\t maxtime: {} \t tdc: {} \t cell ID {}", eDep, adc, time, m_capTime, tdc, ahit->getCellID()); - auto rawhit = new edm4hep::RawCalorimeterHit( - ahit->getCellID(), + if (eDep> 1.e-3) m_log->trace("E sim {} \t adc: {} \t time: {}\t maxtime: {} \t tdc: {} \t cell ID {}", eDep, adc, time, m_capTime, tdc, ahit.getCellID()); + rawhits->create( + ahit.getCellID(), (adc > m_capADC ? m_capADC : adc), tdc ); - rawhits.push_back(rawhit); } + + return std::move(rawhits); } -//------------------------ -// signal_sum_digi -//------------------------ -void CalorimeterHitDigi::signal_sum_digi( void ){ +std::unique_ptr CalorimeterHitDigi::signal_sum_digi(const edm4hep::SimCalorimeterHitCollection &simhits) { + auto rawhits = std::make_unique(); // find the hits that belong to the same group (for merging) - std::unordered_map> merge_map; - for (auto ahit : simhits) { - int64_t hid = ahit->getCellID() & id_mask; + std::unordered_map> merge_map; + std::size_t ix = 0; + for (const auto &ahit : simhits) { + uint64_t hid = ahit.getCellID() & id_mask; - m_log->trace("org cell ID in {:s}: {:#064b}", m_readout, ahit->getCellID()); + m_log->trace("org cell ID in {:s}: {:#064b}", m_readout, ahit.getCellID()); m_log->trace("new cell ID in {:s}: {:#064b}", m_readout, hid); - auto it = merge_map.find(hid); + merge_map[hid].push_back(ix); - if (it == merge_map.end()) { - merge_map[hid] = {ahit}; - } else { - it->second.push_back(ahit); - } + ix++; } // signal sum // NOTE: we take the cellID of the most energetic hit in this group so it is a real cellID from an MC hit - for (auto &[id, hits] : merge_map) { + for (const auto &[id, ixs] : merge_map) { double edep = 0; double time = std::numeric_limits::max(); double max_edep = 0; - auto mid = hits[0]->getCellID(); + auto mid = simhits[ixs[0]].getCellID(); // sum energy, take time from the most energetic hit - m_log->trace("id: {} \t {}", id, edep); - for (size_t i = 0; i < hits.size(); ++i) { + for (size_t i = 0; i < ixs.size(); ++i) { + auto hit = simhits[ixs[i]]; double timeC = std::numeric_limits::max(); - for (const auto& c : hits[i]->getContributions()) { + for (const auto& c : hit.getContributions()) { if (c.getTime() <= timeC) { timeC = c.getTime(); } } if (timeC > m_capTime) continue; - edep += hits[i]->getEnergy(); - m_log->trace("adding {} \t total: {}", hits[i]->getEnergy(), edep); + edep += hit.getEnergy(); + m_log->trace("adding {} \t total: {}", hit.getEnergy(), edep); // change maximum hit energy & time if necessary - if (hits[i]->getEnergy() > max_edep) { - max_edep = hits[i]->getEnergy(); - mid = hits[i]->getCellID(); - for (const auto& c : hits[i]->getContributions()) { + if (hit.getEnergy() > max_edep) { + max_edep = hit.getEnergy(); + mid = hit.getCellID(); + for (const auto& c : hit.getContributions()) { if (c.getTime() <= time) { time = c.getTime(); } @@ -251,11 +238,12 @@ void CalorimeterHitDigi::signal_sum_digi( void ){ unsigned long long tdc = std::llround((time + m_normDist(generator) * tRes) * stepTDC); if (edep> 1.e-3) m_log->trace("E sim {} \t adc: {} \t time: {}\t maxtime: {} \t tdc: {}", edep, adc, time, m_capTime, tdc); - auto rawhit = new edm4hep::RawCalorimeterHit( + rawhits->create( mid, (adc > m_capADC ? m_capADC : adc), tdc ); - rawhits.push_back(rawhit); } + + return std::move(rawhits); } diff --git a/src/algorithms/calorimetry/CalorimeterHitDigi.h b/src/algorithms/calorimetry/CalorimeterHitDigi.h index d9971664bd..6432bafd3d 100644 --- a/src/algorithms/calorimetry/CalorimeterHitDigi.h +++ b/src/algorithms/calorimetry/CalorimeterHitDigi.h @@ -13,12 +13,13 @@ #pragma once +#include #include #include -#include -#include +#include +#include #include class CalorimeterHitDigi { @@ -27,10 +28,9 @@ class CalorimeterHitDigi { public: CalorimeterHitDigi() = default; - ~CalorimeterHitDigi(){for( auto h : rawhits ) delete h;} // better to use smart pointer? - virtual void AlgorithmInit(std::shared_ptr& logger); - virtual void AlgorithmChangeRun() ; - virtual void AlgorithmProcess() ; + void AlgorithmInit(std::shared_ptr& logger); + void AlgorithmChangeRun() ; + std::unique_ptr AlgorithmProcess(const edm4hep::SimCalorimeterHitCollection &simhits) ; //-------- Configuration Parameters ------------ //instantiate new spdlog logger @@ -78,14 +78,10 @@ class CalorimeterHitDigi { std::shared_ptr m_geoSvc; uint64_t id_mask{0}; - // inputs/outputs - std::vector simhits; - std::vector rawhits; - private: std::default_random_engine generator; // TODO: need something more appropriate here std::normal_distribution m_normDist; // defaults to mean=0, sigma=1 - void single_hits_digi(); - void signal_sum_digi(); + std::unique_ptr single_hits_digi(const edm4hep::SimCalorimeterHitCollection &simhits); + std::unique_ptr signal_sum_digi(const edm4hep::SimCalorimeterHitCollection &simhits); }; diff --git a/src/algorithms/calorimetry/CalorimeterHitReco.cc b/src/algorithms/calorimetry/CalorimeterHitReco.cc index 276d15d4ba..723541c545 100644 --- a/src/algorithms/calorimetry/CalorimeterHitReco.cc +++ b/src/algorithms/calorimetry/CalorimeterHitReco.cc @@ -121,7 +121,8 @@ void CalorimeterHitReco::AlgorithmChangeRun() { //------------------------ // AlgorithmProcess //------------------------ -void CalorimeterHitReco::AlgorithmProcess() { +std::unique_ptr CalorimeterHitReco::AlgorithmProcess(const edm4hep::RawCalorimeterHitCollection &rawhits) { + auto recohits = std::make_unique(); // For some detectors, the cellID in the raw hits may be broken // (currently this is the HcalBarrel). In this case, dd4hep @@ -132,29 +133,29 @@ void CalorimeterHitReco::AlgorithmProcess() { // indicating what is going on is printed below where the // error is detector. auto decoder = m_geoSvc->detector()->readout(m_readout).idSpec().decoder(); - if (NcellIDerrors >= MaxCellIDerrors) return; + if (NcellIDerrors >= MaxCellIDerrors) return std::move(recohits); auto converter = m_geoSvc->cellIDPositionConverter(); - for (const auto rh: rawhits) { + for (const auto &rh: rawhits) { // #pragma GCC diagnostic push // #pragma GCC diagnostic error "-Wsign-converstion" //did not pass the zero-suppresion threshold - const auto cellID = rh->getCellID(); - if (rh->getAmplitude() < m_pedMeanADC + thresholdADC) { + const auto cellID = rh.getCellID(); + if (rh.getAmplitude() < m_pedMeanADC + thresholdADC) { continue; } // convert ADC to energy - float energy = (((signed) rh->getAmplitude() - (signed) m_pedMeanADC)) / static_cast(m_capADC) * m_dyRangeADC / + float energy = (((signed) rh.getAmplitude() - (signed) m_pedMeanADC)) / static_cast(m_capADC) * m_dyRangeADC / m_sampFrac; if (m_readout == "LFHCALHits" && m_sampFracLayer[0] != 0.){ - energy = (((signed) rh->getAmplitude() - (signed) m_pedMeanADC)) / static_cast(m_capADC) * m_dyRangeADC / + energy = (((signed) rh.getAmplitude() - (signed) m_pedMeanADC)) / static_cast(m_capADC) * m_dyRangeADC / m_sampFracLayer[decoder->get(cellID, decoder->index("rlayerz"))]; // use readout layer depth information from decoder } - const float time = rh->getTimeStamp() / stepTDC; - m_log->trace("cellID {}, \t energy: {}, TDC: {}, time: ", cellID, energy, rh->getTimeStamp(), time); + const float time = rh.getTimeStamp() / stepTDC; + m_log->trace("cellID {}, \t energy: {}, TDC: {}, time: ", cellID, energy, rh.getTimeStamp(), time); const int lid = id_dec != nullptr && !m_layerField.empty() ? static_cast(id_dec->get(cellID, layer_idx)) : -1; @@ -237,17 +238,18 @@ void CalorimeterHitReco::AlgorithmProcess() { const decltype(edm4eic::CalorimeterHitData::local) local_position(pos.x() / m_lUnit, pos.y() / m_lUnit, pos.z() / m_lUnit); - auto hit = new edm4eic::CalorimeterHit(rh->getCellID(), - energy, - 0, - time, - 0, - position, - dimension, - sid, - lid, - local_position); - hits.push_back(hit); + recohits->create( + rh.getCellID(), + energy, + 0, + time, + 0, + position, + dimension, + sid, + lid, + local_position); } - return; + + return recohits; } diff --git a/src/algorithms/calorimetry/CalorimeterHitReco.h b/src/algorithms/calorimetry/CalorimeterHitReco.h index dcaff42275..8d1eb73c87 100644 --- a/src/algorithms/calorimetry/CalorimeterHitReco.h +++ b/src/algorithms/calorimetry/CalorimeterHitReco.h @@ -12,23 +12,18 @@ #include #include -#include -#include -#include +#include +#include #include #include class CalorimeterHitReco { - - // Insert any member variables here - public: CalorimeterHitReco() = default; - ~CalorimeterHitReco(){} // better to use smart pointer? - virtual void AlgorithmInit(std::shared_ptr& logger); - virtual void AlgorithmChangeRun() ; - virtual void AlgorithmProcess() ; + void AlgorithmInit(std::shared_ptr& logger); + void AlgorithmChangeRun(); + std::unique_ptr AlgorithmProcess(const edm4hep::RawCalorimeterHitCollection &rawhits); //-------- Configuration Parameters ------------ //instantiate new spdlog logger @@ -59,8 +54,6 @@ class CalorimeterHitReco { double stepTDC{0}; std::shared_ptr m_geoSvc; - //DataHandle m_inputHitCollection{"inputHitCollection", Gaudi::DataHandle::Reader, this}; - //DataHandle m_outputHitCollection{"outputHitCollection", Gaudi::DataHandle::Writer, this}; // geometry service to get ids, ignored if no names provided std::string m_geoSvcName="geoServiceName"; @@ -82,11 +75,4 @@ class CalorimeterHitReco { std::vector u_localDetFields={}, u_maskPosFields={}; dd4hep::DetElement local; size_t local_mask = ~static_cast(0), gpos_mask = static_cast(0); - - std::vector hits; - std::vector rawhits; - -private: - //std::default_random_engine generator; // TODO: need something more appropriate here - //std::normal_distribution m_normDist; // defaults to mean=0, sigma=1 }; diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index 895d6b41a3..8375a16f9d 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -38,34 +38,32 @@ void CalorimeterHitsMerger::initialize() { m_log->info(fmt::format("ID mask in {:s}: {:#064b}", m_readout, id_mask)); } -void CalorimeterHitsMerger::execute() { +std::unique_ptr CalorimeterHitsMerger::execute(const edm4eic::CalorimeterHitCollection &input) { + auto output = std::make_unique(); // find the hits that belong to the same group (for merging) - std::unordered_map> merge_map; - for (const auto &h: m_inputs) { - int64_t id = h->getCellID() & id_mask; - // use the reference field position - auto it = merge_map.find(id); - if (it == merge_map.end()) { - merge_map[id] = {h}; - } else { - it->second.push_back(h); - } + std::unordered_map> merge_map; + std::size_t ix = 0; + for (const auto &h : input) { + uint64_t id = h.getCellID() & id_mask; + merge_map[id].push_back(ix); + + ix++; } // sort hits by energy from large to small - std::for_each(merge_map.begin(), merge_map.end(), [](auto &it) { - std::sort(it.second.begin(), it.second.end(), [](const auto &h1, const auto &h2) { - return h1->getEnergy() > h2->getEnergy(); + for (auto &it : merge_map) { + std::sort(it.second.begin(), it.second.end(), [&](std::size_t ix1, std::size_t ix2) { + return input[ix1].getEnergy() > input[ix2].getEnergy(); }); - }); + } // reconstruct info for merged hits // dd4hep decoders auto poscon = m_geoSvc->cellIDPositionConverter(); auto volman = m_geoSvc->detector()->volumeManager(); - for (auto &[id, hits]: merge_map) { + for (const auto &[id, ixs] : merge_map) { // reference fields id const uint64_t ref_id = id | ref_mask; // global positions @@ -79,17 +77,18 @@ void CalorimeterHitsMerger::execute() { float energyError = 0.; float time = 0; float timeError = 0; - for (auto &hit: hits) { - energy += hit->getEnergy(); - energyError += hit->getEnergyError() * hit->getEnergyError(); - time += hit->getTime(); - timeError += hit->getTimeError() * hit->getTimeError(); + for (auto ix : ixs) { + auto hit = input[ix]; + energy += hit.getEnergy(); + energyError += hit.getEnergyError() * hit.getEnergyError(); + time += hit.getTime(); + timeError += hit.getTimeError() * hit.getTimeError(); } energyError = sqrt(energyError); - time /= hits.size(); - timeError = sqrt(timeError) / hits.size(); + time /= ixs.size(); + timeError = sqrt(timeError) / ixs.size(); - const auto &href = hits.front(); + const auto href = input[ixs.front()]; // create const vectors for passing to hit initializer list const decltype(edm4eic::CalorimeterHitData::position) position( @@ -99,19 +98,20 @@ void CalorimeterHitsMerger::execute() { pos.x(), pos.y(), pos.z() ); - m_outputs.push_back( - new edm4eic::CalorimeterHit{ - href->getCellID(), + output->create( + href.getCellID(), energy, energyError, time, timeError, position, - href->getDimension(), - href->getSector(), - href->getLayer(), - local}); // Can do better here? Right now position is mapped on the central hit + href.getDimension(), + href.getSector(), + href.getLayer(), + local); // Can do better here? Right now position is mapped on the central hit } - m_log->debug(fmt::format("Size before = {}, after = {}", m_inputs.size(), m_outputs.size()) ); + m_log->debug(fmt::format("Size before = {}, after = {}", input.size(), output->size()) ); + + return output; } diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.h b/src/algorithms/calorimetry/CalorimeterHitsMerger.h index 9f2eb7ec7b..5b010eb01e 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.h @@ -12,13 +12,13 @@ #include #include +#include #include #include #include #include -#include -#include +#include #include #include @@ -33,16 +33,13 @@ class CalorimeterHitsMerger { std::shared_ptr m_geoSvc; uint64_t id_mask{0}, ref_mask{0}; - std::vector m_inputs; - std::vector m_outputs; - std::shared_ptr m_log; public: CalorimeterHitsMerger() = default; - virtual ~CalorimeterHitsMerger() {} + ~CalorimeterHitsMerger() {} - virtual void initialize(); - virtual void execute(); + void initialize(); + std::unique_ptr execute(const edm4eic::CalorimeterHitCollection &input); }; // class CalorimeterHitsMerger diff --git a/src/algorithms/calorimetry/CalorimeterTruthClustering.cc b/src/algorithms/calorimetry/CalorimeterTruthClustering.cc index 2d4a51513a..3f92d16b66 100644 --- a/src/algorithms/calorimetry/CalorimeterTruthClustering.cc +++ b/src/algorithms/calorimetry/CalorimeterTruthClustering.cc @@ -1,6 +1,5 @@ - -// SPDX-License-Identifier: LGPL-3.0-or-later // Copyright (C) 2022 Sylvester Joosten, Whitney Armstrong, Wouter Deconinck +// SPDX-License-Identifier: LGPL-3.0-or-later #include "CalorimeterTruthClustering.h" @@ -11,9 +10,6 @@ using namespace dd4hep; -//this algorithm converted from https://eicweb.phy.anl.gov/EIC/juggler/-/blob/master/JugReco/src/components/CalorimeterHitReco.cpp - - //------------------------ // AlgorithmInit //------------------------ @@ -33,14 +29,9 @@ void CalorimeterTruthClustering::AlgorithmChangeRun() { //------------------------ // AlgorithmProcess //------------------------ -void CalorimeterTruthClustering::AlgorithmProcess() { - - // input collections - const auto& hits = m_inputHits; - const auto& mc = m_mcHits; +std::unique_ptr CalorimeterTruthClustering::AlgorithmProcess(const edm4eic::CalorimeterHitCollection &hits, const edm4hep::SimCalorimeterHitCollection &mc) { // Create output collections - - std::vector proto; + auto output = std::make_unique(); // Map mc track ID to protoCluster index std::map protoIndex; @@ -65,38 +56,34 @@ void CalorimeterTruthClustering::AlgorithmProcess() { // FIXME: This is clearly not the right way to do this! Podio needs // FIXME: to be fixed so proper object tracking can be done without // FIXME: requiring Collection classes be used to manage all objects. - const edm4hep::SimCalorimeterHit* mcHit = nullptr; - if( hit->getObjectID().index>=0 && hit->getObjectID().indexgetObjectID().index]; - }else{ - for( auto tmpmc : mc ){ - if( tmpmc->getCellID() == hit->getCellID() ){ - mcHit = tmpmc; + std::size_t mcIndex; + if ((hit.getObjectID().index >= 0) && (hit.getObjectID().index < mc.size())) { + mcIndex = hit.getObjectID().index; + } else { + mcIndex = 0; + bool success = false; + for (auto tmpmc : mc) { + if (tmpmc.getCellID() == hit.getCellID()) { + success = true; break; } + mcIndex++; + } + if (not success) { + continue; // ignore hit if we couldn't match it to truth hit } } - if( ! mcHit ) continue; // ignore hit if we couldn't match it to truth hit - const auto &trackID = mcHit->getContributions(0).getParticle().id(); + const auto &trackID = mc[mcIndex].getContributions(0).getParticle().id(); // Create a new protocluster if we don't have one for this trackID if (protoIndex.count(trackID) == 0) { - proto.push_back( new edm4eic::MutableProtoCluster() ); - protoIndex[trackID] = proto.size() - 1; + output->create(); + protoIndex[trackID] = output->size() - 1; } // Add hit to the appropriate protocluster - proto[protoIndex[trackID]]->addToHits(*hit); - proto[protoIndex[trackID]]->addToWeights(1); + (*output)[protoIndex[trackID]].addToHits(hit); + (*output)[protoIndex[trackID]].addToWeights(1); } - // iterate over proto and push to m_outputProtoClusters - for (auto& p : proto) { - edm4eic::ProtoCluster* to_add=new edm4eic::ProtoCluster(*p); - m_outputProtoClusters.push_back(to_add); - } - - // free allocated memory - for (auto& p : proto) { - delete p; - } + return std::move(output); } diff --git a/src/algorithms/calorimetry/CalorimeterTruthClustering.h b/src/algorithms/calorimetry/CalorimeterTruthClustering.h index 9ef1ba19f3..c67f46fd97 100644 --- a/src/algorithms/calorimetry/CalorimeterTruthClustering.h +++ b/src/algorithms/calorimetry/CalorimeterTruthClustering.h @@ -8,10 +8,9 @@ #include #include -#include -#include -#include -#include +#include +#include +#include #include @@ -24,18 +23,7 @@ class CalorimeterTruthClustering { public: CalorimeterTruthClustering() = default; - ~CalorimeterTruthClustering(){} // better to use smart pointer? - virtual void AlgorithmInit(std::shared_ptr &logger) ; - virtual void AlgorithmChangeRun() ; - virtual void AlgorithmProcess() ; - - //-------- Configuration Parameters ------------ - - std::vector m_inputHits;//{"inputHits", Gaudi::DataHandle::Reader, this}; - std::vector m_mcHits;//{"mcHits", Gaudi::DataHandle::Reader, this}; - - std::vector m_outputProtoClusters;//{"outputProtoClusters", Gaudi::DataHandle::Writer, this}; - -private: - + void AlgorithmInit(std::shared_ptr &logger); + void AlgorithmChangeRun(); + std::unique_ptr AlgorithmProcess(const edm4eic::CalorimeterHitCollection &hits, const edm4hep::SimCalorimeterHitCollection &mc); }; diff --git a/src/algorithms/calorimetry/ImagingPixelReco.h b/src/algorithms/calorimetry/ImagingPixelReco.h index ad89fef6e2..e26af7cc97 100644 --- a/src/algorithms/calorimetry/ImagingPixelReco.h +++ b/src/algorithms/calorimetry/ImagingPixelReco.h @@ -9,6 +9,7 @@ #include #include +#include #include "DDRec/CellIDPositionConverter.h" #include "DDRec/Surface.h" @@ -46,10 +47,6 @@ class ImagingPixelReco { // Calibration! double m_sampFrac; // {this, "samplingFraction", 1.0}; - // hits containers - std::vector m_inputHits; - std::vector m_outputHits; - // Pointer to the geometry service std::shared_ptr m_geoSvc; @@ -84,11 +81,8 @@ class ImagingPixelReco { } } - void execute() { - // input collections - const auto &rawhits = m_inputHits; - // Create output collections - auto &hits = m_outputHits; + std::unique_ptr execute(const edm4hep::RawCalorimeterHitCollection &rawhits) { + auto recohits = std::make_unique(); // energy time reconstruction for (const auto &rh: rawhits) { @@ -97,18 +91,18 @@ class ImagingPixelReco { #pragma GCC diagnostic error "-Wsign-conversion" // did not pass the threshold - if (rh->getAmplitude() < m_pedMeanADC + m_thresholdFactor * m_pedSigmaADC) { + if (rh.getAmplitude() < m_pedMeanADC + m_thresholdFactor * m_pedSigmaADC) { continue; } const double energy = - (((signed) rh->getAmplitude() - (signed) m_pedMeanADC)) / (double) m_capADC * m_dyRangeADC / + (((signed) rh.getAmplitude() - (signed) m_pedMeanADC)) / (double) m_capADC * m_dyRangeADC / m_sampFrac; // convert ADC -> energy - const double time = rh->getTimeStamp() * 1.e-6; // dd4hep::ns + const double time = rh.getTimeStamp() * 1.e-6; // dd4hep::ns #pragma GCC diagnostic pop try { - const auto id = rh->getCellID(); + const auto id = rh.getCellID(); // @TODO remove const int lid = (int) id_dec->get(id, layer_idx); const int sid = (int) id_dec->get(id, sector_idx); @@ -130,18 +124,19 @@ class ImagingPixelReco { pos.x() / m_lUnit, pos.y() / m_lUnit, pos.z() / m_lUnit ); - hits.push_back(new edm4eic::CalorimeterHit{id, // cellID - static_cast(energy), // energy - 0, // energyError - static_cast(time), // time - 0, // timeError TODO - position, // global pos - {0, 0, 0}, // @TODO: add dimension - sid, lid, - local}); // local pos - }catch(std::exception &e){ + recohits->create(id, // cellID + static_cast(energy), // energy + 0, // energyError + static_cast(time), // time + 0, // timeError TODO + position, // global pos + edm4hep::Vector3f({0, 0, 0}), // @TODO: add dimension + sid, lid, + local); // local pos + } catch(std::exception &e) { m_log->error("ImagingPixelReco::execute {}", e.what()); } } + return recohits; } }; diff --git a/src/detectors/B0ECAL/CalorimeterHit_factory_B0ECalRecHits.h b/src/detectors/B0ECAL/CalorimeterHit_factory_B0ECalRecHits.h index 1fcd672641..8bb10a5206 100644 --- a/src/detectors/B0ECAL/CalorimeterHit_factory_B0ECalRecHits.h +++ b/src/detectors/B0ECAL/CalorimeterHit_factory_B0ECalRecHits.h @@ -77,15 +77,14 @@ class CalorimeterHit_factory_B0ECalRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - rawhits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto recohits_coll = AlgorithmProcess(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(hits); - hits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } }; diff --git a/src/detectors/B0ECAL/ProtoCluster_factory_B0ECalTruthProtoClusters.h b/src/detectors/B0ECAL/ProtoCluster_factory_B0ECalTruthProtoClusters.h index 46d9b30049..5d884a9974 100644 --- a/src/detectors/B0ECAL/ProtoCluster_factory_B0ECalTruthProtoClusters.h +++ b/src/detectors/B0ECAL/ProtoCluster_factory_B0ECalTruthProtoClusters.h @@ -41,15 +41,14 @@ class ProtoCluster_factory_B0ECalTruthProtoClusters : public JChainFactoryT &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0]); - m_mcHits = event->Get(GetInputTags()[1]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); + auto sim_coll = static_cast(event->GetCollectionBase(GetInputTags()[1])); // Call Process for generic algorithm - AlgorithmProcess(); + auto protoclust_coll = AlgorithmProcess(*hits_coll, *sim_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputProtoClusters); - m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(protoclust_coll)); } }; diff --git a/src/detectors/B0ECAL/RawCalorimeterHit_factory_B0ECalRawHits.h b/src/detectors/B0ECAL/RawCalorimeterHit_factory_B0ECalRawHits.h index 3b9cf785ab..672a6f19c1 100644 --- a/src/detectors/B0ECAL/RawCalorimeterHit_factory_B0ECalRawHits.h +++ b/src/detectors/B0ECAL/RawCalorimeterHit_factory_B0ECalRawHits.h @@ -80,15 +80,14 @@ class RawCalorimeterHit_factory_B0ECalRawHits : public JChainFactoryT &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/detectors/B0ECAL/TruthCluster_factory_B0ECalTruthProtoClusters.h b/src/detectors/B0ECAL/TruthCluster_factory_B0ECalTruthProtoClusters.h index 3bc5930c96..332aeb79df 100644 --- a/src/detectors/B0ECAL/TruthCluster_factory_B0ECalTruthProtoClusters.h +++ b/src/detectors/B0ECAL/TruthCluster_factory_B0ECalTruthProtoClusters.h @@ -37,15 +37,14 @@ class TruthCluster_factory_B0ECalTruthProtoClusters : public JChainFactoryT &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0][0]); - m_mcHits = event->Get(GetInputTags()[0][1]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0][0])); + auto sim_coll = static_cast(event->GetCollectionBase(GetInputTags()[0][1])); // Call Process for generic algorithm - AlgorithmProcess(); + auto protoclust_coll = AlgorithmProcess(*hits_coll, *sim_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputProtoClusters); - m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(protoclust_coll)); } }; diff --git a/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelImagingRecHits.h b/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelImagingRecHits.h index 396be67926..d3d7b9c297 100644 --- a/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelImagingRecHits.h +++ b/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelImagingRecHits.h @@ -55,15 +55,14 @@ class CalorimeterHit_factory_EcalBarrelImagingRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - execute(); + auto recohits_coll = execute(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputHits); - m_outputHits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } }; diff --git a/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelScFiMergedHits.h b/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelScFiMergedHits.h index 40eaf5ec77..256606e3f2 100644 --- a/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelScFiMergedHits.h +++ b/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelScFiMergedHits.h @@ -45,14 +45,13 @@ class CalorimeterHit_factory_EcalBarrelScFiMergedHits : public JChainFactoryT &event) override{ - // Prefill inputs - m_inputs = event->Get(GetInputTags()[0]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - execute(); + auto mergedhits_coll = execute(*hits_coll); - // Hand ownership of algorithm objects over to JANA - Set(m_outputs); - m_outputs.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(mergedhits_coll)); } }; diff --git a/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelScFiRecHits.h b/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelScFiRecHits.h index 395ad8bc39..9ee29e14d0 100644 --- a/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelScFiRecHits.h +++ b/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelScFiRecHits.h @@ -79,15 +79,14 @@ class CalorimeterHit_factory_EcalBarrelScFiRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - rawhits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto recohits_coll = AlgorithmProcess(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(hits); - hits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } }; diff --git a/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelSciGlassRecHits.h b/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelSciGlassRecHits.h index 8dd49d5bf5..de9768df3f 100644 --- a/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelSciGlassRecHits.h +++ b/src/detectors/BEMC/CalorimeterHit_factory_EcalBarrelSciGlassRecHits.h @@ -69,15 +69,14 @@ class CalorimeterHit_factory_EcalBarrelSciGlassRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - rawhits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto recohits_coll = AlgorithmProcess(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(hits); - hits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } }; diff --git a/src/detectors/BEMC/ProtoCluster_factory_EcalBarrelSciGlassTruthProtoClusters.h b/src/detectors/BEMC/ProtoCluster_factory_EcalBarrelSciGlassTruthProtoClusters.h index d8a0af76a0..16b5f88e40 100644 --- a/src/detectors/BEMC/ProtoCluster_factory_EcalBarrelSciGlassTruthProtoClusters.h +++ b/src/detectors/BEMC/ProtoCluster_factory_EcalBarrelSciGlassTruthProtoClusters.h @@ -39,15 +39,14 @@ class ProtoCluster_factory_EcalBarrelSciGlassTruthProtoClusters : public JChainF //------------------------------------------ // Process void Process(const std::shared_ptr &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0]); - m_mcHits = event->Get(GetInputTags()[1]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); + auto sim_coll = static_cast(event->GetCollectionBase(GetInputTags()[1])); // Call Process for generic algorithm - AlgorithmProcess(); + auto protoclust_coll = AlgorithmProcess(*hits_coll, *sim_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputProtoClusters); - m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(protoclust_coll)); } }; diff --git a/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelImagingRawHits.h b/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelImagingRawHits.h index 8a6b5d0499..edbc5769b3 100644 --- a/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelImagingRawHits.h +++ b/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelImagingRawHits.h @@ -75,15 +75,14 @@ class RawCalorimeterHit_factory_EcalBarrelImagingRawHits : public JChainFactoryT //------------------------------------------ // Process void Process(const std::shared_ptr &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelScFiRawHits.h b/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelScFiRawHits.h index 6cae50bf47..c9e3abd4d5 100644 --- a/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelScFiRawHits.h +++ b/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelScFiRawHits.h @@ -76,15 +76,14 @@ class RawCalorimeterHit_factory_EcalBarrelScFiRawHits : public JChainFactoryT &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits.h b/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits.h index f270bb1ac6..6fb66dcb0a 100644 --- a/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits.h +++ b/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits.h @@ -79,15 +79,14 @@ class RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits : public JChainFactory //------------------------------------------ // Process void Process(const std::shared_ptr &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/detectors/BHCAL/CalorimeterHit_factory_HcalBarrelRecHits.h b/src/detectors/BHCAL/CalorimeterHit_factory_HcalBarrelRecHits.h index 7aacfa071d..c929168b05 100644 --- a/src/detectors/BHCAL/CalorimeterHit_factory_HcalBarrelRecHits.h +++ b/src/detectors/BHCAL/CalorimeterHit_factory_HcalBarrelRecHits.h @@ -76,15 +76,14 @@ class CalorimeterHit_factory_HcalBarrelRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - rawhits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto recohits_coll = AlgorithmProcess(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(hits); - hits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } std::shared_ptr m_log; diff --git a/src/detectors/BHCAL/ProtoCluster_factory_HcalBarrelTruthProtoClusters.h b/src/detectors/BHCAL/ProtoCluster_factory_HcalBarrelTruthProtoClusters.h index d1f462a15a..e569724029 100644 --- a/src/detectors/BHCAL/ProtoCluster_factory_HcalBarrelTruthProtoClusters.h +++ b/src/detectors/BHCAL/ProtoCluster_factory_HcalBarrelTruthProtoClusters.h @@ -42,16 +42,15 @@ class ProtoCluster_factory_HcalBarrelTruthProtoClusters : public JChainFactoryT< //------------------------------------------ // Process void Process(const std::shared_ptr &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0]); - m_mcHits = event->Get(GetInputTags()[1]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); + auto sim_coll = static_cast(event->GetCollectionBase(GetInputTags()[1])); // Call Process for generic algorithm - AlgorithmProcess(); + auto protoclust_coll = AlgorithmProcess(*hits_coll, *sim_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputProtoClusters); - m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(protoclust_coll)); } private: std::shared_ptr m_log; diff --git a/src/detectors/BHCAL/RawCalorimeterHit_factory_HcalBarrelRawHits.h b/src/detectors/BHCAL/RawCalorimeterHit_factory_HcalBarrelRawHits.h index 71541810a4..e888f65093 100644 --- a/src/detectors/BHCAL/RawCalorimeterHit_factory_HcalBarrelRawHits.h +++ b/src/detectors/BHCAL/RawCalorimeterHit_factory_HcalBarrelRawHits.h @@ -79,15 +79,14 @@ class RawCalorimeterHit_factory_HcalBarrelRawHits : public JChainFactoryT &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/detectors/EEMC/CalorimeterHit_factory_EcalEndcapNRecHits.h b/src/detectors/EEMC/CalorimeterHit_factory_EcalEndcapNRecHits.h index ab587e3377..359d9bcfba 100644 --- a/src/detectors/EEMC/CalorimeterHit_factory_EcalEndcapNRecHits.h +++ b/src/detectors/EEMC/CalorimeterHit_factory_EcalEndcapNRecHits.h @@ -76,15 +76,14 @@ class CalorimeterHit_factory_EcalEndcapNRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - rawhits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto recohits_coll = AlgorithmProcess(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(hits); - hits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } }; diff --git a/src/detectors/EEMC/ProtoCluster_factory_EcalEndcapNTruthProtoClusters.h b/src/detectors/EEMC/ProtoCluster_factory_EcalEndcapNTruthProtoClusters.h index efe1f82e7b..55097fc327 100644 --- a/src/detectors/EEMC/ProtoCluster_factory_EcalEndcapNTruthProtoClusters.h +++ b/src/detectors/EEMC/ProtoCluster_factory_EcalEndcapNTruthProtoClusters.h @@ -41,15 +41,14 @@ class ProtoCluster_factory_EcalEndcapNTruthProtoClusters : public JChainFactoryT //------------------------------------------ // Process void Process(const std::shared_ptr &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0]); - m_mcHits = event->Get(GetInputTags()[1]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); + auto sim_coll = static_cast(event->GetCollectionBase(GetInputTags()[1])); // Call Process for generic algorithm - AlgorithmProcess(); + auto protoclust_coll = AlgorithmProcess(*hits_coll, *sim_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputProtoClusters); - m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(protoclust_coll)); } }; diff --git a/src/detectors/EEMC/RawCalorimeterHit_factory_EcalEndcapNRawHits.h b/src/detectors/EEMC/RawCalorimeterHit_factory_EcalEndcapNRawHits.h index cfd52ea722..d57a17895c 100644 --- a/src/detectors/EEMC/RawCalorimeterHit_factory_EcalEndcapNRawHits.h +++ b/src/detectors/EEMC/RawCalorimeterHit_factory_EcalEndcapNRawHits.h @@ -79,15 +79,14 @@ class RawCalorimeterHit_factory_EcalEndcapNRawHits : public JChainFactoryT &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/detectors/EHCAL/CalorimeterHit_factory_HcalEndcapNMergedHits.h b/src/detectors/EHCAL/CalorimeterHit_factory_HcalEndcapNMergedHits.h index 18d6c5c2eb..36a670f6a6 100644 --- a/src/detectors/EHCAL/CalorimeterHit_factory_HcalEndcapNMergedHits.h +++ b/src/detectors/EHCAL/CalorimeterHit_factory_HcalEndcapNMergedHits.h @@ -45,14 +45,13 @@ class CalorimeterHit_factory_HcalEndcapNMergedHits : public JChainFactoryT &event) override{ - // Prefill inputs - m_inputs = event->Get(GetInputTags()[0]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - execute(); + auto mergedhits_coll = execute(*hits_coll); - // Hand ownership of algorithm objects over to JANA - Set(m_outputs); - m_outputs.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(mergedhits_coll)); } }; diff --git a/src/detectors/EHCAL/CalorimeterHit_factory_HcalEndcapNRecHits.h b/src/detectors/EHCAL/CalorimeterHit_factory_HcalEndcapNRecHits.h index 64ee101d8f..ab402d3d82 100644 --- a/src/detectors/EHCAL/CalorimeterHit_factory_HcalEndcapNRecHits.h +++ b/src/detectors/EHCAL/CalorimeterHit_factory_HcalEndcapNRecHits.h @@ -76,15 +76,14 @@ class CalorimeterHit_factory_HcalEndcapNRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - rawhits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto recohits_coll = AlgorithmProcess(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(hits); - hits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } }; diff --git a/src/detectors/EHCAL/ProtoCluster_factory_HcalEndcapNTruthProtoClusters.h b/src/detectors/EHCAL/ProtoCluster_factory_HcalEndcapNTruthProtoClusters.h index 867743ed03..a16a0f5cd5 100644 --- a/src/detectors/EHCAL/ProtoCluster_factory_HcalEndcapNTruthProtoClusters.h +++ b/src/detectors/EHCAL/ProtoCluster_factory_HcalEndcapNTruthProtoClusters.h @@ -41,15 +41,14 @@ class ProtoCluster_factory_HcalEndcapNTruthProtoClusters : public JChainFactoryT //------------------------------------------ // Process void Process(const std::shared_ptr &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0]); - m_mcHits = event->Get(GetInputTags()[1]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); + auto sim_coll = static_cast(event->GetCollectionBase(GetInputTags()[1])); // Call Process for generic algorithm - AlgorithmProcess(); + auto protoclust_coll = AlgorithmProcess(*hits_coll, *sim_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputProtoClusters); - m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(protoclust_coll)); } }; diff --git a/src/detectors/EHCAL/RawCalorimeterHit_factory_HcalEndcapNRawHits.h b/src/detectors/EHCAL/RawCalorimeterHit_factory_HcalEndcapNRawHits.h index 30ab50cd9d..38c8661059 100644 --- a/src/detectors/EHCAL/RawCalorimeterHit_factory_HcalEndcapNRawHits.h +++ b/src/detectors/EHCAL/RawCalorimeterHit_factory_HcalEndcapNRawHits.h @@ -78,15 +78,14 @@ class RawCalorimeterHit_factory_HcalEndcapNRawHits : public JChainFactoryT &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/detectors/FEMC/CalorimeterHit_factory_EcalEndcapPInsertRecHits.h b/src/detectors/FEMC/CalorimeterHit_factory_EcalEndcapPInsertRecHits.h index 2ff949fb8c..1ea42ffa7d 100644 --- a/src/detectors/FEMC/CalorimeterHit_factory_EcalEndcapPInsertRecHits.h +++ b/src/detectors/FEMC/CalorimeterHit_factory_EcalEndcapPInsertRecHits.h @@ -75,15 +75,14 @@ class CalorimeterHit_factory_EcalEndcapPInsertRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - rawhits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto recohits_coll = AlgorithmProcess(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(hits); - hits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } }; diff --git a/src/detectors/FEMC/CalorimeterHit_factory_EcalEndcapPRecHits.h b/src/detectors/FEMC/CalorimeterHit_factory_EcalEndcapPRecHits.h index a85436aa4d..99d88baf49 100644 --- a/src/detectors/FEMC/CalorimeterHit_factory_EcalEndcapPRecHits.h +++ b/src/detectors/FEMC/CalorimeterHit_factory_EcalEndcapPRecHits.h @@ -76,15 +76,14 @@ class CalorimeterHit_factory_EcalEndcapPRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - rawhits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto recohits_coll = AlgorithmProcess(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(hits); - hits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } }; diff --git a/src/detectors/FEMC/ProtoCluster_factory_EcalEndcapPInsertTruthProtoClusters.h b/src/detectors/FEMC/ProtoCluster_factory_EcalEndcapPInsertTruthProtoClusters.h index 4c54ae5d46..e672a7143b 100644 --- a/src/detectors/FEMC/ProtoCluster_factory_EcalEndcapPInsertTruthProtoClusters.h +++ b/src/detectors/FEMC/ProtoCluster_factory_EcalEndcapPInsertTruthProtoClusters.h @@ -39,15 +39,14 @@ class ProtoCluster_factory_EcalEndcapPInsertTruthProtoClusters : public JChainFa //------------------------------------------ // Process void Process(const std::shared_ptr &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0]); - m_mcHits = event->Get(GetInputTags()[1]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); + auto sim_coll = static_cast(event->GetCollectionBase(GetInputTags()[1])); // Call Process for generic algorithm - AlgorithmProcess(); + auto protoclust_coll = AlgorithmProcess(*hits_coll, *sim_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputProtoClusters); - m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(protoclust_coll)); } }; diff --git a/src/detectors/FEMC/ProtoCluster_factory_EcalEndcapPTruthProtoClusters.h b/src/detectors/FEMC/ProtoCluster_factory_EcalEndcapPTruthProtoClusters.h index 050ebf973b..aef08fd67a 100644 --- a/src/detectors/FEMC/ProtoCluster_factory_EcalEndcapPTruthProtoClusters.h +++ b/src/detectors/FEMC/ProtoCluster_factory_EcalEndcapPTruthProtoClusters.h @@ -41,15 +41,14 @@ class ProtoCluster_factory_EcalEndcapPTruthProtoClusters : public JChainFactoryT //------------------------------------------ // Process void Process(const std::shared_ptr &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0]); - m_mcHits = event->Get(GetInputTags()[1]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); + auto sim_coll = static_cast(event->GetCollectionBase(GetInputTags()[1])); // Call Process for generic algorithm - AlgorithmProcess(); + auto protoclust_coll = AlgorithmProcess(*hits_coll, *sim_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputProtoClusters); - m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(protoclust_coll)); } }; diff --git a/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPInsertRawHits.h b/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPInsertRawHits.h index da439b46af..0d54ee1065 100644 --- a/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPInsertRawHits.h +++ b/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPInsertRawHits.h @@ -76,15 +76,14 @@ class RawCalorimeterHit_factory_EcalEndcapPInsertRawHits : public JChainFactoryT //------------------------------------------ // Process void Process(const std::shared_ptr &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPRawHits.h b/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPRawHits.h index a38b34a8f5..f45a6dd39c 100644 --- a/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPRawHits.h +++ b/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPRawHits.h @@ -81,15 +81,14 @@ class RawCalorimeterHit_factory_EcalEndcapPRawHits : public JChainFactoryT &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPInsertMergedHits.h b/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPInsertMergedHits.h index 885ffc0373..64123859bd 100644 --- a/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPInsertMergedHits.h +++ b/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPInsertMergedHits.h @@ -44,14 +44,13 @@ class CalorimeterHit_factory_HcalEndcapPInsertMergedHits : public JChainFactoryT //------------------------------------------ // Process void Process(const std::shared_ptr &event) override{ - // Prefill inputs - m_inputs = event->Get(GetInputTags()[0]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - execute(); + auto mergedhits_coll = execute(*hits_coll); - // Hand ownership of algorithm objects over to JANA - Set(m_outputs); - m_outputs.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(mergedhits_coll)); } }; diff --git a/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPInsertRecHits.h b/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPInsertRecHits.h index 403c20e965..404c5466fe 100644 --- a/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPInsertRecHits.h +++ b/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPInsertRecHits.h @@ -75,15 +75,14 @@ class CalorimeterHit_factory_HcalEndcapPInsertRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - rawhits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto recohits_coll = AlgorithmProcess(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(hits); - hits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } }; diff --git a/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPMergedHits.h b/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPMergedHits.h index 0912fa2488..caa838142f 100644 --- a/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPMergedHits.h +++ b/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPMergedHits.h @@ -45,14 +45,13 @@ class CalorimeterHit_factory_HcalEndcapPMergedHits : public JChainFactoryT &event) override{ - // Prefill inputs - m_inputs = event->Get(GetInputTags()[0]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - execute(); + auto mergedhits_coll = execute(*hits_coll); - // Hand ownership of algorithm objects over to JANA - Set(m_outputs); - m_outputs.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(mergedhits_coll)); } }; diff --git a/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPRecHits.h b/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPRecHits.h index d34b9323d9..02084024d1 100644 --- a/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPRecHits.h +++ b/src/detectors/FHCAL/CalorimeterHit_factory_HcalEndcapPRecHits.h @@ -76,15 +76,14 @@ class CalorimeterHit_factory_HcalEndcapPRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - rawhits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto recohits_coll = AlgorithmProcess(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(hits); - hits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } }; diff --git a/src/detectors/FHCAL/CalorimeterHit_factory_LFHCALRecHits.h b/src/detectors/FHCAL/CalorimeterHit_factory_LFHCALRecHits.h index 0e05524c48..1c17c548e9 100644 --- a/src/detectors/FHCAL/CalorimeterHit_factory_LFHCALRecHits.h +++ b/src/detectors/FHCAL/CalorimeterHit_factory_LFHCALRecHits.h @@ -80,15 +80,14 @@ class CalorimeterHit_factory_LFHCALRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - rawhits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto recohits_coll = AlgorithmProcess(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(hits); - hits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } }; diff --git a/src/detectors/FHCAL/ProtoCluster_factory_HcalEndcapPInsertTruthProtoClusters.h b/src/detectors/FHCAL/ProtoCluster_factory_HcalEndcapPInsertTruthProtoClusters.h index e657d8c520..13a4da2b6f 100644 --- a/src/detectors/FHCAL/ProtoCluster_factory_HcalEndcapPInsertTruthProtoClusters.h +++ b/src/detectors/FHCAL/ProtoCluster_factory_HcalEndcapPInsertTruthProtoClusters.h @@ -39,15 +39,14 @@ class ProtoCluster_factory_HcalEndcapPInsertTruthProtoClusters : public JChainFa //------------------------------------------ // Process void Process(const std::shared_ptr &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0]); - m_mcHits = event->Get(GetInputTags()[1]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); + auto sim_coll = static_cast(event->GetCollectionBase(GetInputTags()[1])); // Call Process for generic algorithm - AlgorithmProcess(); + auto protoclust_coll = AlgorithmProcess(*hits_coll, *sim_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputProtoClusters); - m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(protoclust_coll)); } }; diff --git a/src/detectors/FHCAL/ProtoCluster_factory_HcalEndcapPTruthProtoClusters.h b/src/detectors/FHCAL/ProtoCluster_factory_HcalEndcapPTruthProtoClusters.h index 81a548d509..79f47cc70b 100644 --- a/src/detectors/FHCAL/ProtoCluster_factory_HcalEndcapPTruthProtoClusters.h +++ b/src/detectors/FHCAL/ProtoCluster_factory_HcalEndcapPTruthProtoClusters.h @@ -41,15 +41,14 @@ class ProtoCluster_factory_HcalEndcapPTruthProtoClusters : public JChainFactoryT //------------------------------------------ // Process void Process(const std::shared_ptr &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0]); - m_mcHits = event->Get(GetInputTags()[1]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); + auto sim_coll = static_cast(event->GetCollectionBase(GetInputTags()[1])); // Call Process for generic algorithm - AlgorithmProcess(); + auto protoclust_coll = AlgorithmProcess(*hits_coll, *sim_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputProtoClusters); - m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(protoclust_coll)); } }; diff --git a/src/detectors/FHCAL/ProtoCluster_factory_LFHCALTruthProtoClusters.h b/src/detectors/FHCAL/ProtoCluster_factory_LFHCALTruthProtoClusters.h index c90972a374..1592652782 100644 --- a/src/detectors/FHCAL/ProtoCluster_factory_LFHCALTruthProtoClusters.h +++ b/src/detectors/FHCAL/ProtoCluster_factory_LFHCALTruthProtoClusters.h @@ -40,16 +40,15 @@ class ProtoCluster_factory_LFHCALTruthProtoClusters : public JChainFactoryT &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0]); - m_mcHits = event->Get(GetInputTags()[1]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); + auto sim_coll = static_cast(event->GetCollectionBase(GetInputTags()[1])); // Call Process for generic algorithm - AlgorithmProcess(); + auto protoclust_coll = AlgorithmProcess(*hits_coll, *sim_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputProtoClusters); - m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(protoclust_coll)); } }; diff --git a/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPInsertRawHits.h b/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPInsertRawHits.h index 581a9eabc7..acb5bccef0 100644 --- a/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPInsertRawHits.h +++ b/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPInsertRawHits.h @@ -76,15 +76,14 @@ class RawCalorimeterHit_factory_HcalEndcapPInsertRawHits : public JChainFactoryT //------------------------------------------ // Process void Process(const std::shared_ptr &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPRawHits.h b/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPRawHits.h index a5f64c4f1a..b11d31d574 100644 --- a/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPRawHits.h +++ b/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPRawHits.h @@ -78,15 +78,14 @@ class RawCalorimeterHit_factory_HcalEndcapPRawHits : public JChainFactoryT &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/detectors/FHCAL/RawCalorimeterHit_factory_LFHCALRawHits.h b/src/detectors/FHCAL/RawCalorimeterHit_factory_LFHCALRawHits.h index 944ea9d374..67d73ca41d 100644 --- a/src/detectors/FHCAL/RawCalorimeterHit_factory_LFHCALRawHits.h +++ b/src/detectors/FHCAL/RawCalorimeterHit_factory_LFHCALRawHits.h @@ -79,15 +79,14 @@ class RawCalorimeterHit_factory_LFHCALRawHits : public JChainFactoryT &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/detectors/LUMISPECCAL/CalorimeterHit_factory_EcalLumiSpecRecHits.h b/src/detectors/LUMISPECCAL/CalorimeterHit_factory_EcalLumiSpecRecHits.h index 57c6c27af1..884d6008cf 100644 --- a/src/detectors/LUMISPECCAL/CalorimeterHit_factory_EcalLumiSpecRecHits.h +++ b/src/detectors/LUMISPECCAL/CalorimeterHit_factory_EcalLumiSpecRecHits.h @@ -77,15 +77,14 @@ class CalorimeterHit_factory_EcalLumiSpecRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - rawhits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto recohits_coll = AlgorithmProcess(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(hits); - hits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } }; diff --git a/src/detectors/LUMISPECCAL/ProtoCluster_factory_EcalLumiSpecTruthProtoClusters.h b/src/detectors/LUMISPECCAL/ProtoCluster_factory_EcalLumiSpecTruthProtoClusters.h index 329820424f..94c6b4ec93 100644 --- a/src/detectors/LUMISPECCAL/ProtoCluster_factory_EcalLumiSpecTruthProtoClusters.h +++ b/src/detectors/LUMISPECCAL/ProtoCluster_factory_EcalLumiSpecTruthProtoClusters.h @@ -41,15 +41,14 @@ class ProtoCluster_factory_EcalLumiSpecTruthProtoClusters : public JChainFactory //------------------------------------------ // Process void Process(const std::shared_ptr &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0]); - m_mcHits = event->Get(GetInputTags()[1]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); + auto sim_coll = static_cast(event->GetCollectionBase(GetInputTags()[1])); // Call Process for generic algorithm - AlgorithmProcess(); + auto protoclust_coll = AlgorithmProcess(*hits_coll, *sim_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputProtoClusters); - m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(protoclust_coll)); } }; diff --git a/src/detectors/LUMISPECCAL/RawCalorimeterHit_factory_EcalLumiSpecRawHits.h b/src/detectors/LUMISPECCAL/RawCalorimeterHit_factory_EcalLumiSpecRawHits.h index e81a66f0f5..73e7cba7f4 100644 --- a/src/detectors/LUMISPECCAL/RawCalorimeterHit_factory_EcalLumiSpecRawHits.h +++ b/src/detectors/LUMISPECCAL/RawCalorimeterHit_factory_EcalLumiSpecRawHits.h @@ -79,15 +79,14 @@ class RawCalorimeterHit_factory_EcalLumiSpecRawHits : public JChainFactoryT &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/detectors/ZDC/CalorimeterHit_factory_ZDCEcalRecHits.h b/src/detectors/ZDC/CalorimeterHit_factory_ZDCEcalRecHits.h index fd11ef5500..311b511e70 100644 --- a/src/detectors/ZDC/CalorimeterHit_factory_ZDCEcalRecHits.h +++ b/src/detectors/ZDC/CalorimeterHit_factory_ZDCEcalRecHits.h @@ -76,15 +76,14 @@ class CalorimeterHit_factory_ZDCEcalRecHits : public JChainFactoryT &event) override{ - // Prefill inputs - rawhits = event->Get(GetInputTags()[0]); + // Get input collection + auto rawhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto recohits_coll = AlgorithmProcess(*rawhits_coll); - // Hand owner of algorithm objects over to JANA - Set(hits); - hits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(recohits_coll)); } }; diff --git a/src/detectors/ZDC/ProtoCluster_factory_ZDCEcalTruthProtoClusters.h b/src/detectors/ZDC/ProtoCluster_factory_ZDCEcalTruthProtoClusters.h index 8619551ae3..e8eb9f35df 100644 --- a/src/detectors/ZDC/ProtoCluster_factory_ZDCEcalTruthProtoClusters.h +++ b/src/detectors/ZDC/ProtoCluster_factory_ZDCEcalTruthProtoClusters.h @@ -41,15 +41,14 @@ class ProtoCluster_factory_ZDCEcalTruthProtoClusters : public JChainFactoryT &event) override{ - // Prefill inputs - m_inputHits = event->Get(GetInputTags()[0]); - m_mcHits = event->Get(GetInputTags()[1]); + // Get input collection + auto hits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); + auto sim_coll = static_cast(event->GetCollectionBase(GetInputTags()[1])); // Call Process for generic algorithm - AlgorithmProcess(); + auto protoclust_coll = AlgorithmProcess(*hits_coll, *sim_coll); - // Hand owner of algorithm objects over to JANA - Set(m_outputProtoClusters); - m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(protoclust_coll)); } }; diff --git a/src/detectors/ZDC/RawCalorimeterHit_factory_ZDCEcalRawHits.h b/src/detectors/ZDC/RawCalorimeterHit_factory_ZDCEcalRawHits.h index e3e568da7a..7912b5ec6c 100644 --- a/src/detectors/ZDC/RawCalorimeterHit_factory_ZDCEcalRawHits.h +++ b/src/detectors/ZDC/RawCalorimeterHit_factory_ZDCEcalRawHits.h @@ -78,15 +78,14 @@ class RawCalorimeterHit_factory_ZDCEcalRawHits : public JChainFactoryT &event) override { - // Prefill inputs - simhits = event->Get(GetInputTags()[0]); + // Get input collection + auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); // Call Process for generic algorithm - AlgorithmProcess(); + auto rawhits_coll = AlgorithmProcess(*simhits_coll); - // Hand owner of algorithm objects over to JANA - Set(rawhits); - rawhits.clear(); // not really needed, but better to not leave dangling pointers around + // Hand algorithm objects over to JANA + SetCollection(std::move(rawhits_coll)); } }; diff --git a/src/tests/algorithms_test/calorimetry_CalorimeterHitDigi.cc b/src/tests/algorithms_test/calorimetry_CalorimeterHitDigi.cc index 61dd7c5b0f..ed07451db9 100644 --- a/src/tests/algorithms_test/calorimetry_CalorimeterHitDigi.cc +++ b/src/tests/algorithms_test/calorimetry_CalorimeterHitDigi.cc @@ -30,11 +30,12 @@ TEST_CASE( "the clustering algorithm runs", "[CalorimeterHitDigi]" ) { algo.AlgorithmInit(logger); algo.AlgorithmChangeRun(); - auto mhit = edm4hep::MutableSimCalorimeterHit { + edm4hep::SimCalorimeterHitCollection simhits; + auto mhit = simhits.create( 0xABABABAB, // std::uint64_t cellID 1.0 /* GeV */, // float energy - {0. /* mm */, 0. /* mm */, 0. /* mm */}, // edm4hep::Vector3f position - }; + edm4hep::Vector3f({0. /* mm */, 0. /* mm */, 0. /* mm */}) // edm4hep::Vector3f position + ); mhit.addToContributions({ 0, // std::int32_t PDG 0.5 /* GeV */, // float energy @@ -47,15 +48,12 @@ TEST_CASE( "the clustering algorithm runs", "[CalorimeterHitDigi]" ) { 9.0 /* ns */, // float time {0. /* mm */, 0. /* mm */, 0. /* mm */}, // edm4hep::Vector3f stepPosition }); - algo.simhits = { - new edm4hep::SimCalorimeterHit(mhit), - }; - algo.AlgorithmProcess(); + std::unique_ptr rawhits = algo.AlgorithmProcess(simhits); - REQUIRE( algo.rawhits.size() == 1 ); - REQUIRE( algo.rawhits[0]->getCellID() == 0xABABABAB); - REQUIRE( algo.rawhits[0]->getAmplitude() == 123 + 111 ); - REQUIRE( algo.rawhits[0]->getTimeStamp() == 7 ); // currently, earliest contribution is returned + REQUIRE( (*rawhits).size() == 1 ); + REQUIRE( (*rawhits)[0].getCellID() == 0xABABABAB); + REQUIRE( (*rawhits)[0].getAmplitude() == 123 + 111 ); + REQUIRE( (*rawhits)[0].getTimeStamp() == 7 ); // currently, earliest contribution is returned } }