Skip to content
Closed
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
1 change: 1 addition & 0 deletions src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ CalorimeterClusterRecoCoG::reconstruct(const edm4eic::ProtoCluster& pcl) const {
cl.setEnergyError(0.);
cl.setTime(time);
cl.setTimeError(timeError);
cl.setType(m_cfg.clusterType);

// center of gravity with logarithmic weighting
float tw = 0.;
Expand Down
8 changes: 8 additions & 0 deletions src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <vector>
#include <Evaluator/DD4hepUnits.h>

#include "ClusterTypes.h"

namespace eicrecon {

struct CalorimeterClusterRecoCoGConfig {
Expand All @@ -27,6 +29,12 @@ struct CalorimeterClusterRecoCoGConfig {
// the eta of the contributing hits. This is useful to avoid edge effects
// for endcaps.
bool enableEtaBounds = false;

// cluster type: can be used to flag clusters
// as being a type specified by the Jug::Reco::ClusterType
// enum in ClusterTypes.h. This can be useful for, eg.,
// flagging EMCal vs. HCal clusters in downstream algorithms
int32_t clusterType = Jug::Reco::ClusterType::kCluster2D;
};

} // namespace eicrecon
8 changes: 7 additions & 1 deletion src/algorithms/calorimetry/ClusterTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@
#pragma once

namespace Jug::Reco {
enum ClusterType : int32_t { kCluster2D = 0, kCluster3D = 1, kClusterSlice = 2 };
enum ClusterType : int32_t {
kCluster2D = 0,
kCluster3D = 1,
kClusterSlice = 2,
kClusterEMCal = 3,
kClusterHCal = 4
};
Comment on lines +6 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a mutually exclusive enumeration. What about an Ecal cluster makes it impossible to be a 2D or 3D cluster?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct! Ultimately, I think a longer-term, more flexible approach would be to treat the type as a bit field where we could turn on/off bits for 2D, 3D, EMCal, HCal, etc. I say a few words about this in EDM4eic#122.

My rationale in just extending the enum here rather than proceeding with the bit-field approach is that this is a minimal change that still satisfies what's needed for PFA3 (a generic way to identify EMCal vs. HCal clusters). This would allow for PF development to proceed in parallel with exploring better, long-term solutions.

}
2 changes: 1 addition & 1 deletion src/algorithms/calorimetry/EnergyPositionClusterMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "algorithms/calorimetry/EnergyPositionClusterMerger.h"

#include <edm4eic/Cov3f.h>
#include <edm4hep/MCParticle.h>
#include <edm4hep/Vector3f.h>
#include <edm4hep/utils/vector_utils.h>
Expand Down Expand Up @@ -86,6 +85,7 @@ void EnergyPositionClusterMerger::process(const Input& input, const Output& outp
auto new_clus = merged_clus->create();
new_clus.setEnergy(ec.getEnergy());
new_clus.setEnergyError(ec.getEnergyError());
new_clus.setType(m_cfg.clusterType);
new_clus.setTime(pc.getTime());
new_clus.setNhits(pc.getNhits() + ec.getNhits());
new_clus.setPosition(pc.getPosition());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@

#pragma once

#include "ClusterTypes.h"

namespace eicrecon {

struct EnergyPositionClusterMergerConfig {

double energyRelTolerance{0.5};
double phiTolerance{0.1};
double etaTolerance{0.2};

// cluster type: can be used to flag clusters
// as being a type specified by the Jug::Reco::ClusterType
// enum in ClusterTypes.h. This can be useful for, eg.,
// flagging EMCal vs. HCal clusters in downstream algorithms
int32_t clusterType{Jug::Reco::ClusterType::kCluster3D};
};

} // namespace eicrecon
12 changes: 8 additions & 4 deletions src/algorithms/calorimetry/TruthEnergyPositionClusterMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
#include "algorithms/calorimetry/TruthEnergyPositionClusterMerger.h"

#include <Evaluator/DD4hepUnits.h>
#include <edm4eic/Cov3f.h>
#include <edm4hep/Vector3d.h>
#include <edm4hep/Vector3f.h>
#include <edm4hep/utils/vector_utils.h>
#include <fmt/core.h>
#include <podio/ObjectID.h>
Expand All @@ -16,6 +14,8 @@
#include <initializer_list>
#include <vector>

#include "algorithms/calorimetry/TruthEnergyPositionClusterMergerConfig.h"

namespace eicrecon {

void TruthEnergyPositionClusterMerger::process(const Input& input, const Output& output) const {
Expand Down Expand Up @@ -54,13 +54,15 @@ void TruthEnergyPositionClusterMerger::process(const Input& input, const Output&

debug(" --> Processing position cluster {}, mcID: {}, energy: {}", pclus.getObjectID().index,
mcID, pclus.getEnergy());
if (energyMap.count(mcID)) {

if (energyMap.contains(mcID)) {

const auto& eclus = energyMap[mcID];

auto new_clus = merged_clus->create();
new_clus.setEnergy(eclus.getEnergy());
new_clus.setEnergyError(eclus.getEnergyError());
new_clus.setType(m_cfg.clusterType);
new_clus.setTime(pclus.getTime());
new_clus.setNhits(pclus.getNhits() + eclus.getNhits());
new_clus.setPosition(pclus.getPosition());
Expand Down Expand Up @@ -96,6 +98,7 @@ void TruthEnergyPositionClusterMerger::process(const Input& input, const Output&
debug(" --> No matching energy cluster found, copying over position cluster");
auto new_clus = pclus.clone();
new_clus.addToClusters(pclus);
new_clus.setType(m_cfg.clusterType);
merged_clus->push_back(new_clus);

// set association
Expand All @@ -120,6 +123,7 @@ void TruthEnergyPositionClusterMerger::process(const Input& input, const Output&
auto new_clus = merged_clus->create();
new_clus.setEnergy(eclus.getEnergy());
new_clus.setEnergyError(eclus.getEnergyError());
new_clus.setType(m_cfg.clusterType);
new_clus.setTime(eclus.getTime());
new_clus.setNhits(eclus.getNhits());
// FIXME use nominal dd4hep::radius of 110cm, and use start vertex theta and phi
Expand Down Expand Up @@ -169,7 +173,7 @@ std::map<int, edm4eic::Cluster> TruthEnergyPositionClusterMerger::indexedCluster
continue;
}

const bool duplicate = matched.count(mcID);
const bool duplicate = matched.contains(mcID);
if (duplicate) {
trace(" --> WARNING: this is a duplicate mcID, keeping the higher energy cluster");
if (cluster.getEnergy() < matched[mcID].getEnergy()) {
Expand Down
21 changes: 13 additions & 8 deletions src/algorithms/calorimetry/TruthEnergyPositionClusterMerger.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include <string>
#include <string_view>

#include "TruthEnergyPositionClusterMergerConfig.h"
#include "algorithms/interfaces/WithPodConfig.h"

namespace eicrecon {

using TruthEnergyPositionClusterMergerAlgorithm = algorithms::Algorithm<
Expand All @@ -22,14 +25,16 @@ using TruthEnergyPositionClusterMergerAlgorithm = algorithms::Algorithm<
edm4eic::MCRecoClusterParticleAssociationCollection>>;

/** Simple algorithm to merge the energy measurement from cluster1 with the position
* measurement of cluster2 (in case matching clusters are found). If not, it will
* propagate the raw cluster from cluster1 or cluster2
*
* Matching occurs based on the mc truth information of the clusters.
*
* \ingroup reco
*/
class TruthEnergyPositionClusterMerger : public TruthEnergyPositionClusterMergerAlgorithm {
* measurement of cluster2 (in case matching clusters are found). If not, it will
* propagate the raw cluster from cluster1 or cluster2
*
* Matching occurs based on the mc truth information of the clusters.
*
* \ingroup reco
*/
class TruthEnergyPositionClusterMerger
: public TruthEnergyPositionClusterMergerAlgorithm,
public WithPodConfig<TruthEnergyPositionClusterMergerConfig> {

public:
TruthEnergyPositionClusterMerger(std::string_view name)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2025 Derek Anderson

#pragma once

#include "ClusterTypes.h"

namespace eicrecon {

struct TruthEnergyPositionClusterMergerConfig {

// cluster type: can be used to flag clusters
// as being a type specified by the Jug::Reco::ClusterType
// enum in ClusterTypes.h. This can be useful for, eg.,
// flagging EMCal vs. HCal clusters in downstream algorithms
int32_t clusterType{Jug::Reco::ClusterType::kCluster3D};
};

} // namespace eicrecon
13 changes: 11 additions & 2 deletions src/detectors/B0ECAL/B0ECAL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <variant>
#include <vector>

#include "algorithms/calorimetry/ClusterTypes.h"
#include "extensions/jana/JOmniFactoryGeneratorT.h"
#include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h"
#include "factories/calorimetry/CalorimeterClusterShape_factory.h"
Expand Down Expand Up @@ -88,7 +89,11 @@ void InitPlugin(JApplication* app) {
},
{"B0ECalClustersWithoutShapes", // edm4eic::Cluster
"B0ECalClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
{.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 3.6, .enableEtaBounds = false},
{.energyWeight = "log",
.sampFrac = 1.0,
.logWeightBase = 3.6,
.enableEtaBounds = false,
.clusterType = Jug::Reco::ClusterType::kClusterEMCal},
app));

app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
Expand All @@ -104,7 +109,11 @@ void InitPlugin(JApplication* app) {
},
{"B0ECalTruthClustersWithoutShapes", // edm4eic::Cluster
"B0ECalTruthClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
{.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 6.2, .enableEtaBounds = false},
{.energyWeight = "log",
.sampFrac = 1.0,
.logWeightBase = 6.2,
.enableEtaBounds = false,
.clusterType = Jug::Reco::ClusterType::kClusterEMCal},
app));

app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
Expand Down
3 changes: 3 additions & 0 deletions src/detectors/BEMC/BEMC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <vector>

#include "algorithms/calorimetry/CalorimeterHitDigiConfig.h"
#include "algorithms/calorimetry/ClusterTypes.h"
#include "algorithms/calorimetry/ImagingTopoClusterConfig.h"
#include "algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h"
#include "algorithms/digi/PulseGenerationConfig.h"
Expand Down Expand Up @@ -279,6 +280,7 @@ void InitPlugin(JApplication* app) {
.energyRelTolerance = 0.5,
.phiTolerance = 0.1,
.etaTolerance = 0.2,
.clusterType = Jug::Reco::ClusterType::kClusterEMCal,
},
app // TODO: Remove me once fixed
));
Expand All @@ -287,6 +289,7 @@ void InitPlugin(JApplication* app) {
{"MCParticles", "EcalBarrelScFiClusters", "EcalBarrelScFiClusterAssociations",
"EcalBarrelImagingClusters", "EcalBarrelImagingClusterAssociations"},
{"EcalBarrelTruthClusters", "EcalBarrelTruthClusterAssociations"},
{.clusterType = Jug::Reco::ClusterType::kClusterEMCal},
app // TODO: Remove me once fixed
));
}
Expand Down
19 changes: 16 additions & 3 deletions src/detectors/BHCAL/BHCAL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "algorithms/calorimetry/CalorimeterHitDigiConfig.h"
#include "algorithms/calorimetry/CalorimeterIslandClusterConfig.h"
#include "algorithms/calorimetry/ClusterTypes.h"
#include "extensions/jana/JOmniFactoryGeneratorT.h"
#include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h"
#include "factories/calorimetry/CalorimeterClusterShape_factory.h"
Expand Down Expand Up @@ -130,7 +131,11 @@ void InitPlugin(JApplication* app) {
},
{"HcalBarrelClustersWithoutShapes", // edm4eic::Cluster
"HcalBarrelClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
{.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 6.2, .enableEtaBounds = false},
{.energyWeight = "log",
.sampFrac = 1.0,
.logWeightBase = 6.2,
.enableEtaBounds = false,
.clusterType = Jug::Reco::ClusterType::kClusterHCal},
app // TODO: Remove me once fixed
));

Expand All @@ -148,7 +153,11 @@ void InitPlugin(JApplication* app) {
},
{"HcalBarrelTruthClustersWithoutShapes", // edm4eic::Cluster
"HcalBarrelTruthClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
{.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 6.2, .enableEtaBounds = false},
{.energyWeight = "log",
.sampFrac = 1.0,
.logWeightBase = 6.2,
.enableEtaBounds = false,
.clusterType = Jug::Reco::ClusterType::kClusterHCal},
app // TODO: Remove me once fixed
));

Expand Down Expand Up @@ -180,7 +189,11 @@ void InitPlugin(JApplication* app) {
},
{"HcalBarrelSplitMergeClustersWithoutShapes", // edm4eic::Cluster
"HcalBarrelSplitMergeClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
{.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 6.2, .enableEtaBounds = false},
{.energyWeight = "log",
.sampFrac = 1.0,
.logWeightBase = 6.2,
.enableEtaBounds = false,
.clusterType = Jug::Reco::ClusterType::kClusterHCal},
app // TODO: Remove me once fixed
));

Expand Down
24 changes: 16 additions & 8 deletions src/detectors/EEMC/EEMC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <vector>

#include "algorithms/calorimetry/CalorimeterHitDigiConfig.h"
#include "algorithms/calorimetry/ClusterTypes.h"
#include "extensions/jana/JOmniFactoryGeneratorT.h"
#include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h"
#include "factories/calorimetry/CalorimeterHitDigi_factory.h"
Expand Down Expand Up @@ -116,7 +117,11 @@ void InitPlugin(JApplication* app) {
},
{"EcalEndcapNTruthClustersWithoutShapes", // edm4eic::Cluster
"EcalEndcapNTruthClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
{.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 4.6, .enableEtaBounds = false},
{.energyWeight = "log",
.sampFrac = 1.0,
.logWeightBase = 4.6,
.enableEtaBounds = false,
.clusterType = Jug::Reco::ClusterType::kClusterEMCal},
app // TODO: Remove me once fixed
));

Expand All @@ -143,12 +148,11 @@ void InitPlugin(JApplication* app) {
{"EcalEndcapNClustersWithoutShapes", // edm4eic::Cluster
"EcalEndcapNClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
#endif
{
.energyWeight = "log",
.sampFrac = 1.0,
.logWeightBase = 3.6,
.enableEtaBounds = false,
},
{.energyWeight = "log",
.sampFrac = 1.0,
.logWeightBase = 3.6,
.enableEtaBounds = false,
.clusterType = Jug::Reco::ClusterType::kClusterEMCal},
app // TODO: Remove me once fixed
));

Expand Down Expand Up @@ -227,7 +231,11 @@ void InitPlugin(JApplication* app) {
},
{"EcalEndcapNSplitMergeClustersWithoutShapes", // edm4eic::Cluster
"EcalEndcapNSplitMergeClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
{.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 3.6, .enableEtaBounds = false},
{.energyWeight = "log",
.sampFrac = 1.0,
.logWeightBase = 3.6,
.enableEtaBounds = false,
.clusterType = Jug::Reco::ClusterType::kClusterEMCal},
app // TODO: Remove me once fixed
));

Expand Down
Loading
Loading