Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 09:55:36

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 Sylvester Joosten, Chao Peng, Whitney Armstrong
0003 
0004 /*
0005  *  Reconstruct the cluster with Center of Gravity method
0006  *  Logarithmic weighting is used for mimicing energy deposit in transverse direction
0007  *
0008  *  Author: Sylvester Joosten (ANL), Chao Peng (ANL) 09/19/2022
0009  */
0010 
0011 #include <algorithms/algorithm.h>
0012 #include <algorithms/geo.h>
0013 
0014 // Data types
0015 #include <edm4eic/ClusterCollection.h>
0016 #include <edm4eic/MCRecoClusterParticleAssociationCollection.h>
0017 #include <edm4eic/ProtoClusterCollection.h>
0018 #include <edm4hep/SimCalorimeterHitCollection.h>
0019 
0020 namespace algorithms::calorimetry {
0021 
0022 using ClusteringAlgorithm = Algorithm<
0023     Input<edm4eic::ProtoClusterCollection, std::optional<edm4hep::SimCalorimeterHitCollection>>,
0024     Output<edm4eic::ClusterCollection,
0025            std::optional<edm4eic::MCRecoClusterParticleAssociationCollection>>>;
0026 
0027 /** Clustering with center of gravity method.
0028  *
0029  *  Reconstruct the cluster with Center of Gravity method
0030  *  Logarithmic weighting is used for mimicking energy deposit in transverse direction
0031  *
0032  * \ingroup reco
0033  */
0034 class ClusterRecoCoG : public ClusteringAlgorithm {
0035 public:
0036   using WeightFunc = std::function<double(double, double, double)>;
0037 
0038   // TODO: get rid of "Collection" in names
0039   ClusterRecoCoG(std::string_view name)
0040       : ClusteringAlgorithm{name,
0041                             {"inputProtoClusterCollection", "mcHits"},
0042                             {"outputClusterCollection", "outputAssociations"},
0043                             "Reconstruct a cluster with the Center of Gravity method. For "
0044                             "simulation results it optionally creates a Cluster <-> MCParticle "
0045                             "association provided both optional arguments are provided."} {}
0046 
0047   void init() final;
0048   void process(const Input&, const Output&) const final;
0049 
0050 private:
0051   edm4eic::MutableCluster reconstruct(const edm4eic::ProtoCluster&) const;
0052 
0053   // TODO FIXME does the sampling fraction belong here or in the hit reconstruction?
0054   Property<double> m_sampFrac{this, "samplingFraction", 1.0, "Sampling fraction"};
0055   Property<double> m_logWeightBase{this, "logWeightBase", 3.6, "Weight base for log weighting"};
0056   Property<std::string> m_energyWeight{this, "energyWeight", "log", "Default hit weight method"};
0057   Property<std::string> m_moduleDimZName{this, "moduleDimZName", "", "z-dim name of the module"};
0058   // Constrain the cluster position eta to be within
0059   // the eta of the contributing hits. This is useful to avoid edge effects
0060   // for endcaps.
0061   Property<bool> m_enableEtaBounds{this, "enableEtaBounds", true, "Constrain cluster to hit eta?"};
0062 
0063   WeightFunc m_weightFunc;
0064 
0065   const GeoSvc& m_geo = GeoSvc::instance();
0066 };
0067 } // namespace algorithms::calorimetry
0068