From ea151140b0ecab8d422c79812a3869deb4afcf9c Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Fri, 21 Jun 2024 15:04:00 +0200 Subject: [PATCH] Add a few comments and remove others that are not necessary --- k4Reco/Overlay/components/OverlayTiming.cpp | 39 +++++---------------- k4Reco/Overlay/components/OverlayTiming.h | 6 +--- 2 files changed, 10 insertions(+), 35 deletions(-) diff --git a/k4Reco/Overlay/components/OverlayTiming.cpp b/k4Reco/Overlay/components/OverlayTiming.cpp index 2cbb27d..8db6e0a 100644 --- a/k4Reco/Overlay/components/OverlayTiming.cpp +++ b/k4Reco/Overlay/components/OverlayTiming.cpp @@ -50,6 +50,7 @@ StatusCode OverlayTiming::initialize() { for (auto& file : m_inputFileNames.value()) { err += " " + file[0]; } + error() << err << endmsg; return StatusCode::FAILURE; } } @@ -61,7 +62,6 @@ StatusCode OverlayTiming::initialize() { m_Noverlay.value() = std::vector(m_bkgEvents->size(), 1); } - std::vector actualPoisson; if (m_Poisson.empty()) { info() << "Using the default overlay mode (no Poission distribution) for each group, since none was specified with " "Poisson_random_Noverlay" @@ -178,7 +178,7 @@ retType OverlayTiming::operator()(const edm4hep::EventHeaderCollection& m_bkgEvents->m_nextEntry = m_startWithBackgroundEvent; } - // Now overlay the background evnts to each bunchcrossing in the bunch train + // Overlay the background events to each bunchcrossing in the bunch train for (int bxInTrain = 0; bxInTrain < _nBunchTrain; ++bxInTrain) { const int BX_number_in_train = permutation.at(bxInTrain); @@ -198,10 +198,11 @@ retType OverlayTiming::operator()(const edm4hep::EventHeaderCollection& << endmsg; auto backgroundEvent = m_bkgEvents->m_rootFileReaders[groupIndex].readEvent(m_bkgEvents->m_nextEntry); - // if (!ptr) { - // warning() << "No more events in background file " << endmsg; - // break; + // m_bkgEvents->m_nextEntry++; + // if(m_bkgEvents->m_nextEntry >= m_bkgEvents->m_totalNumberOfEvents[groupIndex] && !m_allowReusingBackgroundFiles) { + // throw GaudiException("No more events in background file", name(), StatusCode::FAILURE); // } + // m_bkgEvents->m_nextEntry %= m_bkgEvents->m_totalNumberOfEvents[groupIndex]; auto availableCollections = backgroundEvent.getAvailableCollections(); // Either 0 or negative @@ -279,25 +280,6 @@ retType OverlayTiming::operator()(const edm4hep::EventHeaderCollection& ocoll->push_back(nhit); } } - // else if (TPCHits) { - // for (auto elem : backgroundEvent.get(name)) { - // const float tof = time_of_flight(elem.getPosition()); - // if (!((elem.getTime() + timeOffset > this_start + tof) && - // (elem.getTime() + timeOffset < this_stop + tof))) - // continue; - // auto nhit = elem.clone(); - // auto position = elem.getPosition(); - // if (position.z <= 0.) { - // position.z -= timeOffset * _tpcVdrift_mm_ns; - // } else { - // position.z += timeOffset * _tpcVdrift_mm_ns; - // } - // nhit.setPosition(position); - // nhit.setTime(nhit.getTime() + timeOffset); - // nhit.setOverlay(true); - // ocoll->push_back(nhit); - // } - // } } for (size_t i = 0; i < simCaloHits.size(); ++i) { @@ -335,10 +317,6 @@ retType OverlayTiming::operator()(const edm4hep::EventHeaderCollection& calhit.setCellID(elem.getCellID()); calhit.setEnergy(elem.getEnergy()); calhit.setPosition(elem.getPosition()); - // if (calhit.getCellID() == 18444492282485805327ULL) { - // info() << "Adding hit with cellID " << calhit.getCellID() << " to collection " << name - // << " with index " << calhit.id().index << endmsg; - // } calHitMap[calhit.getCellID()] = calhit; } } else { @@ -359,6 +337,9 @@ retType OverlayTiming::operator()(const edm4hep::EventHeaderCollection& } } } + // Move the SimCalorimeterHitCollections to the output vector + // So far they are stored in a map with the cellID as key + // but they don't belong to any collection yet for (auto& [index, calHitMap] : cellIDsMap) { auto ocoll = edm4hep::SimCalorimeterHitCollection(); for (auto& [cellID, hit] : calHitMap) { @@ -372,5 +353,3 @@ retType OverlayTiming::operator()(const edm4hep::EventHeaderCollection& return std::make_tuple(std::move(oparticles), std::move(osimTrackerHits), std::move(osimCaloHits), std::move(ocaloHitContribs)); } - -StatusCode OverlayTiming::finalize() { return Gaudi::Algorithm::finalize(); } diff --git a/k4Reco/Overlay/components/OverlayTiming.h b/k4Reco/Overlay/components/OverlayTiming.h index f6043d5..e1bc503 100644 --- a/k4Reco/Overlay/components/OverlayTiming.h +++ b/k4Reco/Overlay/components/OverlayTiming.h @@ -11,6 +11,7 @@ #include "k4FWCore/Transformer.h" #include "k4Interface/IUniqueIDGenSvc.h" +// Needed for some of the more complex properties #include "Gaudi/Parsers/Factory.h" #include "Gaudi/Property.h" @@ -59,16 +60,11 @@ struct OverlayTiming : public k4FWCore::MultiTransformer void overlayCollection(std::string collName, const podio::CollectionBase& inColl); virtual StatusCode initialize() final; - /** Execute. - * @return status code - */ - virtual StatusCode finalize() final; retType virtual operator()( const edm4hep::EventHeaderCollection& headers, const edm4hep::MCParticleCollection& mcParticles, const std::vector& simTrackerHits, const std::vector& simCalorimeterHits - // const std::map& caloHitContribs ) const final; std::pair define_time_windows(const std::string& Collection_name) const;