From 9ff6a88706792fad9314844f4dd1441ad5dc1beb Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 15 Aug 2024 15:41:41 -0500 Subject: [PATCH] feat: inject the barrel imaging calorimeter hits into track reconstruction --- .../calorimetry/CalorimeterHitToTrackerHit.cc | 66 +++++++++++++++++++ .../calorimetry/CalorimeterHitToTrackerHit.h | 56 ++++++++++++++++ src/detectors/BEMC/BEMC.cc | 15 ++++- .../CalorimeterHitToTrackerHit_factory.h | 41 ++++++++++++ src/global/tracking/tracking.cc | 22 +++++-- src/services/io/podio/JEventProcessorPODIO.cc | 4 ++ 6 files changed, 198 insertions(+), 6 deletions(-) create mode 100644 src/algorithms/calorimetry/CalorimeterHitToTrackerHit.cc create mode 100644 src/algorithms/calorimetry/CalorimeterHitToTrackerHit.h create mode 100644 src/factories/calorimetry/CalorimeterHitToTrackerHit_factory.h diff --git a/src/algorithms/calorimetry/CalorimeterHitToTrackerHit.cc b/src/algorithms/calorimetry/CalorimeterHitToTrackerHit.cc new file mode 100644 index 000000000..a531571a5 --- /dev/null +++ b/src/algorithms/calorimetry/CalorimeterHitToTrackerHit.cc @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2024 Wouter Deconinck + +#include "algorithms/calorimetry/CalorimeterHitToTrackerHit.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "services/evaluator/EvaluatorSvc.h" + +using namespace dd4hep; + +namespace eicrecon { + +void CalorimeterHitToTrackerHit::init() { } + +void CalorimeterHitToTrackerHit::process( + const CalorimeterHitToTrackerHit::Input& input, + const CalorimeterHitToTrackerHit::Output& output) const { + + const auto [calorimeter_hits] = input; + auto [tracker_hits] = output; + + for (const auto &calorimeter_hit: *calorimeter_hits) { + + edm4eic::CovDiag3f position_error; + + [[maybe_unused]] + auto tracker_hit = tracker_hits->create( + calorimeter_hit.getCellID(), + calorimeter_hit.getPosition(), + position_error, + calorimeter_hit.getTime(), + calorimeter_hit.getTimeError(), + calorimeter_hit.getEnergy(), + calorimeter_hit.getEnergyError() + ); + + } +} + +} // namespace eicrecon diff --git a/src/algorithms/calorimetry/CalorimeterHitToTrackerHit.h b/src/algorithms/calorimetry/CalorimeterHitToTrackerHit.h new file mode 100644 index 000000000..8af9de391 --- /dev/null +++ b/src/algorithms/calorimetry/CalorimeterHitToTrackerHit.h @@ -0,0 +1,56 @@ + +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2022 Chao Peng, Sylvester Joosten, Wouter Deconinck, Chao, Whitney Armstrong + +// Reconstruct digitized outputs, paired with Jug::Digi::CalorimeterHitDigi +// Author: Chao Peng +// Date: 06/14/2021 + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace eicrecon { + + using CalorimeterHitToTrackerHitAlgorithm = algorithms::Algorithm< + algorithms::Input< + edm4eic::CalorimeterHitCollection + >, + algorithms::Output< + edm4eic::TrackerHitCollection + > + >; + + class CalorimeterHitToTrackerHit + : public CalorimeterHitToTrackerHitAlgorithm { + + public: + CalorimeterHitToTrackerHit(std::string_view name) + : CalorimeterHitToTrackerHitAlgorithm{name, + {"inputCalorimeterHitCollection"}, + {"outputTrackerHitCollection"}, + "Convert calorimeter hits into tracker hits."} {} + + void init() final; + void process(const Input&, const Output&) const final; + + private: + const dd4hep::Detector* m_detector{algorithms::GeoSvc::instance().detector()}; + const dd4hep::VolumeManager m_volume_manager{m_detector->volumeManager()}; + + }; + +} // namespace eicrecon diff --git a/src/detectors/BEMC/BEMC.cc b/src/detectors/BEMC/BEMC.cc index 36b2d9953..da7641136 100644 --- a/src/detectors/BEMC/BEMC.cc +++ b/src/detectors/BEMC/BEMC.cc @@ -14,11 +14,14 @@ #include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h" #include "factories/calorimetry/CalorimeterHitDigi_factory.h" #include "factories/calorimetry/CalorimeterHitReco_factory.h" +#include "factories/calorimetry/CalorimeterHitToTrackerHit_factory.h" #include "factories/calorimetry/CalorimeterIslandCluster_factory.h" #include "factories/calorimetry/EnergyPositionClusterMerger_factory.h" #include "factories/calorimetry/ImagingClusterReco_factory.h" #include "factories/calorimetry/ImagingTopoCluster_factory.h" #include "factories/calorimetry/TruthEnergyPositionClusterMerger_factory.h" +#include "factories/meta/SubDivideCollection_factory.h" +#include "algorithms/meta/SubDivideFunctors.h" extern "C" { @@ -155,8 +158,18 @@ extern "C" { .layerField = "layer", .sectorField = "sector", }, - app // TODO: Remove me once fixed + app // TODO: Remove me once fixed )); + app->Add(new JOmniFactoryGeneratorT>( + "EcalBarrelImaging1stLayerRecHits", {"EcalBarrelImagingRecHits"}, {"EcalBarrelImaging1stLayerRecHits"}, + { + .function = ValueSplit<&edm4eic::CalorimeterHit::getLayer>{{{1}}}, + }, + app)); + app->Add(new JOmniFactoryGeneratorT( + "EcalBarrelImagingTrackerRecHits", {"EcalBarrelImaging1stLayerRecHits"}, {"EcalBarrelImagingTrackerRecHits"}, + app)); + app->Add(new JOmniFactoryGeneratorT( "EcalBarrelImagingProtoClusters", {"EcalBarrelImagingRecHits"}, {"EcalBarrelImagingProtoClusters"}, { diff --git a/src/factories/calorimetry/CalorimeterHitToTrackerHit_factory.h b/src/factories/calorimetry/CalorimeterHitToTrackerHit_factory.h new file mode 100644 index 000000000..07a9bb68d --- /dev/null +++ b/src/factories/calorimetry/CalorimeterHitToTrackerHit_factory.h @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2023 Wouter Deconinck + +#pragma once + +#include "algorithms/calorimetry/CalorimeterHitToTrackerHit.h" +#include "services/algorithms_init/AlgorithmsInit_service.h" +#include "extensions/jana/JOmniFactory.h" + + +namespace eicrecon { + +class CalorimeterHitToTrackerHit_factory : public JOmniFactory { + +private: +public: + using AlgoT = eicrecon::CalorimeterHitToTrackerHit; +private: + std::unique_ptr m_algo; + + PodioInput m_calorimeter_hits_input {this}; + PodioOutput m_tracker_hits_output {this}; + + Service m_algorithmsInit {this}; + +public: + void Configure() { + m_algo = std::make_unique(GetPrefix()); + m_algo->level(static_cast(logger()->level())); + m_algo->init(); + } + + void ChangeRun(int64_t run_number) { + } + + void Process(int64_t run_number, uint64_t event_number) { + m_algo->process({m_calorimeter_hits_input()}, {m_tracker_hits_output().get()}); + } +}; + +} // eicrecon diff --git a/src/global/tracking/tracking.cc b/src/global/tracking/tracking.cc index 7221bfa91..4c3bbf602 100644 --- a/src/global/tracking/tracking.cc +++ b/src/global/tracking/tracking.cc @@ -85,12 +85,24 @@ void InitPlugin(JApplication *app) { {"CentralTrackingRawHitAssociations"}, // Output collection name app)); + // Calorimeter hits collector + app->Add(new JOmniFactoryGeneratorT>( + "CentralCalorimeterRecHits", + {"EcalBarrelImagingTrackerRecHits"}, + {"CentralCalorimeterRecHits"}, // Output collection name + app)); + + app->Add(new JOmniFactoryGeneratorT>( + "CentralTrackingCalorimeterRecHits", + {"CentralTrackingRecHits", "CentralCalorimeterRecHits"}, + {"CentralTrackingCalorimeterRecHits"}, // Output collection name + app)); + app->Add(new JOmniFactoryGeneratorT( - "CentralTrackerMeasurements", - {"CentralTrackingRecHits"}, - {"CentralTrackerMeasurements"}, - app - )); + "CentralTrackerMeasurements", + {"CentralTrackingCalorimeterRecHits"}, + {"CentralTrackerMeasurements"}, + app)); app->Add(new JOmniFactoryGeneratorT( "CentralCKFTruthSeededTrajectories", diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index f510c3df5..70ece2810 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -62,8 +62,10 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "MCParticlesHeadOnFrameNoBeamFX", // All tracking hits combined + "CentralCalorimeterRecHits", "CentralTrackingRecHits", "CentralTrackingRawHitAssociations", + "CentralTrackingCalorimeterRecHits", "CentralTrackSeedingResults", "CentralTrackerMeasurements", @@ -258,6 +260,8 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "EcalBarrelTruthClusterAssociations", "EcalBarrelImagingRawHits", "EcalBarrelImagingRecHits", + "EcalBarrelImaging1stLayerRecHits", + "EcalBarrelImagingTrackerRecHits", "EcalBarrelImagingClusters", "EcalBarrelImagingClusterAssociations", "EcalBarrelScFiRawHits",