Skip to content

Commit

Permalink
First working algorithm implementation, ready to finish Juggler end
Browse files Browse the repository at this point in the history
  • Loading branch information
sly2j committed Sep 21, 2022
1 parent 5d85f7d commit 8b0de86
Show file tree
Hide file tree
Showing 6 changed files with 335 additions and 325 deletions.
1 change: 1 addition & 0 deletions external/algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ find_package(fmt REQUIRED)
include(GNUInstallDirs)

add_subdirectory(core)
add_subdirectory(calorimetry)
45 changes: 45 additions & 0 deletions external/algorithms/calorimetry/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (C) 2022 Sylvester Joosten

################################################################################
# Package: algorithms core utilities
################################################################################

set(SUBDIR "calorimetry")
set(LIBRARY "algo${SUBDIR}")
set(TARGETS ${TARGETS} ${LIBRARY} PARENT_SCOPE)

file(GLOB SRC CONFIGURE_DEPENDS src/*.cpp)

add_library(${LIBRARY} SHARED ${SRC})
target_link_libraries(${LIBRARY}
PUBLIC
EDM4HEP::edm4hep
EDM4EIC::edm4eic
DD4hep::DDRec
algocore
fmt::fmt)
target_include_directories(${LIBRARY}
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/${SUBDIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(${LIBRARY} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})

install(TARGETS ${LIBRARY}
EXPORT algorithmsTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
NAMESPACE algorithms::)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/${SUBDIR}/include/algorithms
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT dev)

# TODO: Testing
#if(BUILD_TESTING)
# enable_testing()
#endif()

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2022 Sylvester Joosten, Chao, Chao Peng, Whitney Armstrong

/*
* Reconstruct the cluster with Center of Gravity method
* Logarithmic weighting is used for mimicing energy deposit in transverse direction
*
* Author: Sylvester Joosten (ANL), Chao Peng (ANL) 09/19/2022
*/

#include <algorithms/algorithm.h>
#include <algorithms/geo.h>
#include <algorithms/property.h>

// Data types
#include <edm4eic/ClusterCollection.h>
#include <edm4eic/MCRecoClusterParticleAssociationCollection.h>
#include <edm4eic/ProtoClusterCollection.h>
#include <edm4hep/SimCalorimeterHitCollection.h>

namespace algorithms::calorimetry {

using ClusterRecoCoGBase = Algorithm<
Input<edm4eic::ProtoClusterCollection, std::optional<edm4hep::SimCalorimeterHitCollection>>,
Output<edm4eic::ClusterCollection,
std::optional<edm4eic::MCRecoClusterParticleAssociationCollection>>>;

/** Clustering with center of gravity method.
*
* Reconstruct the cluster with Center of Gravity method
* Logarithmic weighting is used for mimicking energy deposit in transverse direction
*
* \ingroup reco
*/
class ClusterRecoCoG : public ClusterRecoCoGBase {
public:
using Input = ClusterRecoCoGBase::Input;
using Output = ClusterRecoCoGBase::Output;
using WeightFunc = std::function<double(double, double, double)>;

// TODO: get rid of "Collection" in names
ClusterRecoCoG(std::string_view name)
: ClusterRecoCoGBase{name,
{"inputProtoClusterCollection", "mcHits"},
{"outputClusterCollection", "outputAssociations"}} {}

void init();
void process(const Input&, const Output&);

private:
edm4eic::MutableCluster reconstruct(const edm4eic::ProtoCluster&) const;

// FIXME do we really want sampling fraction here?
Property<double> m_sampFrac{this, "samplingFraction", 1.0};
Property<double> m_logWeightBase{this, "logWeightBase", 3.6};
Property<std::string> m_energyWeight{this, "energyWeight", "log"};
Property<std::string> m_moduleDimZName{this, "moduleDimZName", ""};
// Constrain the cluster position eta to be within
// the eta of the contributing hits. This is useful to avoid edge effects
// for endcaps.
Property<bool> m_enableEtaBounds{this, "enableEtaBounds", true};

WeightFunc m_weightFunc;

const GeoSvc& m_geo = GeoSvc::instance();
};
} // namespace algorithms::calorimetry

Loading

0 comments on commit 8b0de86

Please sign in to comment.