From 0460774931b520cae595f48927789da0249e24f2 Mon Sep 17 00:00:00 2001 From: Barak Schmookler Date: Tue, 14 Nov 2023 14:26:51 -0500 Subject: [PATCH 001/106] Added digitization for SiPM-on-tile ZDC hits --- src/detectors/ZDC/ZDC.cc | 46 +++++++++---------- src/services/io/podio/JEventProcessorPODIO.cc | 12 ++--- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 396a73181b..b004009a31 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -23,39 +23,39 @@ extern "C" { InitJANAPlugin(app); app->Add(new JChainMultifactoryGeneratorT( - "ZDCEcalRawHits", {"ZDCEcalHits"}, {"ZDCEcalRawHits"}, + "ZDCRawHits", {"HcalFarForwardZDCHits"}, {"ZDCRawHits"}, { .tRes = 0.0 * dd4hep::ns, - .capADC = 8096, - .dyRangeADC = 100 * dd4hep::MeV, + .capADC = 32768, + .dyRangeADC = 200 * dd4hep::MeV, .pedMeanADC = 400, - .pedSigmaADC = 3.2, + .pedSigmaADC = 10, .resolutionTDC = 10 * dd4hep::picosecond, .corrMeanScale = 1.0, }, app // TODO: Remove me once fixed )); app->Add(new JChainMultifactoryGeneratorT( - "ZDCEcalRecHits", {"ZDCEcalRawHits"}, {"ZDCEcalRecHits"}, + "ZDCRecHits", {"ZDCRawHits"}, {"ZDCRecHits"}, { - .capADC = 8096, - .dyRangeADC = 100. * dd4hep::MeV, + .capADC = 32678, + .dyRangeADC = 200. * dd4hep::MeV, .pedMeanADC = 400, - .pedSigmaADC = 3.2, + .pedSigmaADC = 10, .resolutionTDC = 10 * dd4hep::picosecond, - .thresholdFactor = 4.0, - .thresholdValue = 0.0, + .thresholdFactor = 0.0, + .thresholdValue = -100.0, .sampFrac = 1.0, - .readout = "ZDCEcalHits", + .readout = "HcalFarForwardZDCHits", }, app // TODO: Remove me once fixed )); app->Add(new JChainMultifactoryGeneratorT( - "ZDCEcalTruthProtoClusters", {"ZDCEcalRecHits", "ZDCEcalHits"}, {"ZDCEcalTruthProtoClusters"}, + "ZDCTruthProtoClusters", {"ZDCRecHits", "ZDCHits"}, {"ZDCTruthProtoClusters"}, app // TODO: Remove me once fixed )); app->Add(new JChainMultifactoryGeneratorT( - "ZDCEcalIslandProtoClusters", {"ZDCEcalRecHits"}, {"ZDCEcalIslandProtoClusters"}, + "ZDCIslandProtoClusters", {"ZDCRecHits"}, {"ZDCIslandProtoClusters"}, { .sectorDist = 5.0 * dd4hep::cm, .localDistXY = {50 * dd4hep::cm, 50 * dd4hep::cm}, @@ -71,11 +71,11 @@ extern "C" { app->Add( new JChainMultifactoryGeneratorT( - "ZDCEcalTruthClusters", - {"ZDCEcalTruthProtoClusters", // edm4eic::ProtoClusterCollection - "ZDCEcalHits"}, // edm4hep::SimCalorimeterHitCollection - {"ZDCEcalTruthClusters", // edm4eic::Cluster - "ZDCEcalTruthClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation + "ZDCTruthClusters", + {"ZDCTruthProtoClusters", // edm4eic::ProtoClusterCollection + "ZDCHits"}, // edm4hep::SimCalorimeterHitCollection + {"ZDCTruthClusters", // edm4eic::Cluster + "ZDCTruthClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation { .energyWeight = "log", .sampFrac = 1.0, @@ -88,11 +88,11 @@ extern "C" { app->Add( new JChainMultifactoryGeneratorT( - "ZDCEcalClusters", - {"ZDCEcalIslandProtoClusters", // edm4eic::ProtoClusterCollection - "ZDCEcalHits"}, // edm4hep::SimCalorimeterHitCollection - {"ZDCEcalClusters", // edm4eic::Cluster - "ZDCEcalClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation + "ZDCClusters", + {"ZDCIslandProtoClusters", // edm4eic::ProtoClusterCollection + "ZDCHits"}, // edm4hep::SimCalorimeterHitCollection + {"ZDCClusters", // edm4eic::Cluster + "ZDCClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation { .energyWeight = "log", .sampFrac = 1.0, diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index e73815e2f1..54546a340f 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -177,10 +177,10 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "B0ECalRecHits", "B0ECalClusters", "B0ECalClusterAssociations", - "ZDCEcalRawHits", - "ZDCEcalRecHits", - "ZDCEcalClusters", - "ZDCEcalClusterAssociations", + "ZDCRawHits", + "ZDCRecHits", + "ZDCClusters", + "ZDCClusterAssociations", "HcalEndcapNTruthClusters", "HcalEndcapNTruthClusterAssociations", "HcalBarrelTruthClusters", @@ -188,8 +188,8 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "B0ECalRecHits", "B0ECalClusters", "B0ECalClusterAssociations", - "ZDCEcalTruthClusters", - "ZDCEcalTruthClusterAssociations", + "ZDCTruthClusters", + "ZDCTruthClusterAssociations", // DIRC "DIRCRawHits" From dd5b9ccd3b86cf8bf00d5c18a5671b752667bca2 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 5 Dec 2023 20:21:41 -0500 Subject: [PATCH 002/106] added HEXPLIT and LogWeightReco algorithms and implemented them for the ZDC --- src/algorithms/calorimetry/HEXPLIT.cc | 225 ++++++++++++++++++ src/algorithms/calorimetry/HEXPLIT.h | 68 ++++++ src/algorithms/calorimetry/LogWeightReco.cc | 85 +++++++ src/algorithms/calorimetry/LogWeightReco.h | 47 ++++ src/detectors/ZDC/ZDC.cc | 34 +++ src/factories/calorimetry/HEXPLIT_factoryT.h | 83 +++++++ .../calorimetry/LogWeightReco_factoryT.h | 77 ++++++ src/services/io/podio/JEventProcessorPODIO.cc | 2 + 8 files changed, 621 insertions(+) create mode 100644 src/algorithms/calorimetry/HEXPLIT.cc create mode 100644 src/algorithms/calorimetry/HEXPLIT.h create mode 100644 src/algorithms/calorimetry/LogWeightReco.cc create mode 100644 src/algorithms/calorimetry/LogWeightReco.h create mode 100644 src/factories/calorimetry/HEXPLIT_factoryT.h create mode 100644 src/factories/calorimetry/LogWeightReco_factoryT.h diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc new file mode 100644 index 0000000000..e25fe4b9e8 --- /dev/null +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -0,0 +1,225 @@ +// Copyright (C) 2023 Sebouh Paul +// SPDX-License-Identifier: LGPL-3.0-or-later + +// References: +// https://arxiv.org/abs/2308.06939 + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "HEXPLIT.h" + +#include "algorithms/calorimetry/HEXPLITConfig.h" + +//using namespace edm4eic; + +namespace eicrecon { + + + +void HEXPLIT::init(const dd4hep::Detector* detector, std::shared_ptr& logger) { + m_log = logger; + m_detector = detector; +} + + + + //void subcell_reweight(TTreeReaderArray&E,TTreeReaderArray&t,TTreeReaderArray&x,TTreeReaderArray&y,TTreeReaderArray&z, //number of hits, energies, time, and local x,y,z positions of the hits + // vector & subcellE, vector& subcellx, vector & subcelly, vector & subcellz, //returned position of the cluster + // hexplit_opts opts) { +std::unique_ptr HEXPLIT::process(const edm4eic::CalorimeterHitCollection &hits){ + int nhits=hits.size(); + double sl=m_cfg.side_length; + double layer_spacing=m_cfg.layer_spacing; + double Emin=m_cfg.Emin; + double tmax=m_cfg.tmax; + double MIP=m_cfg.MIP; + + double x[nhits]; + double y[nhits]; + double z[nhits]; + double E[nhits]; + double t[nhits]; + + for(int i=0; i(); + double Esum=0; + for(int i=0; itmax) + continue; + + //keep track of the energy in each neighboring cell + double Eneighbors[SUBCELLS]; + for (int j=0; j2.5*layer_spacing || z[i]==z[j]) + continue; + //cout << "z cut" << endl; + if (E[j]tmax) + continue; + //difference in transverse position (in units of side lengths) + double dx=(x[j]-x[i])/sl; + double dy=(y[j]-y[i])/sl; + if (abs(dx)>2 || abs(dy)>sqrt(3)) + continue; + //cout << "dx, dy cut passed: " << dx << " " << dy << endl; + + //loop over locations of the neighboring cells + //and check if the jth hit matches this location + double tol=0.01; //tolerance for rounding errors + for(int k=0;k q = rollAngle * yawAngle * pitchAngle; + + Eigen::Matrix3d rotationMatrix = q.matrix(); + + Eigen::Vector3d translation(m_cfg.trans_x, m_cfg.trans_y, m_cfg.trans_z); + + auto gpos = rotationMatrix*local+translation; + + const decltype(edm4eic::CalorimeterHitData::position) position(gpos[0], gpos[1], gpos[2]); + + //bounding box dimensions depend on the orientation of the rhombus + int orientation = k%3==0; + const decltype(edm4eic::CalorimeterHitData::dimension) dimension(sl*(orientation?1:1.5), sl*sqrt(3)/2.*(orientation?2:1), + hits[i].getDimension()[2]); + + subcellHits->create( + hits[i].getCellID(), + E[i]*weights[k]/sum_weights, + 0, + hits[i].getTime(), + 0, + position, + dimension, + hits[i].getSector(), + hits[i].getLayer(), + local_position); + //subcellE.push_back(E[i]*weights[k]/sum_weights); + //subcellx.push_back(x[i]+subcell_offsets_x[k]*sl); + //subcelly.push_back(y[i]+subcell_offsets_y[k]*sl); + //subcellz.push_back(z[i]); + } + } + return subcellHits; +} + + +} // namespace eicrecon + +/* +// Optional subroutine to merge all hits or subcells at a given transverse position together after doing +// subcell reweighting. This method was found to not improve the angle resolution, so it is not +// used. +void flatten(vector&E, vector& x, vector& y, vector& z, + vector&Enew,vector& xnew, vector& ynew, vector& znew){ + Enew.clear(); + xnew.clear(); + ynew.clear(); + znew.clear(); + for(int i = 0; i& E, vector& x, vector& y, vector& z, double & E_recon, double & x_recon, + double & y_recon, double & z_recon, position_recon_opts& opts){ + + //first determine the total energy of the particle and of the shower + E_recon=0; + double E_shower=0; + for (int i = 0; i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "algorithms/interfaces/WithPodConfig.h" +#include "HEXPLITConfig.h" + +namespace eicrecon { + + class HEXPLIT : public WithPodConfig { + + public: + void init(const dd4hep::Detector* detector, std::shared_ptr& logger); + std::unique_ptr process(const edm4eic::CalorimeterHitCollection &hits) ; + + private: + + + + const int SUBCELLS=12; +//positions where the overlapping cells are relative to a given cell (in units of hexagon side length) + double neighbor_offsets_x[12]={1.5*cos(0), 1.5*cos(M_PI/3), 1.5*cos(2*M_PI/3),1.5*cos(3*M_PI/3), 1.5*cos(4*M_PI/3), 1.5*cos(5*M_PI/3), + -sqrt(3)/2.*sin(0),-sqrt(3)/2.*sin(M_PI/3),-sqrt(3)/2.*sin(2*M_PI/3),-sqrt(3)/2.*sin(3*M_PI/3),-sqrt(3)/2.*sin(4*M_PI/3),-sqrt(3)/2.*sin(5*M_PI/3)}; + double neighbor_offsets_y[12]={1.5*sin(0), 1.5*sin(M_PI/3), 1.5*sin(2*M_PI/3),1.5*sin(3*M_PI/3), 1.5*sin(4*M_PI/3), 1.5*sin(5*M_PI/3), + sqrt(3)/2.*cos(0), sqrt(3)/2.*cos(M_PI/3), sqrt(3)/2.*cos(2*M_PI/3), sqrt(3)/2.*cos(3*M_PI/3), sqrt(3)/2.*cos(4*M_PI/3), sqrt(3)/2.*cos(5*M_PI/3)}; + + //indices of the neighboring cells which overlap to produce a given subcell + int neighbor_indices[12][3]={{0, 11,10}, {1, 6, 11},{2, 7, 6}, {3,8,7}, {4,9,8}, {5,10,9}, + {6, 11, 7}, {7, 6, 8}, {8, 7, 9}, {9,8,10},{10,9,11},{11,10,6}}; + +//positions of the centers of subcells + double subcell_offsets_x[12]={0.75*cos(0), 0.75*cos(M_PI/3), 0.75*cos(2*M_PI/3), 0.75*cos(3*M_PI/3), 0.75*cos(4*M_PI/3), 0.75*cos(5*M_PI/3), + -sqrt(3)/4*cos(0),-sqrt(3)/4*cos(M_PI/3),-sqrt(3)/4*cos(2*M_PI/3),-sqrt(3)/4*cos(3*M_PI/3),-sqrt(3)/4*cos(4*M_PI/3),-sqrt(3)/4*cos(5*M_PI/3)}; + double subcell_offsets_y[12]={0.75*sin(0), 0.75*sin(M_PI/3), 0.75*sin(2*M_PI/3), 0.75*sin(3*M_PI/3), 0.75*sin(4*M_PI/3), 0.75*sin(5*M_PI/3), + sqrt(3)/4*sin(0), sqrt(3)/4*sin(M_PI/3), sqrt(3)/4*sin(2*M_PI/3), sqrt(3)/4*sin(3*M_PI/3), sqrt(3)/4*sin(4*M_PI/3), sqrt(3)/4*sin(5*M_PI/3)}; + + private: + const dd4hep::Detector* m_detector; + std::shared_ptr m_log; + + }; + +} // namespace eicrecon diff --git a/src/algorithms/calorimetry/LogWeightReco.cc b/src/algorithms/calorimetry/LogWeightReco.cc new file mode 100644 index 0000000000..f83b5e297c --- /dev/null +++ b/src/algorithms/calorimetry/LogWeightReco.cc @@ -0,0 +1,85 @@ +// Copyright (C) 2023 Sebouh Paul +// SPDX-License-Identifier: LGPL-3.0-or-later + +// References: +// https://arxiv.org/abs/2308.06939 + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "LogWeightReco.h" + +#include "algorithms/calorimetry/LogWeightRecoConfig.h" + +//using namespace edm4eic; + +namespace eicrecon { + + + + void LogWeightReco::init(const dd4hep::Detector* detector, std::shared_ptr& logger) { + m_log = logger; + m_detector = detector; + } + + + + //void subcell_reweight(TTreeReaderArray&E,TTreeReaderArray&t,TTreeReaderArray&x,TTreeReaderArray&y,TTreeReaderArray&z, //number of hits, energies, time, and local x,y,z positions of the hits + // vector & subcellE, vector& subcellx, vector & subcelly, vector & subcellz, //returned position of the cluster + // hexplit_opts opts) { + std::unique_ptr LogWeightReco::process(const edm4eic::CalorimeterHitCollection &hits){ + + //first determine the total energy of the particle and of the shower + double E_recon=0; + double E_shower=0; + for (int i = 0; i(); + + edm4hep::Vector3f position(x_recon, y_recon, z_recon); + //auto cluster = new edm4eic::Cluster( + auto clus = outputClusters->create(); + + clus.setEnergy(E_recon); + clus.setTime(t_recon); + clus.setPosition(position); + + return outputClusters; + } + +} diff --git a/src/algorithms/calorimetry/LogWeightReco.h b/src/algorithms/calorimetry/LogWeightReco.h new file mode 100644 index 0000000000..560a878c18 --- /dev/null +++ b/src/algorithms/calorimetry/LogWeightReco.h @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2023 Sebouh Paul + +// An algorithm for splitting calorimeter hits in overlapping cells into "subhits" based on the relative +// energies of hits on neighboring layers +// +// Author: Sebouh Paul +// Date: 12/04/2023 + + +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "algorithms/interfaces/WithPodConfig.h" +#include "LogWeightRecoConfig.h" + +namespace eicrecon { + + class LogWeightReco : public WithPodConfig { + + public: + void init(const dd4hep::Detector* detector, std::shared_ptr& logger); + std::unique_ptr process(const edm4eic::CalorimeterHitCollection &hits) ; + + private: + const dd4hep::Detector* m_detector; + std::shared_ptr m_log; + + }; + +} // namespace eicrecon diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index b004009a31..c1e121bec3 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -14,6 +14,9 @@ #include "factories/calorimetry/CalorimeterHitReco_factoryT.h" #include "factories/calorimetry/CalorimeterIslandCluster_factoryT.h" #include "factories/calorimetry/CalorimeterTruthClustering_factoryT.h" +#include "factories/calorimetry/HEXPLIT_factoryT.h" +#include "factories/calorimetry/LogWeightReco_factoryT.h" + extern "C" { void InitPlugin(JApplication *app) { @@ -50,6 +53,37 @@ extern "C" { }, app // TODO: Remove me once fixed )); + + app->Add(new JChainMultifactoryGeneratorT( + "ZDCSubcellHits", {"ZDCRecHits"}, {"ZDCSubcellHits"}, + { + .layer_spacing=25.1*dd4hep::mm, + .side_length=31.3 *dd4hep::mm, + .MIP = 470. * dd4hep::keV, + .Emin= 470./10 * dd4hep::keV, + .tmax=320 * dd4hep::ns, + .rot_x=0, + .rot_y=-0.25, + .rot_z=0, + .trans_x=0, + .trans_y=0, + .trans_z=36601 * dd4hep::mm, + }, + app // TODO: Remove me once fixed + )); + + app->Add(new JChainMultifactoryGeneratorT( + "ZDCLogWeightClusters", {"ZDCSubcellHits"}, {"ZDCLogWeightClusters"}, + { + .sampling_fraction=0.0203, + .E0=50. * dd4hep::GeV, + .w0_a=5.0, + .w0_b=0.65, + .w0_c=0.31, + }, + app // TODO: Remove me once fixed + )); + app->Add(new JChainMultifactoryGeneratorT( "ZDCTruthProtoClusters", {"ZDCRecHits", "ZDCHits"}, {"ZDCTruthProtoClusters"}, app // TODO: Remove me once fixed diff --git a/src/factories/calorimetry/HEXPLIT_factoryT.h b/src/factories/calorimetry/HEXPLIT_factoryT.h new file mode 100644 index 0000000000..566dae82ff --- /dev/null +++ b/src/factories/calorimetry/HEXPLIT_factoryT.h @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2023 Sebouh Paul + +#pragma once + +#include +#include +#include +#include + + +namespace eicrecon { + +class HEXPLIT_factoryT : + public JChainMultifactoryT, + public SpdlogMixin { + + public: + + explicit HEXPLIT_factoryT( + std::string tag, + const std::vector& input_tags, + const std::vector& output_tags, + HEXPLITConfig cfg) + : JChainMultifactoryT(std::move(tag), input_tags, output_tags, cfg) { + + DeclarePodioOutput(GetOutputTags()[0]); + + } + + void Init() override { + + auto app = GetApplication(); + + // This prefix will be used for parameters + std::string plugin_name = GetPluginName(); + std::string param_prefix = plugin_name + ":" + GetTag(); + + // Use DD4hep_service to get dd4hep::Detector + auto geoSvc = app->template GetService(); + + // SpdlogMixin logger initialization, sets m_log + InitLogger(app, GetPrefix(), "info"); + + // Algorithm configuration + auto cfg = GetDefaultConfig(); + + app->SetDefaultParameter(param_prefix + ":MIP", cfg.MIP); + app->SetDefaultParameter(param_prefix + ":Emin", cfg.Emin); + app->SetDefaultParameter(param_prefix + ":tmax", cfg.tmax); + app->SetDefaultParameter(param_prefix + ":side_length", cfg.side_length); + app->SetDefaultParameter(param_prefix + ":layer_spacing", cfg.layer_spacing); + app->SetDefaultParameter(param_prefix + ":rot_x", cfg.rot_x); + app->SetDefaultParameter(param_prefix + ":rot_y", cfg.rot_y); + app->SetDefaultParameter(param_prefix + ":rot_z", cfg.rot_z); + app->SetDefaultParameter(param_prefix + ":trans_x", cfg.trans_x); + app->SetDefaultParameter(param_prefix + ":trans_y", cfg.trans_y); + app->SetDefaultParameter(param_prefix + ":trans_z", cfg.trans_z); + + + m_algo.applyConfig(cfg); + m_algo.init(geoSvc->detector(), logger()); + } + + void Process(const std::shared_ptr &event) override { + auto hits = static_cast(event->GetCollectionBase(GetInputTags()[0])); + + try { + auto subcell_hits = m_algo.process(*hits); + SetCollection(GetOutputTags()[0], std::move(subcell_hits)); + } + catch(std::exception &e) { + throw JException(e.what()); + } + + } + + private: + HEXPLIT m_algo; + +}; + +} // eicrecon diff --git a/src/factories/calorimetry/LogWeightReco_factoryT.h b/src/factories/calorimetry/LogWeightReco_factoryT.h new file mode 100644 index 0000000000..36ab5e048b --- /dev/null +++ b/src/factories/calorimetry/LogWeightReco_factoryT.h @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2023 Sebouh Paul + +#pragma once + +#include +#include +#include +#include + + +namespace eicrecon { + +class LogWeightReco_factoryT : + public JChainMultifactoryT, + public SpdlogMixin { + + public: + + explicit LogWeightReco_factoryT( + std::string tag, + const std::vector& input_tags, + const std::vector& output_tags, + LogWeightRecoConfig cfg) + : JChainMultifactoryT(std::move(tag), input_tags, output_tags, cfg) { + + DeclarePodioOutput(GetOutputTags()[0]); + + } + + void Init() override { + + auto app = GetApplication(); + + // This prefix will be used for parameters + std::string plugin_name = GetPluginName(); + std::string param_prefix = plugin_name + ":" + GetTag(); + + // Use DD4hep_service to get dd4hep::Detector + auto geoSvc = app->template GetService(); + + // SpdlogMixin logger initialization, sets m_log + InitLogger(app, GetPrefix(), "info"); + + // Algorithm configuration + auto cfg = GetDefaultConfig(); + + app->SetDefaultParameter(param_prefix + ":sampling_fraction", cfg.sampling_fraction); + app->SetDefaultParameter(param_prefix + ":E0", cfg.E0); + app->SetDefaultParameter(param_prefix + ":w0_a", cfg.w0_a); + app->SetDefaultParameter(param_prefix + ":w0_b", cfg.w0_b); + app->SetDefaultParameter(param_prefix + ":w0_c", cfg.w0_c); + + + m_algo.applyConfig(cfg); + m_algo.init(geoSvc->detector(), logger()); + } + + void Process(const std::shared_ptr &event) override { + auto hits = static_cast(event->GetCollectionBase(GetInputTags()[0])); + + try { + auto clusters = m_algo.process(*hits); + SetCollection(GetOutputTags()[0], std::move(clusters)); + } + catch(std::exception &e) { + throw JException(e.what()); + } + + } + + private: + LogWeightReco m_algo; + +}; + +} // eicrecon diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index 54546a340f..8a10941090 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -180,6 +180,8 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "ZDCRawHits", "ZDCRecHits", "ZDCClusters", + "ZDCSubcellHits", + "ZDCLogWeightClusters", "ZDCClusterAssociations", "HcalEndcapNTruthClusters", "HcalEndcapNTruthClusterAssociations", From 94d040e4e74047997ae678af4528afe64204b2a6 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Wed, 6 Dec 2023 00:30:10 -0500 Subject: [PATCH 003/106] added files that I had missed earlier --- src/algorithms/calorimetry/HEXPLITConfig.h | 24 +++++++++++++++++++ .../calorimetry/LogWeightRecoConfig.h | 20 ++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/algorithms/calorimetry/HEXPLITConfig.h create mode 100644 src/algorithms/calorimetry/LogWeightRecoConfig.h diff --git a/src/algorithms/calorimetry/HEXPLITConfig.h b/src/algorithms/calorimetry/HEXPLITConfig.h new file mode 100644 index 0000000000..109842873e --- /dev/null +++ b/src/algorithms/calorimetry/HEXPLITConfig.h @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2023 Sebouh Paul + +#pragma once + +namespace eicrecon { + + struct HEXPLITConfig { + + double layer_spacing{24.9}; + double side_length{31.3}; + double MIP{0.000472}; + double Emin{0.0000472}; + double tmax{325}; + //conversion from local to global coordinates + double rot_x{0}; + double rot_y{0}; + double rot_z{0}; + double trans_x{0}; + double trans_y{0}; + double trans_z{0}; + }; + +} // eicrecon diff --git a/src/algorithms/calorimetry/LogWeightRecoConfig.h b/src/algorithms/calorimetry/LogWeightRecoConfig.h new file mode 100644 index 0000000000..4f8f8f5c37 --- /dev/null +++ b/src/algorithms/calorimetry/LogWeightRecoConfig.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2023 Sebouh Paul + +#pragma once + +namespace eicrecon { + + struct LogWeightRecoConfig { + // strawman energy reconstruction + double sampling_fraction{0.0203}; + //parameters to determine the cut-off parameter w0 + // as a function of energy based on an optimized + double E0{50}; + double w0_a{5.0}; + double w0_b{0.65}; + double w0_c{0.31}; + + }; + +} // eicrecon From f7c1ec7737d2881f3bf5d7cf3219b7f1ad91b46c Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 8 Dec 2023 09:36:21 -0500 Subject: [PATCH 004/106] updated HEXPLIT algorithm code after testing and debugging. Also added HexGridXY as a recognized segmentation in src/algorithms/calorimetry/CalorimeterHitReco.cc --- .../calorimetry/CalorimeterHitReco.cc | 2 +- src/algorithms/calorimetry/HEXPLIT.cc | 98 ++----------------- src/algorithms/calorimetry/HEXPLIT.h | 4 +- src/algorithms/calorimetry/HEXPLITConfig.h | 12 +-- src/algorithms/calorimetry/LogWeightReco.cc | 9 +- src/detectors/ZDC/ZDC.cc | 8 +- 6 files changed, 24 insertions(+), 109 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitReco.cc b/src/algorithms/calorimetry/CalorimeterHitReco.cc index 7f117b7d7a..81f9a34b17 100644 --- a/src/algorithms/calorimetry/CalorimeterHitReco.cc +++ b/src/algorithms/calorimetry/CalorimeterHitReco.cc @@ -228,7 +228,7 @@ std::unique_ptr CalorimeterHitReco::process(c std::vector cdim; // get segmentation dimensions auto segmentation_type = m_converter->findReadout(local).segmentation().type(); - if (segmentation_type == "CartesianGridXY") { + if (segmentation_type == "CartesianGridXY" || segmentation_type == "HexGridXY") { auto cell_dim = m_converter->cellDimensions(cellID); cdim.resize(3); cdim[0] = cell_dim[0]; diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index e25fe4b9e8..d4f92b7a08 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -30,25 +30,18 @@ namespace eicrecon { - - void HEXPLIT::init(const dd4hep::Detector* detector, std::shared_ptr& logger) { m_log = logger; m_detector = detector; } - - - //void subcell_reweight(TTreeReaderArray&E,TTreeReaderArray&t,TTreeReaderArray&x,TTreeReaderArray&y,TTreeReaderArray&z, //number of hits, energies, time, and local x,y,z positions of the hits - // vector & subcellE, vector& subcellx, vector & subcelly, vector & subcellz, //returned position of the cluster - // hexplit_opts opts) { std::unique_ptr HEXPLIT::process(const edm4eic::CalorimeterHitCollection &hits){ int nhits=hits.size(); - double sl=m_cfg.side_length; - double layer_spacing=m_cfg.layer_spacing; - double Emin=m_cfg.Emin; - double tmax=m_cfg.tmax; - double MIP=m_cfg.MIP; + double sl=m_cfg.side_length/dd4hep::mm; + double layer_spacing=m_cfg.layer_spacing/dd4hep::mm; + double Emin=m_cfg.Emin/dd4hep::GeV; + double tmax=m_cfg.tmax/dd4hep::ns; + double MIP=m_cfg.MIP/dd4hep::GeV; double x[nhits]; double y[nhits]; @@ -70,7 +63,6 @@ std::unique_ptr HEXPLIT::process(const edm4ei //skip hits that do not pass E and t cuts if (E[i]tmax) continue; - //keep track of the energy in each neighboring cell double Eneighbors[SUBCELLS]; for (int j=0; j HEXPLIT::process(const edm4ei //only look at hits nearby within two layers of the current layer if (abs(z[i]-z[j])>2.5*layer_spacing || z[i]==z[j]) continue; - //cout << "z cut" << endl; if (E[j]tmax) continue; //difference in transverse position (in units of side lengths) @@ -88,15 +79,12 @@ std::unique_ptr HEXPLIT::process(const edm4ei double dy=(y[j]-y[i])/sl; if (abs(dx)>2 || abs(dy)>sqrt(3)) continue; - //cout << "dx, dy cut passed: " << dx << " " << dy << endl; //loop over locations of the neighboring cells //and check if the jth hit matches this location double tol=0.01; //tolerance for rounding errors for(int k=0;k HEXPLIT::process(const edm4ei } for(int k=0; k HEXPLIT::process(const edm4ei Eigen::Matrix3d rotationMatrix = q.matrix(); - Eigen::Vector3d translation(m_cfg.trans_x, m_cfg.trans_y, m_cfg.trans_z); - - auto gpos = rotationMatrix*local+translation; + auto gpos = rotationMatrix*(local+translation); const decltype(edm4eic::CalorimeterHitData::position) position(gpos[0], gpos[1], gpos[2]); @@ -149,10 +135,6 @@ std::unique_ptr HEXPLIT::process(const edm4ei hits[i].getSector(), hits[i].getLayer(), local_position); - //subcellE.push_back(E[i]*weights[k]/sum_weights); - //subcellx.push_back(x[i]+subcell_offsets_x[k]*sl); - //subcelly.push_back(y[i]+subcell_offsets_y[k]*sl); - //subcellz.push_back(z[i]); } } return subcellHits; @@ -161,65 +143,3 @@ std::unique_ptr HEXPLIT::process(const edm4ei } // namespace eicrecon -/* -// Optional subroutine to merge all hits or subcells at a given transverse position together after doing -// subcell reweighting. This method was found to not improve the angle resolution, so it is not -// used. -void flatten(vector&E, vector& x, vector& y, vector& z, - vector&Enew,vector& xnew, vector& ynew, vector& znew){ - Enew.clear(); - xnew.clear(); - ynew.clear(); - znew.clear(); - for(int i = 0; i& E, vector& x, vector& y, vector& z, double & E_recon, double & x_recon, - double & y_recon, double & z_recon, position_recon_opts& opts){ - - //first determine the total energy of the particle and of the shower - E_recon=0; - double E_shower=0; - for (int i = 0; i&E,TTreeReaderArray&t,TTreeReaderArray&x,TTreeReaderArray&y,TTreeReaderArray&z, //number of hits, energies, time, and local x,y,z positions of the hits - // vector & subcellE, vector& subcellx, vector & subcelly, vector & subcellz, //returned position of the cluster - // hexplit_opts opts) { std::unique_ptr LogWeightReco::process(const edm4eic::CalorimeterHitCollection &hits){ - + + double E0=m_cfg.E0/dd4hep::GeV; //first determine the total energy of the particle and of the shower double E_recon=0; double E_shower=0; @@ -72,7 +68,6 @@ namespace eicrecon { auto outputClusters = std::make_unique(); edm4hep::Vector3f position(x_recon, y_recon, z_recon); - //auto cluster = new edm4eic::Cluster( auto clus = outputClusters->create(); clus.setEnergy(E_recon); diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 11a2889b02..d74f4c1685 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -63,12 +63,12 @@ extern "C" { .MIP = 470. * dd4hep::keV, .Emin= 470./10 * dd4hep::keV, .tmax=320 * dd4hep::ns, + .trans_x=0, + .trans_y=0, + .trans_z=36601 * dd4hep::mm, .rot_x=0, - .rot_y=-0.25, + .rot_y=-0.025, .rot_z=0, - .trans_x=0, - .trans_y=0, - .trans_z=36601 * dd4hep::mm, }, app // TODO: Remove me once fixed )); From 724282bc5d71ae3a881a8b42b353b098a744eca5 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 8 Dec 2023 11:01:55 -0500 Subject: [PATCH 005/106] renamed the clusters made from the HEXPLIT subcell hits --- src/detectors/ZDC/ZDC.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index d74f4c1685..845f9d8d7b 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -74,7 +74,7 @@ extern "C" { )); app->Add(new JChainMultifactoryGeneratorT( - "ZDCLogWeightClusters", {"ZDCSubcellHits"}, {"ZDCLogWeightClusters"}, + "ZDC_HEXPLITClusters", {"ZDCSubcellHits"}, {"ZDC_HEXPLITClusters"}, { .sampling_fraction=0.0203, .E0=50. * dd4hep::GeV, From 04f7881f110e8ed275b69512317835aa92deb597 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 11 Dec 2023 11:48:24 -0500 Subject: [PATCH 006/106] fixed sloppy-copied comments in one of the files --- src/algorithms/calorimetry/LogWeightReco.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/LogWeightReco.h b/src/algorithms/calorimetry/LogWeightReco.h index 560a878c18..927ba5ad74 100644 --- a/src/algorithms/calorimetry/LogWeightReco.h +++ b/src/algorithms/calorimetry/LogWeightReco.h @@ -1,8 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright (C) 2023 Sebouh Paul -// An algorithm for splitting calorimeter hits in overlapping cells into "subhits" based on the relative -// energies of hits on neighboring layers +// An algorithm for producing a single cluster with a log-energy-weighted position from a collection of hits. // // Author: Sebouh Paul // Date: 12/04/2023 From 7e22a50d28356e01621a3e89f3738fc3e99cb4b5 Mon Sep 17 00:00:00 2001 From: Barak Schmookler Date: Mon, 11 Dec 2023 18:24:47 -0500 Subject: [PATCH 007/106] Updated default collections --- src/services/io/podio/JEventProcessorPODIO.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index 3dfc025ad6..c094f5dbd2 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -180,6 +180,7 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "ZDCRecHits", "ZDCClusters", "ZDCSubcellHits", + "ZDC_HEXPLITClusters", "ZDCLogWeightClusters", "ZDCClusterAssociations", "HcalEndcapNTruthClusters", From 89f2d65a0c9ee7f2751b14f54b35c94b20f82add Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 14 Dec 2023 13:52:11 -0500 Subject: [PATCH 008/106] made LogWeightReco take in protoclusters collection instead of calorimeter hits collection --- src/algorithms/calorimetry/LogWeightReco.cc | 71 ++++++++++--------- src/algorithms/calorimetry/LogWeightReco.h | 3 +- src/detectors/ZDC/ZDC.cc | 28 +++++++- .../calorimetry/LogWeightReco_factoryT.h | 5 +- 4 files changed, 68 insertions(+), 39 deletions(-) diff --git a/src/algorithms/calorimetry/LogWeightReco.cc b/src/algorithms/calorimetry/LogWeightReco.cc index 9831a94e14..57a44b56e6 100644 --- a/src/algorithms/calorimetry/LogWeightReco.cc +++ b/src/algorithms/calorimetry/LogWeightReco.cc @@ -37,43 +37,46 @@ namespace eicrecon { m_detector = detector; } - std::unique_ptr LogWeightReco::process(const edm4eic::CalorimeterHitCollection &hits){ + std::unique_ptr LogWeightReco::process(const edm4eic::ProtoClusterCollection &protos){ double E0=m_cfg.E0/dd4hep::GeV; - //first determine the total energy of the particle and of the shower - double E_recon=0; - double E_shower=0; - for (int i = 0; i(); - - edm4hep::Vector3f position(x_recon, y_recon, z_recon); - auto clus = outputClusters->create(); - - clus.setEnergy(E_recon); - clus.setTime(t_recon); - clus.setPosition(position); - + for (auto proto : protos){ + auto hits=proto.getHits(); + //first determine the total energy of the particle and of the shower + double E_recon=0; + double E_shower=0; + for (int i = 0; icreate(); + + clus.setEnergy(E_recon); + clus.setTime(t_recon); + clus.setPosition(position); + } return outputClusters; } diff --git a/src/algorithms/calorimetry/LogWeightReco.h b/src/algorithms/calorimetry/LogWeightReco.h index 927ba5ad74..f0189e3f98 100644 --- a/src/algorithms/calorimetry/LogWeightReco.h +++ b/src/algorithms/calorimetry/LogWeightReco.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,7 @@ namespace eicrecon { public: void init(const dd4hep::Detector* detector, std::shared_ptr& logger); - std::unique_ptr process(const edm4eic::CalorimeterHitCollection &hits) ; + std::unique_ptr process(const edm4eic::ProtoClusterCollection &proto) ; private: const dd4hep::Detector* m_detector; diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 845f9d8d7b..be0707fb84 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -17,7 +17,7 @@ #include "factories/calorimetry/CalorimeterTruthClustering_factory.h" #include "factories/calorimetry/HEXPLIT_factoryT.h" #include "factories/calorimetry/LogWeightReco_factoryT.h" - +//#include "factories/calorimetry/ONNXReco_factoryT.h" extern "C" { void InitPlugin(JApplication *app) { @@ -73,8 +73,24 @@ extern "C" { app // TODO: Remove me once fixed )); + + app->Add(new JOmniFactoryGeneratorT( + "ZDCIslandProtoClusters_Hexplit", {"ZDCSubcellHits"}, {"ZDCIslandProtoClusters_Hexplit"}, + { + .sectorDist = 5.0 * dd4hep::cm, + .localDistXY = {50 * dd4hep::cm, 50 * dd4hep::cm}, + .dimScaledLocalDistXY = {50.0*dd4hep::mm, 50.0*dd4hep::mm}, + .splitCluster = true, + .minClusterHitEdep = 0.1 * dd4hep::MeV, + .minClusterCenterEdep = 3.0 * dd4hep::MeV, + .transverseEnergyProfileMetric = "globalDistEtaPhi", + .transverseEnergyProfileScale = 1., + }, + app // TODO: Remove me once fixed + )); + app->Add(new JChainMultifactoryGeneratorT( - "ZDC_HEXPLITClusters", {"ZDCSubcellHits"}, {"ZDC_HEXPLITClusters"}, + "ZDC_HEXPLITClusters", {"ZDCIslandProtoClusters_Hexplit"}, {"ZDC_HEXPLITClusters"}, { .sampling_fraction=0.0203, .E0=50. * dd4hep::GeV, @@ -104,6 +120,14 @@ extern "C" { app // TODO: Remove me once fixed )); + /*app->Add(new JChainMultifactoryGeneratorT( + "ZDC_ONNXClusters", {"ZDCIslandProtoClusters"}, {"ZDC_ONNXClusters"}, + { + .model_path="/path/to/model.onnx", + }, + app // TODO: Remove me once fixed + ));*/ + app->Add(new JOmniFactoryGeneratorT( "ZDCTruthClusters", {"ZDCTruthProtoClusters", // edm4eic::ProtoClusterCollection diff --git a/src/factories/calorimetry/LogWeightReco_factoryT.h b/src/factories/calorimetry/LogWeightReco_factoryT.h index 36ab5e048b..c7dd49cd1d 100644 --- a/src/factories/calorimetry/LogWeightReco_factoryT.h +++ b/src/factories/calorimetry/LogWeightReco_factoryT.h @@ -57,10 +57,11 @@ class LogWeightReco_factoryT : } void Process(const std::shared_ptr &event) override { - auto hits = static_cast(event->GetCollectionBase(GetInputTags()[0])); + //obtain protoclusters from event + auto protos = static_cast(event->GetCollectionBase(GetInputTags()[0])); try { - auto clusters = m_algo.process(*hits); + auto clusters = m_algo.process(*protos); SetCollection(GetOutputTags()[0], std::move(clusters)); } catch(std::exception &e) { From 20f64369bf83a29cb877a3a22aab6a84dae83910 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sat, 16 Dec 2023 13:12:55 -0500 Subject: [PATCH 009/106] Weibin's changes --- src/algorithms/calorimetry/LogWeightReco.cc | 51 ++++++++------ src/algorithms/calorimetry/LogWeightReco.h | 9 +-- src/detectors/ZDC/ZDC.cc | 70 +++++++++++-------- src/factories/calorimetry/HEXPLIT_factory.h | 48 +++++++++++++ .../calorimetry/LogWeightReco_factory.h | 42 +++++++++++ 5 files changed, 162 insertions(+), 58 deletions(-) create mode 100644 src/factories/calorimetry/HEXPLIT_factory.h create mode 100644 src/factories/calorimetry/LogWeightReco_factory.h diff --git a/src/algorithms/calorimetry/LogWeightReco.cc b/src/algorithms/calorimetry/LogWeightReco.cc index 57a44b56e6..096de45334 100644 --- a/src/algorithms/calorimetry/LogWeightReco.cc +++ b/src/algorithms/calorimetry/LogWeightReco.cc @@ -30,53 +30,62 @@ namespace eicrecon { - - void LogWeightReco::init(const dd4hep::Detector* detector, std::shared_ptr& logger) { m_log = logger; m_detector = detector; } - std::unique_ptr LogWeightReco::process(const edm4eic::ProtoClusterCollection &protos){ - - double E0=m_cfg.E0/dd4hep::GeV; + std::unique_ptr + LogWeightReco::process(const edm4eic::ProtoClusterCollection &proto) { + auto outputClusters = std::make_unique(); - for (auto proto : protos){ - auto hits=proto.getHits(); + for (const auto& pcl : proto) + { + if (pcl.hits_size() == 0) + continue; + + const auto& hits = pcl.getHits(); //first determine the total energy of the particle and of the shower double E_recon=0; double E_shower=0; - for (int i = 0; idebug("w0: {}", w0); double sum_weights=0; //position of the cluster - double x_recon=0,y_recon=0,z_recon=0, t_recon=0; + double x_recon=0, y_recon=0, z_recon=0, t_recon=0; for (int i=0; iwarn("0 weight"); + continue; } x_recon/=sum_weights; y_recon/=sum_weights; z_recon/=sum_weights; t_recon/=sum_weights; - - + edm4hep::Vector3f position(x_recon, y_recon, z_recon); + auto clus = outputClusters->create(); - + clus.setNhits(hits.size()); clus.setEnergy(E_recon); clus.setTime(t_recon); clus.setPosition(position); } + return outputClusters; } diff --git a/src/algorithms/calorimetry/LogWeightReco.h b/src/algorithms/calorimetry/LogWeightReco.h index f0189e3f98..88666dc3ab 100644 --- a/src/algorithms/calorimetry/LogWeightReco.h +++ b/src/algorithms/calorimetry/LogWeightReco.h @@ -6,11 +6,10 @@ // Author: Sebouh Paul // Date: 12/04/2023 - #pragma once + #include #include -#include #include #include #include @@ -19,10 +18,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include @@ -36,7 +31,7 @@ namespace eicrecon { public: void init(const dd4hep::Detector* detector, std::shared_ptr& logger); - std::unique_ptr process(const edm4eic::ProtoClusterCollection &proto) ; + std::unique_ptr process(const edm4eic::ProtoClusterCollection &hits) ; private: const dd4hep::Detector* m_detector; diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index be0707fb84..1d7668c9d6 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -8,16 +8,17 @@ #include #include "algorithms/interfaces/WithPodConfig.h" -#include "extensions/jana/JChainMultifactoryGeneratorT.h" +#include "extensions/jana/JOmniFactoryGeneratorT.h" #include "extensions/jana/JOmniFactoryGeneratorT.h" #include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h" #include "factories/calorimetry/CalorimeterHitDigi_factory.h" #include "factories/calorimetry/CalorimeterHitReco_factory.h" #include "factories/calorimetry/CalorimeterIslandCluster_factory.h" +#include "factories/calorimetry/ImagingTopoCluster_factory.h" #include "factories/calorimetry/CalorimeterTruthClustering_factory.h" -#include "factories/calorimetry/HEXPLIT_factoryT.h" -#include "factories/calorimetry/LogWeightReco_factoryT.h" -//#include "factories/calorimetry/ONNXReco_factoryT.h" +#include "factories/calorimetry/HEXPLIT_factory.h" +#include "factories/calorimetry/LogWeightReco_factory.h" + extern "C" { void InitPlugin(JApplication *app) { @@ -25,6 +26,8 @@ extern "C" { InitJANAPlugin(app); + auto side_length = 31.3 * dd4hep::mm; + app->Add(new JOmniFactoryGeneratorT( "ZDCRawHits", {"HcalFarForwardZDCHits"}, {"ZDCRawHits"}, { @@ -51,15 +54,17 @@ extern "C" { .thresholdValue = -100.0, .sampFrac = 1.0, .readout = "HcalFarForwardZDCHits", + .layerField = "layer", + .sectorField = "system", }, app // TODO: Remove me once fixed )); - app->Add(new JChainMultifactoryGeneratorT( + app->Add(new JOmniFactoryGeneratorT( "ZDCSubcellHits", {"ZDCRecHits"}, {"ZDCSubcellHits"}, { .layer_spacing=25.1*dd4hep::mm, - .side_length=31.3 *dd4hep::mm, + .side_length = side_length, .MIP = 470. * dd4hep::keV, .Emin= 470./10 * dd4hep::keV, .tmax=320 * dd4hep::ns, @@ -73,24 +78,37 @@ extern "C" { app // TODO: Remove me once fixed )); + app->Add(new JOmniFactoryGeneratorT( + "ZDCImagingClusterContributions", {"ZDCSubcellHits"}, {"ZDCImagingClusterContributions"}, + { + .neighbourLayersRange = 1, + .localDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)}, + .layerDistEtaPhi = {17e-3, 18.1e-3}, + .sectorDist = 10.0 * dd4hep::cm, + .minClusterHitEdep = 100.0 * dd4hep::keV, + .minClusterCenterEdep = 11.0 * dd4hep::MeV, + .minClusterEdep = 11.0 * dd4hep::MeV, + .minClusterNhits = 10, + }, + app // TODO: Remove me once fixed + )); app->Add(new JOmniFactoryGeneratorT( - "ZDCIslandProtoClusters_Hexplit", {"ZDCSubcellHits"}, {"ZDCIslandProtoClusters_Hexplit"}, - { - .sectorDist = 5.0 * dd4hep::cm, - .localDistXY = {50 * dd4hep::cm, 50 * dd4hep::cm}, - .dimScaledLocalDistXY = {50.0*dd4hep::mm, 50.0*dd4hep::mm}, - .splitCluster = true, - .minClusterHitEdep = 0.1 * dd4hep::MeV, - .minClusterCenterEdep = 3.0 * dd4hep::MeV, - .transverseEnergyProfileMetric = "globalDistEtaPhi", - .transverseEnergyProfileScale = 1., - }, - app // TODO: Remove me once fixed - )); - - app->Add(new JChainMultifactoryGeneratorT( - "ZDC_HEXPLITClusters", {"ZDCIslandProtoClusters_Hexplit"}, {"ZDC_HEXPLITClusters"}, + "ZDCIslandClusterContributions", {"ZDCSubcellHits"}, {"ZDCIslandClusterContributions"}, + { + .sectorDist = 1.5 * dd4hep::cm, + .localDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)}, + .splitCluster = false, + .minClusterHitEdep = 100.0 * dd4hep::keV, + .minClusterCenterEdep = 1.0 * dd4hep::MeV, + // .transverseEnergyProfileMetric = "globalDistEtaPhi", + // .transverseEnergyProfileScale = 1., + }, + app + )); + + app->Add(new JOmniFactoryGeneratorT( + "ZDC_HEXPLITClusters", {"ZDCImagingClusterContributions"}, {"ZDC_HEXPLITClusters"}, { .sampling_fraction=0.0203, .E0=50. * dd4hep::GeV, @@ -120,14 +138,6 @@ extern "C" { app // TODO: Remove me once fixed )); - /*app->Add(new JChainMultifactoryGeneratorT( - "ZDC_ONNXClusters", {"ZDCIslandProtoClusters"}, {"ZDC_ONNXClusters"}, - { - .model_path="/path/to/model.onnx", - }, - app // TODO: Remove me once fixed - ));*/ - app->Add(new JOmniFactoryGeneratorT( "ZDCTruthClusters", {"ZDCTruthProtoClusters", // edm4eic::ProtoClusterCollection diff --git a/src/factories/calorimetry/HEXPLIT_factory.h b/src/factories/calorimetry/HEXPLIT_factory.h new file mode 100644 index 0000000000..5cb3924fa4 --- /dev/null +++ b/src/factories/calorimetry/HEXPLIT_factory.h @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2023 Sebouh Paul + +#pragma once + +#include +#include +#include +// #include + + +namespace eicrecon { + +class HEXPLIT_factory : public JOmniFactory { +private: + HEXPLIT m_algo; + PodioInput m_rec_hits_input {this}; + PodioOutput m_subcell_hits_output {this}; + + ParameterRef m_MIP {this, "MIP", config().MIP}; + ParameterRef m_Emin {this, "Emin", config().Emin}; + ParameterRef m_tmax {this, "tmax", config().tmax}; + ParameterRef m_sl {this, "side_length", config().side_length}; + ParameterRef m_ls {this, "layer_spacing", config().layer_spacing}; + ParameterRef m_rot_x {this, "rot_x", config().rot_x}; + ParameterRef m_rot_y {this, "rot_y", config().rot_y}; + ParameterRef m_rot_z {this, "rot_z", config().rot_z}; + ParameterRef m_trans_x {this, "trans_x", config().trans_x}; + ParameterRef m_trans_y {this, "trans_y", config().trans_y}; + ParameterRef m_trans_z {this, "trans_z", config().trans_z}; + + Service m_geoSvc {this}; + +public: + void Configure() { + m_algo.applyConfig(config()); + m_algo.init(m_geoSvc().detector(), logger()); + } + + void ChangeRun(int64_t run_number) { + } + + void Process(int64_t run_number, uint64_t event_number) { + m_subcell_hits_output() = m_algo.process(*m_rec_hits_input()); + } +}; + +} // eicrecon diff --git a/src/factories/calorimetry/LogWeightReco_factory.h b/src/factories/calorimetry/LogWeightReco_factory.h new file mode 100644 index 0000000000..4b030dd4a9 --- /dev/null +++ b/src/factories/calorimetry/LogWeightReco_factory.h @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2023 Sebouh Paul + +#pragma once + +#include +#include +#include + + +namespace eicrecon { + +class LogWeightReco_factory : public JOmniFactory { +private: + LogWeightReco m_algo; + PodioInput m_proto_cluster_input {this}; + PodioOutput m_cluster_output {this}; + + ParameterRef m_sf {this, "sampling_fraction", config().sampling_fraction}; + ParameterRef m_E0 {this, "E0", config().E0}; + ParameterRef m_w0_a {this, "w0_a", config().w0_a}; + ParameterRef m_w0_b {this, "w0_b", config().w0_b}; + ParameterRef m_w0_c {this, "w0_c", config().w0_c}; + + Service m_geoSvc {this}; + +public: + void Configure() { + m_algo.applyConfig(config()); + m_algo.init(m_geoSvc().detector(), logger()); + } + + void ChangeRun(int64_t run_number) { + } + + void Process(int64_t run_number, uint64_t event_number) { + m_cluster_output() = m_algo.process(*m_proto_cluster_input()); + } + +}; + +} // eicrecon From dd86f034656ed014ade5c02cf66022026bcccca2 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 18 Dec 2023 13:59:25 -0500 Subject: [PATCH 010/106] removed factoryT.h for HEXPLIT and LogWeightReco, and only using factory.h; also changed HEXPLIT to use Emin_in_MIPs instead of Emin --- src/algorithms/calorimetry/HEXPLIT.cc | 5 +- src/algorithms/calorimetry/HEXPLITConfig.h | 2 +- src/detectors/ZDC/ZDC.cc | 4 +- src/factories/calorimetry/HEXPLIT_factory.h | 2 +- src/factories/calorimetry/HEXPLIT_factoryT.h | 83 ------------------- .../calorimetry/LogWeightReco_factoryT.h | 78 ----------------- 6 files changed, 7 insertions(+), 167 deletions(-) delete mode 100644 src/factories/calorimetry/HEXPLIT_factoryT.h delete mode 100644 src/factories/calorimetry/LogWeightReco_factoryT.h diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index d4f92b7a08..3e809ca402 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -39,9 +39,10 @@ std::unique_ptr HEXPLIT::process(const edm4ei int nhits=hits.size(); double sl=m_cfg.side_length/dd4hep::mm; double layer_spacing=m_cfg.layer_spacing/dd4hep::mm; - double Emin=m_cfg.Emin/dd4hep::GeV; - double tmax=m_cfg.tmax/dd4hep::ns; double MIP=m_cfg.MIP/dd4hep::GeV; + double Emin=m_cfg.Emin_in_MIPs*MIP/dd4hep::GeV; + double tmax=m_cfg.tmax/dd4hep::ns; + double x[nhits]; double y[nhits]; diff --git a/src/algorithms/calorimetry/HEXPLITConfig.h b/src/algorithms/calorimetry/HEXPLITConfig.h index 8066d18f56..92e4bfb3fe 100644 --- a/src/algorithms/calorimetry/HEXPLITConfig.h +++ b/src/algorithms/calorimetry/HEXPLITConfig.h @@ -10,7 +10,7 @@ namespace eicrecon { double layer_spacing{24.9}; double side_length{31.3}; double MIP{0.000472}; - double Emin{0.0000472*dd4hep::GeV}; + double Emin_in_MIPs{0.1}; double tmax{325*dd4hep::ns}; //conversion from local to global coordinates. translate first, then rotate double trans_x{0}; diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 1d7668c9d6..00563de1bf 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -65,8 +65,8 @@ extern "C" { { .layer_spacing=25.1*dd4hep::mm, .side_length = side_length, - .MIP = 470. * dd4hep::keV, - .Emin= 470./10 * dd4hep::keV, + .MIP = 472. * dd4hep::keV, + .Emin_in_MIPs=0.1, .tmax=320 * dd4hep::ns, .trans_x=0, .trans_y=0, diff --git a/src/factories/calorimetry/HEXPLIT_factory.h b/src/factories/calorimetry/HEXPLIT_factory.h index 5cb3924fa4..c62edec5f4 100644 --- a/src/factories/calorimetry/HEXPLIT_factory.h +++ b/src/factories/calorimetry/HEXPLIT_factory.h @@ -18,7 +18,7 @@ class HEXPLIT_factory : public JOmniFactory { PodioOutput m_subcell_hits_output {this}; ParameterRef m_MIP {this, "MIP", config().MIP}; - ParameterRef m_Emin {this, "Emin", config().Emin}; + ParameterRef m_Emin_in_MIPs {this, "Emin_in_MIPs", config().Emin_in_MIPs}; ParameterRef m_tmax {this, "tmax", config().tmax}; ParameterRef m_sl {this, "side_length", config().side_length}; ParameterRef m_ls {this, "layer_spacing", config().layer_spacing}; diff --git a/src/factories/calorimetry/HEXPLIT_factoryT.h b/src/factories/calorimetry/HEXPLIT_factoryT.h deleted file mode 100644 index 566dae82ff..0000000000 --- a/src/factories/calorimetry/HEXPLIT_factoryT.h +++ /dev/null @@ -1,83 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2023 Sebouh Paul - -#pragma once - -#include -#include -#include -#include - - -namespace eicrecon { - -class HEXPLIT_factoryT : - public JChainMultifactoryT, - public SpdlogMixin { - - public: - - explicit HEXPLIT_factoryT( - std::string tag, - const std::vector& input_tags, - const std::vector& output_tags, - HEXPLITConfig cfg) - : JChainMultifactoryT(std::move(tag), input_tags, output_tags, cfg) { - - DeclarePodioOutput(GetOutputTags()[0]); - - } - - void Init() override { - - auto app = GetApplication(); - - // This prefix will be used for parameters - std::string plugin_name = GetPluginName(); - std::string param_prefix = plugin_name + ":" + GetTag(); - - // Use DD4hep_service to get dd4hep::Detector - auto geoSvc = app->template GetService(); - - // SpdlogMixin logger initialization, sets m_log - InitLogger(app, GetPrefix(), "info"); - - // Algorithm configuration - auto cfg = GetDefaultConfig(); - - app->SetDefaultParameter(param_prefix + ":MIP", cfg.MIP); - app->SetDefaultParameter(param_prefix + ":Emin", cfg.Emin); - app->SetDefaultParameter(param_prefix + ":tmax", cfg.tmax); - app->SetDefaultParameter(param_prefix + ":side_length", cfg.side_length); - app->SetDefaultParameter(param_prefix + ":layer_spacing", cfg.layer_spacing); - app->SetDefaultParameter(param_prefix + ":rot_x", cfg.rot_x); - app->SetDefaultParameter(param_prefix + ":rot_y", cfg.rot_y); - app->SetDefaultParameter(param_prefix + ":rot_z", cfg.rot_z); - app->SetDefaultParameter(param_prefix + ":trans_x", cfg.trans_x); - app->SetDefaultParameter(param_prefix + ":trans_y", cfg.trans_y); - app->SetDefaultParameter(param_prefix + ":trans_z", cfg.trans_z); - - - m_algo.applyConfig(cfg); - m_algo.init(geoSvc->detector(), logger()); - } - - void Process(const std::shared_ptr &event) override { - auto hits = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - try { - auto subcell_hits = m_algo.process(*hits); - SetCollection(GetOutputTags()[0], std::move(subcell_hits)); - } - catch(std::exception &e) { - throw JException(e.what()); - } - - } - - private: - HEXPLIT m_algo; - -}; - -} // eicrecon diff --git a/src/factories/calorimetry/LogWeightReco_factoryT.h b/src/factories/calorimetry/LogWeightReco_factoryT.h deleted file mode 100644 index c7dd49cd1d..0000000000 --- a/src/factories/calorimetry/LogWeightReco_factoryT.h +++ /dev/null @@ -1,78 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2023 Sebouh Paul - -#pragma once - -#include -#include -#include -#include - - -namespace eicrecon { - -class LogWeightReco_factoryT : - public JChainMultifactoryT, - public SpdlogMixin { - - public: - - explicit LogWeightReco_factoryT( - std::string tag, - const std::vector& input_tags, - const std::vector& output_tags, - LogWeightRecoConfig cfg) - : JChainMultifactoryT(std::move(tag), input_tags, output_tags, cfg) { - - DeclarePodioOutput(GetOutputTags()[0]); - - } - - void Init() override { - - auto app = GetApplication(); - - // This prefix will be used for parameters - std::string plugin_name = GetPluginName(); - std::string param_prefix = plugin_name + ":" + GetTag(); - - // Use DD4hep_service to get dd4hep::Detector - auto geoSvc = app->template GetService(); - - // SpdlogMixin logger initialization, sets m_log - InitLogger(app, GetPrefix(), "info"); - - // Algorithm configuration - auto cfg = GetDefaultConfig(); - - app->SetDefaultParameter(param_prefix + ":sampling_fraction", cfg.sampling_fraction); - app->SetDefaultParameter(param_prefix + ":E0", cfg.E0); - app->SetDefaultParameter(param_prefix + ":w0_a", cfg.w0_a); - app->SetDefaultParameter(param_prefix + ":w0_b", cfg.w0_b); - app->SetDefaultParameter(param_prefix + ":w0_c", cfg.w0_c); - - - m_algo.applyConfig(cfg); - m_algo.init(geoSvc->detector(), logger()); - } - - void Process(const std::shared_ptr &event) override { - //obtain protoclusters from event - auto protos = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - try { - auto clusters = m_algo.process(*protos); - SetCollection(GetOutputTags()[0], std::move(clusters)); - } - catch(std::exception &e) { - throw JException(e.what()); - } - - } - - private: - LogWeightReco m_algo; - -}; - -} // eicrecon From ade3733f42d974d4951bb05b3388723b88f850aa Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 12 Jan 2024 16:12:43 -0500 Subject: [PATCH 011/106] Update ZDC.cc dyRangeZDC set to 800 MeV for ZDC --- src/detectors/ZDC/ZDC.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 00563de1bf..e765f43f21 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -33,7 +33,7 @@ extern "C" { { .tRes = 0.0 * dd4hep::ns, .capADC = 32768, - .dyRangeADC = 200 * dd4hep::MeV, + .dyRangeADC = 800 * dd4hep::MeV, .pedMeanADC = 400, .pedSigmaADC = 10, .resolutionTDC = 10 * dd4hep::picosecond, @@ -46,7 +46,7 @@ extern "C" { "ZDCRecHits", {"ZDCRawHits"}, {"ZDCRecHits"}, { .capADC = 32678, - .dyRangeADC = 200. * dd4hep::MeV, + .dyRangeADC = 800. * dd4hep::MeV, .pedMeanADC = 400, .pedSigmaADC = 10, .resolutionTDC = 10 * dd4hep::picosecond, From c81e1405a323dd88455fff71f6f6a352f578bdf5 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 12 Jan 2024 16:13:13 -0500 Subject: [PATCH 012/106] Update ZDC.cc removed duplicated include statement --- src/detectors/ZDC/ZDC.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index e765f43f21..c91f507b20 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -9,7 +9,7 @@ #include "algorithms/interfaces/WithPodConfig.h" #include "extensions/jana/JOmniFactoryGeneratorT.h" -#include "extensions/jana/JOmniFactoryGeneratorT.h" + #include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h" #include "factories/calorimetry/CalorimeterHitDigi_factory.h" #include "factories/calorimetry/CalorimeterHitReco_factory.h" From f8275eb3e6e4fae6f12599e8c67a7bbfbc361e69 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 12 Jan 2024 15:44:55 -0600 Subject: [PATCH 013/106] Update ZDC.cc restore ZDC ECal reconstruction (this will correspond to the LYSO part of the ZDC) --- src/detectors/ZDC/ZDC.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index c91f507b20..770ceef064 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -26,6 +26,37 @@ extern "C" { InitJANAPlugin(app); + // LYSO part of the ZDC + app->Add(new JOmniFactoryGeneratorT( + "ZDCEcalRawHits", {"ZDCEcalHits"}, {"ZDCEcalRawHits"}, + { + .tRes = 0.0 * dd4hep::ns, + .capADC = 32768, + .dyRangeADC = 2000 * dd4hep::MeV, + .pedMeanADC = 400, + .pedSigmaADC = 3.2, + .resolutionTDC = 10 * dd4hep::picosecond, + .corrMeanScale = 1.0, + }, + app // TODO: Remove me once fixed + )); + app->Add(new JOmniFactoryGeneratorT( + "ZDCEcalRecHits", {"ZDCEcalRawHits"}, {"ZDCEcalRecHits"}, + { + .capADC = 32768, + .dyRangeADC = 2000. * dd4hep::MeV, + .pedMeanADC = 400, + .pedSigmaADC = 3.2, + .resolutionTDC = 10 * dd4hep::picosecond, + .thresholdFactor = 4.0, + .thresholdValue = 0.0, + .sampFrac = 1.0, + .readout = "ZDCEcalHits", + }, + app // TODO: Remove me once fixed + )); + + //side length of hexagonal cells in SiPM-on-tile part of the ZDC auto side_length = 31.3 * dd4hep::mm; app->Add(new JOmniFactoryGeneratorT( From 74618e3970ee972581f0b526079c1b12c25b884c Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 12 Jan 2024 15:48:33 -0600 Subject: [PATCH 014/106] Update JEventProcessorPODIO.cc restored ZDC Ecal recon --- src/services/io/podio/JEventProcessorPODIO.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index c094f5dbd2..6dbf79f341 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -176,6 +176,10 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "B0ECalRecHits", "B0ECalClusters", "B0ECalClusterAssociations", + "ZDCEcalRawHits", + "ZDCEcalRecHits", + "ZDCEcalClusters", + "ZDCEcalClusterAssociations", "ZDCRawHits", "ZDCRecHits", "ZDCClusters", From 387ac3d68af66b93ff60ca5889a2b461e2b7bbc4 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 12 Jan 2024 15:49:46 -0600 Subject: [PATCH 015/106] Update JEventProcessorPODIO.cc restored ZDC ECal recon for cluster clusters --- src/services/io/podio/JEventProcessorPODIO.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index 6dbf79f341..5ba2151357 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -194,6 +194,8 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "B0ECalRecHits", "B0ECalClusters", "B0ECalClusterAssociations", + "ZDCEcalTruthClusters", + "ZDCEcalTruthClusterAssociations", "ZDCTruthClusters", "ZDCTruthClusterAssociations", From 084df26eef280a85a2a880bde1c708cea0190e46 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 12 Jan 2024 17:24:54 -0500 Subject: [PATCH 016/106] Update ZDC.cc restored part of the ZDC Ecal code. --- src/detectors/ZDC/ZDC.cc | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 770ceef064..72dc991c8b 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -55,6 +55,59 @@ extern "C" { }, app // TODO: Remove me once fixed )); + + app->Add(new JOmniFactoryGeneratorT( + "ZDCEcalTruthProtoClusters", {"ZDCEcalRecHits", "ZDCEcalHits"}, {"ZDCEcalTruthProtoClusters"}, + app // TODO: Remove me once fixed + )); + app->Add(new JOmniFactoryGeneratorT( + "ZDCEcalIslandProtoClusters", {"ZDCEcalRecHits"}, {"ZDCEcalIslandProtoClusters"}, + { + .sectorDist = 5.0 * dd4hep::cm, + .localDistXY = {50 * dd4hep::cm, 50 * dd4hep::cm}, + .dimScaledLocalDistXY = {50.0*dd4hep::mm, 50.0*dd4hep::mm}, + .splitCluster = true, + .minClusterHitEdep = 0.1 * dd4hep::MeV, + .minClusterCenterEdep = 3.0 * dd4hep::MeV, + .transverseEnergyProfileMetric = "globalDistEtaPhi", + .transverseEnergyProfileScale = 1., + }, + app // TODO: Remove me once fixed + )); + + app->Add( + new JOmniFactoryGeneratorT( + "ZDCEcalTruthClusters", + {"ZDCEcalTruthProtoClusters", // edm4eic::ProtoClusterCollection + "ZDCEcalHits"}, // edm4hep::SimCalorimeterHitCollection + {"ZDCEcalTruthClusters", // edm4eic::Cluster + "ZDCEcalTruthClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation + { + .energyWeight = "log", + .sampFrac = 1.0, + .logWeightBase = 3.6, + .enableEtaBounds = false + }, + app // TODO: Remove me once fixed + ) + ); + + app->Add( + new JOmniFactoryGeneratorT( + "ZDCEcalClusters", + {"ZDCEcalIslandProtoClusters", // edm4eic::ProtoClusterCollection + "ZDCEcalHits"}, // edm4hep::SimCalorimeterHitCollection + {"ZDCEcalClusters", // edm4eic::Cluster + "ZDCEcalClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation + { + .energyWeight = "log", + .sampFrac = 1.0, + .logWeightBase = 6.2, + .enableEtaBounds = false, + }, + app // TODO: Remove me once fixed + ) + ); //side length of hexagonal cells in SiPM-on-tile part of the ZDC auto side_length = 31.3 * dd4hep::mm; From c602b1139f593e824c283523e601807b8e9742ce Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 12 Jan 2024 17:29:11 -0500 Subject: [PATCH 017/106] Update ZDC.cc clean up non-functional changes to code. --- src/detectors/ZDC/ZDC.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 72dc991c8b..86286eb63a 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -9,7 +9,6 @@ #include "algorithms/interfaces/WithPodConfig.h" #include "extensions/jana/JOmniFactoryGeneratorT.h" - #include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h" #include "factories/calorimetry/CalorimeterHitDigi_factory.h" #include "factories/calorimetry/CalorimeterHitReco_factory.h" @@ -27,7 +26,7 @@ extern "C" { InitJANAPlugin(app); // LYSO part of the ZDC - app->Add(new JOmniFactoryGeneratorT( + app->Add(new JOmniFactoryGeneratorT( "ZDCEcalRawHits", {"ZDCEcalHits"}, {"ZDCEcalRawHits"}, { .tRes = 0.0 * dd4hep::ns, @@ -55,8 +54,7 @@ extern "C" { }, app // TODO: Remove me once fixed )); - - app->Add(new JOmniFactoryGeneratorT( + app->Add(new JOmniFactoryGeneratorT( "ZDCEcalTruthProtoClusters", {"ZDCEcalRecHits", "ZDCEcalHits"}, {"ZDCEcalTruthProtoClusters"}, app // TODO: Remove me once fixed )); From 98a603dedee4954b0f3e50999f5638c3db371612 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 12 Jan 2024 17:31:07 -0500 Subject: [PATCH 018/106] Update JEventProcessorPODIO.cc changed tabs to spaces. --- src/services/io/podio/JEventProcessorPODIO.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index 5ba2151357..ae610d5f4b 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -176,7 +176,7 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "B0ECalRecHits", "B0ECalClusters", "B0ECalClusterAssociations", - "ZDCEcalRawHits", + "ZDCEcalRawHits", "ZDCEcalRecHits", "ZDCEcalClusters", "ZDCEcalClusterAssociations", @@ -194,7 +194,7 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "B0ECalRecHits", "B0ECalClusters", "B0ECalClusterAssociations", - "ZDCEcalTruthClusters", + "ZDCEcalTruthClusters", "ZDCEcalTruthClusterAssociations", "ZDCTruthClusters", "ZDCTruthClusterAssociations", From c4701feea5cf29382c9de7442f22ac761c025831 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 12 Jan 2024 22:58:44 +0000 Subject: [PATCH 019/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/HEXPLIT.cc | 37 ++++--- src/algorithms/calorimetry/HEXPLIT.h | 8 +- src/algorithms/calorimetry/HEXPLITConfig.h | 4 +- src/algorithms/calorimetry/LogWeightReco.cc | 8 +- src/algorithms/calorimetry/LogWeightReco.h | 4 +- .../calorimetry/LogWeightRecoConfig.h | 2 +- src/detectors/ZDC/ZDC.cc | 100 +++++++++--------- src/factories/calorimetry/HEXPLIT_factory.h | 30 +++--- .../calorimetry/LogWeightReco_factory.h | 28 ++--- src/services/io/podio/JEventProcessorPODIO.cc | 6 +- 10 files changed, 113 insertions(+), 114 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 3e809ca402..76589a617a 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -35,7 +35,7 @@ void HEXPLIT::init(const dd4hep::Detector* detector, std::shared_ptr HEXPLIT::process(const edm4eic::CalorimeterHitCollection &hits){ +std::unique_ptr HEXPLIT::process(const edm4eic::CalorimeterHitCollection &hits){ int nhits=hits.size(); double sl=m_cfg.side_length/dd4hep::mm; double layer_spacing=m_cfg.layer_spacing/dd4hep::mm; @@ -68,27 +68,27 @@ std::unique_ptr HEXPLIT::process(const edm4ei double Eneighbors[SUBCELLS]; for (int j=0; j2.5*layer_spacing || z[i]==z[j]) - continue; + continue; if (E[j]tmax) - continue; + continue; //difference in transverse position (in units of side lengths) double dx=(x[j]-x[i])/sl; double dy=(y[j]-y[i])/sl; if (abs(dx)>2 || abs(dy)>sqrt(3)) - continue; - + continue; + //loop over locations of the neighboring cells //and check if the jth hit matches this location double tol=0.01; //tolerance for rounding errors for(int k=0;k HEXPLIT::process(const edm4ei } for(int k=0; k HEXPLIT::process(const edm4ei Eigen::AngleAxisd pitchAngle(m_cfg.rot_x, Eigen::Vector3d::UnitX()); Eigen::Quaternion q = rollAngle * yawAngle * pitchAngle; - + Eigen::Matrix3d rotationMatrix = q.matrix(); auto gpos = rotationMatrix*(local+translation); const decltype(edm4eic::CalorimeterHitData::position) position(gpos[0], gpos[1], gpos[2]); - + //bounding box dimensions depend on the orientation of the rhombus int orientation = k%3==0; const decltype(edm4eic::CalorimeterHitData::dimension) dimension(sl*(orientation?1:1.5), sl*sqrt(3)/2.*(orientation?2:1), - hits[i].getDimension()[2]); - + hits[i].getDimension()[2]); + subcellHits->create( - hits[i].getCellID(), - E[i]*weights[k]/sum_weights, + hits[i].getCellID(), + E[i]*weights[k]/sum_weights, 0, hits[i].getTime(), 0, @@ -135,7 +135,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei dimension, hits[i].getSector(), hits[i].getLayer(), - local_position); + local_position); } } return subcellHits; @@ -143,4 +143,3 @@ std::unique_ptr HEXPLIT::process(const edm4ei } // namespace eicrecon - diff --git a/src/algorithms/calorimetry/HEXPLIT.h b/src/algorithms/calorimetry/HEXPLIT.h index 71a9a5b58d..eac5b3a15c 100644 --- a/src/algorithms/calorimetry/HEXPLIT.h +++ b/src/algorithms/calorimetry/HEXPLIT.h @@ -37,11 +37,11 @@ namespace eicrecon { public: void init(const dd4hep::Detector* detector, std::shared_ptr& logger); std::unique_ptr process(const edm4eic::CalorimeterHitCollection &hits) ; - + private: - - - + + + const int SUBCELLS=12; //positions where the overlapping cells are relative to a given cell (in units of hexagon side length) double neighbor_offsets_x[12]={1.5*cos(0), 1.5*cos(M_PI/3), 1.5*cos(2*M_PI/3),1.5*cos(3*M_PI/3), 1.5*cos(4*M_PI/3), 1.5*cos(5*M_PI/3), diff --git a/src/algorithms/calorimetry/HEXPLITConfig.h b/src/algorithms/calorimetry/HEXPLITConfig.h index 92e4bfb3fe..07e7ce4a6d 100644 --- a/src/algorithms/calorimetry/HEXPLITConfig.h +++ b/src/algorithms/calorimetry/HEXPLITConfig.h @@ -17,8 +17,8 @@ namespace eicrecon { double trans_y{0}; double trans_z{0}; double rot_x{0}; - double rot_y{0}; - double rot_z{0}; + double rot_y{0}; + double rot_z{0}; }; } // eicrecon diff --git a/src/algorithms/calorimetry/LogWeightReco.cc b/src/algorithms/calorimetry/LogWeightReco.cc index 096de45334..7b1bb6f8d4 100644 --- a/src/algorithms/calorimetry/LogWeightReco.cc +++ b/src/algorithms/calorimetry/LogWeightReco.cc @@ -36,8 +36,8 @@ namespace eicrecon { } std::unique_ptr - LogWeightReco::process(const edm4eic::ProtoClusterCollection &proto) { - + LogWeightReco::process(const edm4eic::ProtoClusterCollection &proto) { + auto outputClusters = std::make_unique(); for (const auto& pcl : proto) { @@ -54,12 +54,12 @@ namespace eicrecon { E_recon += E_shower/m_cfg.sampling_fraction; //now determine the value of w0 to use - double w0=m_cfg.w0_a+m_cfg.w0_b*log(E_recon/m_cfg.E0)+m_cfg.w0_c*pow(log(E_recon/m_cfg.E0),2); + double w0=m_cfg.w0_a+m_cfg.w0_b*log(E_recon/m_cfg.E0)+m_cfg.w0_c*pow(log(E_recon/m_cfg.E0),2); m_log->debug("w0: {}", w0); double sum_weights=0; //position of the cluster double x_recon=0, y_recon=0, z_recon=0, t_recon=0; - for (int i=0; i& logger); std::unique_ptr process(const edm4eic::ProtoClusterCollection &hits) ; - + private: const dd4hep::Detector* m_detector; std::shared_ptr m_log; diff --git a/src/algorithms/calorimetry/LogWeightRecoConfig.h b/src/algorithms/calorimetry/LogWeightRecoConfig.h index 4f8f8f5c37..fb466d08e3 100644 --- a/src/algorithms/calorimetry/LogWeightRecoConfig.h +++ b/src/algorithms/calorimetry/LogWeightRecoConfig.h @@ -9,7 +9,7 @@ namespace eicrecon { // strawman energy reconstruction double sampling_fraction{0.0203}; //parameters to determine the cut-off parameter w0 - // as a function of energy based on an optimized + // as a function of energy based on an optimized double E0{50}; double w0_a{5.0}; double w0_b{0.65}; diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 86286eb63a..0c0af719df 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -25,7 +25,7 @@ extern "C" { InitJANAPlugin(app); - // LYSO part of the ZDC + // LYSO part of the ZDC app->Add(new JOmniFactoryGeneratorT( "ZDCEcalRawHits", {"ZDCEcalHits"}, {"ZDCEcalRawHits"}, { @@ -106,9 +106,9 @@ extern "C" { app // TODO: Remove me once fixed ) ); - - //side length of hexagonal cells in SiPM-on-tile part of the ZDC - auto side_length = 31.3 * dd4hep::mm; + + //side length of hexagonal cells in SiPM-on-tile part of the ZDC + auto side_length = 31.3 * dd4hep::mm; app->Add(new JOmniFactoryGeneratorT( "ZDCRawHits", {"HcalFarForwardZDCHits"}, {"ZDCRawHits"}, @@ -136,71 +136,71 @@ extern "C" { .thresholdValue = -100.0, .sampFrac = 1.0, .readout = "HcalFarForwardZDCHits", - .layerField = "layer", - .sectorField = "system", + .layerField = "layer", + .sectorField = "system", }, app // TODO: Remove me once fixed )); - - app->Add(new JOmniFactoryGeneratorT( + + app->Add(new JOmniFactoryGeneratorT( "ZDCSubcellHits", {"ZDCRecHits"}, {"ZDCSubcellHits"}, { .layer_spacing=25.1*dd4hep::mm, .side_length = side_length, .MIP = 472. * dd4hep::keV, - .Emin_in_MIPs=0.1, + .Emin_in_MIPs=0.1, .tmax=320 * dd4hep::ns, - .trans_x=0, + .trans_x=0, .trans_y=0, .trans_z=36601 * dd4hep::mm, - .rot_x=0, - .rot_y=-0.025, - .rot_z=0, + .rot_x=0, + .rot_y=-0.025, + .rot_z=0, }, app // TODO: Remove me once fixed - )); - - app->Add(new JOmniFactoryGeneratorT( - "ZDCImagingClusterContributions", {"ZDCSubcellHits"}, {"ZDCImagingClusterContributions"}, - { - .neighbourLayersRange = 1, - .localDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)}, - .layerDistEtaPhi = {17e-3, 18.1e-3}, - .sectorDist = 10.0 * dd4hep::cm, - .minClusterHitEdep = 100.0 * dd4hep::keV, - .minClusterCenterEdep = 11.0 * dd4hep::MeV, - .minClusterEdep = 11.0 * dd4hep::MeV, - .minClusterNhits = 10, - }, - app // TODO: Remove me once fixed - )); - - app->Add(new JOmniFactoryGeneratorT( - "ZDCIslandClusterContributions", {"ZDCSubcellHits"}, {"ZDCIslandClusterContributions"}, - { - .sectorDist = 1.5 * dd4hep::cm, - .localDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)}, - .splitCluster = false, - .minClusterHitEdep = 100.0 * dd4hep::keV, - .minClusterCenterEdep = 1.0 * dd4hep::MeV, - // .transverseEnergyProfileMetric = "globalDistEtaPhi", - // .transverseEnergyProfileScale = 1., - }, - app - )); - - app->Add(new JOmniFactoryGeneratorT( - "ZDC_HEXPLITClusters", {"ZDCImagingClusterContributions"}, {"ZDC_HEXPLITClusters"}, + )); + + app->Add(new JOmniFactoryGeneratorT( + "ZDCImagingClusterContributions", {"ZDCSubcellHits"}, {"ZDCImagingClusterContributions"}, + { + .neighbourLayersRange = 1, + .localDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)}, + .layerDistEtaPhi = {17e-3, 18.1e-3}, + .sectorDist = 10.0 * dd4hep::cm, + .minClusterHitEdep = 100.0 * dd4hep::keV, + .minClusterCenterEdep = 11.0 * dd4hep::MeV, + .minClusterEdep = 11.0 * dd4hep::MeV, + .minClusterNhits = 10, + }, + app // TODO: Remove me once fixed + )); + + app->Add(new JOmniFactoryGeneratorT( + "ZDCIslandClusterContributions", {"ZDCSubcellHits"}, {"ZDCIslandClusterContributions"}, + { + .sectorDist = 1.5 * dd4hep::cm, + .localDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)}, + .splitCluster = false, + .minClusterHitEdep = 100.0 * dd4hep::keV, + .minClusterCenterEdep = 1.0 * dd4hep::MeV, + // .transverseEnergyProfileMetric = "globalDistEtaPhi", + // .transverseEnergyProfileScale = 1., + }, + app + )); + + app->Add(new JOmniFactoryGeneratorT( + "ZDC_HEXPLITClusters", {"ZDCImagingClusterContributions"}, {"ZDC_HEXPLITClusters"}, { .sampling_fraction=0.0203, .E0=50. * dd4hep::GeV, .w0_a=5.0, - .w0_b=0.65, - .w0_c=0.31, + .w0_b=0.65, + .w0_c=0.31, }, app // TODO: Remove me once fixed - )); - + )); + app->Add(new JOmniFactoryGeneratorT( "ZDCTruthProtoClusters", {"ZDCRecHits", "ZDCHits"}, {"ZDCTruthProtoClusters"}, app // TODO: Remove me once fixed diff --git a/src/factories/calorimetry/HEXPLIT_factory.h b/src/factories/calorimetry/HEXPLIT_factory.h index c62edec5f4..3e580108c6 100644 --- a/src/factories/calorimetry/HEXPLIT_factory.h +++ b/src/factories/calorimetry/HEXPLIT_factory.h @@ -14,14 +14,14 @@ namespace eicrecon { class HEXPLIT_factory : public JOmniFactory { private: HEXPLIT m_algo; - PodioInput m_rec_hits_input {this}; + PodioInput m_rec_hits_input {this}; PodioOutput m_subcell_hits_output {this}; - ParameterRef m_MIP {this, "MIP", config().MIP}; + ParameterRef m_MIP {this, "MIP", config().MIP}; ParameterRef m_Emin_in_MIPs {this, "Emin_in_MIPs", config().Emin_in_MIPs}; ParameterRef m_tmax {this, "tmax", config().tmax}; - ParameterRef m_sl {this, "side_length", config().side_length}; - ParameterRef m_ls {this, "layer_spacing", config().layer_spacing}; + ParameterRef m_sl {this, "side_length", config().side_length}; + ParameterRef m_ls {this, "layer_spacing", config().layer_spacing}; ParameterRef m_rot_x {this, "rot_x", config().rot_x}; ParameterRef m_rot_y {this, "rot_y", config().rot_y}; ParameterRef m_rot_z {this, "rot_z", config().rot_z}; @@ -32,17 +32,17 @@ class HEXPLIT_factory : public JOmniFactory { Service m_geoSvc {this}; public: - void Configure() { - m_algo.applyConfig(config()); - m_algo.init(m_geoSvc().detector(), logger()); - } - - void ChangeRun(int64_t run_number) { - } - - void Process(int64_t run_number, uint64_t event_number) { - m_subcell_hits_output() = m_algo.process(*m_rec_hits_input()); - } + void Configure() { + m_algo.applyConfig(config()); + m_algo.init(m_geoSvc().detector(), logger()); + } + + void ChangeRun(int64_t run_number) { + } + + void Process(int64_t run_number, uint64_t event_number) { + m_subcell_hits_output() = m_algo.process(*m_rec_hits_input()); + } }; } // eicrecon diff --git a/src/factories/calorimetry/LogWeightReco_factory.h b/src/factories/calorimetry/LogWeightReco_factory.h index 4b030dd4a9..757a06d291 100644 --- a/src/factories/calorimetry/LogWeightReco_factory.h +++ b/src/factories/calorimetry/LogWeightReco_factory.h @@ -13,11 +13,11 @@ namespace eicrecon { class LogWeightReco_factory : public JOmniFactory { private: LogWeightReco m_algo; - PodioInput m_proto_cluster_input {this}; + PodioInput m_proto_cluster_input {this}; PodioOutput m_cluster_output {this}; - ParameterRef m_sf {this, "sampling_fraction", config().sampling_fraction}; - ParameterRef m_E0 {this, "E0", config().E0}; + ParameterRef m_sf {this, "sampling_fraction", config().sampling_fraction}; + ParameterRef m_E0 {this, "E0", config().E0}; ParameterRef m_w0_a {this, "w0_a", config().w0_a}; ParameterRef m_w0_b {this, "w0_b", config().w0_b}; ParameterRef m_w0_c {this, "w0_c", config().w0_c}; @@ -25,17 +25,17 @@ class LogWeightReco_factory : public JOmniFactory m_geoSvc {this}; public: - void Configure() { - m_algo.applyConfig(config()); - m_algo.init(m_geoSvc().detector(), logger()); - } - - void ChangeRun(int64_t run_number) { - } - - void Process(int64_t run_number, uint64_t event_number) { - m_cluster_output() = m_algo.process(*m_proto_cluster_input()); - } + void Configure() { + m_algo.applyConfig(config()); + m_algo.init(m_geoSvc().detector(), logger()); + } + + void ChangeRun(int64_t run_number) { + } + + void Process(int64_t run_number, uint64_t event_number) { + m_cluster_output() = m_algo.process(*m_proto_cluster_input()); + } }; diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index ae610d5f4b..d27a1086a9 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -183,9 +183,9 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "ZDCRawHits", "ZDCRecHits", "ZDCClusters", - "ZDCSubcellHits", - "ZDC_HEXPLITClusters", - "ZDCLogWeightClusters", + "ZDCSubcellHits", + "ZDC_HEXPLITClusters", + "ZDCLogWeightClusters", "ZDCClusterAssociations", "HcalEndcapNTruthClusters", "HcalEndcapNTruthClusterAssociations", From 8b93eb93d8c53052464df590635feacf0526fcfa Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sat, 13 Jan 2024 09:33:58 -0600 Subject: [PATCH 020/106] Update HEXPLIT.cc use cell id to determine the transform to get the global position of a subcell hit from the local position --- src/algorithms/calorimetry/HEXPLIT.cc | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 76589a617a..578e08d906 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -57,7 +57,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei E[i]=hits[i].getEnergy(); t[i]=hits[i].getTime(); } - + auto volman = m_detector->volumeManager(); auto subcellHits = std::make_unique(); double Esum=0; for(int i=0; i HEXPLIT::process(const edm4ei Eigen::Vector3d local(x[i]+subcell_offsets_x[k]*sl, y[i]+subcell_offsets_y[k]*sl, z[i]); const decltype(edm4eic::CalorimeterHitData::local) local_position(local[0], local[1], local[2]); - //also convert this to the detector's global coordinates. First translate, then rotate. - Eigen::Vector3d translation(m_cfg.trans_x/dd4hep::mm, m_cfg.trans_y/dd4hep::mm, m_cfg.trans_z/dd4hep::mm); - Eigen::AngleAxisd rollAngle(m_cfg.rot_z, Eigen::Vector3d::UnitZ()); - Eigen::AngleAxisd yawAngle(m_cfg.rot_y, Eigen::Vector3d::UnitY()); - Eigen::AngleAxisd pitchAngle(m_cfg.rot_x, Eigen::Vector3d::UnitX()); - - Eigen::Quaternion q = rollAngle * yawAngle * pitchAngle; - - Eigen::Matrix3d rotationMatrix = q.matrix(); - - auto gpos = rotationMatrix*(local+translation); + //also convert this to the detector's global coordinates. To do: check if this is correct + auto alignment = volman.lookupDetElement(hits[i].getCellID()).nominal(); + auto gpos = alignment.worldToLocal(dd4hep::Position(gpos.x(), gpos.y(), gpos.z()));; const decltype(edm4eic::CalorimeterHitData::position) position(gpos[0], gpos[1], gpos[2]); From 680392e1ece5898dc553660c7a57b8de5edf5ffc Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sat, 13 Jan 2024 09:50:09 -0600 Subject: [PATCH 021/106] Update HEXPLITConfig.h Remove the rotation and translation to global coordinates from the configuration --- src/algorithms/calorimetry/HEXPLITConfig.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLITConfig.h b/src/algorithms/calorimetry/HEXPLITConfig.h index 07e7ce4a6d..c3625e18e0 100644 --- a/src/algorithms/calorimetry/HEXPLITConfig.h +++ b/src/algorithms/calorimetry/HEXPLITConfig.h @@ -12,13 +12,7 @@ namespace eicrecon { double MIP{0.000472}; double Emin_in_MIPs{0.1}; double tmax{325*dd4hep::ns}; - //conversion from local to global coordinates. translate first, then rotate - double trans_x{0}; - double trans_y{0}; - double trans_z{0}; - double rot_x{0}; - double rot_y{0}; - double rot_z{0}; + }; } // eicrecon From f6263c7a33022c886bf5deb2c2fa53443d37ee6a Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sat, 13 Jan 2024 09:51:23 -0600 Subject: [PATCH 022/106] Update HEXPLIT_factory.h removed transformation from local to global from the configuration parameters --- src/factories/calorimetry/HEXPLIT_factory.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/factories/calorimetry/HEXPLIT_factory.h b/src/factories/calorimetry/HEXPLIT_factory.h index 3e580108c6..c17e473dc1 100644 --- a/src/factories/calorimetry/HEXPLIT_factory.h +++ b/src/factories/calorimetry/HEXPLIT_factory.h @@ -22,12 +22,6 @@ class HEXPLIT_factory : public JOmniFactory { ParameterRef m_tmax {this, "tmax", config().tmax}; ParameterRef m_sl {this, "side_length", config().side_length}; ParameterRef m_ls {this, "layer_spacing", config().layer_spacing}; - ParameterRef m_rot_x {this, "rot_x", config().rot_x}; - ParameterRef m_rot_y {this, "rot_y", config().rot_y}; - ParameterRef m_rot_z {this, "rot_z", config().rot_z}; - ParameterRef m_trans_x {this, "trans_x", config().trans_x}; - ParameterRef m_trans_y {this, "trans_y", config().trans_y}; - ParameterRef m_trans_z {this, "trans_z", config().trans_z}; Service m_geoSvc {this}; From f1334025b9d8dfb5f9ad94bffccf7056a73171ec Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sat, 13 Jan 2024 09:53:02 -0600 Subject: [PATCH 023/106] Update ZDC.cc remove transformation from local to global coordinates from HEXPLIT parameters --- src/detectors/ZDC/ZDC.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 0c0af719df..6114272d50 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -150,12 +150,6 @@ extern "C" { .MIP = 472. * dd4hep::keV, .Emin_in_MIPs=0.1, .tmax=320 * dd4hep::ns, - .trans_x=0, - .trans_y=0, - .trans_z=36601 * dd4hep::mm, - .rot_x=0, - .rot_y=-0.025, - .rot_z=0, }, app // TODO: Remove me once fixed )); From d71845f010a1f0d11af55b9e44d6490e129ba1c8 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sat, 13 Jan 2024 09:54:03 -0600 Subject: [PATCH 024/106] Update HEXPLIT.cc changed worldToLocal to localToWorld. --- src/algorithms/calorimetry/HEXPLIT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 578e08d906..685fcb2da3 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -108,7 +108,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei //also convert this to the detector's global coordinates. To do: check if this is correct auto alignment = volman.lookupDetElement(hits[i].getCellID()).nominal(); - auto gpos = alignment.worldToLocal(dd4hep::Position(gpos.x(), gpos.y(), gpos.z()));; + auto gpos = alignment.localToWorld(dd4hep::Position(gpos.x(), gpos.y(), gpos.z()));; const decltype(edm4eic::CalorimeterHitData::position) position(gpos[0], gpos[1], gpos[2]); From 22dfc617e1f21a9223f2ae06ccfe9b62901ec3ac Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sat, 13 Jan 2024 11:28:06 -0600 Subject: [PATCH 025/106] get the global positions of hits using the volume manager --- src/algorithms/calorimetry/HEXPLIT.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 685fcb2da3..80baaa24c1 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -103,14 +103,21 @@ std::unique_ptr HEXPLIT::process(const edm4ei for(int k=0; k HEXPLIT::process(const edm4ei dimension, hits[i].getSector(), hits[i].getLayer(), - local_position); + local); } } return subcellHits; From 072bbfa44c243de294f4a118ce1557d9c9e5c5d7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 13 Jan 2024 17:28:15 +0000 Subject: [PATCH 026/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/HEXPLIT.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 80baaa24c1..5510006323 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -103,7 +103,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei for(int k=0; k HEXPLIT::process(const edm4ei local_position.SetX(local.x); local_position.SetY(local.y); local_position.SetZ(local.z); - + //also convert this to the detector's global coordinates. To do: check if this is correct auto alignment = volman.lookupDetElement(hits[i].getCellID()).nominal(); From 0ccf939bdad4427249e452d896a00e3b0e711879 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sat, 13 Jan 2024 11:51:19 -0600 Subject: [PATCH 027/106] avoid using large arrays such as x[], y[], z[] --- src/algorithms/calorimetry/HEXPLIT.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 80baaa24c1..c2cd77559c 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -44,7 +44,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei double tmax=m_cfg.tmax/dd4hep::ns; - double x[nhits]; + /*double x[nhits]; double y[nhits]; double z[nhits]; double E[nhits]; @@ -56,13 +56,13 @@ std::unique_ptr HEXPLIT::process(const edm4ei z[i]=hits[i].getLocal().z; E[i]=hits[i].getEnergy(); t[i]=hits[i].getTime(); - } + }*/ auto volman = m_detector->volumeManager(); auto subcellHits = std::make_unique(); double Esum=0; for(int i=0; itmax) + if (hits[i].getEnergy()tmax) continue; //keep track of the energy in each neighboring cell double Eneighbors[SUBCELLS]; @@ -71,13 +71,14 @@ std::unique_ptr HEXPLIT::process(const edm4ei for (int j=0; j2.5*layer_spacing || z[i]==z[j]) + double dz=abs(hits[i].getLocal().z-hits[j].getLocal().z); + if (dz>2.5*layer_spacing || dz==0) continue; - if (E[j]tmax) + if (hits[j].getEnergy()tmax) continue; //difference in transverse position (in units of side lengths) - double dx=(x[j]-x[i])/sl; - double dy=(y[j]-y[i])/sl; + double dx=(hits[j].getLocal().x-hits[i].getLocal().x)/sl; + double dy=(hits[j].getLocal().y-hits[i].getLocal().y)/sl; if (abs(dx)>2 || abs(dy)>sqrt(3)) continue; @@ -86,7 +87,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei double tol=0.01; //tolerance for rounding errors for(int k=0;k HEXPLIT::process(const edm4ei //create the subcell hits. First determine their positions in local coordinates. - const decltype(edm4eic::CalorimeterHitData::local) local(x[i]+subcell_offsets_x[k]*sl, y[i]+subcell_offsets_y[k]*sl, z[i]); + const decltype(edm4eic::CalorimeterHitData::local) local(hits[i].getLocal().x+subcell_offsets_x[k]*sl, hits[i].getLocal().y+subcell_offsets_y[k]*sl, hits[i].getLocal().z); //convert this to a position object so that the global position can be determined dd4hep::Position local_position; @@ -126,7 +127,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei subcellHits->create( hits[i].getCellID(), - E[i]*weights[k]/sum_weights, + hits[i].getEnergy()*weights[k]/sum_weights, 0, hits[i].getTime(), 0, From 125559e0d3bc7f31a1de3d22d3dd8802faa616b6 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sat, 13 Jan 2024 12:13:06 -0600 Subject: [PATCH 028/106] use iteration over the hits, instead of using nhits --- src/algorithms/calorimetry/HEXPLIT.cc | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index e9310d7e91..7ad3c630df 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -36,7 +36,7 @@ void HEXPLIT::init(const dd4hep::Detector* detector, std::shared_ptr HEXPLIT::process(const edm4eic::CalorimeterHitCollection &hits){ - int nhits=hits.size(); + //int nhits=hits.size(); double sl=m_cfg.side_length/dd4hep::mm; double layer_spacing=m_cfg.layer_spacing/dd4hep::mm; double MIP=m_cfg.MIP/dd4hep::GeV; @@ -60,25 +60,25 @@ std::unique_ptr HEXPLIT::process(const edm4ei auto volman = m_detector->volumeManager(); auto subcellHits = std::make_unique(); double Esum=0; - for(int i=0; itmax) + if (hit.getEnergy()tmax) continue; //keep track of the energy in each neighboring cell double Eneighbors[SUBCELLS]; for (int j=0; j2.5*layer_spacing || dz==0) continue; - if (hits[j].getEnergy()tmax) + if (other_hit.getEnergy()tmax) continue; //difference in transverse position (in units of side lengths) - double dx=(hits[j].getLocal().x-hits[i].getLocal().x)/sl; - double dy=(hits[j].getLocal().y-hits[i].getLocal().y)/sl; + double dx=(other_hit.getLocal().x-hit.getLocal().x)/sl; + double dy=(other_hit.getLocal().y-hit.getLocal().y)/sl; if (abs(dx)>2 || abs(dy)>sqrt(3)) continue; @@ -87,7 +87,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei double tol=0.01; //tolerance for rounding errors for(int k=0;k HEXPLIT::process(const edm4ei for(int k=0; k HEXPLIT::process(const edm4ei local_position.SetZ(local.z); //also convert this to the detector's global coordinates. To do: check if this is correct - auto alignment = volman.lookupDetElement(hits[i].getCellID()).nominal(); + auto alignment = volman.lookupDetElement(hit.getCellID()).nominal(); auto global_position = alignment.localToWorld(local_position); //convert this from position object to a vector object @@ -122,18 +122,18 @@ std::unique_ptr HEXPLIT::process(const edm4ei //bounding box dimensions depend on the orientation of the rhombus int orientation = k%3==0; const decltype(edm4eic::CalorimeterHitData::dimension) dimension(sl*(orientation?1:1.5), sl*sqrt(3)/2.*(orientation?2:1), - hits[i].getDimension()[2]); + hit.getDimension()[2]); subcellHits->create( - hits[i].getCellID(), - hits[i].getEnergy()*weights[k]/sum_weights, + hit.getCellID(), + hit.getEnergy()*weights[k]/sum_weights, 0, - hits[i].getTime(), + hit.getTime(), 0, position, dimension, - hits[i].getSector(), - hits[i].getLayer(), + hit.getSector(), + hit.getLayer(), local); } } From 955934da88db479a2337333e7f40bd44adccb129 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sat, 13 Jan 2024 13:58:45 -0600 Subject: [PATCH 029/106] for(const auto& hit: hits) --- src/algorithms/calorimetry/HEXPLIT.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 7ad3c630df..6dd2a4f1fc 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -60,7 +60,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei auto volman = m_detector->volumeManager(); auto subcellHits = std::make_unique(); double Esum=0; - for(auto hit : hits){ + for(const auto& hit : hits){ //skip hits that do not pass E and t cuts if (hit.getEnergy()tmax) continue; @@ -69,7 +69,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei for (int j=0; j2.5*layer_spacing || dz==0) From 9eea2e60ecf0317015eb6ce81963b73d4bae9855 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sat, 13 Jan 2024 14:05:55 -0600 Subject: [PATCH 030/106] fixed an issue with units regarding Emin --- src/algorithms/calorimetry/HEXPLIT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 6dd2a4f1fc..05ad23a763 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -40,7 +40,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei double sl=m_cfg.side_length/dd4hep::mm; double layer_spacing=m_cfg.layer_spacing/dd4hep::mm; double MIP=m_cfg.MIP/dd4hep::GeV; - double Emin=m_cfg.Emin_in_MIPs*MIP/dd4hep::GeV; + double Emin=m_cfg.Emin_in_MIPs*MIP; double tmax=m_cfg.tmax/dd4hep::ns; From 0a4c529544b53e4fd72e67882aaf2cddda62543a Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sat, 13 Jan 2024 14:11:46 -0600 Subject: [PATCH 031/106] removed commented code --- src/algorithms/calorimetry/HEXPLIT.cc | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 05ad23a763..9cdd913150 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -36,27 +36,13 @@ void HEXPLIT::init(const dd4hep::Detector* detector, std::shared_ptr HEXPLIT::process(const edm4eic::CalorimeterHitCollection &hits){ - //int nhits=hits.size(); + double sl=m_cfg.side_length/dd4hep::mm; double layer_spacing=m_cfg.layer_spacing/dd4hep::mm; double MIP=m_cfg.MIP/dd4hep::GeV; double Emin=m_cfg.Emin_in_MIPs*MIP; double tmax=m_cfg.tmax/dd4hep::ns; - - /*double x[nhits]; - double y[nhits]; - double z[nhits]; - double E[nhits]; - double t[nhits]; - - for(int i=0; ivolumeManager(); auto subcellHits = std::make_unique(); double Esum=0; @@ -68,11 +54,13 @@ std::unique_ptr HEXPLIT::process(const edm4ei double Eneighbors[SUBCELLS]; for (int j=0; j2.5*layer_spacing || dz==0) + if (dz>2.5*layer_spacing || dztmax) continue; @@ -84,7 +72,6 @@ std::unique_ptr HEXPLIT::process(const edm4ei //loop over locations of the neighboring cells //and check if the jth hit matches this location - double tol=0.01; //tolerance for rounding errors for(int k=0;k Date: Sat, 13 Jan 2024 20:11:54 +0000 Subject: [PATCH 032/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/HEXPLIT.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 9cdd913150..74bc505562 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -54,10 +54,10 @@ std::unique_ptr HEXPLIT::process(const edm4ei double Eneighbors[SUBCELLS]; for (int j=0; j2.5*layer_spacing || dz Date: Sat, 13 Jan 2024 14:20:15 -0600 Subject: [PATCH 033/106] use vector constructor for Eneighbors --- src/algorithms/calorimetry/HEXPLIT.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 9cdd913150..3c28d207ad 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -51,9 +51,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei if (hit.getEnergy()tmax) continue; //keep track of the energy in each neighboring cell - double Eneighbors[SUBCELLS]; - for (int j=0; j Eneighbors(SUBCELLS, 0.0); for (const auto& other_hit : hits){ double tol=0.01; //tolerance for rounding errors From b907230bc1fa6d9d46f04caa57bf58f45b5d46fa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 13 Jan 2024 20:22:59 +0000 Subject: [PATCH 034/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/HEXPLIT.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index a073037fda..dad171c25a 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -50,10 +50,10 @@ std::unique_ptr HEXPLIT::process(const edm4ei //skip hits that do not pass E and t cuts if (hit.getEnergy()tmax) continue; - + //keep track of the energy in each neighboring cell std::vector Eneighbors(SUBCELLS, 0.0); - + for (const auto& other_hit : hits){ double tol=0.01; //tolerance for rounding errors From cfc5e9ac04a1c489d5866067f275e56c2cace643 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sat, 13 Jan 2024 14:24:55 -0600 Subject: [PATCH 035/106] use typeid for this instead of hit-by-hit string comparisons --- src/algorithms/calorimetry/CalorimeterHitReco.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitReco.cc b/src/algorithms/calorimetry/CalorimeterHitReco.cc index 3fa7f7d1da..59fa15c319 100644 --- a/src/algorithms/calorimetry/CalorimeterHitReco.cc +++ b/src/algorithms/calorimetry/CalorimeterHitReco.cc @@ -17,6 +17,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -233,16 +236,17 @@ void CalorimeterHitReco::process( const auto pos = local.nominal().worldToLocal(gpos); std::vector cdim; // get segmentation dimensions - auto segmentation_type = m_converter->findReadout(local).segmentation().type(); - if (segmentation_type == "CartesianGridXY" || segmentation_type == "HexGridXY") { + auto& segmentation_type = typeid(m_converter->findReadout(local).segmentation()); + if (segmentation_type == typeid(dd4hep::DDSegmentation::CartesianGridXY) + || segmentation_type == typeid(dd4hep::DDSegmentation::HexGrid)) { auto cell_dim = m_converter->cellDimensions(cellID); cdim.resize(3); cdim[0] = cell_dim[0]; cdim[1] = cell_dim[1]; m_log->debug("Using segmentation for cell dimensions: {}", fmt::join(cdim, ", ")); } else { - if ((segmentation_type != "NoSegmentation") && (!warned_unsupported_segmentation)) { - m_log->warn("Unsupported segmentation type \"{}\"", segmentation_type); + if ((segmentation_type != typeid(dd4hep::DDSegmentation::NoSegmentation)) && (!warned_unsupported_segmentation)) { + m_log->warn("Unsupported segmentation type \"{}\"", segmentation_type.name()); warned_unsupported_segmentation = true; } From b32dcb1e13d4857cd66bb988dbf5d0f7b03182b4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 13 Jan 2024 20:25:26 +0000 Subject: [PATCH 036/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/CalorimeterHitReco.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitReco.cc b/src/algorithms/calorimetry/CalorimeterHitReco.cc index 59fa15c319..fcad9482ed 100644 --- a/src/algorithms/calorimetry/CalorimeterHitReco.cc +++ b/src/algorithms/calorimetry/CalorimeterHitReco.cc @@ -238,7 +238,7 @@ void CalorimeterHitReco::process( // get segmentation dimensions auto& segmentation_type = typeid(m_converter->findReadout(local).segmentation()); if (segmentation_type == typeid(dd4hep::DDSegmentation::CartesianGridXY) - || segmentation_type == typeid(dd4hep::DDSegmentation::HexGrid)) { + || segmentation_type == typeid(dd4hep::DDSegmentation::HexGrid)) { auto cell_dim = m_converter->cellDimensions(cellID); cdim.resize(3); cdim[0] = cell_dim[0]; From 75a670395513c4d553a7e6b5e254703a5bb3f543 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 15 Jan 2024 12:37:13 -0500 Subject: [PATCH 037/106] removed side_length and layer_spacing from configuration in HEXPLIT --- src/algorithms/calorimetry/HEXPLIT.cc | 9 ++++----- src/algorithms/calorimetry/HEXPLITConfig.h | 4 ---- src/detectors/ZDC/ZDC.cc | 6 +----- src/factories/calorimetry/HEXPLIT_factory.h | 2 -- 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index dad171c25a..c0f95b4184 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -37,15 +37,13 @@ void HEXPLIT::init(const dd4hep::Detector* detector, std::shared_ptr HEXPLIT::process(const edm4eic::CalorimeterHitCollection &hits){ - double sl=m_cfg.side_length/dd4hep::mm; - double layer_spacing=m_cfg.layer_spacing/dd4hep::mm; double MIP=m_cfg.MIP/dd4hep::GeV; double Emin=m_cfg.Emin_in_MIPs*MIP; double tmax=m_cfg.tmax/dd4hep::ns; auto volman = m_detector->volumeManager(); auto subcellHits = std::make_unique(); - double Esum=0; + for(const auto& hit : hits){ //skip hits that do not pass E and t cuts if (hit.getEnergy()tmax) @@ -54,12 +52,13 @@ std::unique_ptr HEXPLIT::process(const edm4ei //keep track of the energy in each neighboring cell std::vector Eneighbors(SUBCELLS, 0.0); + double sl = hit.getDimension().x/2.; for (const auto& other_hit : hits){ double tol=0.01; //tolerance for rounding errors //only look at hits nearby within two layers of the current layer - double dz=abs(hit.getLocal().z-other_hit.getLocal().z); - if (dz>2.5*layer_spacing || dz2 || dz==0) continue; if (other_hit.getEnergy()tmax) continue; diff --git a/src/algorithms/calorimetry/HEXPLITConfig.h b/src/algorithms/calorimetry/HEXPLITConfig.h index c3625e18e0..51332c40f9 100644 --- a/src/algorithms/calorimetry/HEXPLITConfig.h +++ b/src/algorithms/calorimetry/HEXPLITConfig.h @@ -6,13 +6,9 @@ namespace eicrecon { struct HEXPLITConfig { - - double layer_spacing{24.9}; - double side_length{31.3}; double MIP{0.000472}; double Emin_in_MIPs{0.1}; double tmax{325*dd4hep::ns}; - }; } // eicrecon diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 6114272d50..77c1f8e6cd 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -107,9 +107,6 @@ extern "C" { ) ); - //side length of hexagonal cells in SiPM-on-tile part of the ZDC - auto side_length = 31.3 * dd4hep::mm; - app->Add(new JOmniFactoryGeneratorT( "ZDCRawHits", {"HcalFarForwardZDCHits"}, {"ZDCRawHits"}, { @@ -145,8 +142,6 @@ extern "C" { app->Add(new JOmniFactoryGeneratorT( "ZDCSubcellHits", {"ZDCRecHits"}, {"ZDCSubcellHits"}, { - .layer_spacing=25.1*dd4hep::mm, - .side_length = side_length, .MIP = 472. * dd4hep::keV, .Emin_in_MIPs=0.1, .tmax=320 * dd4hep::ns, @@ -154,6 +149,7 @@ extern "C" { app // TODO: Remove me once fixed )); + double side_length=31.3 * dd4hep::mm; app->Add(new JOmniFactoryGeneratorT( "ZDCImagingClusterContributions", {"ZDCSubcellHits"}, {"ZDCImagingClusterContributions"}, { diff --git a/src/factories/calorimetry/HEXPLIT_factory.h b/src/factories/calorimetry/HEXPLIT_factory.h index c17e473dc1..b5cde32464 100644 --- a/src/factories/calorimetry/HEXPLIT_factory.h +++ b/src/factories/calorimetry/HEXPLIT_factory.h @@ -20,8 +20,6 @@ class HEXPLIT_factory : public JOmniFactory { ParameterRef m_MIP {this, "MIP", config().MIP}; ParameterRef m_Emin_in_MIPs {this, "Emin_in_MIPs", config().Emin_in_MIPs}; ParameterRef m_tmax {this, "tmax", config().tmax}; - ParameterRef m_sl {this, "side_length", config().side_length}; - ParameterRef m_ls {this, "layer_spacing", config().layer_spacing}; Service m_geoSvc {this}; From 83e0a7920142fee0486af12b9fda2653fb9717c0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 17:37:36 +0000 Subject: [PATCH 038/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/HEXPLIT.cc | 2 +- src/detectors/ZDC/ZDC.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index c0f95b4184..0a4e1059cd 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -43,7 +43,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei auto volman = m_detector->volumeManager(); auto subcellHits = std::make_unique(); - + for(const auto& hit : hits){ //skip hits that do not pass E and t cuts if (hit.getEnergy()tmax) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 77c1f8e6cd..c521edc125 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -149,7 +149,7 @@ extern "C" { app // TODO: Remove me once fixed )); - double side_length=31.3 * dd4hep::mm; + double side_length=31.3 * dd4hep::mm; app->Add(new JOmniFactoryGeneratorT( "ZDCImagingClusterContributions", {"ZDCSubcellHits"}, {"ZDCImagingClusterContributions"}, { From 1e935e51b973ba220cddabf611e0e2189a8de9ef Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 15 Jan 2024 15:08:27 -0500 Subject: [PATCH 039/106] removed LogWeightReco, instead using CalorimeterClusterRecoCoG with extended functionality for a variable log weight base --- .../calorimetry/CalorimeterClusterRecoCoG.cc | 9 ++++++++- .../CalorimeterClusterRecoCoGConfig.h | 8 ++++++++ src/detectors/ZDC/ZDC.cc | 18 ++++++++++++++++-- .../CalorimeterClusterRecoCoG_factory.h | 4 ++++ 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index fd43506acf..9e9012bd40 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -193,11 +193,18 @@ std::optional CalorimeterClusterRecoCoG::reconstruct(const edm // center of gravity with logarithmic weighting float tw = 0.; auto v = cl.getPosition(); + + double logWeightBase=m_cfg.logWeightBase; + if (m_cfg.variableLogWeightBase){ + double l=log(cl.getEnergy()/m_cfg.logWeightBase_Eref); + logWeightBase+=m_cfg.logWeightBase_lin*l+m_cfg.logWeightBase_quad*l*l; + } + for (unsigned i = 0; i < pcl.getHits().size(); ++i) { const auto& hit = pcl.getHits()[i]; const auto weight = pcl.getWeights()[i]; // _DBG_<<" -- weight = " << weight << " E=" << hit.getEnergy() << " totalE=" <Add(new JOmniFactoryGeneratorT( + /*app->Add(new JOmniFactoryGeneratorT( "ZDC_HEXPLITClusters", {"ZDCImagingClusterContributions"}, {"ZDC_HEXPLITClusters"}, { .sampling_fraction=0.0203, @@ -189,7 +189,21 @@ extern "C" { .w0_c=0.31, }, app // TODO: Remove me once fixed - )); + ));*/ + + app->Add(new JOmniFactoryGeneratorT( + "ZDC_HEXPLITClusters", {"ZDCImagingClusterContributions"}, {"ZDC_HEXPLITClusters"}, + { + .energyWeight = "log", + .sampFrac=0.0203, + .logWeightBase=5.0, + .variableLogWeightBase=true, + .logWeightBase_lin=0.65, + .logWeightBase_quad=0.31, + .logWeightBase_Eref=50*dd4hep::GeV, + }, + app // TODO: Remove me once fixed + )); app->Add(new JOmniFactoryGeneratorT( "ZDCTruthProtoClusters", {"ZDCRecHits", "ZDCHits"}, {"ZDCTruthProtoClusters"}, diff --git a/src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h b/src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h index f3c284b526..d0405f619e 100644 --- a/src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h +++ b/src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h @@ -27,6 +27,10 @@ class CalorimeterClusterRecoCoG_factory : public JOmniFactory m_energyWeight {this, "energyWeight", config().energyWeight}; ParameterRef m_samplingFraction {this, "samplingFraction", config().sampFrac}; ParameterRef m_logWeightBase {this, "logWeightBase", config().logWeightBase}; + ParameterRef m_variableLogWeightBase {this, "variableLogWeightBase", config().variableLogWeightBase}; + ParameterRef m_logWeightBase_lin {this, "logWeightBase_lin", config().logWeightBase_lin}; + ParameterRef m_logWeightBase_quad {this, "logWeightBase_quad", config().logWeightBase_quad}; + ParameterRef m_logWeightBase_Eref {this, "logWeightBase_Eref", config().logWeightBase_Eref}; ParameterRef m_enableEtaBounds {this, "enableEtaBounds", config().enableEtaBounds}; public: From 72211f3636bd6bbf1660a8bb41ff8654ad469423 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 20:09:36 +0000 Subject: [PATCH 040/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc | 4 ++-- src/detectors/ZDC/ZDC.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index bb1cdee56c..6a663a7a43 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -192,13 +192,13 @@ std::optional CalorimeterClusterRecoCoG::reconstruct(const edm // center of gravity with logarithmic weighting float tw = 0.; auto v = cl.getPosition(); - + double logWeightBase=m_cfg.logWeightBase; if (m_cfg.variableLogWeightBase){ double l=log(cl.getEnergy()/m_cfg.logWeightBase_Eref); logWeightBase+=m_cfg.logWeightBase_lin*l+m_cfg.logWeightBase_quad*l*l; } - + for (unsigned i = 0; i < pcl.getHits().size(); ++i) { const auto& hit = pcl.getHits()[i]; const auto weight = pcl.getWeights()[i]; diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 1e9e65b0bc..36a96466e2 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -190,7 +190,7 @@ extern "C" { }, app // TODO: Remove me once fixed ));*/ - + app->Add(new JOmniFactoryGeneratorT( "ZDC_HEXPLITClusters", {"ZDCImagingClusterContributions"}, {"ZDC_HEXPLITClusters"}, { From 911c11f345869c5c00fcbed38348ec0c769940ff Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 15 Jan 2024 15:11:26 -0500 Subject: [PATCH 041/106] removed broken include statement from previous commit --- src/detectors/ZDC/ZDC.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 1e9e65b0bc..1c7271e7c3 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -16,7 +16,6 @@ #include "factories/calorimetry/ImagingTopoCluster_factory.h" #include "factories/calorimetry/CalorimeterTruthClustering_factory.h" #include "factories/calorimetry/HEXPLIT_factory.h" -#include "factories/calorimetry/LogWeightReco_factory.h" extern "C" { void InitPlugin(JApplication *app) { From adf6307748c188d6bdb0a54ef8697f20522bd576 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 15 Jan 2024 15:20:14 -0500 Subject: [PATCH 042/106] removed the files for the LogWeightReco --- src/algorithms/calorimetry/LogWeightReco.cc | 92 ------------------- src/algorithms/calorimetry/LogWeightReco.h | 42 --------- .../calorimetry/LogWeightRecoConfig.h | 20 ---- .../calorimetry/LogWeightReco_factory.h | 42 --------- 4 files changed, 196 deletions(-) delete mode 100644 src/algorithms/calorimetry/LogWeightReco.cc delete mode 100644 src/algorithms/calorimetry/LogWeightReco.h delete mode 100644 src/algorithms/calorimetry/LogWeightRecoConfig.h delete mode 100644 src/factories/calorimetry/LogWeightReco_factory.h diff --git a/src/algorithms/calorimetry/LogWeightReco.cc b/src/algorithms/calorimetry/LogWeightReco.cc deleted file mode 100644 index 7b1bb6f8d4..0000000000 --- a/src/algorithms/calorimetry/LogWeightReco.cc +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2023 Sebouh Paul -// SPDX-License-Identifier: LGPL-3.0-or-later - -// References: -// https://arxiv.org/abs/2308.06939 - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "LogWeightReco.h" - -#include "algorithms/calorimetry/LogWeightRecoConfig.h" - -//using namespace edm4eic; - -namespace eicrecon { - - void LogWeightReco::init(const dd4hep::Detector* detector, std::shared_ptr& logger) { - m_log = logger; - m_detector = detector; - } - - std::unique_ptr - LogWeightReco::process(const edm4eic::ProtoClusterCollection &proto) { - - auto outputClusters = std::make_unique(); - for (const auto& pcl : proto) - { - if (pcl.hits_size() == 0) - continue; - - const auto& hits = pcl.getHits(); - //first determine the total energy of the particle and of the shower - double E_recon=0; - double E_shower=0; - for (int i=0; idebug("w0: {}", w0); - double sum_weights=0; - //position of the cluster - double x_recon=0, y_recon=0, z_recon=0, t_recon=0; - for (int i=0; iwarn("0 weight"); - continue; - } - x_recon/=sum_weights; - y_recon/=sum_weights; - z_recon/=sum_weights; - t_recon/=sum_weights; - - edm4hep::Vector3f position(x_recon, y_recon, z_recon); - - auto clus = outputClusters->create(); - clus.setNhits(hits.size()); - clus.setEnergy(E_recon); - clus.setTime(t_recon); - clus.setPosition(position); - } - - return outputClusters; - } - -} diff --git a/src/algorithms/calorimetry/LogWeightReco.h b/src/algorithms/calorimetry/LogWeightReco.h deleted file mode 100644 index 7bd97ef315..0000000000 --- a/src/algorithms/calorimetry/LogWeightReco.h +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2023 Sebouh Paul - -// An algorithm for producing a single cluster with a log-energy-weighted position from a collection of hits. -// -// Author: Sebouh Paul -// Date: 12/04/2023 - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "algorithms/interfaces/WithPodConfig.h" -#include "LogWeightRecoConfig.h" - -namespace eicrecon { - - class LogWeightReco : public WithPodConfig { - - public: - void init(const dd4hep::Detector* detector, std::shared_ptr& logger); - std::unique_ptr process(const edm4eic::ProtoClusterCollection &hits) ; - - private: - const dd4hep::Detector* m_detector; - std::shared_ptr m_log; - - }; - -} // namespace eicrecon diff --git a/src/algorithms/calorimetry/LogWeightRecoConfig.h b/src/algorithms/calorimetry/LogWeightRecoConfig.h deleted file mode 100644 index fb466d08e3..0000000000 --- a/src/algorithms/calorimetry/LogWeightRecoConfig.h +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2023 Sebouh Paul - -#pragma once - -namespace eicrecon { - - struct LogWeightRecoConfig { - // strawman energy reconstruction - double sampling_fraction{0.0203}; - //parameters to determine the cut-off parameter w0 - // as a function of energy based on an optimized - double E0{50}; - double w0_a{5.0}; - double w0_b{0.65}; - double w0_c{0.31}; - - }; - -} // eicrecon diff --git a/src/factories/calorimetry/LogWeightReco_factory.h b/src/factories/calorimetry/LogWeightReco_factory.h deleted file mode 100644 index 757a06d291..0000000000 --- a/src/factories/calorimetry/LogWeightReco_factory.h +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2023 Sebouh Paul - -#pragma once - -#include -#include -#include - - -namespace eicrecon { - -class LogWeightReco_factory : public JOmniFactory { -private: - LogWeightReco m_algo; - PodioInput m_proto_cluster_input {this}; - PodioOutput m_cluster_output {this}; - - ParameterRef m_sf {this, "sampling_fraction", config().sampling_fraction}; - ParameterRef m_E0 {this, "E0", config().E0}; - ParameterRef m_w0_a {this, "w0_a", config().w0_a}; - ParameterRef m_w0_b {this, "w0_b", config().w0_b}; - ParameterRef m_w0_c {this, "w0_c", config().w0_c}; - - Service m_geoSvc {this}; - -public: - void Configure() { - m_algo.applyConfig(config()); - m_algo.init(m_geoSvc().detector(), logger()); - } - - void ChangeRun(int64_t run_number) { - } - - void Process(int64_t run_number, uint64_t event_number) { - m_cluster_output() = m_algo.process(*m_proto_cluster_input()); - } - -}; - -} // eicrecon From ae7fbae3a604967eff2a7dc8acf87369a4be24fb Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 15 Jan 2024 16:29:02 -0500 Subject: [PATCH 043/106] made the arrays in HEXPLIT.h constant, and moved them to HEXPLIT.cc --- src/algorithms/calorimetry/HEXPLIT.cc | 16 ++++++++++++++++ src/algorithms/calorimetry/HEXPLIT.h | 15 +++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 0a4e1059cd..277ef6aae3 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -30,9 +30,25 @@ namespace eicrecon { +const double HEXPLIT::neighbor_offsets_x[12]={1.5*cos(0), 1.5*cos(M_PI/3), 1.5*cos(2*M_PI/3),1.5*cos(3*M_PI/3), 1.5*cos(4*M_PI/3), 1.5*cos(5*M_PI/3), + -sqrt(3)/2.*sin(0),-sqrt(3)/2.*sin(M_PI/3),-sqrt(3)/2.*sin(2*M_PI/3),-sqrt(3)/2.*sin(3*M_PI/3),-sqrt(3)/2.*sin(4*M_PI/3),-sqrt(3)/2.*sin(5*M_PI/3)}; +const double HEXPLIT::neighbor_offsets_y[12]={1.5*sin(0), 1.5*sin(M_PI/3), 1.5*sin(2*M_PI/3),1.5*sin(3*M_PI/3), 1.5*sin(4*M_PI/3), 1.5*sin(5*M_PI/3), + sqrt(3)/2.*cos(0), sqrt(3)/2.*cos(M_PI/3), sqrt(3)/2.*cos(2*M_PI/3), sqrt(3)/2.*cos(3*M_PI/3), sqrt(3)/2.*cos(4*M_PI/3), sqrt(3)/2.*cos(5*M_PI/3)}; + +//indices of the neighboring cells which overlap to produce a given subcell +const int HEXPLIT::neighbor_indices[12][3]={{0, 11,10}, {1, 6, 11},{2, 7, 6}, {3,8,7}, {4,9,8}, {5,10,9}, + {6, 11, 7}, {7, 6, 8}, {8, 7, 9}, {9,8,10},{10,9,11},{11,10,6}}; + +//positions of the centers of subcells +const double HEXPLIT::subcell_offsets_x[12]={0.75*cos(0), 0.75*cos(M_PI/3), 0.75*cos(2*M_PI/3), 0.75*cos(3*M_PI/3), 0.75*cos(4*M_PI/3), 0.75*cos(5*M_PI/3), + -sqrt(3)/4*sin(0),-sqrt(3)/4*sin(M_PI/3),-sqrt(3)/4*sin(2*M_PI/3),-sqrt(3)/4*sin(3*M_PI/3),-sqrt(3)/4*sin(4*M_PI/3),-sqrt(3)/4*sin(5*M_PI/3)}; +const double HEXPLIT::subcell_offsets_y[12]={0.75*sin(0), 0.75*sin(M_PI/3), 0.75*sin(2*M_PI/3), 0.75*sin(3*M_PI/3), 0.75*sin(4*M_PI/3), 0.75*sin(5*M_PI/3), + sqrt(3)/4*cos(0), sqrt(3)/4*cos(M_PI/3), sqrt(3)/4*cos(2*M_PI/3), sqrt(3)/4*cos(3*M_PI/3), sqrt(3)/4*cos(4*M_PI/3), sqrt(3)/4*cos(5*M_PI/3)}; + void HEXPLIT::init(const dd4hep::Detector* detector, std::shared_ptr& logger) { m_log = logger; m_detector = detector; + } std::unique_ptr HEXPLIT::process(const edm4eic::CalorimeterHitCollection &hits){ diff --git a/src/algorithms/calorimetry/HEXPLIT.h b/src/algorithms/calorimetry/HEXPLIT.h index eac5b3a15c..1a2b589577 100644 --- a/src/algorithms/calorimetry/HEXPLIT.h +++ b/src/algorithms/calorimetry/HEXPLIT.h @@ -44,20 +44,15 @@ namespace eicrecon { const int SUBCELLS=12; //positions where the overlapping cells are relative to a given cell (in units of hexagon side length) - double neighbor_offsets_x[12]={1.5*cos(0), 1.5*cos(M_PI/3), 1.5*cos(2*M_PI/3),1.5*cos(3*M_PI/3), 1.5*cos(4*M_PI/3), 1.5*cos(5*M_PI/3), - -sqrt(3)/2.*sin(0),-sqrt(3)/2.*sin(M_PI/3),-sqrt(3)/2.*sin(2*M_PI/3),-sqrt(3)/2.*sin(3*M_PI/3),-sqrt(3)/2.*sin(4*M_PI/3),-sqrt(3)/2.*sin(5*M_PI/3)}; - double neighbor_offsets_y[12]={1.5*sin(0), 1.5*sin(M_PI/3), 1.5*sin(2*M_PI/3),1.5*sin(3*M_PI/3), 1.5*sin(4*M_PI/3), 1.5*sin(5*M_PI/3), - sqrt(3)/2.*cos(0), sqrt(3)/2.*cos(M_PI/3), sqrt(3)/2.*cos(2*M_PI/3), sqrt(3)/2.*cos(3*M_PI/3), sqrt(3)/2.*cos(4*M_PI/3), sqrt(3)/2.*cos(5*M_PI/3)}; + static const double neighbor_offsets_x[12]; + static const double neighbor_offsets_y[12]; //indices of the neighboring cells which overlap to produce a given subcell - int neighbor_indices[12][3]={{0, 11,10}, {1, 6, 11},{2, 7, 6}, {3,8,7}, {4,9,8}, {5,10,9}, - {6, 11, 7}, {7, 6, 8}, {8, 7, 9}, {9,8,10},{10,9,11},{11,10,6}}; + static const int neighbor_indices[12][3]; //positions of the centers of subcells - double subcell_offsets_x[12]={0.75*cos(0), 0.75*cos(M_PI/3), 0.75*cos(2*M_PI/3), 0.75*cos(3*M_PI/3), 0.75*cos(4*M_PI/3), 0.75*cos(5*M_PI/3), - -sqrt(3)/4*sin(0),-sqrt(3)/4*sin(M_PI/3),-sqrt(3)/4*sin(2*M_PI/3),-sqrt(3)/4*sin(3*M_PI/3),-sqrt(3)/4*sin(4*M_PI/3),-sqrt(3)/4*sin(5*M_PI/3)}; - double subcell_offsets_y[12]={0.75*sin(0), 0.75*sin(M_PI/3), 0.75*sin(2*M_PI/3), 0.75*sin(3*M_PI/3), 0.75*sin(4*M_PI/3), 0.75*sin(5*M_PI/3), - sqrt(3)/4*cos(0), sqrt(3)/4*cos(M_PI/3), sqrt(3)/4*cos(2*M_PI/3), sqrt(3)/4*cos(3*M_PI/3), sqrt(3)/4*cos(4*M_PI/3), sqrt(3)/4*cos(5*M_PI/3)}; + static const double subcell_offsets_x[12]; + static const double subcell_offsets_y[12]; private: const dd4hep::Detector* m_detector; From 60010f24d104a37a9afdf57d5a4b9aa541c4b6b0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 21:29:19 +0000 Subject: [PATCH 044/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/HEXPLIT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 277ef6aae3..39c5a3a13b 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -48,7 +48,7 @@ const double HEXPLIT::subcell_offsets_y[12]={0.75*sin(0), 0.75*sin(M_PI/3), 0.75 void HEXPLIT::init(const dd4hep::Detector* detector, std::shared_ptr& logger) { m_log = logger; m_detector = detector; - + } std::unique_ptr HEXPLIT::process(const edm4eic::CalorimeterHitCollection &hits){ From f15e476b72dd49e6d9dc85b5e927cb107ee202ba Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 15 Jan 2024 20:15:22 -0500 Subject: [PATCH 045/106] removed include for Eigen in HEXPLIT --- src/algorithms/calorimetry/HEXPLIT.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 39c5a3a13b..eb878ec997 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include From 18bd2ea4182b58ecca88473854fd8f9bcd4bf203 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 16 Jan 2024 13:09:17 -0500 Subject: [PATCH 046/106] Update ZDC.cc rename all banks for the ZDC to begin with HcalFarForwardZDC or EcalFarForwardZDC --- src/detectors/ZDC/ZDC.cc | 78 +++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 45 deletions(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 8fa573593d..bfd3786b38 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -26,7 +26,7 @@ extern "C" { // LYSO part of the ZDC app->Add(new JOmniFactoryGeneratorT( - "ZDCEcalRawHits", {"ZDCEcalHits"}, {"ZDCEcalRawHits"}, + "EcalFarForwardZDCRawHits", {"EcalFarForwardZDCHits"}, {"EcalFarForwardZDCRawHits"}, { .tRes = 0.0 * dd4hep::ns, .capADC = 32768, @@ -39,7 +39,7 @@ extern "C" { app // TODO: Remove me once fixed )); app->Add(new JOmniFactoryGeneratorT( - "ZDCEcalRecHits", {"ZDCEcalRawHits"}, {"ZDCEcalRecHits"}, + "EcalFarForwardZDCRecHits", {"EcalFarForwardZDCRawHits"}, {"EcalFarForwardZDCRecHits"}, { .capADC = 32768, .dyRangeADC = 2000. * dd4hep::MeV, @@ -49,16 +49,16 @@ extern "C" { .thresholdFactor = 4.0, .thresholdValue = 0.0, .sampFrac = 1.0, - .readout = "ZDCEcalHits", + .readout = "EcalFarForwardZDCHits", }, app // TODO: Remove me once fixed )); app->Add(new JOmniFactoryGeneratorT( - "ZDCEcalTruthProtoClusters", {"ZDCEcalRecHits", "ZDCEcalHits"}, {"ZDCEcalTruthProtoClusters"}, + "EcalFarForwardZDCTruthProtoClusters", {"EcalFarForwardZDCRecHits", "EcalFarForwardZDCHits"}, {"EcalFarForwardZDCTruthProtoClusters"}, app // TODO: Remove me once fixed )); app->Add(new JOmniFactoryGeneratorT( - "ZDCEcalIslandProtoClusters", {"ZDCEcalRecHits"}, {"ZDCEcalIslandProtoClusters"}, + "EcalFarForwardZDCIslandProtoClusters", {"EcalFarForwardZDCRecHits"}, {"EcalFarForwardZDCIslandProtoClusters"}, { .sectorDist = 5.0 * dd4hep::cm, .localDistXY = {50 * dd4hep::cm, 50 * dd4hep::cm}, @@ -74,11 +74,11 @@ extern "C" { app->Add( new JOmniFactoryGeneratorT( - "ZDCEcalTruthClusters", - {"ZDCEcalTruthProtoClusters", // edm4eic::ProtoClusterCollection - "ZDCEcalHits"}, // edm4hep::SimCalorimeterHitCollection - {"ZDCEcalTruthClusters", // edm4eic::Cluster - "ZDCEcalTruthClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation + "EcalFarForwardZDCTruthClusters", + {"EcalFarForwardZDCTruthProtoClusters", // edm4eic::ProtoClusterCollection + "EcalFarForwardZDCHits"}, // edm4hep::SimCalorimeterHitCollection + {"EcalFarForwardZDCTruthClusters", // edm4eic::Cluster + "EcalFarForwardZDCTruthClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation { .energyWeight = "log", .sampFrac = 1.0, @@ -91,11 +91,11 @@ extern "C" { app->Add( new JOmniFactoryGeneratorT( - "ZDCEcalClusters", - {"ZDCEcalIslandProtoClusters", // edm4eic::ProtoClusterCollection - "ZDCEcalHits"}, // edm4hep::SimCalorimeterHitCollection - {"ZDCEcalClusters", // edm4eic::Cluster - "ZDCEcalClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation + "EcalFarForwardZDCClusters", + {"EcalFarForwardZDCIslandProtoClusters", // edm4eic::ProtoClusterCollection + "EcalFarForwardZDCHits"}, // edm4hep::SimCalorimeterHitCollection + {"EcalFarForwardZDCClusters", // edm4eic::Cluster + "EcalFarForwardZDCClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation { .energyWeight = "log", .sampFrac = 1.0, @@ -107,7 +107,7 @@ extern "C" { ); app->Add(new JOmniFactoryGeneratorT( - "ZDCRawHits", {"HcalFarForwardZDCHits"}, {"ZDCRawHits"}, + "HcalFarForwardZDCRawHits", {"HcalFarForwardZDCHits"}, {"HcalFarForwardZDCRawHits"}, { .tRes = 0.0 * dd4hep::ns, .capADC = 32768, @@ -121,7 +121,7 @@ extern "C" { )); app->Add(new JOmniFactoryGeneratorT( - "ZDCRecHits", {"ZDCRawHits"}, {"ZDCRecHits"}, + "HcalFarForwardZDCRecHits", {"HcalFarForwardZDCRawHits"}, {"HcalFarForwardZDCRecHits"}, { .capADC = 32678, .dyRangeADC = 800. * dd4hep::MeV, @@ -139,7 +139,7 @@ extern "C" { )); app->Add(new JOmniFactoryGeneratorT( - "ZDCSubcellHits", {"ZDCRecHits"}, {"ZDCSubcellHits"}, + "HcalFarForwardZDCSubcellHits", {"HcalFarForwardZDCRecHits"}, {"HcalFarForwardZDCSubcellHits"}, { .MIP = 472. * dd4hep::keV, .Emin_in_MIPs=0.1, @@ -150,7 +150,7 @@ extern "C" { double side_length=31.3 * dd4hep::mm; app->Add(new JOmniFactoryGeneratorT( - "ZDCImagingClusterContributions", {"ZDCSubcellHits"}, {"ZDCImagingClusterContributions"}, + "HcalFarForwardZDCImagingClusterContributions", {"HcalFarForwardZDCSubcellHits"}, {"HcalFarForwardZDCImagingClusterContributions"}, { .neighbourLayersRange = 1, .localDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)}, @@ -165,7 +165,7 @@ extern "C" { )); app->Add(new JOmniFactoryGeneratorT( - "ZDCIslandClusterContributions", {"ZDCSubcellHits"}, {"ZDCIslandClusterContributions"}, + "HcalFarForwardZDCIslandClusterContributions", {"HcalFarForwardZDCSubcellHits"}, {"HcalFarForwardZDCIslandClusterContributions"}, { .sectorDist = 1.5 * dd4hep::cm, .localDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)}, @@ -178,20 +178,8 @@ extern "C" { app )); - /*app->Add(new JOmniFactoryGeneratorT( - "ZDC_HEXPLITClusters", {"ZDCImagingClusterContributions"}, {"ZDC_HEXPLITClusters"}, - { - .sampling_fraction=0.0203, - .E0=50. * dd4hep::GeV, - .w0_a=5.0, - .w0_b=0.65, - .w0_c=0.31, - }, - app // TODO: Remove me once fixed - ));*/ - app->Add(new JOmniFactoryGeneratorT( - "ZDC_HEXPLITClusters", {"ZDCImagingClusterContributions"}, {"ZDC_HEXPLITClusters"}, + "HcalFarForwardZDC_HEXPLITClusters", {"HcalFarForwardZDCImagingClusterContributions"}, {"HcalFarForwardZDC_HEXPLITClusters"}, { .energyWeight = "log", .sampFrac=0.0203, @@ -205,11 +193,11 @@ extern "C" { )); app->Add(new JOmniFactoryGeneratorT( - "ZDCTruthProtoClusters", {"ZDCRecHits", "ZDCHits"}, {"ZDCTruthProtoClusters"}, + "HcalFarForwardZDCTruthProtoClusters", {"HcalFarForwardZDCRecHits", "HcalFarForwardZDCHits"}, {"HcalFarForwardZDCTruthProtoClusters"}, app // TODO: Remove me once fixed )); app->Add(new JOmniFactoryGeneratorT( - "ZDCIslandProtoClusters", {"ZDCRecHits"}, {"ZDCIslandProtoClusters"}, + "HcalFarForwardZDCIslandProtoClusters", {"HcalFarForwardZDCRecHits"}, {"HcalFarForwardZDCIslandProtoClusters"}, { .sectorDist = 5.0 * dd4hep::cm, .localDistXY = {50 * dd4hep::cm, 50 * dd4hep::cm}, @@ -224,11 +212,11 @@ extern "C" { )); app->Add(new JOmniFactoryGeneratorT( - "ZDCTruthClusters", - {"ZDCTruthProtoClusters", // edm4eic::ProtoClusterCollection - "ZDCHits"}, // edm4hep::SimCalorimeterHitCollection - {"ZDCTruthClusters", // edm4eic::Cluster - "ZDCTruthClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation + "HcalFarForwardZDCTruthClusters", + {"HcalFarForwardZDCTruthProtoClusters", // edm4eic::ProtoClusterCollection + "HcalFarForwardZDCHits"}, // edm4hep::SimCalorimeterHitCollection + {"HcalFarForwardZDCTruthClusters", // edm4eic::Cluster + "HcalFarForwardZDCTruthClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation { .energyWeight = "log", .sampFrac = 1.0, @@ -240,11 +228,11 @@ extern "C" { ); app->Add(new JOmniFactoryGeneratorT( - "ZDCClusters", - {"ZDCIslandProtoClusters", // edm4eic::ProtoClusterCollection - "ZDCHits"}, // edm4hep::SimCalorimeterHitCollection - {"ZDCClusters", // edm4eic::Cluster - "ZDCClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation + "HcalFarForwardZDCClusters", + {"HcalFarForwardZDCIslandProtoClusters", // edm4eic::ProtoClusterCollection + "HcalFarForwardZDCHits"}, // edm4hep::SimCalorimeterHitCollection + {"HcalFarForwardZDCClusters", // edm4eic::Cluster + "HcalFarForwardZDCClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation { .energyWeight = "log", .sampFrac = 1.0, From 0a6ef4edde5e0271c4c47ae97b3235256cacc56d Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 16 Jan 2024 14:05:22 -0500 Subject: [PATCH 047/106] Update HEXPLIT.cc redefined the tolerance for finding the neighbors at specified positions so that it is relative to the side length. This way it is loose enough that if there is a misalignment between layers in the detector it doesn't cause the HEXPLIT to not be able to determine the neighbors at each of these positions. --- src/algorithms/calorimetry/HEXPLIT.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index eb878ec997..63b63aa1d9 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -69,7 +69,10 @@ std::unique_ptr HEXPLIT::process(const edm4ei double sl = hit.getDimension().x/2.; for (const auto& other_hit : hits){ - double tol=0.01; //tolerance for rounding errors + // maximum distance between where the neighboring cell is and where it should be + // based on an ideal geometry using the staggered tesselation pattern. + // Deviations could arise from rounding errors or from detector misalignment. + double tol=0.1*sl; //only look at hits nearby within two layers of the current layer int dz=abs(hit.getLayer()-other_hit.getLayer()); From 3d4707956bb5a34693370b82ccc073790ba84424 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 16 Jan 2024 19:05:29 +0000 Subject: [PATCH 048/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/HEXPLIT.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 63b63aa1d9..295efb022f 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -69,10 +69,10 @@ std::unique_ptr HEXPLIT::process(const edm4ei double sl = hit.getDimension().x/2.; for (const auto& other_hit : hits){ - // maximum distance between where the neighboring cell is and where it should be - // based on an ideal geometry using the staggered tesselation pattern. - // Deviations could arise from rounding errors or from detector misalignment. - double tol=0.1*sl; + // maximum distance between where the neighboring cell is and where it should be + // based on an ideal geometry using the staggered tesselation pattern. + // Deviations could arise from rounding errors or from detector misalignment. + double tol=0.1*sl; //only look at hits nearby within two layers of the current layer int dz=abs(hit.getLayer()-other_hit.getLayer()); From a94b716e01b59a2aef6b780fb25ae005eb22df8d Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 16 Jan 2024 14:44:36 -0500 Subject: [PATCH 049/106] Update JEventProcessorPODIO.cc use the new convention for the ZDC objects: HcalFarForwardZDC or EcalFarForwardZDC --- src/services/io/podio/JEventProcessorPODIO.cc | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index d27a1086a9..873aefb9e6 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -176,17 +176,17 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "B0ECalRecHits", "B0ECalClusters", "B0ECalClusterAssociations", - "ZDCEcalRawHits", - "ZDCEcalRecHits", - "ZDCEcalClusters", - "ZDCEcalClusterAssociations", - "ZDCRawHits", - "ZDCRecHits", - "ZDCClusters", - "ZDCSubcellHits", - "ZDC_HEXPLITClusters", - "ZDCLogWeightClusters", - "ZDCClusterAssociations", + "EcalFarForwardZDCRawHits", + "EcalFarForwardZDCRecHits", + "EcalFarForwardZDCClusters", + "EcalFarForwardZDCClusterAssociations", + "HcalFarForwardZDCRawHits", + "HcalFarForwardZDCRecHits", + "HcalFarForwardZDCClusters", + "HcalFarForwardZDCSubcellHits", + "HcalFarForwardZDC_HEXPLITClusters", + "HcalFarForwardZDCLogWeightClusters", + "HcalFarForwardZDCClusterAssociations", "HcalEndcapNTruthClusters", "HcalEndcapNTruthClusterAssociations", "HcalBarrelTruthClusters", @@ -194,10 +194,10 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "B0ECalRecHits", "B0ECalClusters", "B0ECalClusterAssociations", - "ZDCEcalTruthClusters", - "ZDCEcalTruthClusterAssociations", - "ZDCTruthClusters", - "ZDCTruthClusterAssociations", + "EcalFarForwardZDCTruthClusters", + "EcalFarForwardZDCTruthClusterAssociations", + "HcalFarForwardZDCTruthClusters", + "HcalFarForwardZDCTruthClusterAssociations", // DIRC "DIRCRawHits" From 39d5c0a5fe8554ac9bff5f9a123fd804e49762e0 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 16 Jan 2024 20:45:09 -0500 Subject: [PATCH 050/106] use the correct units for converting the local to global position in HEXPLIT.cc --- src/algorithms/calorimetry/HEXPLIT.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 295efb022f..00c1fbb988 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -111,16 +111,19 @@ std::unique_ptr HEXPLIT::process(const edm4ei //convert this to a position object so that the global position can be determined dd4hep::Position local_position; - local_position.SetX(local.x); - local_position.SetY(local.y); - local_position.SetZ(local.z); + local_position.SetX(local.x*dd4hep::mm); + local_position.SetY(local.y*dd4hep::mm); + local_position.SetZ(local.z*dd4hep::mm); //also convert this to the detector's global coordinates. To do: check if this is correct auto alignment = volman.lookupDetElement(hit.getCellID()).nominal(); auto global_position = alignment.localToWorld(local_position); + //std::cout << "local: " << local_position.X() << " " << local_position.Y() << " " << local_position.Z() << std::endl; + //std::cout << "global: " << global_position.X() << " " << global_position.Y() << " " << global_position.Z() << std::endl < Date: Wed, 17 Jan 2024 01:45:17 +0000 Subject: [PATCH 051/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/HEXPLIT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 00c1fbb988..5ab05b9eb3 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -121,7 +121,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei auto global_position = alignment.localToWorld(local_position); //std::cout << "local: " << local_position.X() << " " << local_position.Y() << " " << local_position.Z() << std::endl; //std::cout << "global: " << global_position.X() << " " << global_position.Y() << " " << global_position.Z() << std::endl < Date: Wed, 17 Jan 2024 02:06:06 -0500 Subject: [PATCH 052/106] fixed input and output list for CoG recon in ZDC.cc --- src/detectors/ZDC/ZDC.cc | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index bfd3786b38..76a92779b8 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -168,7 +168,7 @@ extern "C" { "HcalFarForwardZDCIslandClusterContributions", {"HcalFarForwardZDCSubcellHits"}, {"HcalFarForwardZDCIslandClusterContributions"}, { .sectorDist = 1.5 * dd4hep::cm, - .localDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)}, + .localDistXY = {0.9*side_length, 0.76*side_length*sin(M_PI/3)}, .splitCluster = false, .minClusterHitEdep = 100.0 * dd4hep::keV, .minClusterCenterEdep = 1.0 * dd4hep::MeV, @@ -178,19 +178,23 @@ extern "C" { app )); - app->Add(new JOmniFactoryGeneratorT( - "HcalFarForwardZDC_HEXPLITClusters", {"HcalFarForwardZDCImagingClusterContributions"}, {"HcalFarForwardZDC_HEXPLITClusters"}, - { - .energyWeight = "log", - .sampFrac=0.0203, - .logWeightBase=5.0, - .variableLogWeightBase=true, - .logWeightBase_lin=0.65, - .logWeightBase_quad=0.31, - .logWeightBase_Eref=50*dd4hep::GeV, - }, - app // TODO: Remove me once fixed - )); + app->Add(new JOmniFactoryGeneratorT( + "HcalFarForwardZDC_HEXPLITClusters", + {"HcalFarForwardZDCIslandClusterContributions", // edm4eic::ProtoClusterCollection + "HcalFarForwardZDCHits"}, // edm4hep::SimCalorimeterHitCollection + {"HcalFarForwardZDC_HEXPLITClusters", // edm4eic::Cluster + "HcalFarForwardZDCClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation + { + .energyWeight = "log", + .sampFrac = 0.0203, + .logWeightBase=5.0, + .variableLogWeightBase=true, + .logWeightBase_lin=0.65, + .logWeightBase_quad=0.31, + .logWeightBase_Eref=50*dd4hep::GeV, + }, + app // TODO: Remove me once fixed + )); app->Add(new JOmniFactoryGeneratorT( "HcalFarForwardZDCTruthProtoClusters", {"HcalFarForwardZDCRecHits", "HcalFarForwardZDCHits"}, {"HcalFarForwardZDCTruthProtoClusters"}, From d7993a44f789ea4ba697ecda7fba8aed9f1a8440 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 07:06:59 +0000 Subject: [PATCH 053/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/detectors/ZDC/ZDC.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 76a92779b8..481c93c4c9 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -190,7 +190,7 @@ extern "C" { .logWeightBase=5.0, .variableLogWeightBase=true, .logWeightBase_lin=0.65, - .logWeightBase_quad=0.31, + .logWeightBase_quad=0.31, .logWeightBase_Eref=50*dd4hep::GeV, }, app // TODO: Remove me once fixed From acafa2fb9bfd38182650a1159e95af0e0dd66d77 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Wed, 17 Jan 2024 02:22:07 -0500 Subject: [PATCH 054/106] fixed a bug involving the 'tol' value. --- src/algorithms/calorimetry/HEXPLIT.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 5ab05b9eb3..80cf8b59b5 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -72,7 +72,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei // maximum distance between where the neighboring cell is and where it should be // based on an ideal geometry using the staggered tesselation pattern. // Deviations could arise from rounding errors or from detector misalignment. - double tol=0.1*sl; + double tol=0.1; // in units of side lengths. //only look at hits nearby within two layers of the current layer int dz=abs(hit.getLayer()-other_hit.getLayer()); @@ -119,8 +119,6 @@ std::unique_ptr HEXPLIT::process(const edm4ei auto alignment = volman.lookupDetElement(hit.getCellID()).nominal(); auto global_position = alignment.localToWorld(local_position); - //std::cout << "local: " << local_position.X() << " " << local_position.Y() << " " << local_position.Z() << std::endl; - //std::cout << "global: " << global_position.X() << " " << global_position.Y() << " " << global_position.Z() << std::endl < Date: Wed, 17 Jan 2024 02:45:26 -0500 Subject: [PATCH 055/106] reverted an earlier commit taht was causing problems at runtime involving typeid of segmentation classes --- src/algorithms/calorimetry/CalorimeterHitReco.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitReco.cc b/src/algorithms/calorimetry/CalorimeterHitReco.cc index fcad9482ed..32d565ee2b 100644 --- a/src/algorithms/calorimetry/CalorimeterHitReco.cc +++ b/src/algorithms/calorimetry/CalorimeterHitReco.cc @@ -236,17 +236,17 @@ void CalorimeterHitReco::process( const auto pos = local.nominal().worldToLocal(gpos); std::vector cdim; // get segmentation dimensions - auto& segmentation_type = typeid(m_converter->findReadout(local).segmentation()); - if (segmentation_type == typeid(dd4hep::DDSegmentation::CartesianGridXY) - || segmentation_type == typeid(dd4hep::DDSegmentation::HexGrid)) { + auto segmentation_type = m_converter->findReadout(local).segmentation().type(); + auto& segmentation_typeid = typeid(m_converter->findReadout(local).segmentation()); + if (segmentation_type == "CartesianGridXY" || segmentation_type == "HexGridXY") { auto cell_dim = m_converter->cellDimensions(cellID); cdim.resize(3); cdim[0] = cell_dim[0]; cdim[1] = cell_dim[1]; m_log->debug("Using segmentation for cell dimensions: {}", fmt::join(cdim, ", ")); } else { - if ((segmentation_type != typeid(dd4hep::DDSegmentation::NoSegmentation)) && (!warned_unsupported_segmentation)) { - m_log->warn("Unsupported segmentation type \"{}\"", segmentation_type.name()); + if ((segmentation_type != "NoSegmentation") && (!warned_unsupported_segmentation)) { + m_log->warn("Unsupported segmentation type \"{}\"", segmentation_type); warned_unsupported_segmentation = true; } From 331ceed9a8002a49cc23a81b351c2e0cb59acdf3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 07:45:35 +0000 Subject: [PATCH 056/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/CalorimeterHitReco.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitReco.cc b/src/algorithms/calorimetry/CalorimeterHitReco.cc index 32d565ee2b..787fd0654d 100644 --- a/src/algorithms/calorimetry/CalorimeterHitReco.cc +++ b/src/algorithms/calorimetry/CalorimeterHitReco.cc @@ -236,8 +236,8 @@ void CalorimeterHitReco::process( const auto pos = local.nominal().worldToLocal(gpos); std::vector cdim; // get segmentation dimensions - auto segmentation_type = m_converter->findReadout(local).segmentation().type(); - auto& segmentation_typeid = typeid(m_converter->findReadout(local).segmentation()); + auto segmentation_type = m_converter->findReadout(local).segmentation().type(); + auto& segmentation_typeid = typeid(m_converter->findReadout(local).segmentation()); if (segmentation_type == "CartesianGridXY" || segmentation_type == "HexGridXY") { auto cell_dim = m_converter->cellDimensions(cellID); cdim.resize(3); From 3751e66d16a17a5816e45f1b03d88b15f93081bf Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Wed, 17 Jan 2024 12:06:28 -0500 Subject: [PATCH 057/106] explicitly cast to float (avoids compiler errors) --- src/algorithms/calorimetry/HEXPLIT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 80cf8b59b5..bfbb9e84c3 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -121,7 +121,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei auto global_position = alignment.localToWorld(local_position); //convert this from position object to a vector object - const decltype(edm4eic::CalorimeterHitData::position) position = {global_position.X()/dd4hep::mm, global_position.Y()/dd4hep::mm, global_position.Z()/dd4hep::mm}; + const decltype(edm4eic::CalorimeterHitData::position) position = {(float)(global_position.X()/dd4hep::mm), (float)(global_position.Y()/dd4hep::mm), (float)(global_position.Z()/dd4hep::mm)}; //bounding box dimensions depend on the orientation of the rhombus int orientation = k%3==0; From e038edc0f046fabba683e242b7b179671faa7f4b Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Wed, 17 Jan 2024 13:05:28 -0500 Subject: [PATCH 058/106] static_cast to float (avoids compiler errors) --- src/algorithms/calorimetry/HEXPLIT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index bfbb9e84c3..47c2f166f7 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -121,7 +121,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei auto global_position = alignment.localToWorld(local_position); //convert this from position object to a vector object - const decltype(edm4eic::CalorimeterHitData::position) position = {(float)(global_position.X()/dd4hep::mm), (float)(global_position.Y()/dd4hep::mm), (float)(global_position.Z()/dd4hep::mm)}; + const decltype(edm4eic::CalorimeterHitData::position) position = {static_cast((global_position.X()/dd4hep::mm), static_cast((global_position.Y()/dd4hep::mm), static_cast((global_position.Z()/dd4hep::mm)}; //bounding box dimensions depend on the orientation of the rhombus int orientation = k%3==0; From 656220e17094c88195f0af2af09df1b815f8e91b Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Wed, 17 Jan 2024 13:28:13 -0500 Subject: [PATCH 059/106] fiksed a mispelled werd in teh coments in the HEXPLIT.cc code --- src/algorithms/calorimetry/HEXPLIT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 47c2f166f7..1184fca19f 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -70,7 +70,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei double sl = hit.getDimension().x/2.; for (const auto& other_hit : hits){ // maximum distance between where the neighboring cell is and where it should be - // based on an ideal geometry using the staggered tesselation pattern. + // based on an ideal geometry using the staggered tessellation pattern. // Deviations could arise from rounding errors or from detector misalignment. double tol=0.1; // in units of side lengths. From 803d4050cc9e718c02c625325c82d57725fd2f36 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Wed, 17 Jan 2024 13:31:55 -0500 Subject: [PATCH 060/106] fixed parenthesis problem from previous commit --- src/algorithms/calorimetry/HEXPLIT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 1184fca19f..564928c2a4 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -121,7 +121,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei auto global_position = alignment.localToWorld(local_position); //convert this from position object to a vector object - const decltype(edm4eic::CalorimeterHitData::position) position = {static_cast((global_position.X()/dd4hep::mm), static_cast((global_position.Y()/dd4hep::mm), static_cast((global_position.Z()/dd4hep::mm)}; + const decltype(edm4eic::CalorimeterHitData::position) position = {static_cast(global_position.X()/dd4hep::mm), static_cast(global_position.Y()/dd4hep::mm), static_cast(global_position.Z()/dd4hep::mm)}; //bounding box dimensions depend on the orientation of the rhombus int orientation = k%3==0; From d90afccad100b1c5aabcda86535d4f701b3e5e46 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 13:35:16 -0500 Subject: [PATCH 061/106] Update CalorimeterHitReco.cc removed line that declares an unused variable --- src/algorithms/calorimetry/CalorimeterHitReco.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitReco.cc b/src/algorithms/calorimetry/CalorimeterHitReco.cc index 787fd0654d..4f7252cc87 100644 --- a/src/algorithms/calorimetry/CalorimeterHitReco.cc +++ b/src/algorithms/calorimetry/CalorimeterHitReco.cc @@ -237,7 +237,6 @@ void CalorimeterHitReco::process( std::vector cdim; // get segmentation dimensions auto segmentation_type = m_converter->findReadout(local).segmentation().type(); - auto& segmentation_typeid = typeid(m_converter->findReadout(local).segmentation()); if (segmentation_type == "CartesianGridXY" || segmentation_type == "HexGridXY") { auto cell_dim = m_converter->cellDimensions(cellID); cdim.resize(3); From 423a26a232eb1ad3396a76defa9aa5c939378f64 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 13:37:23 -0500 Subject: [PATCH 062/106] Update src/algorithms/calorimetry/HEXPLITConfig.h use units for the default value for the "MIP" parameter Co-authored-by: Dmitry Kalinkin --- src/algorithms/calorimetry/HEXPLITConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/HEXPLITConfig.h b/src/algorithms/calorimetry/HEXPLITConfig.h index 51332c40f9..1e2d0d1c72 100644 --- a/src/algorithms/calorimetry/HEXPLITConfig.h +++ b/src/algorithms/calorimetry/HEXPLITConfig.h @@ -6,7 +6,7 @@ namespace eicrecon { struct HEXPLITConfig { - double MIP{0.000472}; + double MIP{472.*dd4hep::keV}; double Emin_in_MIPs{0.1}; double tmax{325*dd4hep::ns}; }; From 9001a26a13481ebb6eb0b28a1b98008f3580a617 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 13:40:39 -0500 Subject: [PATCH 063/106] Update src/algorithms/calorimetry/HEXPLIT.cc removed commented line Co-authored-by: Dmitry Kalinkin --- src/algorithms/calorimetry/HEXPLIT.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 564928c2a4..3da024c092 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -25,8 +25,6 @@ #include "algorithms/calorimetry/HEXPLITConfig.h" -//using namespace edm4eic; - namespace eicrecon { const double HEXPLIT::neighbor_offsets_x[12]={1.5*cos(0), 1.5*cos(M_PI/3), 1.5*cos(2*M_PI/3),1.5*cos(3*M_PI/3), 1.5*cos(4*M_PI/3), 1.5*cos(5*M_PI/3), From 26ea571d077a4eaf014f905df15773fe879ecdd2 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 13:41:24 -0500 Subject: [PATCH 064/106] Update src/factories/calorimetry/HEXPLIT_factory.h Co-authored-by: Dmitry Kalinkin --- src/factories/calorimetry/HEXPLIT_factory.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/factories/calorimetry/HEXPLIT_factory.h b/src/factories/calorimetry/HEXPLIT_factory.h index b5cde32464..c26f62a355 100644 --- a/src/factories/calorimetry/HEXPLIT_factory.h +++ b/src/factories/calorimetry/HEXPLIT_factory.h @@ -6,7 +6,6 @@ #include #include #include -// #include namespace eicrecon { From 5c0c0e0deb1bfb48b8ac86393da57a76cdd57f3b Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 13:41:55 -0500 Subject: [PATCH 065/106] Update src/algorithms/calorimetry/CalorimeterHitReco.cc Co-authored-by: Dmitry Kalinkin --- src/algorithms/calorimetry/CalorimeterHitReco.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitReco.cc b/src/algorithms/calorimetry/CalorimeterHitReco.cc index 4f7252cc87..3fa7f7d1da 100644 --- a/src/algorithms/calorimetry/CalorimeterHitReco.cc +++ b/src/algorithms/calorimetry/CalorimeterHitReco.cc @@ -17,9 +17,6 @@ #include #include #include -#include -#include -#include #include #include #include From b323bc6862361b70faac7089a99e6fbe277ef057 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 13:42:37 -0500 Subject: [PATCH 066/106] Update src/algorithms/calorimetry/HEXPLIT.cc Co-authored-by: Dmitry Kalinkin --- src/algorithms/calorimetry/HEXPLIT.cc | 33 ++++++++++++--------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 3da024c092..9a87d8f57a 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -4,26 +4,21 @@ // References: // https://arxiv.org/abs/2308.06939 - -#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "HEXPLIT.h" - -#include "algorithms/calorimetry/HEXPLITConfig.h" +#include +#include +#include +#include +#include +#include + #include + + #include "HEXPLIT.h" + #include "algorithms/calorimetry/HEXPLITConfig.h" namespace eicrecon { From 208c17eb0c2fcd205d31123cf8fabcad5644f316 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 18:42:42 +0000 Subject: [PATCH 067/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/HEXPLIT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 9a87d8f57a..535d8367d9 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -16,7 +16,7 @@ #include #include #include - + #include "HEXPLIT.h" #include "algorithms/calorimetry/HEXPLITConfig.h" From 9a97d85e65a139e75b3032dc16b6720560b40f7d Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 13:43:20 -0500 Subject: [PATCH 068/106] Update src/algorithms/calorimetry/HEXPLIT.h Co-authored-by: Dmitry Kalinkin --- src/algorithms/calorimetry/HEXPLIT.h | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.h b/src/algorithms/calorimetry/HEXPLIT.h index 1a2b589577..f74322eed6 100644 --- a/src/algorithms/calorimetry/HEXPLIT.h +++ b/src/algorithms/calorimetry/HEXPLIT.h @@ -7,28 +7,16 @@ // Author: Sebouh Paul // Date: 12/04/2023 - #pragma once + +#include #include -#include #include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include #include -#include -#include - -#include "algorithms/interfaces/WithPodConfig.h" + #include "HEXPLITConfig.h" +#include "algorithms/interfaces/WithPodConfig.h" namespace eicrecon { From e5f6617f0ee96d5ea963a2f6bf266994a6b5aedd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 18:43:26 +0000 Subject: [PATCH 069/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/HEXPLIT.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.h b/src/algorithms/calorimetry/HEXPLIT.h index f74322eed6..16c4f5a86f 100644 --- a/src/algorithms/calorimetry/HEXPLIT.h +++ b/src/algorithms/calorimetry/HEXPLIT.h @@ -14,7 +14,7 @@ #include #include #include - + #include "HEXPLITConfig.h" #include "algorithms/interfaces/WithPodConfig.h" From d20a4f2516367df87ce28f4859fa7481848290c1 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 13:44:15 -0500 Subject: [PATCH 070/106] Update src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc Co-authored-by: Dmitry Kalinkin --- src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index 6a663a7a43..c0da1319fa 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -194,7 +194,7 @@ std::optional CalorimeterClusterRecoCoG::reconstruct(const edm auto v = cl.getPosition(); double logWeightBase=m_cfg.logWeightBase; - if (m_cfg.variableLogWeightBase){ + if ((m_cfg.logWeightBase_lin != 0) || (m_cfg.logWeightBase_quad != 0)){ double l=log(cl.getEnergy()/m_cfg.logWeightBase_Eref); logWeightBase+=m_cfg.logWeightBase_lin*l+m_cfg.logWeightBase_quad*l*l; } From 1707f0b8756613bdd4a787e379192eb1a8770a1e Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 13:44:47 -0500 Subject: [PATCH 071/106] Update src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h Co-authored-by: Dmitry Kalinkin --- src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h b/src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h index 14b3eb1791..8d8b7f7d76 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h @@ -17,7 +17,6 @@ namespace eicrecon { //optional: have the log weight base depend on the energy // logWeightBase+logWeightBase_lin*l+logWeightBase_quad*l*l // where l = log(cl.getEnergy()/logWeightBase_Eref) - bool variableLogWeightBase=false; double logWeightBase_lin=0; double logWeightBase_quad=0; double logWeightBase_Eref=50; From 518044b9ca5a7b467ab3b7b1777400050b272859 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 13:45:04 -0500 Subject: [PATCH 072/106] Update src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h Co-authored-by: Dmitry Kalinkin --- src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h b/src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h index d0405f619e..940a4e94f8 100644 --- a/src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h +++ b/src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h @@ -27,7 +27,6 @@ class CalorimeterClusterRecoCoG_factory : public JOmniFactory m_energyWeight {this, "energyWeight", config().energyWeight}; ParameterRef m_samplingFraction {this, "samplingFraction", config().sampFrac}; ParameterRef m_logWeightBase {this, "logWeightBase", config().logWeightBase}; - ParameterRef m_variableLogWeightBase {this, "variableLogWeightBase", config().variableLogWeightBase}; ParameterRef m_logWeightBase_lin {this, "logWeightBase_lin", config().logWeightBase_lin}; ParameterRef m_logWeightBase_quad {this, "logWeightBase_quad", config().logWeightBase_quad}; ParameterRef m_logWeightBase_Eref {this, "logWeightBase_Eref", config().logWeightBase_Eref}; From b8c3e7ce0103701f75a466db68be015e42071752 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 13:45:25 -0500 Subject: [PATCH 073/106] Update src/algorithms/calorimetry/HEXPLIT.h Co-authored-by: Dmitry Kalinkin --- src/algorithms/calorimetry/HEXPLIT.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.h b/src/algorithms/calorimetry/HEXPLIT.h index 16c4f5a86f..37e953b057 100644 --- a/src/algorithms/calorimetry/HEXPLIT.h +++ b/src/algorithms/calorimetry/HEXPLIT.h @@ -27,9 +27,6 @@ namespace eicrecon { std::unique_ptr process(const edm4eic::CalorimeterHitCollection &hits) ; private: - - - const int SUBCELLS=12; //positions where the overlapping cells are relative to a given cell (in units of hexagon side length) static const double neighbor_offsets_x[12]; From f4b22a9a812e3c67025acae22a64c4ade18fce50 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 13:51:46 -0500 Subject: [PATCH 074/106] removed parameter variableLogWeightBase from ZDC.cc --- src/detectors/ZDC/ZDC.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 481c93c4c9..15e8c20340 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -188,7 +188,6 @@ extern "C" { .energyWeight = "log", .sampFrac = 0.0203, .logWeightBase=5.0, - .variableLogWeightBase=true, .logWeightBase_lin=0.65, .logWeightBase_quad=0.31, .logWeightBase_Eref=50*dd4hep::GeV, From e0dece1ce3f03586158616fc2679bebc44330770 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 16:07:03 -0500 Subject: [PATCH 075/106] use the correct 'algorithm' interface --- src/algorithms/calorimetry/HEXPLIT.cc | 18 ++++++++++-------- src/algorithms/calorimetry/HEXPLIT.h | 21 +++++++++++++++++++-- src/factories/calorimetry/HEXPLIT_factory.h | 13 ++++++++----- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 535d8367d9..1e34e1efe6 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -15,10 +15,10 @@ #include #include #include - #include +#include - #include "HEXPLIT.h" - #include "algorithms/calorimetry/HEXPLITConfig.h" +#include "HEXPLIT.h" +#include "algorithms/calorimetry/HEXPLITConfig.h" namespace eicrecon { @@ -43,16 +43,19 @@ void HEXPLIT::init(const dd4hep::Detector* detector, std::shared_ptr HEXPLIT::process(const edm4eic::CalorimeterHitCollection &hits){ +void HEXPLIT::process(const HEXPLIT::Input& input, + const HEXPLIT::Output& output) const { + const auto [hits] = input; + auto [subcellHits] = output; + double MIP=m_cfg.MIP/dd4hep::GeV; double Emin=m_cfg.Emin_in_MIPs*MIP; double tmax=m_cfg.tmax/dd4hep::ns; auto volman = m_detector->volumeManager(); - auto subcellHits = std::make_unique(); - for(const auto& hit : hits){ + for(const auto& hit : *hits){ //skip hits that do not pass E and t cuts if (hit.getEnergy()tmax) continue; @@ -61,7 +64,7 @@ std::unique_ptr HEXPLIT::process(const edm4ei std::vector Eneighbors(SUBCELLS, 0.0); double sl = hit.getDimension().x/2.; - for (const auto& other_hit : hits){ + for (const auto& other_hit : *hits){ // maximum distance between where the neighboring cell is and where it should be // based on an ideal geometry using the staggered tessellation pattern. // Deviations could arise from rounding errors or from detector misalignment. @@ -134,7 +137,6 @@ std::unique_ptr HEXPLIT::process(const edm4ei local); } } - return subcellHits; } diff --git a/src/algorithms/calorimetry/HEXPLIT.h b/src/algorithms/calorimetry/HEXPLIT.h index 37e953b057..cdfcdde035 100644 --- a/src/algorithms/calorimetry/HEXPLIT.h +++ b/src/algorithms/calorimetry/HEXPLIT.h @@ -19,12 +19,29 @@ #include "algorithms/interfaces/WithPodConfig.h" namespace eicrecon { + +using HEXPLITAlgorithm = algorithms::Algorithm< + algorithms::Input< + const edm4eic::CalorimeterHitCollection + >, + algorithms::Output< + edm4eic::CalorimeterHitCollection + > + >; - class HEXPLIT : public WithPodConfig { + class HEXPLIT + : public HEXPLITAlgorithm, + public WithPodConfig { public: + HEXPLIT(std::string_view name) + : HEXPLITAlgorithm{name, + {"inputHits"}, + {"outputSubcellHits"}, + "Split hits into subcell hits"} {} + void init(const dd4hep::Detector* detector, std::shared_ptr& logger); - std::unique_ptr process(const edm4eic::CalorimeterHitCollection &hits) ; + void process(const Input&, const Output&) const final; private: const int SUBCELLS=12; diff --git a/src/factories/calorimetry/HEXPLIT_factory.h b/src/factories/calorimetry/HEXPLIT_factory.h index c26f62a355..16f050db58 100644 --- a/src/factories/calorimetry/HEXPLIT_factory.h +++ b/src/factories/calorimetry/HEXPLIT_factory.h @@ -11,8 +11,10 @@ namespace eicrecon { class HEXPLIT_factory : public JOmniFactory { -private: - HEXPLIT m_algo; + + using AlgoT = eicrecon::HEXPLIT; + private: + std::unique_ptr m_algo; PodioInput m_rec_hits_input {this}; PodioOutput m_subcell_hits_output {this}; @@ -24,15 +26,16 @@ class HEXPLIT_factory : public JOmniFactory { public: void Configure() { - m_algo.applyConfig(config()); - m_algo.init(m_geoSvc().detector(), logger()); + m_algo = std::make_unique(GetPrefix()); + m_algo->applyConfig(config()); + m_algo->init(m_geoSvc().detector(), logger()); } void ChangeRun(int64_t run_number) { } void Process(int64_t run_number, uint64_t event_number) { - m_subcell_hits_output() = m_algo.process(*m_rec_hits_input()); + m_algo->process({m_rec_hits_input()},{m_subcell_hits_output().get()}); } }; From 9104f4636fa7a161150422db5e52c1559b0835bf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 21:07:48 +0000 Subject: [PATCH 076/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/HEXPLIT.cc | 2 +- src/algorithms/calorimetry/HEXPLIT.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 1e34e1efe6..0f7d3267a2 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -48,7 +48,7 @@ void HEXPLIT::process(const HEXPLIT::Input& input, const auto [hits] = input; auto [subcellHits] = output; - + double MIP=m_cfg.MIP/dd4hep::GeV; double Emin=m_cfg.Emin_in_MIPs*MIP; double tmax=m_cfg.tmax/dd4hep::ns; diff --git a/src/algorithms/calorimetry/HEXPLIT.h b/src/algorithms/calorimetry/HEXPLIT.h index cdfcdde035..2f54e019d7 100644 --- a/src/algorithms/calorimetry/HEXPLIT.h +++ b/src/algorithms/calorimetry/HEXPLIT.h @@ -19,7 +19,7 @@ #include "algorithms/interfaces/WithPodConfig.h" namespace eicrecon { - + using HEXPLITAlgorithm = algorithms::Algorithm< algorithms::Input< const edm4eic::CalorimeterHitCollection @@ -39,7 +39,7 @@ using HEXPLITAlgorithm = algorithms::Algorithm< {"inputHits"}, {"outputSubcellHits"}, "Split hits into subcell hits"} {} - + void init(const dd4hep::Detector* detector, std::shared_ptr& logger); void process(const Input&, const Output&) const final; From 4f3b900216043568dd004916034e85f20571db83 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 16:16:19 -0500 Subject: [PATCH 077/106] Update src/algorithms/calorimetry/HEXPLIT.h Co-authored-by: Dmitry Kalinkin --- src/algorithms/calorimetry/HEXPLIT.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.h b/src/algorithms/calorimetry/HEXPLIT.h index 2f54e019d7..0692ab2af1 100644 --- a/src/algorithms/calorimetry/HEXPLIT.h +++ b/src/algorithms/calorimetry/HEXPLIT.h @@ -44,17 +44,18 @@ using HEXPLITAlgorithm = algorithms::Algorithm< void process(const Input&, const Output&) const final; private: - const int SUBCELLS=12; -//positions where the overlapping cells are relative to a given cell (in units of hexagon side length) - static const double neighbor_offsets_x[12]; - static const double neighbor_offsets_y[12]; + static constexpr int SUBCELLS = 12; - //indices of the neighboring cells which overlap to produce a given subcell - static const int neighbor_indices[12][3]; + // positions where the overlapping cells are relative to a given cell (in units of hexagon side length) + static const std::array neighbor_offsets_x; + static const std::array neighbor_offsets_y; -//positions of the centers of subcells - static const double subcell_offsets_x[12]; - static const double subcell_offsets_y[12]; + // indices of the neighboring cells which overlap to produce a given subcell + static const std::array, SUBCELLS> neighbor_indices; + + // positions of the centers of subcells + static const std::array subcell_offsets_x; + static const std::array subcell_offsets_y; private: const dd4hep::Detector* m_detector; From 2e4e7daeb9236212b880d9432bca94d7870ace40 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 18 Jan 2024 16:22:29 -0500 Subject: [PATCH 078/106] undo earlier commit that did not compile correctly --- src/algorithms/calorimetry/HEXPLIT.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.h b/src/algorithms/calorimetry/HEXPLIT.h index 0692ab2af1..9c11fdd493 100644 --- a/src/algorithms/calorimetry/HEXPLIT.h +++ b/src/algorithms/calorimetry/HEXPLIT.h @@ -44,18 +44,15 @@ using HEXPLITAlgorithm = algorithms::Algorithm< void process(const Input&, const Output&) const final; private: - static constexpr int SUBCELLS = 12; - - // positions where the overlapping cells are relative to a given cell (in units of hexagon side length) - static const std::array neighbor_offsets_x; - static const std::array neighbor_offsets_y; - - // indices of the neighboring cells which overlap to produce a given subcell - static const std::array, SUBCELLS> neighbor_indices; - - // positions of the centers of subcells - static const std::array subcell_offsets_x; - static const std::array subcell_offsets_y; + const int SUBCELLS=12; + //positions where the overlapping cells are relative to a given cell (in units of hexagon side length) + static const double neighbor_offsets_x[12]; + static const double neighbor_offsets_y[12]; + //indices of the neighboring cells which overlap to produce a given subcell + static const int neighbor_indices[12][3]; + //positions of the centers of subcells + static const double subcell_offsets_x[12]; + static const double subcell_offsets_y[12]; private: const dd4hep::Detector* m_detector; From 7404c503e614f3d0b4cfd8fa1260f106f21d9289 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 19 Jan 2024 09:20:24 -0500 Subject: [PATCH 079/106] added a test for the HEXPLIT algorithm. Doesn't work yet, adding it in here so that I can ask the reviewers for help getting it to work --- src/tests/algorithms_test/CMakeLists.txt | 1 + .../algorithms_test/calorimetry_HEXPLIT.cc | 134 ++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 src/tests/algorithms_test/calorimetry_HEXPLIT.cc diff --git a/src/tests/algorithms_test/CMakeLists.txt b/src/tests/algorithms_test/CMakeLists.txt index b0a398fe82..64b82d29e7 100644 --- a/src/tests/algorithms_test/CMakeLists.txt +++ b/src/tests/algorithms_test/CMakeLists.txt @@ -5,6 +5,7 @@ get_filename_component(TEST_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) add_executable(${TEST_NAME} calorimetry_CalorimeterIslandCluster.cc calorimetry_CalorimeterHitDigi.cc + calorimetry_HEXPLIT.cc pid_MergeTracks.cc pid_MergeParticleID.cc ) diff --git a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc new file mode 100644 index 0000000000..d18a9d708a --- /dev/null +++ b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc @@ -0,0 +1,134 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2023, Dmitry Kalinkin + +#include "DD4hep/DetFactoryHelper.h" +#include +#include +#include +#include "DD4hep/VolumeManager.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "algorithms/calorimetry/HEXPLIT.h" +#include "algorithms/calorimetry/HEXPLITConfig.h" + +using eicrecon::HEXPLIT; +using eicrecon::HEXPLITConfig; + +TEST_CASE( "the subcell-splitting algorithm runs", "[HEXPLIT]" ) { + HEXPLIT algo("HEXPLIT"); + std::shared_ptr logger = spdlog::default_logger()->clone("HEXPLIT"); + logger->set_level(spdlog::level::trace); + HEXPLITConfig cfg; + cfg.MIP = 472. * dd4hep::keV; + cfg.tmax = 1000. * dd4hep::ns; + std::cout << "creating mock detector"<add(id_desc); + std::cout << "added id_desc to detector"<add(readout); + std::cout << "added readout to detector"<material("Pb"); +// // Defining envelope volume +// dd4hep::Volume envelopeVol("MockDetector", envelope, mat); +// +// dd4hep::DetElement det("MockDetector", detID); +// dd4hep::Volume motherVol = detector->pickMotherVolume(det); +// +// // Placing detector in world volume +// auto tr = dd4hep::Transform3D(dd4hep::RotationZYX(0, 0, 0),dd4hep::Position(0, 0, 0)); +// dd4hep::PlacedVolume phv = motherVol.placeVolume(envelopeVol, tr); +// phv.addPhysVolID("system", detID); +// det.setPlacement(phv); + + //dimension of a cell + auto dimension = edm4hep::Vector3f(2*side_length, sqrt(3)*side_length, thickness); + + algo.applyConfig(cfg); + std::cout << "applied config to algo"< layer={0,1,2,3,4}; + std::array x={0,0.75*side_length,0,0.75*side_length,0}; + std::array y={sqrt(3)/2*side_length,-0.25*sqrt(3)*side_length,0,0.25*sqrt(3)*side_length,sqrt(3)/2*side_length}; + for(size_t i=0; i<5; i++){ + hits_coll.create( + id_desc.encode({{"system", 255}, {"x", 0}, {"y", 0}}), // std::uint64_t cellID, + 5.0*dd4hep::MeV, // float energy, + 0.0, // float energyError, + 0.0, // float time, + 0.0, // float timeError, + edm4hep::Vector3f(x[i], y[i], layer[i]*layer_spacing), // edm4hep::Vector3f position, + dimension, // edm4hep::Vector3f dimension, + 0, // std::int32_t sector, + layer[i], // std::int32_t layer, + edm4hep::Vector3f(x[i], y[i], layer[i]*layer_spacing) // edm4hep::Vector3f local + ); + } + std::cout << "created input hits"<volumeManager().adoptPlacement(0,context); + std::cout <<"applied volume manager context" << std::endl; + + + auto subcellhits_coll = std::make_unique(); + std::cout << "created output subcell hits collection"< Date: Fri, 19 Jan 2024 14:20:33 +0000 Subject: [PATCH 080/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../algorithms_test/calorimetry_HEXPLIT.cc | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc index d18a9d708a..26d7ed5936 100644 --- a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc +++ b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc @@ -49,18 +49,18 @@ TEST_CASE( "the subcell-splitting algorithm runs", "[HEXPLIT]" ) { std::cout << "added id_desc to detector"<add(readout); std::cout << "added readout to detector"< layer={0,1,2,3,4}; @@ -113,22 +113,22 @@ TEST_CASE( "the subcell-splitting algorithm runs", "[HEXPLIT]" ) { std::cout <<"created volume manager context" << std::endl; detector->volumeManager().adoptPlacement(0,context); std::cout <<"applied volume manager context" << std::endl; - - + + auto subcellhits_coll = std::make_unique(); std::cout << "created output subcell hits collection"< Date: Fri, 19 Jan 2024 09:41:25 -0500 Subject: [PATCH 081/106] working on writing the test for the HEXPLIT algorithm. Doesn't work yet, adding it in here so that I can ask the reviewers for help getting it to work --- src/tests/algorithms_test/calorimetry_HEXPLIT.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc index d18a9d708a..0feffd7d02 100644 --- a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc +++ b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc @@ -109,13 +109,14 @@ TEST_CASE( "the subcell-splitting algorithm runs", "[HEXPLIT]" ) { ); } std::cout << "created input hits"<volumeManager().adoptPlacement(0,context); - std::cout <<"applied volume manager context" << std::endl; + //auto context = new dd4hep::VolumeManagerContext; + //std::cout <<"created volume manager context" << std::endl; + //detector->volumeManager().adoptPlacement(0,context); + //std::cout <<"applied volume manager context" << std::endl; auto subcellhits_coll = std::make_unique(); + //edm4eic::CalorimeterHitCollection subcellhits_coll; std::cout << "created output subcell hits collection"<(global_position.X()/dd4hep::mm), static_cast(global_position.Y()/dd4hep::mm), static_cast(global_position.Z()/dd4hep::mm)}; diff --git a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc index 34bc7c2441..38adfdbe4d 100644 --- a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc +++ b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc @@ -50,34 +50,11 @@ TEST_CASE( "the subcell-splitting algorithm runs", "[HEXPLIT]" ) { detector->add(readout); std::cout << "added readout to detector"<material("Pb"); -// // Defining envelope volume -// dd4hep::Volume envelopeVol("MockDetector", envelope, mat); -// -// dd4hep::DetElement det("MockDetector", detID); -// dd4hep::Volume motherVol = detector->pickMotherVolume(det); -// -// // Placing detector in world volume -// auto tr = dd4hep::Transform3D(dd4hep::RotationZYX(0, 0, 0),dd4hep::Position(0, 0, 0)); -// dd4hep::PlacedVolume phv = motherVol.placeVolume(envelopeVol, tr); -// phv.addPhysVolID("system", detID); -// det.setPlacement(phv); - //dimension of a cell auto dimension = edm4hep::Vector3f(2*side_length, sqrt(3)*side_length, thickness); @@ -94,10 +71,11 @@ TEST_CASE( "the subcell-splitting algorithm runs", "[HEXPLIT]" ) { std::array layer={0,1,2,3,4}; std::array x={0,0.75*side_length,0,0.75*side_length,0}; std::array y={sqrt(3)/2*side_length,-0.25*sqrt(3)*side_length,0,0.25*sqrt(3)*side_length,sqrt(3)/2*side_length}; + std::array E={50*dd4hep::MeV,50*dd4hep::MeV,50*dd4hep::MeV,50*dd4hep::MeV,50*dd4hep::MeV}; for(size_t i=0; i<5; i++){ hits_coll.create( id_desc.encode({{"system", 255}, {"x", 0}, {"y", 0}}), // std::uint64_t cellID, - 5.0*dd4hep::MeV, // float energy, + E[i], // float energy, 0.0, // float energyError, 0.0, // float time, 0.0, // float timeError, @@ -128,8 +106,23 @@ TEST_CASE( "the subcell-splitting algorithm runs", "[HEXPLIT]" ) { //the number of subcell hits should be equal to the //number of subcells per cell (12) times the number of cells (5) REQUIRE( (*subcellhits_coll).size() == 60); - //REQUIRE( (*protoclust_coll)[0].hits_size() == 1 ); - //REQUIRE( (*protoclust_coll)[0].weights_size() == 1 ); + + //next check that the sum of the hit energies equals the energy that I gave the hits + double tol=0.001; + double Esum=0; + int i=0; + for (auto subcell : *subcellhits_coll){ + std::cout << "Esum=" << Esum << ",i="<< i << ", E expected="<0.95); } From 5e36910badaaaafd0b91027cd657bae720a6ea64 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 21 Jan 2024 06:25:00 +0000 Subject: [PATCH 083/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/HEXPLIT.cc | 10 +++++----- src/tests/algorithms_test/calorimetry_HEXPLIT.cc | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index bc0cb3e065..caa8b6caa3 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -104,21 +104,21 @@ void HEXPLIT::process(const HEXPLIT::Input& input, //create the subcell hits. First determine their positions in local coordinates. const decltype(edm4eic::CalorimeterHitData::local) local(hit.getLocal().x+subcell_offsets_x[k]*sl, hit.getLocal().y+subcell_offsets_y[k]*sl, hit.getLocal().z); - + //convert this to a position object so that the global position can be determined dd4hep::Position local_position; local_position.SetX(local.x*dd4hep::mm); local_position.SetY(local.y*dd4hep::mm); local_position.SetZ(local.z*dd4hep::mm); - + dd4hep::Position global_position; try { - + //also convert this to the detector's global coordinates. To do: check if this is correct auto alignment = volman.lookupDetElement(hit.getCellID()).nominal(); - + global_position = alignment.localToWorld(local_position); - + } catch (...){ // do this to prevent errors when running the test on the mock detector diff --git a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc index 38adfdbe4d..ee1c80dc65 100644 --- a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc +++ b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc @@ -106,7 +106,7 @@ TEST_CASE( "the subcell-splitting algorithm runs", "[HEXPLIT]" ) { //the number of subcell hits should be equal to the //number of subcells per cell (12) times the number of cells (5) REQUIRE( (*subcellhits_coll).size() == 60); - + //next check that the sum of the hit energies equals the energy that I gave the hits double tol=0.001; double Esum=0; From 2a62af3c14c33c3949bef65a80f089dd6c0faa11 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sun, 21 Jan 2024 01:27:32 -0500 Subject: [PATCH 084/106] cleaned up the code for the test for the HEXPLIT algorithm; removed commented code and excessive print statements --- .../algorithms_test/calorimetry_HEXPLIT.cc | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc index 38adfdbe4d..d7c9cbc763 100644 --- a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc +++ b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc @@ -36,19 +36,12 @@ TEST_CASE( "the subcell-splitting algorithm runs", "[HEXPLIT]" ) { HEXPLITConfig cfg; cfg.MIP = 472. * dd4hep::keV; cfg.tmax = 1000. * dd4hep::ns; - std::cout << "creating mock detector"<add(id_desc); - std::cout << "added id_desc to detector"<add(readout); - std::cout << "added readout to detector"<volumeManager().adoptPlacement(0,context); - //std::cout <<"applied volume manager context" << std::endl; auto subcellhits_coll = std::make_unique(); - //edm4eic::CalorimeterHitCollection subcellhits_coll; - std::cout << "created output subcell hits collection"< Date: Sun, 21 Jan 2024 06:27:49 +0000 Subject: [PATCH 085/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/tests/algorithms_test/calorimetry_HEXPLIT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc index 9899a3e1b0..dcbf9fadd3 100644 --- a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc +++ b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc @@ -79,7 +79,7 @@ TEST_CASE( "the subcell-splitting algorithm runs", "[HEXPLIT]" ) { auto subcellhits_coll = std::make_unique(); algo.process({&hits_coll}, {subcellhits_coll.get()}); - + //the number of subcell hits should be equal to the //number of subcells per cell (12) times the number of cells (5) From a7340dc1f268feb0847f5202f50661e1c20a0a44 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sun, 21 Jan 2024 12:30:18 -0500 Subject: [PATCH 086/106] test if commenting out some of the unused factories will cause it to pass certain checks --- src/detectors/ZDC/ZDC.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 15e8c20340..d5ef6a8092 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -195,7 +195,7 @@ extern "C" { app // TODO: Remove me once fixed )); - app->Add(new JOmniFactoryGeneratorT( + /*app->Add(new JOmniFactoryGeneratorT( "HcalFarForwardZDCTruthProtoClusters", {"HcalFarForwardZDCRecHits", "HcalFarForwardZDCHits"}, {"HcalFarForwardZDCTruthProtoClusters"}, app // TODO: Remove me once fixed )); @@ -244,6 +244,6 @@ extern "C" { }, app // TODO: Remove me once fixed ) - ); + );*/ } } From d84b9ceba5bf2511361876f996b3e968fc9366d8 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sun, 21 Jan 2024 13:44:41 -0500 Subject: [PATCH 087/106] test if commenting out some of the unused factories will cause it to pass certain checks. uncomment half the factories --- src/detectors/ZDC/ZDC.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index d5ef6a8092..0e3da6b530 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -195,7 +195,7 @@ extern "C" { app // TODO: Remove me once fixed )); - /*app->Add(new JOmniFactoryGeneratorT( + app->Add(new JOmniFactoryGeneratorT( "HcalFarForwardZDCTruthProtoClusters", {"HcalFarForwardZDCRecHits", "HcalFarForwardZDCHits"}, {"HcalFarForwardZDCTruthProtoClusters"}, app // TODO: Remove me once fixed )); @@ -213,7 +213,7 @@ extern "C" { }, app // TODO: Remove me once fixed )); - + /* app->Add(new JOmniFactoryGeneratorT( "HcalFarForwardZDCTruthClusters", {"HcalFarForwardZDCTruthProtoClusters", // edm4eic::ProtoClusterCollection From a5d741f99d4195ff889b19dddbea259b60a466ad Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Sun, 21 Jan 2024 14:21:07 -0500 Subject: [PATCH 088/106] test if commenting out some of the unused factories will cause it to pass certain checks. uncomment another factory --- src/detectors/ZDC/ZDC.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 0e3da6b530..ae37d86dee 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -213,7 +213,7 @@ extern "C" { }, app // TODO: Remove me once fixed )); - /* + app->Add(new JOmniFactoryGeneratorT( "HcalFarForwardZDCTruthClusters", {"HcalFarForwardZDCTruthProtoClusters", // edm4eic::ProtoClusterCollection @@ -229,7 +229,7 @@ extern "C" { app // TODO: Remove me once fixed ) ); - + /* app->Add(new JOmniFactoryGeneratorT( "HcalFarForwardZDCClusters", {"HcalFarForwardZDCIslandProtoClusters", // edm4eic::ProtoClusterCollection From 5c1a296f1e859fdb2d06b5ba41f38274e5fcc995 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 21 Jan 2024 19:21:15 +0000 Subject: [PATCH 089/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/detectors/ZDC/ZDC.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index ae37d86dee..991cf2c7ce 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -213,7 +213,7 @@ extern "C" { }, app // TODO: Remove me once fixed )); - + app->Add(new JOmniFactoryGeneratorT( "HcalFarForwardZDCTruthClusters", {"HcalFarForwardZDCTruthProtoClusters", // edm4eic::ProtoClusterCollection From 7e6b62e693e3e0d69c3df027bfc3e0b0a170f587 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 22 Jan 2024 01:01:21 -0500 Subject: [PATCH 090/106] test if commenting out some of the unused factories will cause it to pass certain checks. uncomment the last factory --- src/detectors/ZDC/ZDC.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index ae37d86dee..0b1fad02cc 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -229,7 +229,7 @@ extern "C" { app // TODO: Remove me once fixed ) ); - /* + app->Add(new JOmniFactoryGeneratorT( "HcalFarForwardZDCClusters", {"HcalFarForwardZDCIslandProtoClusters", // edm4eic::ProtoClusterCollection @@ -244,6 +244,6 @@ extern "C" { }, app // TODO: Remove me once fixed ) - );*/ + ); } } From ea2fc2c93ef7342401cbeeb0567c29a6b4eec354 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 06:01:39 +0000 Subject: [PATCH 091/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/detectors/ZDC/ZDC.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index b44725dbfa..15e8c20340 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -229,7 +229,7 @@ extern "C" { app // TODO: Remove me once fixed ) ); - + app->Add(new JOmniFactoryGeneratorT( "HcalFarForwardZDCClusters", {"HcalFarForwardZDCIslandProtoClusters", // edm4eic::ProtoClusterCollection From 1988de253d22a25612ffad46829e6a6e2698b57f Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 22 Jan 2024 01:03:46 -0500 Subject: [PATCH 092/106] fix the top of the the HEXPLIT test codefile. correct the copyright info. --- src/tests/algorithms_test/calorimetry_HEXPLIT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc index dcbf9fadd3..ab2f2a59e3 100644 --- a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc +++ b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc @@ -1,5 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2023, Dmitry Kalinkin +// Copyright (C) 2024, Sebouh Paul #include "DD4hep/DetFactoryHelper.h" #include From b7362702650c55a7a3743be31e5a05178c88e455 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 22 Jan 2024 01:21:55 -0500 Subject: [PATCH 093/106] test if reducing sampling fraction fixes issue in CoG factory for ZDC --- src/detectors/ZDC/ZDC.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 15e8c20340..cfa44be8f2 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -238,7 +238,7 @@ extern "C" { "HcalFarForwardZDCClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation { .energyWeight = "log", - .sampFrac = 1.0, + .sampFrac = 0.0203, .logWeightBase = 6.2, .enableEtaBounds = false, }, From d71719dd383d6231995cc2951a808fb86d412f3b Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 22 Jan 2024 09:23:36 -0500 Subject: [PATCH 094/106] fix naming conflict among banks in ZDC plugin --- src/detectors/ZDC/ZDC.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index cfa44be8f2..2d702fa3aa 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -183,7 +183,7 @@ extern "C" { {"HcalFarForwardZDCIslandClusterContributions", // edm4eic::ProtoClusterCollection "HcalFarForwardZDCHits"}, // edm4hep::SimCalorimeterHitCollection {"HcalFarForwardZDC_HEXPLITClusters", // edm4eic::Cluster - "HcalFarForwardZDCClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation + "HcalFarForwardZDC_HEXPLITClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation { .energyWeight = "log", .sampFrac = 0.0203, From 0005f075cb8becea7c13a5df1e4979feafd4ae96 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 22 Jan 2024 13:29:18 -0500 Subject: [PATCH 095/106] try to appease the iwyu --- src/algorithms/calorimetry/HEXPLIT.cc | 2 +- src/algorithms/calorimetry/HEXPLIT.h | 3 +- src/detectors/ZDC/ZDC.cc | 2 +- .../algorithms_test/calorimetry_HEXPLIT.cc | 42 ++++++++----------- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index caa8b6caa3..99c7dd6c54 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -15,8 +15,8 @@ #include #include #include +#include // for not_null #include - #include "HEXPLIT.h" #include "algorithms/calorimetry/HEXPLITConfig.h" diff --git a/src/algorithms/calorimetry/HEXPLIT.h b/src/algorithms/calorimetry/HEXPLIT.h index 9c11fdd493..10a13d231f 100644 --- a/src/algorithms/calorimetry/HEXPLIT.h +++ b/src/algorithms/calorimetry/HEXPLIT.h @@ -14,7 +14,8 @@ #include #include #include - +#include // for basic_string +#include // for string_view #include "HEXPLITConfig.h" #include "algorithms/interfaces/WithPodConfig.h" diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 2d702fa3aa..a00ee7867b 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -5,8 +5,8 @@ #include #include +#include #include - #include "algorithms/interfaces/WithPodConfig.h" #include "extensions/jana/JOmniFactoryGeneratorT.h" #include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h" diff --git a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc index ab2f2a59e3..71ee53acef 100644 --- a/src/tests/algorithms_test/calorimetry_HEXPLIT.cc +++ b/src/tests/algorithms_test/calorimetry_HEXPLIT.cc @@ -1,30 +1,24 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright (C) 2024, Sebouh Paul -#include "DD4hep/DetFactoryHelper.h" -#include -#include -#include -#include "DD4hep/VolumeManager.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "algorithms/calorimetry/HEXPLIT.h" -#include "algorithms/calorimetry/HEXPLITConfig.h" +#include // for Detector +#include // for IDDescriptor +#include // for Readout +#include // for MeV, mm, keV, ns +#include // for CalorimeterHitCollection, MutableCalorimeterHit, CalorimeterHitMutableCollectionIterator +#include // for Vector3f +#include // for level_enum +#include // for logger +#include // for default_logger +#include // for size_t +#include // for array +#include // for AssertionHandler, operator""_catch_sr, StringRef, REQUIRE, operator<, operator==, operator>, TEST_CASE +#include // for sqrt, abs +#include // for allocator, unique_ptr, make_unique, shared_ptr, __shared_ptr_access +#include // for string +#include // for pair +#include "algorithms/calorimetry/HEXPLIT.h" // for HEXPLIT +#include "algorithms/calorimetry/HEXPLITConfig.h" // for HEXPLITConfig using eicrecon::HEXPLIT; using eicrecon::HEXPLITConfig; From 7c156ab6f518cb3e7b98ba7dff0fd80cbaf82bbd Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 22 Jan 2024 14:26:44 -0500 Subject: [PATCH 096/106] try to appease iwyu --- src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index c0da1319fa..88f63d1231 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include From 8b5daebf3f641a595e36fde0528b651d7c1121ad Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 22 Jan 2024 14:46:33 -0500 Subject: [PATCH 097/106] undo previous commit. --- src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index 88f63d1231..c0da1319fa 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include From 752aad47ee8a8cf711472b93fbddb90e9e0cdbc1 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 22 Jan 2024 16:17:35 -0500 Subject: [PATCH 098/106] use constants for the number of subcells per cell, the number of positions on neighboring cells that used for defining the subcells on the current cell, and the number of neighbors who overlap on a given subcell. These numbers are 12, 12, and 3 --- src/algorithms/calorimetry/HEXPLIT.cc | 16 ++++++++-------- src/algorithms/calorimetry/HEXPLIT.h | 17 +++++++++++------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index 99c7dd6c54..d9db38586f 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -22,19 +22,19 @@ namespace eicrecon { -const double HEXPLIT::neighbor_offsets_x[12]={1.5*cos(0), 1.5*cos(M_PI/3), 1.5*cos(2*M_PI/3),1.5*cos(3*M_PI/3), 1.5*cos(4*M_PI/3), 1.5*cos(5*M_PI/3), +const double HEXPLIT::neighbor_offsets_x[NEIGHBORS]={1.5*cos(0), 1.5*cos(M_PI/3), 1.5*cos(2*M_PI/3),1.5*cos(3*M_PI/3), 1.5*cos(4*M_PI/3), 1.5*cos(5*M_PI/3), -sqrt(3)/2.*sin(0),-sqrt(3)/2.*sin(M_PI/3),-sqrt(3)/2.*sin(2*M_PI/3),-sqrt(3)/2.*sin(3*M_PI/3),-sqrt(3)/2.*sin(4*M_PI/3),-sqrt(3)/2.*sin(5*M_PI/3)}; -const double HEXPLIT::neighbor_offsets_y[12]={1.5*sin(0), 1.5*sin(M_PI/3), 1.5*sin(2*M_PI/3),1.5*sin(3*M_PI/3), 1.5*sin(4*M_PI/3), 1.5*sin(5*M_PI/3), +const double HEXPLIT::neighbor_offsets_y[NEIGHBORS]={1.5*sin(0), 1.5*sin(M_PI/3), 1.5*sin(2*M_PI/3),1.5*sin(3*M_PI/3), 1.5*sin(4*M_PI/3), 1.5*sin(5*M_PI/3), sqrt(3)/2.*cos(0), sqrt(3)/2.*cos(M_PI/3), sqrt(3)/2.*cos(2*M_PI/3), sqrt(3)/2.*cos(3*M_PI/3), sqrt(3)/2.*cos(4*M_PI/3), sqrt(3)/2.*cos(5*M_PI/3)}; //indices of the neighboring cells which overlap to produce a given subcell -const int HEXPLIT::neighbor_indices[12][3]={{0, 11,10}, {1, 6, 11},{2, 7, 6}, {3,8,7}, {4,9,8}, {5,10,9}, +const int HEXPLIT::neighbor_indices[SUBCELLS][OVERLAP]={{0, 11,10}, {1, 6, 11},{2, 7, 6}, {3,8,7}, {4,9,8}, {5,10,9}, {6, 11, 7}, {7, 6, 8}, {8, 7, 9}, {9,8,10},{10,9,11},{11,10,6}}; //positions of the centers of subcells -const double HEXPLIT::subcell_offsets_x[12]={0.75*cos(0), 0.75*cos(M_PI/3), 0.75*cos(2*M_PI/3), 0.75*cos(3*M_PI/3), 0.75*cos(4*M_PI/3), 0.75*cos(5*M_PI/3), +const double HEXPLIT::subcell_offsets_x[SUBCELLS]={0.75*cos(0), 0.75*cos(M_PI/3), 0.75*cos(2*M_PI/3), 0.75*cos(3*M_PI/3), 0.75*cos(4*M_PI/3), 0.75*cos(5*M_PI/3), -sqrt(3)/4*sin(0),-sqrt(3)/4*sin(M_PI/3),-sqrt(3)/4*sin(2*M_PI/3),-sqrt(3)/4*sin(3*M_PI/3),-sqrt(3)/4*sin(4*M_PI/3),-sqrt(3)/4*sin(5*M_PI/3)}; -const double HEXPLIT::subcell_offsets_y[12]={0.75*sin(0), 0.75*sin(M_PI/3), 0.75*sin(2*M_PI/3), 0.75*sin(3*M_PI/3), 0.75*sin(4*M_PI/3), 0.75*sin(5*M_PI/3), +const double HEXPLIT::subcell_offsets_y[SUBCELLS]={0.75*sin(0), 0.75*sin(M_PI/3), 0.75*sin(2*M_PI/3), 0.75*sin(3*M_PI/3), 0.75*sin(4*M_PI/3), 0.75*sin(5*M_PI/3), sqrt(3)/4*cos(0), sqrt(3)/4*cos(M_PI/3), sqrt(3)/4*cos(2*M_PI/3), sqrt(3)/4*cos(3*M_PI/3), sqrt(3)/4*cos(4*M_PI/3), sqrt(3)/4*cos(5*M_PI/3)}; void HEXPLIT::init(const dd4hep::Detector* detector, std::shared_ptr& logger) { @@ -61,7 +61,7 @@ void HEXPLIT::process(const HEXPLIT::Input& input, continue; //keep track of the energy in each neighboring cell - std::vector Eneighbors(SUBCELLS, 0.0); + std::vector Eneighbors(NEIGHBORS, 0.0); double sl = hit.getDimension().x/2.; for (const auto& other_hit : *hits){ @@ -84,7 +84,7 @@ void HEXPLIT::process(const HEXPLIT::Input& input, //loop over locations of the neighboring cells //and check if the jth hit matches this location - for(int k=0;k Date: Mon, 22 Jan 2024 18:29:39 -0500 Subject: [PATCH 099/106] fixed the naming conventions for the ZDC --- src/detectors/ZDC/ZDC.cc | 22 ++++++++++--------- src/services/io/podio/JEventProcessorPODIO.cc | 6 +++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index a00ee7867b..b39f8f721f 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -165,7 +165,7 @@ extern "C" { )); app->Add(new JOmniFactoryGeneratorT( - "HcalFarForwardZDCIslandClusterContributions", {"HcalFarForwardZDCSubcellHits"}, {"HcalFarForwardZDCIslandClusterContributions"}, + "HcalFarForwardZDCIslandProtoClusters", {"HcalFarForwardZDCSubcellHits"}, {"HcalFarForwardZDCIslandProtoClusters"}, { .sectorDist = 1.5 * dd4hep::cm, .localDistXY = {0.9*side_length, 0.76*side_length*sin(M_PI/3)}, @@ -179,11 +179,11 @@ extern "C" { )); app->Add(new JOmniFactoryGeneratorT( - "HcalFarForwardZDC_HEXPLITClusters", - {"HcalFarForwardZDCIslandClusterContributions", // edm4eic::ProtoClusterCollection + "HcalFarForwardZDCClusters", + {"HcalFarForwardZDCIslandProtoClusters", // edm4eic::ProtoClusterCollection "HcalFarForwardZDCHits"}, // edm4hep::SimCalorimeterHitCollection - {"HcalFarForwardZDC_HEXPLITClusters", // edm4eic::Cluster - "HcalFarForwardZDC_HEXPLITClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation + {"HcalFarForwardZDCClusters", // edm4eic::Cluster + "HcalFarForwardZDCClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation { .energyWeight = "log", .sampFrac = 0.0203, @@ -199,8 +199,10 @@ extern "C" { "HcalFarForwardZDCTruthProtoClusters", {"HcalFarForwardZDCRecHits", "HcalFarForwardZDCHits"}, {"HcalFarForwardZDCTruthProtoClusters"}, app // TODO: Remove me once fixed )); + + //Clusters with the baseline algorithm (no HEXPLIT) app->Add(new JOmniFactoryGeneratorT( - "HcalFarForwardZDCIslandProtoClusters", {"HcalFarForwardZDCRecHits"}, {"HcalFarForwardZDCIslandProtoClusters"}, + "HcalFarForwardZDCIslandProtoClustersBaseline", {"HcalFarForwardZDCRecHits"}, {"HcalFarForwardZDCIslandProtoClustersBaseline"}, { .sectorDist = 5.0 * dd4hep::cm, .localDistXY = {50 * dd4hep::cm, 50 * dd4hep::cm}, @@ -231,11 +233,11 @@ extern "C" { ); app->Add(new JOmniFactoryGeneratorT( - "HcalFarForwardZDCClusters", - {"HcalFarForwardZDCIslandProtoClusters", // edm4eic::ProtoClusterCollection + "HcalFarForwardZDCClustersBaseline", + {"HcalFarForwardZDCIslandProtoClustersBaseline", // edm4eic::ProtoClusterCollection "HcalFarForwardZDCHits"}, // edm4hep::SimCalorimeterHitCollection - {"HcalFarForwardZDCClusters", // edm4eic::Cluster - "HcalFarForwardZDCClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation + {"HcalFarForwardZDCClustersBaseline", // edm4eic::Cluster + "HcalFarForwardZDCClusterAssociationsBaseline"}, // edm4eic::MCRecoClusterParticleAssociation { .energyWeight = "log", .sampFrac = 0.0203, diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index 873aefb9e6..c7680370c5 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -183,10 +183,12 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "HcalFarForwardZDCRawHits", "HcalFarForwardZDCRecHits", "HcalFarForwardZDCClusters", + "HcalFarForwardZDCProtoClusters", "HcalFarForwardZDCSubcellHits", - "HcalFarForwardZDC_HEXPLITClusters", - "HcalFarForwardZDCLogWeightClusters", "HcalFarForwardZDCClusterAssociations", + "HcalFarForwardZDCClustersBaseline", + "HcalFarForwardZDCProtoClustersBaseline", + "HcalFarForwardZDCClusterAssociationsBaseline", "HcalEndcapNTruthClusters", "HcalEndcapNTruthClusterAssociations", "HcalBarrelTruthClusters", From 225ba854f407d5e80591fe777a886813453a7008 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 23:31:00 +0000 Subject: [PATCH 100/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/detectors/ZDC/ZDC.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index b39f8f721f..7e0c1ad85c 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -199,7 +199,7 @@ extern "C" { "HcalFarForwardZDCTruthProtoClusters", {"HcalFarForwardZDCRecHits", "HcalFarForwardZDCHits"}, {"HcalFarForwardZDCTruthProtoClusters"}, app // TODO: Remove me once fixed )); - + //Clusters with the baseline algorithm (no HEXPLIT) app->Add(new JOmniFactoryGeneratorT( "HcalFarForwardZDCIslandProtoClustersBaseline", {"HcalFarForwardZDCRecHits"}, {"HcalFarForwardZDCIslandProtoClustersBaseline"}, From 4b3eca1cd7a3818cdf1b12ab01594545b0f4d4ca Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 22 Jan 2024 18:33:47 -0500 Subject: [PATCH 101/106] fixed the naming conventions for the ZDC --- src/detectors/ZDC/ZDC.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index b39f8f721f..f53c9c1fa5 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -150,7 +150,7 @@ extern "C" { double side_length=31.3 * dd4hep::mm; app->Add(new JOmniFactoryGeneratorT( - "HcalFarForwardZDCImagingClusterContributions", {"HcalFarForwardZDCSubcellHits"}, {"HcalFarForwardZDCImagingClusterContributions"}, + "HcalFarForwardZDCImagingProtoClusters", {"HcalFarForwardZDCSubcellHits"}, {"HcalFarForwardZDCImagingProtoClusters}, { .neighbourLayersRange = 1, .localDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)}, From e51ced0f89bc2dd7cb344ca8d32bb7348b0ece6c Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 22 Jan 2024 18:54:04 -0500 Subject: [PATCH 102/106] fixed the order of the bank names --- src/services/io/podio/JEventProcessorPODIO.cc | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index c7680370c5..11b5beb6b8 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -176,31 +176,36 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "B0ECalRecHits", "B0ECalClusters", "B0ECalClusterAssociations", + "HcalEndcapNTruthClusters", + "HcalEndcapNTruthClusterAssociations", + "HcalBarrelTruthClusters", + "HcalBarrelTruthClusterAssociations", + "B0ECalRecHits", + "B0ECalClusters", + "B0ECalClusterAssociations", + + //ZDC Ecal "EcalFarForwardZDCRawHits", "EcalFarForwardZDCRecHits", "EcalFarForwardZDCClusters", "EcalFarForwardZDCClusterAssociations", + "EcalFarForwardZDCTruthClusters", + "EcalFarForwardZDCTruthClusterAssociations", + + //ZDC HCal "HcalFarForwardZDCRawHits", "HcalFarForwardZDCRecHits", - "HcalFarForwardZDCClusters", - "HcalFarForwardZDCProtoClusters", "HcalFarForwardZDCSubcellHits", + "HcalFarForwardZDCProtoClusters", + "HcalFarForwardZDCClusters", "HcalFarForwardZDCClusterAssociations", - "HcalFarForwardZDCClustersBaseline", "HcalFarForwardZDCProtoClustersBaseline", + "HcalFarForwardZDCClustersBaseline", "HcalFarForwardZDCClusterAssociationsBaseline", - "HcalEndcapNTruthClusters", - "HcalEndcapNTruthClusterAssociations", - "HcalBarrelTruthClusters", - "HcalBarrelTruthClusterAssociations", - "B0ECalRecHits", - "B0ECalClusters", - "B0ECalClusterAssociations", - "EcalFarForwardZDCTruthClusters", - "EcalFarForwardZDCTruthClusterAssociations", "HcalFarForwardZDCTruthClusters", "HcalFarForwardZDCTruthClusterAssociations", - + + // DIRC "DIRCRawHits" }; From 9dc9ff1edc3a8f4fd5db521c992f0e11cceff1ff Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 23:54:13 +0000 Subject: [PATCH 103/106] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/services/io/podio/JEventProcessorPODIO.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index 11b5beb6b8..57908d0634 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -191,7 +191,7 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "EcalFarForwardZDCClusterAssociations", "EcalFarForwardZDCTruthClusters", "EcalFarForwardZDCTruthClusterAssociations", - + //ZDC HCal "HcalFarForwardZDCRawHits", "HcalFarForwardZDCRecHits", @@ -204,8 +204,8 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "HcalFarForwardZDCClusterAssociationsBaseline", "HcalFarForwardZDCTruthClusters", "HcalFarForwardZDCTruthClusterAssociations", - - + + // DIRC "DIRCRawHits" }; From 8c03d5a409612702661824eeb980c666284540d5 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 22 Jan 2024 22:08:25 -0500 Subject: [PATCH 104/106] fixed a missing end quote --- src/detectors/ZDC/ZDC.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index 48ecfd361f..def7d26bed 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -150,7 +150,7 @@ extern "C" { double side_length=31.3 * dd4hep::mm; app->Add(new JOmniFactoryGeneratorT( - "HcalFarForwardZDCImagingProtoClusters", {"HcalFarForwardZDCSubcellHits"}, {"HcalFarForwardZDCImagingProtoClusters}, + "HcalFarForwardZDCImagingProtoClusters", {"HcalFarForwardZDCSubcellHits"}, {"HcalFarForwardZDCImagingProtoClusters"}, { .neighbourLayersRange = 1, .localDistXY = {0.76*side_length, 0.76*side_length*sin(M_PI/3)}, From 87d906d2561e9cf10a442f25614695378b6ac475 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 23 Jan 2024 00:47:41 -0500 Subject: [PATCH 105/106] use lambdas to set the values in the neighbor and subcell offsets in HEXPLIT --- src/algorithms/calorimetry/HEXPLIT.cc | 51 ++++++++++++++++++++++----- src/algorithms/calorimetry/HEXPLIT.h | 8 ++--- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/algorithms/calorimetry/HEXPLIT.cc b/src/algorithms/calorimetry/HEXPLIT.cc index d9db38586f..6f2a4d3152 100644 --- a/src/algorithms/calorimetry/HEXPLIT.cc +++ b/src/algorithms/calorimetry/HEXPLIT.cc @@ -22,20 +22,55 @@ namespace eicrecon { -const double HEXPLIT::neighbor_offsets_x[NEIGHBORS]={1.5*cos(0), 1.5*cos(M_PI/3), 1.5*cos(2*M_PI/3),1.5*cos(3*M_PI/3), 1.5*cos(4*M_PI/3), 1.5*cos(5*M_PI/3), - -sqrt(3)/2.*sin(0),-sqrt(3)/2.*sin(M_PI/3),-sqrt(3)/2.*sin(2*M_PI/3),-sqrt(3)/2.*sin(3*M_PI/3),-sqrt(3)/2.*sin(4*M_PI/3),-sqrt(3)/2.*sin(5*M_PI/3)}; -const double HEXPLIT::neighbor_offsets_y[NEIGHBORS]={1.5*sin(0), 1.5*sin(M_PI/3), 1.5*sin(2*M_PI/3),1.5*sin(3*M_PI/3), 1.5*sin(4*M_PI/3), 1.5*sin(5*M_PI/3), - sqrt(3)/2.*cos(0), sqrt(3)/2.*cos(M_PI/3), sqrt(3)/2.*cos(2*M_PI/3), sqrt(3)/2.*cos(3*M_PI/3), sqrt(3)/2.*cos(4*M_PI/3), sqrt(3)/2.*cos(5*M_PI/3)}; +//positions where the overlapping cells are relative to a given cell (in units of hexagon side length) +const std::vector HEXPLIT::neighbor_offsets_x =[]() { + std::vector x; + double rs[2] ={1.5, sqrt(3)/2.}; + double offsets[2]={0, M_PI/2}; + for (int i = 0; i<2; i++){ + for (int j = 0; j < 6; j += 1) + x.push_back(rs[i]*cos(j*M_PI/3+offsets[i])); + } + return x; +}(); + +const std::vector HEXPLIT::neighbor_offsets_y =[]() { + std::vector y; + double rs[2] ={1.5, sqrt(3)/2.}; + double offsets[2]={0, M_PI/2}; + for (int i = 0; i<2; i++){ + for (int j = 0; j < 6; j += 1) + y.push_back(rs[i]*sin(j*M_PI/3+offsets[i])); + } + return y; +}(); //indices of the neighboring cells which overlap to produce a given subcell const int HEXPLIT::neighbor_indices[SUBCELLS][OVERLAP]={{0, 11,10}, {1, 6, 11},{2, 7, 6}, {3,8,7}, {4,9,8}, {5,10,9}, {6, 11, 7}, {7, 6, 8}, {8, 7, 9}, {9,8,10},{10,9,11},{11,10,6}}; //positions of the centers of subcells -const double HEXPLIT::subcell_offsets_x[SUBCELLS]={0.75*cos(0), 0.75*cos(M_PI/3), 0.75*cos(2*M_PI/3), 0.75*cos(3*M_PI/3), 0.75*cos(4*M_PI/3), 0.75*cos(5*M_PI/3), - -sqrt(3)/4*sin(0),-sqrt(3)/4*sin(M_PI/3),-sqrt(3)/4*sin(2*M_PI/3),-sqrt(3)/4*sin(3*M_PI/3),-sqrt(3)/4*sin(4*M_PI/3),-sqrt(3)/4*sin(5*M_PI/3)}; -const double HEXPLIT::subcell_offsets_y[SUBCELLS]={0.75*sin(0), 0.75*sin(M_PI/3), 0.75*sin(2*M_PI/3), 0.75*sin(3*M_PI/3), 0.75*sin(4*M_PI/3), 0.75*sin(5*M_PI/3), - sqrt(3)/4*cos(0), sqrt(3)/4*cos(M_PI/3), sqrt(3)/4*cos(2*M_PI/3), sqrt(3)/4*cos(3*M_PI/3), sqrt(3)/4*cos(4*M_PI/3), sqrt(3)/4*cos(5*M_PI/3)}; +const std::vector HEXPLIT::subcell_offsets_x =[]() { + std::vector x; + double rs[2] ={0.75, sqrt(3)/4.}; + double offsets[2]={0, M_PI/2}; + for (int i = 0; i<2; i++){ + for (int j = 0; j < 6; j += 1) + x.push_back(rs[i]*cos(j*M_PI/3+offsets[i])); + } + return x; +}(); + +const std::vector HEXPLIT::subcell_offsets_y =[]() { + std::vector y; + double rs[2] ={0.75, sqrt(3)/4.}; + double offsets[2]={0, M_PI/2}; + for (int i = 0; i<2; i++){ + for (int j = 0; j < 6; j += 1) + y.push_back(rs[i]*sin(j*M_PI/3+offsets[i])); + } + return y; +}(); void HEXPLIT::init(const dd4hep::Detector* detector, std::shared_ptr& logger) { m_log = logger; diff --git a/src/algorithms/calorimetry/HEXPLIT.h b/src/algorithms/calorimetry/HEXPLIT.h index b6522b4a38..f080bb166b 100644 --- a/src/algorithms/calorimetry/HEXPLIT.h +++ b/src/algorithms/calorimetry/HEXPLIT.h @@ -52,13 +52,13 @@ using HEXPLITAlgorithm = algorithms::Algorithm< // number of neighboring cells that overlap to obtain a subcell static const int OVERLAP=3; //positions where the overlapping cells are relative to a given cell (in units of hexagon side length) - static const double neighbor_offsets_x[NEIGHBORS]; - static const double neighbor_offsets_y[NEIGHBORS]; + static const std::vector neighbor_offsets_x; + static const std::vector neighbor_offsets_y; //indices of the neighboring cells which overlap to produce a given subcell static const int neighbor_indices[SUBCELLS][OVERLAP]; //positions of the centers of subcells - static const double subcell_offsets_x[SUBCELLS]; - static const double subcell_offsets_y[SUBCELLS]; + static const std::vector subcell_offsets_x; + static const std::vector subcell_offsets_y; private: const dd4hep::Detector* m_detector; From baebf9f755d6dff7b794520350605b73122ca5f2 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 23 Jan 2024 01:22:46 -0500 Subject: [PATCH 106/106] simplified the parameters list for CalorimeterClusterRecoCoG --- src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc | 7 +++++-- .../calorimetry/CalorimeterClusterRecoCoGConfig.h | 7 ++++--- src/detectors/ZDC/ZDC.cc | 4 +--- .../calorimetry/CalorimeterClusterRecoCoG_factory.h | 3 +-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc index c0da1319fa..de12e60095 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc @@ -194,9 +194,12 @@ std::optional CalorimeterClusterRecoCoG::reconstruct(const edm auto v = cl.getPosition(); double logWeightBase=m_cfg.logWeightBase; - if ((m_cfg.logWeightBase_lin != 0) || (m_cfg.logWeightBase_quad != 0)){ + if (m_cfg.logWeightBaseCoeffs.size() != 0){ double l=log(cl.getEnergy()/m_cfg.logWeightBase_Eref); - logWeightBase+=m_cfg.logWeightBase_lin*l+m_cfg.logWeightBase_quad*l*l; + logWeightBase=0; + for(std::size_t i =0; i +#include namespace eicrecon { @@ -15,10 +16,10 @@ namespace eicrecon { double logWeightBase = 3.6; //optional: have the log weight base depend on the energy - // logWeightBase+logWeightBase_lin*l+logWeightBase_quad*l*l + // logWeightBaseCoeffs[0]+logWeightBaseCoeffs[1]*l+logWeightBaseCoeffs[2]*l*l + ... // where l = log(cl.getEnergy()/logWeightBase_Eref) - double logWeightBase_lin=0; - double logWeightBase_quad=0; + // If this is empty, use the logWeightBase parameter for backwards compatibility. + std::vector logWeightBaseCoeffs{}; double logWeightBase_Eref=50; // Constrain the cluster position eta to be within diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index def7d26bed..90917a4203 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -187,9 +187,7 @@ extern "C" { { .energyWeight = "log", .sampFrac = 0.0203, - .logWeightBase=5.0, - .logWeightBase_lin=0.65, - .logWeightBase_quad=0.31, + .logWeightBaseCoeffs={5.0,0.65,0.31}, .logWeightBase_Eref=50*dd4hep::GeV, }, app // TODO: Remove me once fixed diff --git a/src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h b/src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h index 940a4e94f8..28995a3d55 100644 --- a/src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h +++ b/src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h @@ -27,8 +27,7 @@ class CalorimeterClusterRecoCoG_factory : public JOmniFactory m_energyWeight {this, "energyWeight", config().energyWeight}; ParameterRef m_samplingFraction {this, "samplingFraction", config().sampFrac}; ParameterRef m_logWeightBase {this, "logWeightBase", config().logWeightBase}; - ParameterRef m_logWeightBase_lin {this, "logWeightBase_lin", config().logWeightBase_lin}; - ParameterRef m_logWeightBase_quad {this, "logWeightBase_quad", config().logWeightBase_quad}; + ParameterRef> m_logWeightBaseCoeffs {this, "logWeightBaseCoeffs", config().logWeightBaseCoeffs}; ParameterRef m_logWeightBase_Eref {this, "logWeightBase_Eref", config().logWeightBase_Eref}; ParameterRef m_enableEtaBounds {this, "enableEtaBounds", config().enableEtaBounds};