Skip to content
Open
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
98 changes: 65 additions & 33 deletions src/detectors/FHCAL/FHCAL.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2023 - 2025 Friederike Bock, Wouter Deconinck
// Copyright (C) 2023 - 2026 Friederike Bock, Wouter Deconinck, Aiden Wu

#include <DD4hep/Detector.h>
#include <DD4hep/Readout.h>
#include <DD4hep/Segmentations.h>
#include <Evaluator/DD4hepUnits.h>
#include <JANA/JApplication.h>
#include <JANA/JApplicationFwd.h>
#include <JANA/Utils/JTypeInfo.h>
#include <TString.h>
Expand All @@ -22,6 +26,7 @@
#include "factories/calorimetry/HEXPLIT_factory.h"
#include "factories/calorimetry/ImagingTopoCluster_factory.h"
#include "factories/calorimetry/TrackClusterMergeSplitter_factory.h"
#include "services/geometry/dd4hep/DD4hep_service.h"

extern "C" {
void InitPlugin(JApplication* app) {
Expand All @@ -30,6 +35,16 @@ void InitPlugin(JApplication* app) {

InitJANAPlugin(app);

// Select the insert clustering path from the loaded geometry's readout segmentation.
bool insertUsesPhysicalTiles = false;
try {
auto detector = app->GetService<DD4hep_service>()->detector();
const auto insertSegmentation = detector->readout("HcalEndcapPInsertHits").segmentation();
insertUsesPhysicalTiles = insertSegmentation.type() == "NoSegmentation";
} catch (...) {
// Preserve legacy reconstruction when the insert readout is unavailable.
}

// Make sure digi and reco use the same value
decltype(CalorimeterHitDigiConfig::capADC) HcalEndcapPInsert_capADC = 32768;
decltype(CalorimeterHitDigiConfig::dyRangeADC) HcalEndcapPInsert_dyRangeADC = 200 * dd4hep::MeV;
Expand Down Expand Up @@ -84,40 +99,57 @@ void InitPlugin(JApplication* app) {
app // TODO: Remove me once fixed
));

app->Add(new JOmniFactoryGeneratorT<HEXPLIT_factory>(
"HcalEndcapPInsertSubcellHits", {"HcalEndcapPInsertRecHits"},
{"HcalEndcapPInsertSubcellHits"},
{
.MIP = 480. * dd4hep::keV,
.Emin_in_MIPs = 0.5,
.tmax = 162 * dd4hep::ns, //150 ns + (z at front face)/(speed of light)
},
app // TODO: Remove me once fixed
));
// Clustering for the new insert design
if (insertUsesPhysicalTiles) {
app->Add(new JOmniFactoryGeneratorT<CalorimeterIslandCluster_factory>(
"HcalEndcapPInsertImagingProtoClusters", {"HcalEndcapPInsertRecHits"},
{"HcalEndcapPInsertImagingProtoClusters"},
{
.sectorDist = 10.0 * dd4hep::cm,
.dimScaledLocalDistXY = {1.5, 1.5},
.splitCluster = false,
.minClusterHitEdep = 5.0 * dd4hep::keV,
.minClusterCenterEdep = 3.0 * dd4hep::MeV,
},
app // TODO: Remove me once fixed
));
} else {
// Also preserve the previous scheme
app->Add(new JOmniFactoryGeneratorT<HEXPLIT_factory>(
"HcalEndcapPInsertSubcellHits", {"HcalEndcapPInsertRecHits"},
{"HcalEndcapPInsertSubcellHits"},
{
.MIP = 480. * dd4hep::keV,
.Emin_in_MIPs = 0.5,
.tmax = 162 * dd4hep::ns, //150 ns + (z at front face)/(speed of light)
},
app // TODO: Remove me once fixed
));

app->Add(new JOmniFactoryGeneratorT<ImagingTopoCluster_factory>(
"HcalEndcapPInsertImagingProtoClusters", {"HcalEndcapPInsertSubcellHits"},
{"HcalEndcapPInsertImagingProtoClusters"},
{
.neighbourLayersRange = 1,
.sameLayerDistXY =
{"0.5 * max(HcalEndcapPInsertCellSizeLGRight, HcalEndcapPInsertCellSizeLGLeft)",
"0.5 * max(HcalEndcapPInsertCellSizeLGRight, HcalEndcapPInsertCellSizeLGLeft) * "
"sin(pi / 3)"},
.diffLayerDistXY =
{"0.25 * max(HcalEndcapPInsertCellSizeLGRight, HcalEndcapPInsertCellSizeLGLeft)",
"0.25 * max(HcalEndcapPInsertCellSizeLGRight, HcalEndcapPInsertCellSizeLGLeft) * "
"sin(pi / 3)"},
app->Add(new JOmniFactoryGeneratorT<ImagingTopoCluster_factory>(
"HcalEndcapPInsertImagingProtoClusters", {"HcalEndcapPInsertSubcellHits"},
{"HcalEndcapPInsertImagingProtoClusters"},
{
.neighbourLayersRange = 1,
.sameLayerDistXY =
{"0.5 * max(HcalEndcapPInsertCellSizeLGRight, HcalEndcapPInsertCellSizeLGLeft)",
"0.5 * max(HcalEndcapPInsertCellSizeLGRight, HcalEndcapPInsertCellSizeLGLeft) * "
"sin(pi / 3)"},
.diffLayerDistXY =
{"0.25 * max(HcalEndcapPInsertCellSizeLGRight, HcalEndcapPInsertCellSizeLGLeft)",
"0.25 * max(HcalEndcapPInsertCellSizeLGRight, HcalEndcapPInsertCellSizeLGLeft) * "
"sin(pi / 3)"},

.sameLayerMode = eicrecon::ImagingTopoClusterConfig::ELayerMode::xy,
.sectorDist = 10.0 * dd4hep::cm,
.minClusterHitEdep = 5.0 * dd4hep::keV,
.minClusterCenterEdep = 3.0 * dd4hep::MeV,
.minClusterEdep = 11.0 * dd4hep::MeV,
.minClusterNhits = 100,
},
app // TODO: Remove me once fixed
));
.sameLayerMode = eicrecon::ImagingTopoClusterConfig::ELayerMode::xy,
.sectorDist = 10.0 * dd4hep::cm,
.minClusterHitEdep = 5.0 * dd4hep::keV,
.minClusterCenterEdep = 3.0 * dd4hep::MeV,
.minClusterEdep = 11.0 * dd4hep::MeV,
.minClusterNhits = 100,
},
app // TODO: Remove me once fixed
));
}

app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
"HcalEndcapPInsertTruthClustersWithoutShapes",
Expand Down
Loading