File indexing completed on 2025-07-14 08:50:49
0001
0002
0003
0004 #pragma once
0005
0006 #include <algorithms/algorithm.h>
0007 #include <edm4eic/ClusterCollection.h>
0008 #include <edm4eic/MCRecoClusterParticleAssociationCollection.h>
0009 #include <algorithm>
0010 #include <cmath>
0011 #include <functional>
0012 #include <map>
0013 #include <optional>
0014 #include <string>
0015 #include <string_view>
0016
0017 #include "CalorimeterClusterShapeConfig.h"
0018 #include "algorithms/interfaces/WithPodConfig.h"
0019
0020 namespace eicrecon {
0021
0022
0023
0024
0025 using CalorimeterClusterShapeAlgorithm = algorithms::Algorithm<
0026 algorithms::Input<edm4eic::ClusterCollection,
0027 std::optional<edm4eic::MCRecoClusterParticleAssociationCollection>>,
0028 algorithms::Output<edm4eic::ClusterCollection,
0029 std::optional<edm4eic::MCRecoClusterParticleAssociationCollection>>>;
0030
0031
0032
0033
0034
0035
0036
0037
0038 class CalorimeterClusterShape : public CalorimeterClusterShapeAlgorithm,
0039 public WithPodConfig<CalorimeterClusterShapeConfig> {
0040
0041 public:
0042
0043 CalorimeterClusterShape(std::string_view name)
0044 : CalorimeterClusterShapeAlgorithm{name,
0045 {"inputClusters", "inputMCClusterAssociations"},
0046 {"outputClusters", "outputMCClusterAssociations"},
0047 "Computes cluster shape parameters"} {}
0048
0049
0050 void init() final;
0051 void process(const Input&, const Output&) const final;
0052
0053 private:
0054
0055 static double constWeight(double , double , double , int ) { return 1.0; }
0056
0057
0058 static double linearWeight(double E, double , double , int ) { return E; }
0059
0060
0061 static double logWeight(double E, double tE, double base, int ) {
0062 return std::max(0., base + std::log(E / tE));
0063 }
0064
0065
0066 const std::map<std::string, std::function<double(double, double, double, int)>> m_weightMethods =
0067 {{"none", constWeight}, {"linear", linearWeight}, {"log", logWeight}};
0068
0069
0070 std::function<double(double, double, double, int)> m_weightFunc;
0071 };
0072
0073 }