Skip to content

Commit

Permalink
feat: inject the barrel imaging calorimeter hits into track reconstru…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
wdconinc committed Sep 20, 2024
1 parent ae5ce86 commit 9ff6a88
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 6 deletions.
66 changes: 66 additions & 0 deletions src/algorithms/calorimetry/CalorimeterHitToTrackerHit.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2024 Wouter Deconinck

#include "algorithms/calorimetry/CalorimeterHitToTrackerHit.h"

#include <DD4hep/Alignments.h>
#include <DD4hep/IDDescriptor.h>
#include <DD4hep/Objects.h>
#include <DD4hep/Readout.h>
#include <DD4hep/Segmentations.h>
#include <DD4hep/Shapes.h>
#include <DD4hep/VolumeManager.h>
#include <DD4hep/Volumes.h>
#include <DD4hep/config.h>
#include <DDSegmentation/BitFieldCoder.h>
#include <Evaluator/DD4hepUnits.h>
#include <Math/GenVector/Cartesian3D.h>
#include <Math/GenVector/DisplacementVector3D.h>
#include <algorithms/service.h>
#include <edm4eic/EDM4eicVersion.h>
#include <fmt/core.h>
#include <fmt/format.h>
#include <algorithm>
#include <cctype>
#include <gsl/pointers>
#include <map>
#include <ostream>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

#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
56 changes: 56 additions & 0 deletions src/algorithms/calorimetry/CalorimeterHitToTrackerHit.h
Original file line number Diff line number Diff line change
@@ -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 <DD4hep/DetElement.h>
#include <DD4hep/Detector.h>
#include <DD4hep/IDDescriptor.h>
#include <DDRec/CellIDPositionConverter.h>
#include <Parsers/Primitives.h>
#include <algorithms/algorithm.h>
#include <algorithms/geo.h>
#include <edm4eic/CalorimeterHitCollection.h>
#include <edm4eic/TrackerHitCollection.h>
#include <stddef.h>
#include <stdint.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::VolumeManager m_volume_manager{m_detector->volumeManager()};

};

} // namespace eicrecon
15 changes: 14 additions & 1 deletion src/detectors/BEMC/BEMC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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<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

0 comments on commit 9ff6a88

Please sign in to comment.