From 20c9d8097a3e21f948adc62f103ee7eb9db29414 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 27 Jul 2023 16:18:09 -0500 Subject: [PATCH] feat: Calorimeter hit digi simplification (#794) ### Briefly, what does this PR introduce? This applies the #666 treatment to the CalorimeterHitDigi algorithms: - put all configuration in a single configuration struct for use with WithPodConfig mixin, - update the unit tests that are affected, - create a templated factory-factory to use in the plugins, - replace all old explicit RawCalorimeterHit factories with the new factory-factory. ### What kind of change does this PR introduce? - [ ] Bug fix (issue #__) - [x] New feature (issue #__) - [ ] Documentation update - [ ] Other: __ ### Please check if this PR fulfills the following: - [ ] Tests for the changes have been added - [ ] Documentation has been added / updated - [x] Changes have been communicated to collaborators @veprbl @nathanwbrei ### Does this PR introduce breaking changes? What changes might users need to make to their code? No. ### Does this PR change default behavior? No. --------- Co-authored-by: Dmitry Kalinkin --- .../calorimetry/CalorimeterClusterRecoCoG.h | 3 - .../calorimetry/CalorimeterHitDigi.cc | 121 +++++++----------- .../calorimetry/CalorimeterHitDigi.h | 66 +++------- .../calorimetry/CalorimeterHitDigiConfig.h | 34 +++++ src/detectors/B0ECAL/B0ECAL.cc | 22 +++- .../RawCalorimeterHit_factory_B0ECalRawHits.h | 93 -------------- src/detectors/BEMC/BEMC.cc | 67 ++++++++-- ...eterHit_factory_EcalBarrelImagingRawHits.h | 88 ------------- ...rimeterHit_factory_EcalBarrelScFiRawHits.h | 89 ------------- ...terHit_factory_EcalBarrelSciGlassRawHits.h | 92 ------------- src/detectors/BHCAL/BHCAL.cc | 20 ++- ...CalorimeterHit_factory_HcalBarrelRawHits.h | 92 ------------- src/detectors/EEMC/EEMC.cc | 22 +++- ...alorimeterHit_factory_EcalEndcapNRawHits.h | 92 ------------- src/detectors/EHCAL/EHCAL.cc | 21 ++- ...alorimeterHit_factory_HcalEndcapNRawHits.h | 91 ------------- src/detectors/FEMC/FEMC.cc | 44 +++++-- ...eterHit_factory_EcalEndcapPInsertRawHits.h | 89 ------------- ...alorimeterHit_factory_EcalEndcapPRawHits.h | 94 -------------- src/detectors/FHCAL/FHCAL.cc | 67 +++++++--- ...eterHit_factory_HcalEndcapPInsertRawHits.h | 89 ------------- ...alorimeterHit_factory_HcalEndcapPRawHits.h | 91 ------------- .../RawCalorimeterHit_factory_LFHCALRawHits.h | 94 -------------- src/detectors/LUMISPECCAL/LUMISPECCAL.cc | 22 +++- ...lorimeterHit_factory_EcalLumiSpecRawHits.h | 92 ------------- ...RawCalorimeterHit_factory_ZDCEcalRawHits.h | 91 ------------- src/detectors/ZDC/ZDC.cc | 17 ++- .../calorimetry/CalorimeterHitDigi_factoryT.h | 86 +++++++++++++ src/tests/BEMC_test/BEMC_test.cc | 58 --------- src/tests/BEMC_test/CMakeLists.txt | 26 ---- src/tests/CMakeLists.txt | 1 - .../calorimetry_CalorimeterHitDigi.cc | 27 ++-- 32 files changed, 438 insertions(+), 1563 deletions(-) create mode 100644 src/algorithms/calorimetry/CalorimeterHitDigiConfig.h delete mode 100644 src/detectors/B0ECAL/RawCalorimeterHit_factory_B0ECalRawHits.h delete mode 100644 src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelImagingRawHits.h delete mode 100644 src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelScFiRawHits.h delete mode 100644 src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits.h delete mode 100644 src/detectors/BHCAL/RawCalorimeterHit_factory_HcalBarrelRawHits.h delete mode 100644 src/detectors/EEMC/RawCalorimeterHit_factory_EcalEndcapNRawHits.h delete mode 100644 src/detectors/EHCAL/RawCalorimeterHit_factory_HcalEndcapNRawHits.h delete mode 100644 src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPInsertRawHits.h delete mode 100644 src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPRawHits.h delete mode 100644 src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPInsertRawHits.h delete mode 100644 src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPRawHits.h delete mode 100644 src/detectors/FHCAL/RawCalorimeterHit_factory_LFHCALRawHits.h delete mode 100644 src/detectors/LUMISPECCAL/RawCalorimeterHit_factory_EcalLumiSpecRawHits.h delete mode 100644 src/detectors/ZDC/RawCalorimeterHit_factory_ZDCEcalRawHits.h create mode 100644 src/factories/calorimetry/CalorimeterHitDigi_factoryT.h delete mode 100644 src/tests/BEMC_test/BEMC_test.cc delete mode 100644 src/tests/BEMC_test/CMakeLists.txt diff --git a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.h b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.h index ce52e33cd3..c1fea697ff 100644 --- a/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.h +++ b/src/algorithms/calorimetry/CalorimeterClusterRecoCoG.h @@ -56,9 +56,6 @@ namespace eicrecon { const dd4hep::Detector* m_detector; std::shared_ptr m_log; - std::string m_input_simhit_tag; - std::string m_input_protoclust_tag; - std::function weightFunc; private: diff --git a/src/algorithms/calorimetry/CalorimeterHitDigi.cc b/src/algorithms/calorimetry/CalorimeterHitDigi.cc index d54eed5835..9096b58661 100644 --- a/src/algorithms/calorimetry/CalorimeterHitDigi.cc +++ b/src/algorithms/calorimetry/CalorimeterHitDigi.cc @@ -18,10 +18,8 @@ #include using namespace dd4hep; -// -// This algorithm converted from: -// -// https://eicweb.phy.anl.gov/EIC/juggler/-/blob/master/JugDigi/src/components/CalorimeterHitDigi.cpp +namespace eicrecon { + // // TODO: // - Array type configuration parameters are not yet supported in JANA (needs to be added) @@ -31,13 +29,9 @@ using namespace dd4hep; // values here. This needs to be confirmed. - -//------------------------ -// AlgorithmInit -//------------------------ -void CalorimeterHitDigi::AlgorithmInit(std::shared_ptr& logger) { - - // Assume all configuration parameter data members have been filled in already. +void CalorimeterHitDigi::init(const dd4hep::Detector* detector, std::shared_ptr& logger) { + m_detector = detector; + m_log = logger; // Gaudi implements a random number generator service. It is not clear to me how this // can work. There are multiple race conditions that occur in parallel event processing: @@ -54,68 +48,53 @@ void CalorimeterHitDigi::AlgorithmInit(std::shared_ptr& logger) // now, just use default values defined in header file. // set energy resolution numbers - m_log=logger; - - if (u_eRes.empty()) { - u_eRes.resize(3); - } else if (u_eRes.size() != 3) { - m_log->error("Invalid u_eRes.size()"); - throw std::runtime_error("Invalid u_eRes.size()"); + if (m_cfg.eRes.empty()) { + m_cfg.eRes.resize(3); + } else if (m_cfg.eRes.size() != 3) { + m_log->error("Invalid m_cfg.eRes.size()"); + throw std::runtime_error("Invalid m_cfg.eRes.size()"); } // using juggler internal units (GeV, mm, radian, ns) - tRes = m_tRes / dd4hep::ns; - stepTDC = dd4hep::ns / m_resolutionTDC; + tRes = m_cfg.tRes / dd4hep::ns; + stepTDC = dd4hep::ns / m_cfg.resolutionTDC; // all these are for signal sum at digitization level merge_hits = false; - if (!u_fields.empty()) { + if (!m_cfg.fields.empty()) { // sanity checks - if (!m_geoSvc) { - m_log->error("Unable to locate Geometry Service."); + if (!m_detector) { + m_log->error("Unable to locate geometry."); throw std::runtime_error("Unable to locate Geometry Service."); } - if (m_readout.empty()) { + if (m_cfg.readout.empty()) { m_log->error("readoutClass is not provided, it is needed to know the fields in readout ids."); throw std::runtime_error("readoutClass is not provided."); } // get decoders try { - auto id_desc = m_geoSvc->detector()->readout(m_readout).idSpec(); + auto id_desc = m_detector->readout(m_cfg.readout).idSpec(); id_mask = 0; - for (size_t i = 0; i < u_fields.size(); ++i) { - id_mask |= id_desc.field(u_fields[i])->mask(); + for (size_t i = 0; i < m_cfg.fields.size(); ++i) { + id_mask |= id_desc.field(m_cfg.fields[i])->mask(); } } catch (...) { // a workaround to avoid breaking the whole analysis if a field is not in some configurations // TODO: it should be a fatal error to not cause unexpected analysis results - m_log->warn("Failed to load ID decoder for {}, hits will not be merged.", m_readout); - // throw::runtime_error(fmt::format("Failed to load ID decoder for {}", m_readout)); + m_log->warn("Failed to load ID decoder for {}, hits will not be merged.", m_cfg.readout); + // throw::runtime_error(fmt::format("Failed to load ID decoder for {}", m_cfg.readout)); return; } id_mask = ~id_mask; - m_log->info("ID mask in {:s}: {:#064b}", m_readout, id_mask); + m_log->info("ID mask in {:s}: {:#064b}", m_cfg.readout, id_mask); // all checks passed merge_hits = true; } } - -//------------------------ -// AlgorithmChangeRun -//------------------------ -void CalorimeterHitDigi::AlgorithmChangeRun() { - /// This is automatically run before Process, when a new run number is seen - /// Usually we update our calibration constants by asking a JService - /// to give us the latest data for this run number -} - -//------------------------ -// AlgorithmProcess -//------------------------ -std::unique_ptr CalorimeterHitDigi::AlgorithmProcess(const edm4hep::SimCalorimeterHitCollection &simhits) { +std::unique_ptr CalorimeterHitDigi::process(const edm4hep::SimCalorimeterHitCollection &simhits) { if (merge_hits) { return std::move(signal_sum_digi(simhits)); } else { @@ -132,20 +111,16 @@ std::unique_ptr CalorimeterHitDigi::single const double eDep = ahit.getEnergy(); // apply additional calorimeter noise to corrected energy deposit - const double eResRel = (eDep > m_threshold) + const double eResRel = (eDep > m_cfg.threshold) ? m_normDist(generator) * std::sqrt( - std::pow(u_eRes[0] / std::sqrt(eDep), 2) + - std::pow(u_eRes[1], 2) + - std::pow(u_eRes[2] / (eDep), 2) - ) + std::pow(m_cfg.eRes[0] / std::sqrt(eDep), 2) + + std::pow(m_cfg.eRes[1], 2) + + std::pow(m_cfg.eRes[2] / (eDep), 2) + ) : 0; -// const double eResRel = (eDep > 1e-6) -// ? m_normDist(generator) * std::sqrt(std::pow(u_eRes[0] / std::sqrt(eDep), 2) + -// std::pow(u_eRes[1], 2) + std::pow(u_eRes[2] / (eDep), 2)) -// : 0; - const double ped = m_pedMeanADC + m_normDist(generator) * m_pedSigmaADC; - const long long adc = std::llround(ped + eDep * (m_corrMeanScale + eResRel) / m_dyRangeADC * m_capADC); + const double ped = m_cfg.pedMeanADC + m_normDist(generator) * m_cfg.pedSigmaADC; + const long long adc = std::llround(ped + eDep * (m_cfg.corrMeanScale + eResRel) / m_cfg.dyRangeADC * m_cfg.capADC); double time = std::numeric_limits::max(); for (const auto& c : ahit.getContributions()) { @@ -153,14 +128,14 @@ std::unique_ptr CalorimeterHitDigi::single time = c.getTime(); } } - if (time > m_capTime) continue; + if (time > m_cfg.capTime) continue; const long long tdc = std::llround((time + m_normDist(generator) * tRes) * stepTDC); - if (eDep> 1.e-3) m_log->trace("E sim {} \t adc: {} \t time: {}\t maxtime: {} \t tdc: {} \t cell ID {}", eDep, adc, time, m_capTime, tdc, ahit.getCellID()); + if (eDep> 1.e-3) m_log->trace("E sim {} \t adc: {} \t time: {}\t maxtime: {} \t tdc: {} \t cell ID {}", eDep, adc, time, m_cfg.capTime, tdc, ahit.getCellID()); rawhits->create( ahit.getCellID(), - (adc > m_capADC ? m_capADC : adc), + (adc > m_cfg.capADC ? m_cfg.capADC : adc), tdc ); } @@ -177,8 +152,8 @@ std::unique_ptr CalorimeterHitDigi::signal for (const auto &ahit : simhits) { uint64_t hid = ahit.getCellID() & id_mask; - m_log->trace("org cell ID in {:s}: {:#064b}", m_readout, ahit.getCellID()); - m_log->trace("new cell ID in {:s}: {:#064b}", m_readout, hid); + m_log->trace("org cell ID in {:s}: {:#064b}", m_cfg.readout, ahit.getCellID()); + m_log->trace("new cell ID in {:s}: {:#064b}", m_cfg.readout, hid); merge_map[hid].push_back(ix); @@ -202,7 +177,7 @@ std::unique_ptr CalorimeterHitDigi::signal timeC = c.getTime(); } } - if (timeC > m_capTime) continue; + if (timeC > m_cfg.capTime) continue; edep += hit.getEnergy(); m_log->trace("adding {} \t total: {}", hit.getEnergy(), edep); @@ -221,29 +196,25 @@ std::unique_ptr CalorimeterHitDigi::signal } } -// double eResRel = 0.; // safety check - const double eResRel = (edep > m_threshold) - ? m_normDist(generator) * u_eRes[0] / std::sqrt(edep) + - m_normDist(generator) * u_eRes[1] + - m_normDist(generator) * u_eRes[2] / edep + const double eResRel = (edep > m_cfg.threshold) + ? m_normDist(generator) * m_cfg.eRes[0] / std::sqrt(edep) + + m_normDist(generator) * m_cfg.eRes[1] + + m_normDist(generator) * m_cfg.eRes[2] / edep : 0; -// if (edep > 1e-6) { -// eResRel = m_normDist(generator) * u_eRes[0] / std::sqrt(edep) + -// m_normDist(generator) * u_eRes[1] + -// m_normDist(generator) * u_eRes[2] / edep; -// } - double ped = m_pedMeanADC + m_normDist(generator) * m_pedSigmaADC; - unsigned long long adc = std::llround(ped + edep * (m_corrMeanScale + eResRel) / m_dyRangeADC * m_capADC); + double ped = m_cfg.pedMeanADC + m_normDist(generator) * m_cfg.pedSigmaADC; + unsigned long long adc = std::llround(ped + edep * (m_cfg.corrMeanScale + eResRel) / m_cfg.dyRangeADC * m_cfg.capADC); unsigned long long tdc = std::llround((time + m_normDist(generator) * tRes) * stepTDC); - if (edep> 1.e-3) m_log->trace("E sim {} \t adc: {} \t time: {}\t maxtime: {} \t tdc: {}", edep, adc, time, m_capTime, tdc); + if (edep> 1.e-3) m_log->trace("E sim {} \t adc: {} \t time: {}\t maxtime: {} \t tdc: {}", edep, adc, time, m_cfg.capTime, tdc); rawhits->create( mid, - (adc > m_capADC ? m_capADC : adc), + (adc > m_cfg.capADC ? m_cfg.capADC : adc), tdc ); } return std::move(rawhits); } + +} // namespace eicrecon diff --git a/src/algorithms/calorimetry/CalorimeterHitDigi.h b/src/algorithms/calorimetry/CalorimeterHitDigi.h index 1a959b4f7c..67307c7eb6 100644 --- a/src/algorithms/calorimetry/CalorimeterHitDigi.h +++ b/src/algorithms/calorimetry/CalorimeterHitDigi.h @@ -16,72 +16,42 @@ #include #include -#include "services/geometry/dd4hep/JDD4hep_service.h" +#include #include #include #include -class CalorimeterHitDigi { +#include "algorithms/interfaces/WithPodConfig.h" +#include "CalorimeterHitDigiConfig.h" - // Insert any member variables here +namespace eicrecon { -public: - CalorimeterHitDigi() = default; - void AlgorithmInit(std::shared_ptr& logger); - void AlgorithmChangeRun() ; - std::unique_ptr AlgorithmProcess(const edm4hep::SimCalorimeterHitCollection &simhits) ; + class CalorimeterHitDigi : public WithPodConfig { - //-------- Configuration Parameters ------------ - //instantiate new spdlog logger - std::shared_ptr m_log; + public: + void init(const dd4hep::Detector* detector, std::shared_ptr& logger); + std::unique_ptr process(const edm4hep::SimCalorimeterHitCollection &simhits) ; - // Name of input data type (collection) - std::string m_input_tag; - - // additional smearing resolutions - std::vector u_eRes; - double m_tRes; - - // single hit energy deposition threshold - double m_threshold=1.0*dd4hep::keV; // {this, "threshold", 1. * keV}; - - // digitization settings - unsigned int m_capADC; - double m_capTime = 1000.; - double m_dyRangeADC; - unsigned int m_pedMeanADC; - double m_pedSigmaADC; - double m_resolutionTDC; - double m_corrMeanScale; - - // signal sums - std::vector u_fields; - std::string m_geoSvcName; - std::string m_readout; - - // This may be used to declare the data members as JANA configuration parameters. - // This should compile OK even without JANA so long as you don't try using it. - // To use it, do something like the following: - // - // mycalohitdigi->SetJANAConfigParameters( japp, "BEMC"); - // - // The above will register config. parameters like: "BEMC:tag". - // The configuration parameter members of this class should be set to their - // defaults *before* calling this. - //----------------------------------------------- + private: // unitless counterparts of inputs double dyRangeADC{0}, stepTDC{0}, tRes{0}; // variables for merging at digitization step bool merge_hits = false; - std::shared_ptr m_geoSvc; + uint64_t id_mask{0}; -private: + private: + const dd4hep::Detector* m_detector; + std::shared_ptr m_log; + std::default_random_engine generator; // TODO: need something more appropriate here std::normal_distribution m_normDist; // defaults to mean=0, sigma=1 std::unique_ptr single_hits_digi(const edm4hep::SimCalorimeterHitCollection &simhits); std::unique_ptr signal_sum_digi(const edm4hep::SimCalorimeterHitCollection &simhits); -}; + + }; + +} // namespace eicrecon diff --git a/src/algorithms/calorimetry/CalorimeterHitDigiConfig.h b/src/algorithms/calorimetry/CalorimeterHitDigiConfig.h new file mode 100644 index 0000000000..6d6702f011 --- /dev/null +++ b/src/algorithms/calorimetry/CalorimeterHitDigiConfig.h @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2023 Wouter Deconinck + +#pragma once + +#include +#include + +namespace eicrecon { + + struct CalorimeterHitDigiConfig { + + std::vector eRes; + double tRes; + + // single hit energy deposition threshold + double threshold{1.0*dd4hep::keV}; + + // digitization settings + unsigned int capADC{1}; + double capTime{1000}; // dynamic range in ns + double dyRangeADC{1}; + unsigned int pedMeanADC{0}; + double pedSigmaADC{0}; + double resolutionTDC{1}; + double corrMeanScale{1}; + + // signal sums + std::string readout{""}; + std::vector fields{}; + + }; + +} // eicrecon diff --git a/src/detectors/B0ECAL/B0ECAL.cc b/src/detectors/B0ECAL/B0ECAL.cc index 0672262264..df1d0df824 100644 --- a/src/detectors/B0ECAL/B0ECAL.cc +++ b/src/detectors/B0ECAL/B0ECAL.cc @@ -7,16 +7,17 @@ #include "extensions/jana/JChainMultifactoryGeneratorT.h" #include "factories/calorimetry/CalorimeterClusterRecoCoG_factoryT.h" +#include "factories/calorimetry/CalorimeterHitDigi_factoryT.h" -#include "RawCalorimeterHit_factory_B0ECalRawHits.h" #include "CalorimeterHit_factory_B0ECalRecHits.h" #include "ProtoCluster_factory_B0ECalTruthProtoClusters.h" #include "ProtoCluster_factory_B0ECalIslandProtoClusters.h" namespace eicrecon { - using Cluster_factory_B0ECalTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_B0ECalClusters = CalorimeterClusterRecoCoG_factoryT<>; + using RawCalorimeterHit_factory_B0ECalRawHits = CalorimeterHitDigi_factoryT<>; + using Cluster_factory_B0ECalTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_B0ECalClusters = CalorimeterClusterRecoCoG_factoryT<>; } @@ -27,8 +28,19 @@ extern "C" { InitJANAPlugin(app); - app->Add(new JChainFactoryGeneratorT( - {"B0ECalHits"}, "B0ECalRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "B0ECalRawHits", {"B0ECalHits"}, {"B0ECalRawHits"}, + { + .eRes = {0.0 * sqrt(dd4hep::GeV), 0.02, 0.0 * dd4hep::GeV}, + .tRes = 0.0 * dd4hep::ns, + .capADC = 16384, + .dyRangeADC = 20 * dd4hep::GeV, + .pedMeanADC = 100, + .pedSigmaADC = 1, + .resolutionTDC = 1e-11, + .corrMeanScale = 1.0, + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"B0ECalRawHits"}, "B0ECalRecHits" diff --git a/src/detectors/B0ECAL/RawCalorimeterHit_factory_B0ECalRawHits.h b/src/detectors/B0ECAL/RawCalorimeterHit_factory_B0ECalRawHits.h deleted file mode 100644 index af477a47cc..0000000000 --- a/src/detectors/B0ECAL/RawCalorimeterHit_factory_B0ECalRawHits.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#pragma once - -#include - -#include -#include -#include -#include -#include - -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_B0ECalRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_B0ECalRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {0.0 * sqrt(dd4hep::GeV), 0.02, 0.0 * dd4hep::GeV}; - m_tRes = 0.0 * dd4hep::ns; - m_capADC = 16384; - m_dyRangeADC = 20 * dd4hep::GeV; - m_pedMeanADC = 100; - m_pedSigmaADC = 1; - m_resolutionTDC = 1e-11; - m_corrMeanScale = 1.0; - u_fields={}; - m_geoSvcName = ""; - m_readout = ""; - - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("B0ECAL:B0ECalRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("B0ECAL:B0ECalRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("B0ECAL:B0ECalRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("B0ECAL:B0ECalRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("B0ECAL:B0ECalRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("B0ECAL:B0ECalRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("B0ECAL:B0ECalRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("B0ECAL:B0ECalRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("B0ECAL:B0ECalRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("B0ECAL:B0ECalRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("B0ECAL:B0ECalRawHits:readoutClass", m_readout); - - // Call Init for generic algorithm - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; diff --git a/src/detectors/BEMC/BEMC.cc b/src/detectors/BEMC/BEMC.cc index e05f3d9625..3fdaa5ecf1 100644 --- a/src/detectors/BEMC/BEMC.cc +++ b/src/detectors/BEMC/BEMC.cc @@ -7,19 +7,17 @@ #include "extensions/jana/JChainMultifactoryGeneratorT.h" #include "factories/calorimetry/CalorimeterClusterRecoCoG_factoryT.h" +#include "factories/calorimetry/CalorimeterHitDigi_factoryT.h" -#include "RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits.h" #include "CalorimeterHit_factory_EcalBarrelSciGlassRecHits.h" #include "ProtoCluster_factory_EcalBarrelSciGlassTruthProtoClusters.h" #include "ProtoCluster_factory_EcalBarrelSciGlassProtoClusters.h" #include "Cluster_factory_EcalBarrelSciGlassMergedTruthClusters.h" -#include "RawCalorimeterHit_factory_EcalBarrelScFiRawHits.h" #include "CalorimeterHit_factory_EcalBarrelScFiRecHits.h" #include "CalorimeterHit_factory_EcalBarrelScFiMergedHits.h" #include "ProtoCluster_factory_EcalBarrelScFiProtoClusters.h" -#include "RawCalorimeterHit_factory_EcalBarrelImagingRawHits.h" #include "CalorimeterHit_factory_EcalBarrelImagingRecHits.h" #include "ProtoCluster_factory_EcalBarrelImagingProtoClusters.h" #include "Cluster_factory_EcalBarrelImagingClusters.h" @@ -27,9 +25,12 @@ namespace eicrecon { - using Cluster_factory_EcalBarrelSciGlassTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_EcalBarrelSciGlassClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_EcalBarrelScFiClusters = CalorimeterClusterRecoCoG_factoryT<>; + using RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits = CalorimeterHitDigi_factoryT<>; + using RawCalorimeterHit_factory_EcalBarrelScFiRawHits = CalorimeterHitDigi_factoryT<>; + using RawCalorimeterHit_factory_EcalBarrelImagingRawHits = CalorimeterHitDigi_factoryT<>; + using Cluster_factory_EcalBarrelSciGlassTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_EcalBarrelSciGlassClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_EcalBarrelScFiClusters = CalorimeterClusterRecoCoG_factoryT<>; } extern "C" { @@ -39,8 +40,22 @@ extern "C" { InitJANAPlugin(app); - app->Add(new JChainFactoryGeneratorT( - {"EcalBarrelSciGlassHits"}, "EcalBarrelSciGlassRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "EcalBarrelSciGlassRawHits", + {"EcalBarrelSciGlassHits"}, + {"EcalBarrelSciGlassRawHits"}, + { + .eRes = {0.0 * sqrt(dd4hep::GeV), 0.0, 0.0 * dd4hep::GeV}, + .tRes = 0.0 * dd4hep::ns, + .capADC = 16384, + .dyRangeADC = 20 * dd4hep::GeV, + .pedMeanADC = 100, + .pedSigmaADC = 1, + .resolutionTDC = 10 * dd4hep::picosecond, + .corrMeanScale = 1.0, + .fields = {}, + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"EcalBarrelSciGlassRawHits"}, "EcalBarrelSciGlassRecHits" @@ -68,8 +83,23 @@ extern "C" { ); - app->Add(new JChainFactoryGeneratorT( - {"EcalBarrelScFiHits"}, "EcalBarrelScFiRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "EcalBarrelScFiRawHits", + {"EcalBarrelScFiHits"}, + {"EcalBarrelScFiRawHits"}, + { + .eRes = {0.0 * sqrt(dd4hep::GeV), 0.0, 0.0 * dd4hep::GeV}, + .tRes = 0.0 * dd4hep::ns, + .capADC = 16384, + .dyRangeADC = 750 * dd4hep::MeV, + .pedMeanADC = 20, + .pedSigmaADC = 0.3, + .resolutionTDC = 10 * dd4hep::picosecond, + .corrMeanScale = 1.0, + .readout = "EcalBarrelScFiHits", + .fields = {"fiber", "z"}, + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"EcalBarrelScFiRawHits"}, "EcalBarrelScFiRecHits" @@ -96,8 +126,21 @@ extern "C" { ) ); - app->Add(new JChainFactoryGeneratorT( - {"EcalBarrelImagingHits"}, "EcalBarrelImagingRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "EcalBarrelImagingRawHits", + {"EcalBarrelImagingHits"}, + {"EcalBarrelImagingRawHits"}, + { + .eRes = {0.0 * sqrt(dd4hep::GeV), 0.02, 0.0 * dd4hep::GeV}, + .tRes = 0.0 * dd4hep::ns, + .capADC = 8192, + .dyRangeADC = 3 * dd4hep::MeV, + .pedMeanADC = 100, + .pedSigmaADC = 14, + .resolutionTDC = 10 * dd4hep::picosecond, + .corrMeanScale = 1.0, + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"EcalBarrelImagingRawHits"}, "EcalBarrelImagingRecHits" diff --git a/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelImagingRawHits.h b/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelImagingRawHits.h deleted file mode 100644 index a3dbdbe622..0000000000 --- a/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelImagingRawHits.h +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#pragma once - -#include - -#include -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include -#include -#include -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_EcalBarrelImagingRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_EcalBarrelImagingRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {0.0 * sqrt(dd4hep::GeV), 0.02, 0.0 * dd4hep::GeV}; - m_tRes = 0.0 * dd4hep::ns; - m_capADC = 8192; - m_dyRangeADC = 3 * dd4hep::MeV; - m_pedMeanADC = 100; - m_pedSigmaADC = 14; - m_resolutionTDC = 10 * dd4hep::picosecond; - m_corrMeanScale = 1.0; - m_geoSvcName = "ActsGeometryProvider"; - m_readout = ""; - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("BEMC:EcalBarrelImagingRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("BEMC:EcalBarrelImagingRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("BEMC:EcalBarrelImagingRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("BEMC:EcalBarrelImagingRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("BEMC:EcalBarrelImagingRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("BEMC:EcalBarrelImagingRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("BEMC:EcalBarrelImagingRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("BEMC:EcalBarrelImagingRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("BEMC:EcalBarrelImagingRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("BEMC:EcalBarrelImagingRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("BEMC:EcalBarrelImagingRawHits:readoutClass", m_readout); - - // Call Init for generic algorithm - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; diff --git a/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelScFiRawHits.h b/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelScFiRawHits.h deleted file mode 100644 index cfe3284c47..0000000000 --- a/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelScFiRawHits.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#pragma once - -#include - -#include -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include -#include -#include -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_EcalBarrelScFiRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_EcalBarrelScFiRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {0.0 * sqrt(dd4hep::GeV), 0.0, 0.0 * dd4hep::GeV}; - m_tRes = 0.0 * dd4hep::ns; - m_capADC = 16384; - m_dyRangeADC = 750 * dd4hep::MeV; - m_pedMeanADC = 20; - m_pedSigmaADC = 0.3; - m_resolutionTDC = 10 * dd4hep::picosecond; - m_corrMeanScale = 1.0; - m_geoSvcName = "ActsGeometryProvider"; - m_readout="EcalBarrelScFiHits"; - u_fields = {"fiber", "z"}; - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("BEMC:EcalBarrelScFiRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("BEMC:EcalBarrelScFiRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("BEMC:EcalBarrelScFiRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("BEMC:EcalBarrelScFiRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("BEMC:EcalBarrelScFiRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("BEMC:EcalBarrelScFiRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("BEMC:EcalBarrelScFiRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("BEMC:EcalBarrelScFiRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("BEMC:EcalBarrelScFiRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("BEMC:EcalBarrelScFiRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("BEMC:EcalBarrelScFiRawHits:readoutClass", m_readout); - - // Call Init for generic algorithm - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; diff --git a/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits.h b/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits.h deleted file mode 100644 index 65490c8a67..0000000000 --- a/src/detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#pragma once - -#include - -#include -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include -#include -#include -#include -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {0.0 * sqrt(dd4hep::GeV), 0.0, 0.0 * dd4hep::GeV}; - m_tRes = 0.0 * dd4hep::ns; - m_capADC = 16384; - m_dyRangeADC = 20 * dd4hep::GeV; - m_pedMeanADC = 100; - m_pedSigmaADC = 1; - m_resolutionTDC = 10 * dd4hep::picosecond; - m_corrMeanScale = 1.0; - u_fields={}; - m_geoSvcName = "ActsGeometryProvider"; - m_readout = ""; - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("BEMC:EcalBarrelSciGlassRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("BEMC:EcalBarrelSciGlassRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("BEMC:EcalBarrelSciGlassRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("BEMC:EcalBarrelSciGlassRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("BEMC:EcalBarrelSciGlassRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("BEMC:EcalBarrelSciGlassRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("BEMC:EcalBarrelSciGlassRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("BEMC:EcalBarrelSciGlassRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("BEMC:EcalBarrelSciGlassRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("BEMC:EcalBarrelSciGlassRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("BEMC:EcalBarrelSciGlassRawHits:readoutClass", m_readout); - - // Call Init for generic algorithm - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index 777d021c72..ff2c70976d 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -7,14 +7,15 @@ #include "extensions/jana/JChainMultifactoryGeneratorT.h" #include "factories/calorimetry/CalorimeterClusterRecoCoG_factoryT.h" +#include "factories/calorimetry/CalorimeterHitDigi_factoryT.h" -#include "RawCalorimeterHit_factory_HcalBarrelRawHits.h" #include "CalorimeterHit_factory_HcalBarrelRecHits.h" #include "ProtoCluster_factory_HcalBarrelTruthProtoClusters.h" #include "ProtoCluster_factory_HcalBarrelIslandProtoClusters.h" namespace eicrecon { + using RawCalorimeterHit_factory_HcalBarrelRawHits = CalorimeterHitDigi_factoryT<>; using Cluster_factory_HcalBarrelTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; using Cluster_factory_HcalBarrelClusters = CalorimeterClusterRecoCoG_factoryT<>; } @@ -26,8 +27,21 @@ extern "C" { InitJANAPlugin(app); - app->Add(new JChainFactoryGeneratorT( - {"HcalBarrelHits"}, "HcalBarrelRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "HcalBarrelRawHits", {"HcalBarrelHits"}, {"HcalBarrelRawHits"}, + { + .eRes = {}, + .tRes = 0.0 * dd4hep::ns, + .capADC = 65536, + .capTime = 100, // given in ns, 4 samples in HGCROC + .dyRangeADC = 1.0 * dd4hep::GeV, + .pedMeanADC = 10, + .pedSigmaADC = 2.0, + .resolutionTDC = 1.0 * dd4hep::picosecond, + .corrMeanScale = 1.0, + .readout = "HcalBarrelHits", + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"HcalBarrelRawHits"}, "HcalBarrelRecHits" diff --git a/src/detectors/BHCAL/RawCalorimeterHit_factory_HcalBarrelRawHits.h b/src/detectors/BHCAL/RawCalorimeterHit_factory_HcalBarrelRawHits.h deleted file mode 100644 index 501f9c598d..0000000000 --- a/src/detectors/BHCAL/RawCalorimeterHit_factory_HcalBarrelRawHits.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#pragma once - -#include - -#include -#include -#include -#include -#include - -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_HcalBarrelRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_HcalBarrelRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {}; - m_tRes = 0.0 * dd4hep::ns; - m_capADC = 65536; - m_dyRangeADC = 1.0 * dd4hep::GeV; - m_pedMeanADC = 10; - m_pedSigmaADC = 2.0; - m_capTime = 100 ; // given in ns, 4 samples in HGCROC - m_resolutionTDC = 1.0 * dd4hep::picosecond; - m_corrMeanScale = 1.0; - u_fields={}; - m_geoSvcName = "geoServiceName"; - m_readout = "HcalBarrelHits"; - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("BHCAL:HcalBarrelRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("BHCAL:HcalBarrelRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("BHCAL:HcalBarrelRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("BHCAL:HcalBarrelRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("BHCAL:HcalBarrelRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("BHCAL:HcalBarrelRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("BHCAL:HcalBarrelRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("BHCAL:HcalBarrelRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("BHCAL:HcalBarrelRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("BHCAL:HcalBarrelRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("BHCAL:HcalBarrelRawHits:readoutClass", m_readout); - - // Call Init for generic algorithm - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; diff --git a/src/detectors/EEMC/EEMC.cc b/src/detectors/EEMC/EEMC.cc index d459e18d90..c00e107667 100644 --- a/src/detectors/EEMC/EEMC.cc +++ b/src/detectors/EEMC/EEMC.cc @@ -7,15 +7,16 @@ #include "extensions/jana/JChainMultifactoryGeneratorT.h" #include "factories/calorimetry/CalorimeterClusterRecoCoG_factoryT.h" +#include "factories/calorimetry/CalorimeterHitDigi_factoryT.h" -#include "RawCalorimeterHit_factory_EcalEndcapNRawHits.h" #include "CalorimeterHit_factory_EcalEndcapNRecHits.h" #include "ProtoCluster_factory_EcalEndcapNTruthProtoClusters.h" #include "ProtoCluster_factory_EcalEndcapNIslandProtoClusters.h" namespace eicrecon { - using Cluster_factory_EcalEndcapNTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_EcalEndcapNClusters = CalorimeterClusterRecoCoG_factoryT<>; + using RawCalorimeterHit_factory_EcalEndcapNRawHits = CalorimeterHitDigi_factoryT<>; + using Cluster_factory_EcalEndcapNTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_EcalEndcapNClusters = CalorimeterClusterRecoCoG_factoryT<>; } extern "C" { @@ -25,8 +26,19 @@ extern "C" { InitJANAPlugin(app); - app->Add(new JChainFactoryGeneratorT( - {"EcalEndcapNHits"}, "EcalEndcapNRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "EcalEndcapNRawHits", {"EcalEndcapNHits"}, {"EcalEndcapNRawHits"}, + { + .eRes = {0.0 * sqrt(dd4hep::GeV), 0.02, 0.0 * dd4hep::GeV}, + .tRes = 0.0 * dd4hep::ns, + .capADC = 16384, + .dyRangeADC = 20 * dd4hep::GeV, + .pedMeanADC = 100, + .pedSigmaADC = 1, + .resolutionTDC = 10 * dd4hep::picosecond, + .corrMeanScale = 1.0, + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"EcalEndcapNRawHits"}, "EcalEndcapNRecHits" diff --git a/src/detectors/EEMC/RawCalorimeterHit_factory_EcalEndcapNRawHits.h b/src/detectors/EEMC/RawCalorimeterHit_factory_EcalEndcapNRawHits.h deleted file mode 100644 index 57a12aeebb..0000000000 --- a/src/detectors/EEMC/RawCalorimeterHit_factory_EcalEndcapNRawHits.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#pragma once - -#include - -#include -#include -#include -#include -#include - -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_EcalEndcapNRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_EcalEndcapNRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {0.0 * sqrt(dd4hep::GeV), 0.02, 0.0 * dd4hep::GeV}; // flat 2% - m_tRes = 0.0 * dd4hep::ns; - m_capADC = 16384; - m_dyRangeADC = 20 * dd4hep::GeV; - m_pedMeanADC = 100; - m_pedSigmaADC = 1; - m_resolutionTDC = 10 * dd4hep::picosecond; - m_corrMeanScale = 1.0; - u_fields={}; - m_geoSvcName = "ActsGeometryProvider"; - m_readout = ""; - - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("EEMC:EcalEndcapNRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("EEMC:EcalEndcapNRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("EEMC:EcalEndcapNRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("EEMC:EcalEndcapNRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("EEMC:EcalEndcapNRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("EEMC:EcalEndcapNRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("EEMC:EcalEndcapNRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("EEMC:EcalEndcapNRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("EEMC:EcalEndcapNRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("EEMC:EcalEndcapNRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("EEMC:EcalEndcapNRawHits:readoutClass", m_readout); - - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; diff --git a/src/detectors/EHCAL/EHCAL.cc b/src/detectors/EHCAL/EHCAL.cc index d069a3206d..24a8793d6a 100644 --- a/src/detectors/EHCAL/EHCAL.cc +++ b/src/detectors/EHCAL/EHCAL.cc @@ -7,8 +7,8 @@ #include "extensions/jana/JChainMultifactoryGeneratorT.h" #include "factories/calorimetry/CalorimeterClusterRecoCoG_factoryT.h" +#include "factories/calorimetry/CalorimeterHitDigi_factoryT.h" -#include "RawCalorimeterHit_factory_HcalEndcapNRawHits.h" #include "CalorimeterHit_factory_HcalEndcapNRecHits.h" #include "CalorimeterHit_factory_HcalEndcapNMergedHits.h" #include "ProtoCluster_factory_HcalEndcapNTruthProtoClusters.h" @@ -16,8 +16,9 @@ namespace eicrecon { - using Cluster_factory_HcalEndcapNTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_HcalEndcapNClusters = CalorimeterClusterRecoCoG_factoryT<>; + using RawCalorimeterHit_factory_HcalEndcapNRawHits = CalorimeterHitDigi_factoryT<>; + using Cluster_factory_HcalEndcapNTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_HcalEndcapNClusters = CalorimeterClusterRecoCoG_factoryT<>; } extern "C" { @@ -27,8 +28,18 @@ extern "C" { InitJANAPlugin(app); - app->Add(new JChainFactoryGeneratorT( - {"HcalEndcapNHits"}, "HcalEndcapNRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "HcalEndcapNRawHits", {"HcalEndcapNHits"}, {"HcalEndcapNRawHits"}, + { + .tRes = 0.0 * dd4hep::ns, + .capADC = 1024, + .dyRangeADC = 3.6 * dd4hep::MeV, + .pedMeanADC = 20, + .pedSigmaADC = 0.3, + .resolutionTDC = 10 * dd4hep::picosecond, + .corrMeanScale = 1.0, + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"HcalEndcapNRawHits"}, "HcalEndcapNRecHits" diff --git a/src/detectors/EHCAL/RawCalorimeterHit_factory_HcalEndcapNRawHits.h b/src/detectors/EHCAL/RawCalorimeterHit_factory_HcalEndcapNRawHits.h deleted file mode 100644 index 042ac4122b..0000000000 --- a/src/detectors/EHCAL/RawCalorimeterHit_factory_HcalEndcapNRawHits.h +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#pragma once - -#include - -#include -#include -#include -#include -#include - -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_HcalEndcapNRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_HcalEndcapNRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {}; - m_tRes = 0.0 * dd4hep::ns; - m_capADC = 1024; - m_dyRangeADC = 3.6 * dd4hep::MeV; - m_pedMeanADC = 20; - m_pedSigmaADC = 0.3; - m_resolutionTDC = 10 * dd4hep::picosecond; - m_corrMeanScale = 1.0; - u_fields={}; - m_geoSvcName = "ActsGeometryProvider"; - m_readout = ""; - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("EHCAL:HcalEndcapNRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("EHCAL:HcalEndcapNRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("EHCAL:HcalEndcapNRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("EHCAL:HcalEndcapNRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("EHCAL:HcalEndcapNRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("EHCAL:HcalEndcapNRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("EHCAL:HcalEndcapNRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("EHCAL:HcalEndcapNRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("EHCAL:HcalEndcapNRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("EHCAL:HcalEndcapNRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("EHCAL:HcalEndcapNRawHits:readoutClass", m_readout); - - // Call Init for generic algorithm - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; diff --git a/src/detectors/FEMC/FEMC.cc b/src/detectors/FEMC/FEMC.cc index 33c8dfd76e..1f8ee114d7 100644 --- a/src/detectors/FEMC/FEMC.cc +++ b/src/detectors/FEMC/FEMC.cc @@ -7,22 +7,23 @@ #include "extensions/jana/JChainMultifactoryGeneratorT.h" #include "factories/calorimetry/CalorimeterClusterRecoCoG_factoryT.h" +#include "factories/calorimetry/CalorimeterHitDigi_factoryT.h" -#include "RawCalorimeterHit_factory_EcalEndcapPRawHits.h" #include "CalorimeterHit_factory_EcalEndcapPRecHits.h" #include "ProtoCluster_factory_EcalEndcapPTruthProtoClusters.h" #include "ProtoCluster_factory_EcalEndcapPIslandProtoClusters.h" -#include "RawCalorimeterHit_factory_EcalEndcapPInsertRawHits.h" #include "CalorimeterHit_factory_EcalEndcapPInsertRecHits.h" #include "ProtoCluster_factory_EcalEndcapPInsertTruthProtoClusters.h" #include "ProtoCluster_factory_EcalEndcapPInsertIslandProtoClusters.h" namespace eicrecon { - using Cluster_factory_EcalEndcapPTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_EcalEndcapPClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_EcalEndcapPInsertTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_EcalEndcapPInsertClusters = CalorimeterClusterRecoCoG_factoryT<>; + using RawCalorimeterHit_factory_EcalEndcapPRawHits = CalorimeterHitDigi_factoryT<>; + using RawCalorimeterHit_factory_EcalEndcapPInsertRawHits = CalorimeterHitDigi_factoryT<>; + using Cluster_factory_EcalEndcapPTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_EcalEndcapPClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_EcalEndcapPInsertTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_EcalEndcapPInsertClusters = CalorimeterClusterRecoCoG_factoryT<>; } extern "C" { @@ -32,8 +33,20 @@ extern "C" { InitJANAPlugin(app); - app->Add(new JChainFactoryGeneratorT( - {"EcalEndcapPHits"}, "EcalEndcapPRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "EcalEndcapPRawHits", {"EcalEndcapPHits"}, {"EcalEndcapPRawHits"}, + { + .eRes = {0.00340 * sqrt(dd4hep::GeV), 0.0009, 0.0 * dd4hep::GeV}, // (0.340% / sqrt(E)) \oplus 0.09% + .tRes = 0.0, + .capADC = 65536, //2^16 (approximate HGCROC resolution) old 16384 + .capTime = 100, // given in ns, 4 samples in HGCROC + .dyRangeADC = 3 * dd4hep::GeV, + .pedMeanADC = 100, + .pedSigmaADC = 0.7, + .resolutionTDC = 10 * dd4hep::picosecond, + .corrMeanScale = 0.03, + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"EcalEndcapPRawHits"}, "EcalEndcapPRecHits" @@ -83,8 +96,19 @@ extern "C" { ) ); - app->Add(new JChainFactoryGeneratorT( - {"EcalEndcapPInsertHits"}, "EcalEndcapPInsertRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "EcalEndcapPInsertRawHits", {"EcalEndcapPInsertHits"}, {"EcalEndcapPInsertRawHits"}, + { + .eRes = {0.00340 * sqrt(dd4hep::GeV), 0.0009, 0.0 * dd4hep::GeV}, // (0.340% / sqrt(E)) \oplus 0.09% + .tRes = 0.0 * dd4hep::ns, + .capADC = 16384, + .dyRangeADC = 3 * dd4hep::GeV, + .pedMeanADC = 100, + .pedSigmaADC = 0.7, + .resolutionTDC = 10 * dd4hep::picosecond, + .corrMeanScale = 0.03, + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"EcalEndcapPInsertRawHits"}, "EcalEndcapPInsertRecHits" diff --git a/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPInsertRawHits.h b/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPInsertRawHits.h deleted file mode 100644 index e56d9bec2c..0000000000 --- a/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPInsertRawHits.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#pragma once - -#include - -#include -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include -#include -#include -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_EcalEndcapPInsertRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_EcalEndcapPInsertRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {0.00340 * sqrt(dd4hep::GeV), 0.0009, 0.0 * dd4hep::GeV}; // (0.340% / sqrt(E)) \oplus 0.09% - m_tRes = 0.0 * dd4hep::ns; - m_capADC = 16384; - m_dyRangeADC = 3 * dd4hep::GeV; - m_pedMeanADC = 100; - m_pedSigmaADC = 0.7; - m_resolutionTDC = 10 * dd4hep::picosecond; - m_corrMeanScale = 0.03; - u_fields={}; - m_geoSvcName = "ActsGeometryProvider"; - m_readout = ""; - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("FEMC:EcalEndcapPInsertRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("FEMC:EcalEndcapPInsertRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("FEMC:EcalEndcapPInsertRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("FEMC:EcalEndcapPInsertRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("FEMC:EcalEndcapPInsertRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("FEMC:EcalEndcapPInsertRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("FEMC:EcalEndcapPInsertRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("FEMC:EcalEndcapPInsertRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("FEMC:EcalEndcapPInsertRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("FEMC:EcalEndcapPInsertRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("FEMC:EcalEndcapPInsertRawHits:readoutClass", m_readout); - - // Call Init for generic algorithm - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; diff --git a/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPRawHits.h b/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPRawHits.h deleted file mode 100644 index 83b17526fd..0000000000 --- a/src/detectors/FEMC/RawCalorimeterHit_factory_EcalEndcapPRawHits.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#pragma once - -#include - -#include -#include -#include -#include -#include - -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_EcalEndcapPRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_EcalEndcapPRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {0.00340 * sqrt(dd4hep::GeV), 0.0009, 0.0 * dd4hep::GeV}; // (0.340% / sqrt(E)) \oplus 0.09% - m_tRes = 0.0 ; - m_capTime = 100 ; // given in ns, 4 samples in HGCROC - m_capADC=65536;//2^16 (approximate HGCROC resolution) old 16384 - m_dyRangeADC = 3 * dd4hep::GeV; - m_pedMeanADC = 100; - m_pedSigmaADC = 0.7; - m_resolutionTDC = 10 * dd4hep::picosecond; - m_corrMeanScale = 0.03; - u_fields={}; - m_geoSvcName = "ActsGeometryProvider"; - m_readout = ""; - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("FEMC:EcalEndcapPRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("FEMC:EcalEndcapPRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("FEMC:EcalEndcapPRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("FEMC:EcalEndcapPRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("FEMC:EcalEndcapPRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("FEMC:EcalEndcapPRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("FEMC:EcalEndcapPRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("FEMC:EcalEndcapPRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("FEMC:EcalEndcapPRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("FEMC:EcalEndcapPRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("FEMC:EcalEndcapPRawHits:readoutClass", m_readout); - - // Call Init for generic algorithm - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; diff --git a/src/detectors/FHCAL/FHCAL.cc b/src/detectors/FHCAL/FHCAL.cc index 3fa6dffb6e..d381726c31 100644 --- a/src/detectors/FHCAL/FHCAL.cc +++ b/src/detectors/FHCAL/FHCAL.cc @@ -7,31 +7,32 @@ #include "extensions/jana/JChainMultifactoryGeneratorT.h" #include "factories/calorimetry/CalorimeterClusterRecoCoG_factoryT.h" +#include "factories/calorimetry/CalorimeterHitDigi_factoryT.h" -#include "RawCalorimeterHit_factory_HcalEndcapPRawHits.h" #include "CalorimeterHit_factory_HcalEndcapPRecHits.h" #include "CalorimeterHit_factory_HcalEndcapPMergedHits.h" #include "ProtoCluster_factory_HcalEndcapPTruthProtoClusters.h" #include "ProtoCluster_factory_HcalEndcapPIslandProtoClusters.h" -#include "RawCalorimeterHit_factory_HcalEndcapPInsertRawHits.h" #include "CalorimeterHit_factory_HcalEndcapPInsertRecHits.h" #include "CalorimeterHit_factory_HcalEndcapPInsertMergedHits.h" #include "ProtoCluster_factory_HcalEndcapPInsertTruthProtoClusters.h" #include "ProtoCluster_factory_HcalEndcapPInsertIslandProtoClusters.h" -#include "RawCalorimeterHit_factory_LFHCALRawHits.h" #include "CalorimeterHit_factory_LFHCALRecHits.h" #include "ProtoCluster_factory_LFHCALTruthProtoClusters.h" #include "ProtoCluster_factory_LFHCALIslandProtoClusters.h" namespace eicrecon { - using Cluster_factory_HcalEndcapPTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_HcalEndcapPClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_HcalEndcapPInsertTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_HcalEndcapPInsertClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_LFHCALTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_LFHCALClusters = CalorimeterClusterRecoCoG_factoryT<>; + using RawCalorimeterHit_factory_HcalEndcapPRawHits = CalorimeterHitDigi_factoryT<>; + using RawCalorimeterHit_factory_HcalEndcapPInsertRawHits = CalorimeterHitDigi_factoryT<>; + using RawCalorimeterHit_factory_LFHCALRawHits = CalorimeterHitDigi_factoryT<>; + using Cluster_factory_HcalEndcapPTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_HcalEndcapPClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_HcalEndcapPInsertTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_HcalEndcapPInsertClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_LFHCALTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_LFHCALClusters = CalorimeterClusterRecoCoG_factoryT<>; } extern "C" { @@ -41,8 +42,19 @@ extern "C" { InitJANAPlugin(app); - app->Add(new JChainFactoryGeneratorT( - {"HcalEndcapPHits"}, "HcalEndcapPRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "HcalEndcapPRawHits", {"HcalEndcapPHits"}, {"HcalEndcapPRawHits"}, + { + .eRes = {}, + .tRes = 0.001 * dd4hep::ns, + .capADC = 65536, + .dyRangeADC = 1 * dd4hep::GeV, + .pedMeanADC = 20, + .pedSigmaADC = 0.8, + .resolutionTDC = 10 * dd4hep::picosecond, + .corrMeanScale = 1.0, + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"HcalEndcapPRawHits"}, "HcalEndcapPRecHits" @@ -95,8 +107,19 @@ extern "C" { ) ); - app->Add(new JChainFactoryGeneratorT( - {"HcalEndcapPInsertHits"}, "HcalEndcapPInsertRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "HcalEndcapPInsertRawHits", {"HcalEndcapPInsertHits"}, {"HcalEndcapPInsertRawHits"}, + { + .eRes = {}, + .tRes = 0.0 * dd4hep::ns, + .capADC = 32768, + .dyRangeADC = 200 * dd4hep::MeV, + .pedMeanADC = 400, + .pedSigmaADC = 10, + .resolutionTDC = 10 * dd4hep::picosecond, + .corrMeanScale = 1.0, + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"HcalEndcapPInsertRawHits"}, "HcalEndcapPInsertRecHits" @@ -149,8 +172,22 @@ extern "C" { ) ); - app->Add(new JChainFactoryGeneratorT( - {"LFHCALHits"}, "LFHCALRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "LFHCALRawHits", {"LFHCALHits"}, {"LFHCALRawHits"}, + { + .eRes = {}, + .tRes = 0.0 * dd4hep::ns, + .capADC = 65536, + .capTime = 100, + .dyRangeADC = 1 * dd4hep::GeV, + .pedMeanADC = 20, + .pedSigmaADC = 0.8, + .resolutionTDC = 10 * dd4hep::picosecond, + .corrMeanScale = 1.0, + .readout = "LFHCALHits", + .fields = {"layerz"}, + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"LFHCALRawHits"}, "LFHCALRecHits" diff --git a/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPInsertRawHits.h b/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPInsertRawHits.h deleted file mode 100644 index 1469910d5d..0000000000 --- a/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPInsertRawHits.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#pragma once - -#include - -#include -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include -#include -#include -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_HcalEndcapPInsertRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_HcalEndcapPInsertRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {}; - m_tRes = 0.0 * dd4hep::ns; - m_capADC = 32768; - m_dyRangeADC = 200 * dd4hep::MeV; - m_pedMeanADC = 400; - m_pedSigmaADC = 10; - m_resolutionTDC = 10 * dd4hep::picosecond; - m_corrMeanScale = 1.0; - u_fields={}; - m_geoSvcName = "ActsGeometryProvider"; - m_readout = ""; - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("FHCAL:HcalEndcapPInsertRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("FHCAL:HcalEndcapPInsertRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("FHCAL:HcalEndcapPInsertRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("FHCAL:HcalEndcapPInsertRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("FHCAL:HcalEndcapPInsertRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("FHCAL:HcalEndcapPInsertRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("FHCAL:HcalEndcapPInsertRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("FHCAL:HcalEndcapPInsertRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("FHCAL:HcalEndcapPInsertRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("FHCAL:HcalEndcapPInsertRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("FHCAL:HcalEndcapPInsertRawHits:readoutClass", m_readout); - - // Call Init for generic algorithm - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; diff --git a/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPRawHits.h b/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPRawHits.h deleted file mode 100644 index 6713214824..0000000000 --- a/src/detectors/FHCAL/RawCalorimeterHit_factory_HcalEndcapPRawHits.h +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#pragma once - -#include - -#include -#include -#include -#include -#include - -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_HcalEndcapPRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_HcalEndcapPRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {}; - m_tRes = 0.001 * dd4hep::ns; - m_capADC = 65536; - m_dyRangeADC = 1 * dd4hep::GeV; - m_pedMeanADC = 20 ; - m_pedSigmaADC = 0.8 ; - m_resolutionTDC = 10 * dd4hep::picosecond; - m_corrMeanScale = 1.0; - u_fields={}; - m_geoSvcName = "ActsGeometryProvider"; - m_readout = ""; - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("FHCAL:HcalEndcapPRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("FHCAL:HcalEndcapPRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("FHCAL:HcalEndcapPRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("FHCAL:HcalEndcapPRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("FHCAL:HcalEndcapPRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("FHCAL:HcalEndcapPRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("FHCAL:HcalEndcapPRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("FHCAL:HcalEndcapPRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("FHCAL:HcalEndcapPRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("FHCAL:HcalEndcapPRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("FHCAL:HcalEndcapPRawHits:readoutClass", m_readout); - - // Call Init for generic algorithm - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; diff --git a/src/detectors/FHCAL/RawCalorimeterHit_factory_LFHCALRawHits.h b/src/detectors/FHCAL/RawCalorimeterHit_factory_LFHCALRawHits.h deleted file mode 100644 index c1510f2a17..0000000000 --- a/src/detectors/FHCAL/RawCalorimeterHit_factory_LFHCALRawHits.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2023, Friederike Bock -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#ifndef _RawCalorimeterHit_factory_LFHCALRawHits_h_ -#define _RawCalorimeterHit_factory_LFHCALRawHits_h_ - -#include - -#include -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include -#include -#include -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_LFHCALRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_LFHCALRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {}; - m_tRes = 0.0; // in ns - m_capTime = 100 ; // given in ns, 4 samples in HGCROC - m_capADC=65536;//2^16 - m_dyRangeADC=1 * dd4hep::GeV; - m_pedMeanADC=20; - m_pedSigmaADC = 0.8; - m_resolutionTDC = 10 * dd4hep::picosecond; - m_corrMeanScale = 1.0; - u_fields={"layerz"}; - m_geoSvcName = "geoServiceName"; - m_readout = "LFHCALHits"; - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("FHCAL:LFHCALRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("FHCAL:LFHCALRawHits:maxTimeInt", m_capTime); - app->SetDefaultParameter("FHCAL:LFHCALRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("FHCAL:LFHCALRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("FHCAL:LFHCALRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("FHCAL:LFHCALRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("FHCAL:LFHCALRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("FHCAL:LFHCALRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("FHCAL:LFHCALRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("FHCAL:LFHCALRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("FHCAL:LFHCALRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("FHCAL:LFHCALRawHits:readoutClass", m_readout); - - // Call Init for generic algorithm - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; - -#endif // _RawCalorimeterHit_factory_LFHCALRawHits_h_ diff --git a/src/detectors/LUMISPECCAL/LUMISPECCAL.cc b/src/detectors/LUMISPECCAL/LUMISPECCAL.cc index 91ad1070d5..5aea18afeb 100644 --- a/src/detectors/LUMISPECCAL/LUMISPECCAL.cc +++ b/src/detectors/LUMISPECCAL/LUMISPECCAL.cc @@ -7,15 +7,16 @@ #include "extensions/jana/JChainMultifactoryGeneratorT.h" #include "factories/calorimetry/CalorimeterClusterRecoCoG_factoryT.h" +#include "factories/calorimetry/CalorimeterHitDigi_factoryT.h" -#include "RawCalorimeterHit_factory_EcalLumiSpecRawHits.h" #include "CalorimeterHit_factory_EcalLumiSpecRecHits.h" #include "ProtoCluster_factory_EcalLumiSpecTruthProtoClusters.h" #include "ProtoCluster_factory_EcalLumiSpecIslandProtoClusters.h" namespace eicrecon { - using Cluster_factory_EcalLumiSpecTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; - using Cluster_factory_EcalLumiSpecClusters = CalorimeterClusterRecoCoG_factoryT<>; + using RawCalorimeterHit_factory_EcalLumiSpecRawHits = CalorimeterHitDigi_factoryT<>; + using Cluster_factory_EcalLumiSpecTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; + using Cluster_factory_EcalLumiSpecClusters = CalorimeterClusterRecoCoG_factoryT<>; } extern "C" { @@ -25,8 +26,19 @@ extern "C" { InitJANAPlugin(app); - app->Add(new JChainFactoryGeneratorT( - {"LumiSpecCALHits"}, "EcalLumiSpecRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "EcalLumiSpecRawHits", {"LumiSpecCALHits"}, {"EcalLumiSpecRawHits"}, + { + .eRes = {0.0 * sqrt(dd4hep::GeV), 0.02, 0.0 * dd4hep::GeV}, // flat 2% + .tRes = 0.0 * dd4hep::ns, + .capADC = 16384, + .dyRangeADC = 20 * dd4hep::GeV, + .pedMeanADC = 100, + .pedSigmaADC = 1, + .resolutionTDC = 10 * dd4hep::picosecond, + .corrMeanScale = 1.0, + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"EcalLumiSpecRawHits"}, "EcalLumiSpecRecHits" diff --git a/src/detectors/LUMISPECCAL/RawCalorimeterHit_factory_EcalLumiSpecRawHits.h b/src/detectors/LUMISPECCAL/RawCalorimeterHit_factory_EcalLumiSpecRawHits.h deleted file mode 100644 index e376a27355..0000000000 --- a/src/detectors/LUMISPECCAL/RawCalorimeterHit_factory_EcalLumiSpecRawHits.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#pragma once - -#include - -#include -#include -#include -#include -#include - -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_EcalLumiSpecRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_EcalLumiSpecRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {0.0 * sqrt(dd4hep::GeV), 0.02, 0.0 * dd4hep::GeV}; // flat 2% - m_tRes = 0.0 * dd4hep::ns; - m_capADC = 16384; - m_dyRangeADC = 20 * dd4hep::GeV; - m_pedMeanADC = 100; - m_pedSigmaADC = 1; - m_resolutionTDC = 10 * dd4hep::picosecond; - m_corrMeanScale = 1.0; - u_fields={}; - m_geoSvcName = "ActsGeometryProvider"; - m_readout = ""; - - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("LUMISPECCAL:EcalLumiSpecRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("LUMISPECCAL:EcalLumiSpecRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("LUMISPECCAL:EcalLumiSpecRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("LUMISPECCAL:EcalLumiSpecRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("LUMISPECCAL:EcalLumiSpecRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("LUMISPECCAL:EcalLumiSpecRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("LUMISPECCAL:EcalLumiSpecRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("LUMISPECCAL:EcalLumiSpecRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("LUMISPECCAL:EcalLumiSpecRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("LUMISPECCAL:EcalLumiSpecRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("LUMISPECCAL:EcalLumiSpecRawHits:readoutClass", m_readout); - - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; diff --git a/src/detectors/ZDC/RawCalorimeterHit_factory_ZDCEcalRawHits.h b/src/detectors/ZDC/RawCalorimeterHit_factory_ZDCEcalRawHits.h deleted file mode 100644 index 72d1ac11ab..0000000000 --- a/src/detectors/ZDC/RawCalorimeterHit_factory_ZDCEcalRawHits.h +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#pragma once - -#include - -#include -#include -#include -#include -#include - -#include "extensions/jana/JChainFactoryT.h" -#include "services/geometry/dd4hep/JDD4hep_service.h" -#include "algorithms/calorimetry/CalorimeterHitDigi.h" -#include "services/log/Log_service.h" -#include "extensions/spdlog/SpdlogExtensions.h" - - - -class RawCalorimeterHit_factory_ZDCEcalRawHits : public JChainFactoryT, CalorimeterHitDigi { - -public: - - //------------------------------------------ - // Constructor - RawCalorimeterHit_factory_ZDCEcalRawHits(std::vector default_input_tags) - : JChainFactoryT(std::move(default_input_tags)) { - m_log = japp->GetService()->logger(GetTag()); - } - - //------------------------------------------ - // Init - void Init() override { - InitDataTags(GetPluginName() + ":" + GetTag()); - - auto app = GetApplication(); - - // Set default values for all config. parameters in CalorimeterHitDigi algorithm - u_eRes = {}; - m_tRes = 0.0 * dd4hep::ns; - m_capADC = 8096; - m_dyRangeADC = 100 * dd4hep::MeV; - m_pedMeanADC = 400; - m_pedSigmaADC = 3.2; - m_resolutionTDC = 10 * dd4hep::picosecond; - m_corrMeanScale = 1.0; - u_fields={}; - m_geoSvcName = "ActsGeometryProvider"; - m_readout = ""; - m_geoSvc = app->GetService(); // TODO: implement named geometry service? - - // This is another option for exposing the data members as JANA configuration parameters. - app->SetDefaultParameter("ZDC:ZDCEcalRawHits:energyResolutions",u_eRes); - app->SetDefaultParameter("ZDC:ZDCEcalRawHits:timeResolution", m_tRes); - app->SetDefaultParameter("ZDC:ZDCEcalRawHits:capacityADC", m_capADC); - app->SetDefaultParameter("ZDC:ZDCEcalRawHits:dynamicRangeADC", m_dyRangeADC); - app->SetDefaultParameter("ZDC:ZDCEcalRawHits:pedestalMean", m_pedMeanADC); - app->SetDefaultParameter("ZDC:ZDCEcalRawHits:pedestalSigma", m_pedSigmaADC); - app->SetDefaultParameter("ZDC:ZDCEcalRawHits:resolutionTDC", m_resolutionTDC); - app->SetDefaultParameter("ZDC:ZDCEcalRawHits:scaleResponse", m_corrMeanScale); - app->SetDefaultParameter("ZDC:ZDCEcalRawHits:signalSumFields", u_fields); - app->SetDefaultParameter("ZDC:ZDCEcalRawHits:geoServiceName", m_geoSvcName); - app->SetDefaultParameter("ZDC:ZDCEcalRawHits:readoutClass", m_readout); - - // Call Init for generic algorithm - AlgorithmInit(m_log); - } - - //------------------------------------------ - // ChangeRun - void ChangeRun(const std::shared_ptr &event) override { - AlgorithmChangeRun(); - } - - //------------------------------------------ - // Process - void Process(const std::shared_ptr &event) override { - // Get input collection - auto simhits_coll = static_cast(event->GetCollectionBase(GetInputTags()[0])); - - // Call Process for generic algorithm - auto rawhits_coll = AlgorithmProcess(*simhits_coll); - - // Hand algorithm objects over to JANA - SetCollection(std::move(rawhits_coll)); - } - -}; diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index ffc4214196..8e01afd902 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -7,14 +7,15 @@ #include "extensions/jana/JChainMultifactoryGeneratorT.h" #include "factories/calorimetry/CalorimeterClusterRecoCoG_factoryT.h" +#include "factories/calorimetry/CalorimeterHitDigi_factoryT.h" -#include "RawCalorimeterHit_factory_ZDCEcalRawHits.h" #include "CalorimeterHit_factory_ZDCEcalRecHits.h" #include "ProtoCluster_factory_ZDCEcalTruthProtoClusters.h" #include "ProtoCluster_factory_ZDCEcalIslandProtoClusters.h" namespace eicrecon { + using RawCalorimeterHit_factory_ZDCEcalRawHits = CalorimeterHitDigi_factoryT<>; using Cluster_factory_ZDCEcalTruthClusters = CalorimeterClusterRecoCoG_factoryT<>; using Cluster_factory_ZDCEcalClusters = CalorimeterClusterRecoCoG_factoryT<>; } @@ -26,8 +27,18 @@ extern "C" { InitJANAPlugin(app); - app->Add(new JChainFactoryGeneratorT( - {"ZDCEcalHits"}, "ZDCEcalRawHits" + app->Add(new JChainMultifactoryGeneratorT( + "ZDCEcalRawHits", {"ZDCEcalHits"}, {"ZDCEcalRawHits"}, + { + .tRes = 0.0 * dd4hep::ns, + .capADC = 8096, + .dyRangeADC = 100 * dd4hep::MeV, + .pedMeanADC = 400, + .pedSigmaADC = 3.2, + .resolutionTDC = 10 * dd4hep::picosecond, + .corrMeanScale = 1.0, + }, + app // TODO: Remove me once fixed )); app->Add(new JChainFactoryGeneratorT( {"ZDCEcalRawHits"}, "ZDCEcalRecHits" diff --git a/src/factories/calorimetry/CalorimeterHitDigi_factoryT.h b/src/factories/calorimetry/CalorimeterHitDigi_factoryT.h new file mode 100644 index 0000000000..1110db815b --- /dev/null +++ b/src/factories/calorimetry/CalorimeterHitDigi_factoryT.h @@ -0,0 +1,86 @@ +// Copyright 2023, Wouter Deconinck +// Subject to the terms in the LICENSE file found in the top-level directory. +// + +#pragma once + +#include "algorithms/calorimetry/CalorimeterHitDigi.h" +#include "services/geometry/dd4hep/JDD4hep_service.h" +#include "extensions/jana/JChainMultifactoryT.h" +#include "extensions/spdlog/SpdlogMixin.h" + + +namespace eicrecon { + +// variadic template parameter T unused +template typename... T> +class CalorimeterHitDigi_factoryT : + public JChainMultifactoryT, + public SpdlogMixin>, + public T>... { + + public: + using SpdlogMixin::logger; + + explicit CalorimeterHitDigi_factoryT( + std::string tag, + const std::vector& input_tags, + const std::vector& output_tags, + CalorimeterHitDigiConfig 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 = eicrecon::str::ReplaceAll(GetPluginName(), ".so", ""); + std::string param_prefix = plugin_name + ":" + GetTag(); + + // Use JDD4hep_service to get dd4hep::Detector + auto geoSvc = app->template GetService(); + + // SpdlogMixin logger initialization, sets m_log + SpdlogMixin::InitLogger(JChainMultifactoryT::GetPrefix(), "info"); + + // Algorithm configuration + auto cfg = GetDefaultConfig(); + + app->SetDefaultParameter(param_prefix + ":energyResolutions",cfg.eRes); + app->SetDefaultParameter(param_prefix + ":timeResolution", cfg.tRes); + app->SetDefaultParameter(param_prefix + ":capacityADC", cfg.capADC); + app->SetDefaultParameter(param_prefix + ":dynamicRangeADC", cfg.dyRangeADC); + app->SetDefaultParameter(param_prefix + ":pedestalMean", cfg.pedMeanADC); + app->SetDefaultParameter(param_prefix + ":pedestalSigma", cfg.pedSigmaADC); + app->SetDefaultParameter(param_prefix + ":resolutionTDC", cfg.resolutionTDC); + app->SetDefaultParameter(param_prefix + ":scaleResponse", cfg.corrMeanScale); + app->SetDefaultParameter(param_prefix + ":signalSumFields", cfg.fields); + app->SetDefaultParameter(param_prefix + ":readoutClass", cfg.readout); + + 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 raw_hits = m_algo.process(*hits); + SetCollection(GetOutputTags()[0], std::move(raw_hits)); + } + catch(std::exception &e) { + throw JException(e.what()); + } + + } + + private: + CalorimeterHitDigi m_algo; + +}; + +} // eicrecon diff --git a/src/tests/BEMC_test/BEMC_test.cc b/src/tests/BEMC_test/BEMC_test.cc deleted file mode 100644 index ef0dcc0bce..0000000000 --- a/src/tests/BEMC_test/BEMC_test.cc +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// - -#include -#include -#include - -#include -#include -#include "detectors/BEMC/RawCalorimeterHit_factory_EcalBarrelSciGlassRawHits.h" - - -/// This class is used to demonstrate getting data objects that -/// come from the event source as well as ones generated by a -/// JANA algorithm. The "Eraw" histogram is filled using the -/// energy from the edm4hep::SimCalorimeterHit objects in the -/// EcalBarrelHits collection. The "Edigi" histogram is filled -/// using the amplitude produced by the generic CalorimeterHitDigi -/// algorithm in the form of BEMCRawCalorimeterHit objects. -class BEMC_testProcessor: public JEventProcessorSequentialRoot { -private: - - // Data objects we will need from JANA - PrefetchT rawhits = {this, "EcalBarrelHits"}; - PrefetchT digihits = {this}; - - // Histograms - TH1D* hEraw = nullptr; - TH1D *hEdigi = nullptr ; - -public: - BEMC_testProcessor() { SetTypeName(NAME_OF_THIS); } - - void InitWithGlobalRootLock() override { - - // Create histograms - hEraw = new TH1D("Eraw", "BEMC hit energy (raw)", 100, 0, 0.075); - hEdigi = new TH1D("Edigi", "BEMC hit energy (digi)", 200, 0, 2000.0); - } - - void ProcessSequential(const std::shared_ptr& event) override { - - // Fill histograms - for( auto hit : rawhits() ) hEraw->Fill( hit->getEnergy()); - for( auto hit : digihits() ) hEdigi->Fill( hit->getAmplitude()); - } - - void FinishWithGlobalRootLock() override {} -}; - -// The following just makes this a JANA plugin -extern "C" { - void InitPlugin(JApplication *app) { - InitJANAPlugin(app); - app->Add(new BEMC_testProcessor); - } -} diff --git a/src/tests/BEMC_test/CMakeLists.txt b/src/tests/BEMC_test/CMakeLists.txt deleted file mode 100644 index dbb193b501..0000000000 --- a/src/tests/BEMC_test/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(BEMC_test) - -# Automatically set plugin name the same as the directory name -# Don't forget string(REPLACE " " "_" PLUGIN_NAME ${PLUGIN_NAME}) if this dir has spaces in its name -get_filename_component(PLUGIN_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) - -# Function creates ${PLUGIN_NAME}_plugin and ${PLUGIN_NAME}_library targets -# Setting default includes, libraries and installation paths -plugin_add(${PLUGIN_NAME} ) - -# The macro grabs sources as *.cc *.cpp *.c and headers as *.h *.hh *.hpp -# Then correctly sets sources for ${_name}_plugin and ${_name}_library targets -# Adds headers to the correct installation directory -plugin_glob_all(${PLUGIN_NAME}) - -# Find dependencies -plugin_add_dd4hep(${PLUGIN_NAME}) -plugin_add_event_model(${PLUGIN_NAME}) - -# Add include directories (works same as target_include_directories) -# plugin_include_directories(${PLUGIN_NAME} SYSTEM PUBLIC ... ) - -# Add libraries (works same as target_include_directories) -# plugin_link_libraries(${PLUGIN_NAME} ... ) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index c9007646e9..ad64d892dc 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -8,7 +8,6 @@ else() endif() add_subdirectory(pyjano) -add_subdirectory(BEMC_test) add_subdirectory(reco_test) add_subdirectory(tracking_test) add_subdirectory(track_propagation_test) diff --git a/src/tests/algorithms_test/calorimetry_CalorimeterHitDigi.cc b/src/tests/algorithms_test/calorimetry_CalorimeterHitDigi.cc index 3a8cc72a0a..00fc99d85f 100644 --- a/src/tests/algorithms_test/calorimetry_CalorimeterHitDigi.cc +++ b/src/tests/algorithms_test/calorimetry_CalorimeterHitDigi.cc @@ -7,6 +7,8 @@ #include "algorithms/calorimetry/CalorimeterHitDigi.h" +using eicrecon::CalorimeterHitDigi; +using eicrecon::CalorimeterHitDigiConfig; TEST_CASE( "the clustering algorithm runs", "[CalorimeterHitDigi]" ) { CalorimeterHitDigi algo; @@ -14,21 +16,22 @@ TEST_CASE( "the clustering algorithm runs", "[CalorimeterHitDigi]" ) { std::shared_ptr logger = spdlog::default_logger()->clone("CalorimeterHitDigi"); logger->set_level(spdlog::level::trace); - algo.m_threshold = 0. /* GeV */; - algo.m_corrMeanScale = 1.; + CalorimeterHitDigiConfig cfg; + cfg.threshold = 0. /* GeV */; + cfg.corrMeanScale = 1.; // Keep smearing parameters at zero - algo.m_pedSigmaADC = 0; - algo.m_tRes = 0. * dd4hep::ns; - algo.u_eRes = {0. * sqrt(dd4hep::GeV), 0., 0. * dd4hep::GeV}; + cfg.pedSigmaADC = 0; + cfg.tRes = 0. * dd4hep::ns; + cfg.eRes = {0. * sqrt(dd4hep::GeV), 0., 0. * dd4hep::GeV}; SECTION( "single hit with couple contributions" ) { - algo.m_capADC = 555; - algo.m_dyRangeADC = 5.0 /* GeV */; - algo.m_pedMeanADC = 123; - algo.m_resolutionTDC = 1.0 * dd4hep::ns; - algo.AlgorithmInit(logger); - algo.AlgorithmChangeRun(); + cfg.capADC = 555; + cfg.dyRangeADC = 5.0 /* GeV */; + cfg.pedMeanADC = 123; + cfg.resolutionTDC = 1.0 * dd4hep::ns; + algo.applyConfig(cfg); + algo.init(nullptr, logger); edm4hep::SimCalorimeterHitCollection simhits; auto mhit = simhits.create( @@ -49,7 +52,7 @@ TEST_CASE( "the clustering algorithm runs", "[CalorimeterHitDigi]" ) { {0. /* mm */, 0. /* mm */, 0. /* mm */}, // edm4hep::Vector3f stepPosition }); - std::unique_ptr rawhits = algo.AlgorithmProcess(simhits); + std::unique_ptr rawhits = algo.process(simhits); REQUIRE( (*rawhits).size() == 1 ); REQUIRE( (*rawhits)[0].getCellID() == 0xABABABAB);