Skip to content

Commit

Permalink
Topocluster Δx Δy (#1502)
Browse files Browse the repository at this point in the history
### Briefly, what does this PR introduce?
Use Δx and Δy for determining which hits in adjacent layers are
neighbors to one another in both the forward hadronic calorimeter insert
and the ZDC.

### What kind of change does this PR introduce?
- [ ] Bug fix (issue #__)
- [x] New feature (issue #1506 )
- [ ] Documentation update
- [ ] Other: __

### Please check if this PR fulfills the following:
- [X] Tests for the changes have been added
- [X] Documentation has been added / updated
- [X] Changes have been communicated to collaborators

### Does this PR introduce breaking changes? What changes might users
need to make to their code?
no
### Does this PR change default behavior?
yes.  Uses new Δx, Δy mode for the calorimeter insert and the ZDC

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Wouter Deconinck <[email protected]>
  • Loading branch information
3 people authored Jun 28, 2024
1 parent 87f64cd commit 2413820
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 19 deletions.
30 changes: 24 additions & 6 deletions src/algorithms/calorimetry/ImagingTopoCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace eicrecon {
private:

// unitless counterparts of the input parameters
double localDistXY[2]{0, 0}, layerDistEtaPhi[2]{0, 0}, sectorDist{0};
double localDistXY[2]{0, 0}, layerDistEtaPhi[2]{0, 0}, layerDistXY[2]{0, 0}, sectorDist{0};
double minClusterHitEdep{0}, minClusterCenterEdep{0}, minClusterEdep{0}, minClusterNhits{0};

public:
Expand All @@ -83,6 +83,8 @@ namespace eicrecon {
// using juggler internal units (GeV, dd4hep::mm, dd4hep::ns, dd4hep::rad)
localDistXY[0] = m_cfg.localDistXY[0] / dd4hep::mm;
localDistXY[1] = m_cfg.localDistXY[1] / dd4hep::mm;
layerDistXY[0] = m_cfg.layerDistXY[0] / dd4hep::mm;
layerDistXY[1] = m_cfg.layerDistXY[1] / dd4hep::mm;
layerDistEtaPhi[0] = m_cfg.layerDistEtaPhi[0];
layerDistEtaPhi[1] = m_cfg.layerDistEtaPhi[1] / dd4hep::rad;
sectorDist = m_cfg.sectorDist / dd4hep::mm;
Expand All @@ -95,10 +97,21 @@ namespace eicrecon {
"Local [x, y] distance between hits <= [{:.4f} mm, {:.4f} mm].",
localDistXY[0], localDistXY[1]
);
info("Neighbour layers clustering (same sector and layer id within +- {:d}: "
"Global [eta, phi] distance between hits <= [{:.4f}, {:.4f} rad].",
m_cfg.neighbourLayersRange, layerDistEtaPhi[0], layerDistEtaPhi[1]
);
switch (m_cfg.layerMode) {
case ImagingTopoClusterConfig::ELayerMode::etaphi:
info("Neighbour layers clustering (same sector and layer id within +- {:d}: "
"Global [eta, phi] distance between hits <= [{:.4f}, {:.4f} rad].",
m_cfg.neighbourLayersRange, layerDistEtaPhi[0], layerDistEtaPhi[1]
);

case ImagingTopoClusterConfig::ELayerMode::xy:
info("Neighbour layers clustering (same sector and layer id within +- {:d}: "
"Local [x, y] distance between hits <= [{:.4f}, {:.4f} rad].",
m_cfg.neighbourLayersRange, layerDistXY[0], layerDistXY[1]
);
default:
error("Unknown layer mode.");
}
info("Neighbour sectors clustering (different sector): "
"Global distance between hits <= {:.4f} mm.",
sectorDist
Expand Down Expand Up @@ -169,11 +182,16 @@ namespace eicrecon {
return (std::abs(h1.getLocal().x - h2.getLocal().x) <= localDistXY[0]) &&
(std::abs(h1.getLocal().y - h2.getLocal().y) <= localDistXY[1]);
} else if (ldiff <= m_cfg.neighbourLayersRange) {
switch(m_cfg.layerMode){
case eicrecon::ImagingTopoClusterConfig::ELayerMode::etaphi:
return (std::abs(edm4hep::utils::eta(h1.getPosition()) - edm4hep::utils::eta(h2.getPosition())) <= layerDistEtaPhi[0]) &&
(std::abs(edm4hep::utils::angleAzimuthal(h1.getPosition()) - edm4hep::utils::angleAzimuthal(h2.getPosition())) <=
layerDistEtaPhi[1]);
case eicrecon::ImagingTopoClusterConfig::ELayerMode::xy:
return (std::abs(h1.getPosition().x - h2.getPosition().x) <= layerDistXY[0]) &&
(std::abs(h1.getPosition().y - h2.getPosition().y) <= layerDistXY[1]);
}
}

// not in adjacent layers
return false;
}
Expand Down
35 changes: 34 additions & 1 deletion src/algorithms/calorimetry/ImagingTopoClusterConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <string>
#include <iostream>

namespace eicrecon {

Expand All @@ -13,8 +14,13 @@ namespace eicrecon {
int neighbourLayersRange = 1;
// maximum distance of local (x, y) to be considered as neighbors at the same layer
std::vector<double> localDistXY = {1.0 * dd4hep::mm, 1.0 * dd4hep::mm};
// maximum distance of global (eta, phi) to be considered as neighbors at different layers
// maximum distance of global (eta, phi) to be considered as neighbors at different layers (if layerMode==etaphi)
std::vector<double> layerDistEtaPhi = {0.01, 0.01};
// maximum distance of global (x, y) to be considered as neighbors at different layers (if layerMode==xy)
std::vector<double> layerDistXY = {1.0 * dd4hep::mm, 1.0 * dd4hep::mm};
// determines how neighbors are determined for hits in different layers (using either eta and phi, or x and y)
enum ELayerMode {etaphi=0, xy=1} layerMode = etaphi;

// maximum global distance to be considered as neighbors in different sectors
double sectorDist = 1.0 * dd4hep::cm;

Expand All @@ -29,4 +35,31 @@ namespace eicrecon {

};

std::istream& operator>>(std::istream& in, ImagingTopoClusterConfig::ELayerMode& layerMode) {
std::string s;
in >> s;
// stringifying the enums causes them to be converted to integers before conversion to strings
if (s == "etaphi" or s=="0") {
layerMode = ImagingTopoClusterConfig::ELayerMode::etaphi;
} else if (s == "xy" or s=="1") {
layerMode = ImagingTopoClusterConfig::ELayerMode::xy;
} else {
in.setstate(std::ios::failbit); // Set the fail bit if the input is not valid
}

return in;
}
std::ostream& operator<<(std::ostream& out, ImagingTopoClusterConfig::ELayerMode& layerMode) {
switch(layerMode) {
case ImagingTopoClusterConfig::ELayerMode::etaphi:
out << "etaphi";
break;
case ImagingTopoClusterConfig::ELayerMode::xy:
out << "xy";
break;
default:
out.setstate(std::ios::failbit);
}
return out;
}
} // namespace eicrecon
14 changes: 8 additions & 6 deletions src/detectors/FHCAL/FHCAL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <string>

#include "algorithms/calorimetry/CalorimeterHitDigiConfig.h"
#include "algorithms/calorimetry/ImagingTopoClusterConfig.h"
#include "extensions/jana/JOmniFactoryGeneratorT.h"
#include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h"
#include "factories/calorimetry/CalorimeterHitDigi_factory.h"
Expand Down Expand Up @@ -82,8 +83,8 @@ extern "C" {
"HcalEndcapPInsertSubcellHits", {"HcalEndcapPInsertRecHits"}, {"HcalEndcapPInsertSubcellHits"},
{
.MIP = 800. * dd4hep::keV,
.Emin_in_MIPs=0.1,
.tmax=50 * dd4hep::ns,
.Emin_in_MIPs=0.5,
.tmax=162 * dd4hep::ns, //150 ns + (z at front face)/(speed of light)
},
app // TODO: Remove me once fixed
));
Expand All @@ -94,12 +95,13 @@ extern "C" {
{
.neighbourLayersRange = 1,
.localDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)},
.layerDistEtaPhi = {17e-3, 18.1e-3},
.layerDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)},
.layerMode = eicrecon::ImagingTopoClusterConfig::ELayerMode::xy,
.sectorDist = 10.0 * dd4hep::cm,
.minClusterHitEdep = 100.0 * dd4hep::keV,
.minClusterCenterEdep = 11.0 * dd4hep::MeV,
.minClusterHitEdep = 5.0 * dd4hep::keV,
.minClusterCenterEdep = 5.0 * dd4hep::MeV,
.minClusterEdep = 11.0 * dd4hep::MeV,
.minClusterNhits = 10,
.minClusterNhits = 100,
},
app // TODO: Remove me once fixed
));
Expand Down
14 changes: 8 additions & 6 deletions src/detectors/ZDC/ZDC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <math.h>
#include <string>

#include "algorithms/interfaces/WithPodConfig.h"
#include "algorithms/calorimetry/ImagingTopoClusterConfig.h"
#include "extensions/jana/JOmniFactoryGeneratorT.h"
#include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h"
#include "factories/calorimetry/CalorimeterHitDigi_factory.h"
Expand All @@ -17,6 +17,7 @@
#include "factories/calorimetry/CalorimeterTruthClustering_factory.h"
#include "factories/calorimetry/HEXPLIT_factory.h"
#include "factories/calorimetry/ImagingTopoCluster_factory.h"

extern "C" {
void InitPlugin(JApplication *app) {

Expand Down Expand Up @@ -144,8 +145,8 @@ extern "C" {
"HcalFarForwardZDCSubcellHits", {"HcalFarForwardZDCRecHits"}, {"HcalFarForwardZDCSubcellHits"},
{
.MIP = 472. * dd4hep::keV,
.Emin_in_MIPs=0.1,
.tmax=320 * dd4hep::ns,
.Emin_in_MIPs=0.5,
.tmax=269 * dd4hep::ns,
},
app // TODO: Remove me once fixed
));
Expand All @@ -156,12 +157,13 @@ extern "C" {
{
.neighbourLayersRange = 1,
.localDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)},
.layerDistEtaPhi = {17e-3, 18.1e-3},
.layerDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)},
.layerMode=eicrecon::ImagingTopoClusterConfig::ELayerMode::xy,
.sectorDist = 10.0 * dd4hep::cm,
.minClusterHitEdep = 100.0 * dd4hep::keV,
.minClusterCenterEdep = 1.0 * dd4hep::MeV,
.minClusterCenterEdep = 3.0 * dd4hep::MeV,
.minClusterEdep = 11.0 * dd4hep::MeV,
.minClusterNhits = 10,
.minClusterNhits = 100,
},
app // TODO: Remove me once fixed
));
Expand Down
2 changes: 2 additions & 0 deletions src/factories/calorimetry/ImagingTopoCluster_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class ImagingTopoCluster_factory : public JOmniFactory<ImagingTopoCluster_factor

ParameterRef<std::vector<double>> m_ldxy {this, "localDistXY", config().localDistXY};
ParameterRef<std::vector<double>> m_ldep {this, "layerDistEtaPhi", config().layerDistEtaPhi};
ParameterRef<std::vector<double>> m_ldxy_adjacent {this, "layerDistXY", config().layerDistXY};
ParameterRef<eicrecon::ImagingTopoClusterConfig::ELayerMode> m_laymode {this, "layerMode", config().layerMode};
ParameterRef<int> m_nlr {this, "neighbourLayersRange", config().neighbourLayersRange};
ParameterRef<double> m_sd {this, "sectorDist", config().sectorDist};
ParameterRef<double> m_mched {this, "minClusterHitEdep", config().minClusterHitEdep};
Expand Down
1 change: 1 addition & 0 deletions src/tests/algorithms_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_executable(
${TEST_NAME}
algorithmsInit.cc
calorimetry_CalorimeterIslandCluster.cc
calorimetry_ImagingTopoCluster.cc
tracking_SiliconSimpleCluster.cc
calorimetry_CalorimeterHitDigi.cc
calorimetry_CalorimeterClusterRecoCoG.cc
Expand Down
Loading

0 comments on commit 2413820

Please sign in to comment.