diff --git a/src/algorithms/calorimetry/CalorimeterHitToTrackerHit.cc b/src/algorithms/calorimetry/CalorimeterHitToTrackerHit.cc new file mode 100644 index 000000000..6952a8abe --- /dev/null +++ b/src/algorithms/calorimetry/CalorimeterHitToTrackerHit.cc @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2024 Wouter Deconinck + +#include "algorithms/calorimetry/CalorimeterHitToTrackerHit.h" + +#include +#include +#include + +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) { + + // Get CellID + auto cell_id{calorimeter_hit.getCellID()}; + + // Determine detector element + auto det_element = m_volume_manager.lookupDetElement(cell_id); + + // Cache position errors for detector elements + static std::map position_error; + if (position_error.count(det_element) == 0) { + + // Determine readout and segmentation + auto readout = m_converter->findReadout(det_element); + auto segmentation = readout.segmentation(); + + // Determine position uncertainty + if (segmentation.type() == "CartesianGridXY") { + auto cell_dimensions = m_converter->cellDimensions(cell_id); + position_error[det_element].xx = cell_dimensions[0] / std::sqrt(12); + position_error[det_element].yy = cell_dimensions[1] / std::sqrt(12); + } else { + continue; + } + } + + // Create tracker hit + tracker_hits->create( + calorimeter_hit.getCellID(), + calorimeter_hit.getPosition(), + position_error[det_element], + 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..d7023b736 --- /dev/null +++ b/src/algorithms/calorimetry/CalorimeterHitToTrackerHit.h @@ -0,0 +1,52 @@ + +// 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 + +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::rec::CellIDPositionConverter* m_converter{algorithms::GeoSvc::instance().cellIDPositionConverter()}; + 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..2bc0f6399 100644 --- a/src/detectors/BEMC/BEMC.cc +++ b/src/detectors/BEMC/BEMC.cc @@ -6,19 +6,24 @@ #include #include #include +#include #include -#include +#include +#include #include "algorithms/calorimetry/CalorimeterHitDigiConfig.h" +#include "algorithms/meta/SubDivideFunctors.h" #include "extensions/jana/JOmniFactoryGeneratorT.h" #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" extern "C" { @@ -155,8 +160,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",