Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: inject the barrel imaging calorimeter hits into track reconstruction #1570

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions src/algorithms/calorimetry/CalorimeterHitToTrackerHit.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2024 Wouter Deconinck

#include "algorithms/calorimetry/CalorimeterHitToTrackerHit.h"

#include <DD4hep/config.h>
#include <edm4eic/CovDiag3f.h>
#include <gsl/pointers>

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<dd4hep::DetElement, edm4eic::CovDiag3f> 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
52 changes: 52 additions & 0 deletions src/algorithms/calorimetry/CalorimeterHitToTrackerHit.h
Original file line number Diff line number Diff line change
@@ -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 <DD4hep/Detector.h>
#include <DD4hep/VolumeManager.h>
#include <algorithms/algorithm.h>
#include <algorithms/geo.h>
#include <edm4eic/CalorimeterHitCollection.h>
#include <edm4eic/TrackerHitCollection.h>
#include <gsl/pointers>
#include <string>
#include <string_view>

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
19 changes: 17 additions & 2 deletions src/detectors/BEMC/BEMC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@
#include <edm4eic/EDM4eicVersion.h>
#include <Evaluator/DD4hepUnits.h>
#include <JANA/JApplication.h>
#include <edm4eic/CalorimeterHit.h>
#include <math.h>
#include <string>
#include <map>
#include <vector>

#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" {
Expand Down Expand Up @@ -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<SubDivideCollection_factory<edm4eic::CalorimeterHit>>(
"EcalBarrelImaging1stLayerRecHits", {"EcalBarrelImagingRecHits"}, {"EcalBarrelImaging1stLayerRecHits"},
{
.function = ValueSplit<&edm4eic::CalorimeterHit::getLayer>{{{1}}},
},
app));
app->Add(new JOmniFactoryGeneratorT<CalorimeterHitToTrackerHit_factory>(
"EcalBarrelImagingTrackerRecHits", {"EcalBarrelImaging1stLayerRecHits"}, {"EcalBarrelImagingTrackerRecHits"},
app));

app->Add(new JOmniFactoryGeneratorT<ImagingTopoCluster_factory>(
"EcalBarrelImagingProtoClusters", {"EcalBarrelImagingRecHits"}, {"EcalBarrelImagingProtoClusters"},
{
Expand Down
41 changes: 41 additions & 0 deletions src/factories/calorimetry/CalorimeterHitToTrackerHit_factory.h
Original file line number Diff line number Diff line change
@@ -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<CalorimeterHitToTrackerHit_factory> {

private:
public:
using AlgoT = eicrecon::CalorimeterHitToTrackerHit;
private:
std::unique_ptr<AlgoT> m_algo;

PodioInput<edm4eic::CalorimeterHit> m_calorimeter_hits_input {this};
PodioOutput<edm4eic::TrackerHit> m_tracker_hits_output {this};

Service<AlgorithmsInit_service> m_algorithmsInit {this};

public:
void Configure() {
m_algo = std::make_unique<AlgoT>(GetPrefix());
m_algo->level(static_cast<algorithms::LogLevel>(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
22 changes: 17 additions & 5 deletions src/global/tracking/tracking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,24 @@ void InitPlugin(JApplication *app) {
{"CentralTrackingRawHitAssociations"}, // Output collection name
app));

// Calorimeter hits collector
app->Add(new JOmniFactoryGeneratorT<CollectionCollector_factory<edm4eic::TrackerHit>>(
"CentralCalorimeterRecHits",
{"EcalBarrelImagingTrackerRecHits"},
{"CentralCalorimeterRecHits"}, // Output collection name
app));

app->Add(new JOmniFactoryGeneratorT<CollectionCollector_factory<edm4eic::TrackerHit>>(
"CentralTrackingCalorimeterRecHits",
{"CentralTrackingRecHits", "CentralCalorimeterRecHits"},
{"CentralTrackingCalorimeterRecHits"}, // Output collection name
app));

app->Add(new JOmniFactoryGeneratorT<TrackerMeasurementFromHits_factory>(
"CentralTrackerMeasurements",
{"CentralTrackingRecHits"},
{"CentralTrackerMeasurements"},
app
));
"CentralTrackerMeasurements",
{"CentralTrackingCalorimeterRecHits"},
{"CentralTrackerMeasurements"},
app));

app->Add(new JOmniFactoryGeneratorT<CKFTracking_factory>(
"CentralCKFTruthSeededTrajectories",
Expand Down
4 changes: 4 additions & 0 deletions src/services/io/podio/JEventProcessorPODIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ JEventProcessorPODIO::JEventProcessorPODIO() {
"MCParticlesHeadOnFrameNoBeamFX",

// All tracking hits combined
"CentralCalorimeterRecHits",
"CentralTrackingRecHits",
"CentralTrackingRawHitAssociations",
"CentralTrackingCalorimeterRecHits",
"CentralTrackSeedingResults",
"CentralTrackerMeasurements",

Expand Down Expand Up @@ -258,6 +260,8 @@ JEventProcessorPODIO::JEventProcessorPODIO() {
"EcalBarrelTruthClusterAssociations",
"EcalBarrelImagingRawHits",
"EcalBarrelImagingRecHits",
"EcalBarrelImaging1stLayerRecHits",
"EcalBarrelImagingTrackerRecHits",
"EcalBarrelImagingClusters",
"EcalBarrelImagingClusterAssociations",
"EcalBarrelScFiRawHits",
Expand Down
Loading