File indexing completed on 2026-10-05 09:11:17
0001
0002
0003
0004 #pragma once
0005 #include <DD4hep/Detector.h>
0006 #include <algorithms/algorithm.h>
0007 #include <algorithms/geo.h>
0008 #include <edm4eic/ClusterCollection.h>
0009 #include <edm4eic/ReconstructedParticleCollection.h>
0010 #include <spdlog/logger.h>
0011 #include <gsl/pointers>
0012 #include <memory>
0013 #include <string> // for basic_string
0014 #include <string_view> // for string_view
0015 #include <vector>
0016 #include <functional>
0017 #include "algorithms/interfaces/WithPodConfig.h"
0018 #include "services/particle/ParticleSvc.h"
0019 #include "algorithms/reco/FarForwardNeutralsReconstructionConfig.h"
0020
0021 namespace eicrecon {
0022
0023 using FarForwardNeutralsReconstructionAlgorithm =
0024
0025 algorithms::Algorithm<
0026 algorithms::Input<const edm4eic::ClusterCollection,
0027 const edm4eic::ClusterCollection,
0028 const edm4eic::ClusterCollection,
0029 const edm4eic::ClusterCollection>,
0030
0031 algorithms::Output<
0032 edm4eic::ReconstructedParticleCollection,
0033 edm4eic::ReconstructedParticleCollection,
0034 edm4eic::ReconstructedParticleCollection,
0035 edm4eic::ReconstructedParticleCollection>>;
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 class FarForwardNeutralsReconstruction
0056 : public FarForwardNeutralsReconstructionAlgorithm,
0057 public WithPodConfig<FarForwardNeutralsReconstructionConfig> {
0058 public:
0059 FarForwardNeutralsReconstruction(std::string_view name)
0060 : FarForwardNeutralsReconstructionAlgorithm{
0061 name,
0062
0063 {"clustersHcal", "clustersB0", "clustersEcalEndCapP", "clustersLFHCAL"},
0064
0065 {"outputNeutralsHcal", "outputNeutralsB0", "outputNeutralsEcalEndCapP",
0066 "outputNeutralsLFHCAL"},
0067
0068 "Convert EMCal and HCal clusters into neutron or photon candidates"} {}
0069
0070 void init() final;
0071 void process(const Input&, const Output&) const final;
0072
0073 private:
0074 bool isGamma(const edm4eic::Cluster& cluster) const;
0075 std::shared_ptr<spdlog::logger> m_log;
0076 const algorithms::ParticleSvc& m_particleSvc = algorithms::ParticleSvc::instance();
0077 const dd4hep::Detector* m_detector{algorithms::GeoSvc::instance().detector()};
0078 double m_gammaZMax{0};
0079
0080 enum class GammaMode { None, LeaderOnly, AllPassing };
0081 enum class NeutronMode { None, SumAll, LeaderOnly };
0082
0083 using CorrFunc = std::function<double(double, const std::vector<double>&)>;
0084
0085 static double corrPower(double E, const std::vector<double>& coeffs);
0086
0087 int processNeutralCalo(const edm4eic::ClusterCollection* clusters,
0088 edm4eic::ReconstructedParticleCollection* out_neutrals,
0089 const std::vector<double>& gammaScaleCoeff,
0090 const std::vector<double>& neutronScaleCoeff, bool canDetectGammas,
0091 bool canDetectNeutrons, const CorrFunc& gammaCorr,
0092 const CorrFunc& neutronCorr, GammaMode gammaMode,
0093 double gammaLeaderFracMin, double clusterEmin, NeutronMode neutronMode,
0094 bool associateAllClustersToNeutron) const;
0095 };
0096
0097 }