From d83d77027a471d6cd9e0fda7266e51e21a4cb37a Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Sat, 22 Oct 2022 13:09:22 -0400 Subject: [PATCH 1/7] Correct config. param names. --- ...r_factory_EcalEndcapNIslandProtoClusters.h | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/detectors/EEMC/ProtoCluster_factory_EcalEndcapNIslandProtoClusters.h b/src/detectors/EEMC/ProtoCluster_factory_EcalEndcapNIslandProtoClusters.h index 02dbbfc96e..4a5df051ce 100644 --- a/src/detectors/EEMC/ProtoCluster_factory_EcalEndcapNIslandProtoClusters.h +++ b/src/detectors/EEMC/ProtoCluster_factory_EcalEndcapNIslandProtoClusters.h @@ -41,17 +41,17 @@ class ProtoCluster_factory_EcalEndcapNIslandProtoClusters : public JFactoryTSetDefaultParameter("EEMC:EcalEndcapNClusters:input_tag", m_input_tag, "Name of input collection to use"); - app->SetDefaultParameter("EEMC:EcalEndcapNClusters:splitCluster", m_splitCluster); - app->SetDefaultParameter("EEMC:EcalEndcapNClusters:minClusterHitEdep", m_minClusterHitEdep); - app->SetDefaultParameter("EEMC:EcalEndcapNClusters:minClusterCenterEdep", m_minClusterCenterEdep); - app->SetDefaultParameter("EEMC:EcalEndcapNClusters:sectorDist", m_sectorDist); - app->SetDefaultParameter("EEMC:EcalEndcapNClusters:localDistXY", u_localDistXY); - app->SetDefaultParameter("EEMC:EcalEndcapNClusters:localDistXZ", u_localDistXZ); - app->SetDefaultParameter("EEMC:EcalEndcapNClusters:localDistYZ", u_localDistYZ); - app->SetDefaultParameter("EEMC:EcalEndcapNClusters:globalDistRPhi", u_globalDistRPhi); - app->SetDefaultParameter("EEMC:EcalEndcapNClusters:globalDistEtaPhi", u_globalDistEtaPhi); - app->SetDefaultParameter("EEMC:EcalEndcapNClusters:dimScaledLocalDistXY", u_dimScaledLocalDistXY); + app->SetDefaultParameter("EEMC:EcalEndcapNIslandProtoClusters:input_tag", m_input_tag, "Name of input collection to use"); + app->SetDefaultParameter("EEMC:EcalEndcapNIslandProtoClusters:splitCluster", m_splitCluster); + app->SetDefaultParameter("EEMC:EcalEndcapNIslandProtoClusters:minClusterHitEdep", m_minClusterHitEdep); + app->SetDefaultParameter("EEMC:EcalEndcapNIslandProtoClusters:minClusterCenterEdep", m_minClusterCenterEdep); + app->SetDefaultParameter("EEMC:EcalEndcapNIslandProtoClusters:sectorDist", m_sectorDist); + app->SetDefaultParameter("EEMC:EcalEndcapNIslandProtoClusters:localDistXY", u_localDistXY); + app->SetDefaultParameter("EEMC:EcalEndcapNIslandProtoClusters:localDistXZ", u_localDistXZ); + app->SetDefaultParameter("EEMC:EcalEndcapNIslandProtoClusters:localDistYZ", u_localDistYZ); + app->SetDefaultParameter("EEMC:EcalEndcapNIslandProtoClusters:globalDistRPhi", u_globalDistRPhi); + app->SetDefaultParameter("EEMC:EcalEndcapNIslandProtoClusters:globalDistEtaPhi", u_globalDistEtaPhi); + app->SetDefaultParameter("EEMC:EcalEndcapNIslandProtoClusters:dimScaledLocalDistXY", u_dimScaledLocalDistXY); m_geoSvc = app->template GetService(); std::string tag=this->GetTag(); From a8b302172894f9a27e9d6742716cfacb1b926dd8 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Sat, 22 Oct 2022 13:09:57 -0400 Subject: [PATCH 2/7] Add B0 ECal --- src/detectors/B0ECAL/B0ECAL.cc | 31 ++++++ src/detectors/B0ECAL/CMakeLists.txt | 34 ++++++ .../CalorimeterHit_factory_B0ECalRecHits.h | 99 +++++++++++++++++ .../B0ECAL/Cluster_factory_B0ECalClusters.h | 97 +++++++++++++++++ .../Cluster_factory_B0ECalMergedClusters.h | 80 ++++++++++++++ ...luster_factory_B0ECalIslandProtoClusters.h | 87 +++++++++++++++ ...Cluster_factory_B0ECalTruthProtoClusters.h | 62 +++++++++++ .../RawCalorimeterHit_factory_B0ECalRawHits.h | 103 ++++++++++++++++++ ...Cluster_factory_B0ECalTruthProtoClusters.h | 61 +++++++++++ src/detectors/CMakeLists.txt | 1 + src/tools/default_flags_table/reco_flags.py | 92 +++++++++++----- 11 files changed, 717 insertions(+), 30 deletions(-) create mode 100644 src/detectors/B0ECAL/B0ECAL.cc create mode 100644 src/detectors/B0ECAL/CMakeLists.txt create mode 100644 src/detectors/B0ECAL/CalorimeterHit_factory_B0ECalRecHits.h create mode 100644 src/detectors/B0ECAL/Cluster_factory_B0ECalClusters.h create mode 100644 src/detectors/B0ECAL/Cluster_factory_B0ECalMergedClusters.h create mode 100644 src/detectors/B0ECAL/ProtoCluster_factory_B0ECalIslandProtoClusters.h create mode 100644 src/detectors/B0ECAL/ProtoCluster_factory_B0ECalTruthProtoClusters.h create mode 100644 src/detectors/B0ECAL/RawCalorimeterHit_factory_B0ECalRawHits.h create mode 100644 src/detectors/B0ECAL/TruthCluster_factory_B0ECalTruthProtoClusters.h diff --git a/src/detectors/B0ECAL/B0ECAL.cc b/src/detectors/B0ECAL/B0ECAL.cc new file mode 100644 index 0000000000..1afd154616 --- /dev/null +++ b/src/detectors/B0ECAL/B0ECAL.cc @@ -0,0 +1,31 @@ +// Copyright 2022, David Lawrence +// Subject to the terms in the LICENSE file found in the top-level directory. +// +// + +#include +#include + + +#include "RawCalorimeterHit_factory_B0ECalRawHits.h" +#include "CalorimeterHit_factory_B0ECalRecHits.h" +#include "ProtoCluster_factory_B0ECalTruthProtoClusters.h" +#include "ProtoCluster_factory_B0ECalIslandProtoClusters.h" +#include "Cluster_factory_B0ECalClusters.h" +#include "Cluster_factory_B0ECalMergedClusters.h" +#include "TruthCluster_factory_B0ECalTruthProtoClusters.h" + + +extern "C" { + void InitPlugin(JApplication *app) { + InitJANAPlugin(app); + app->Add(new JFactoryGeneratorT()); + app->Add(new JFactoryGeneratorT()); + app->Add(new JFactoryGeneratorT()); + app->Add(new JFactoryGeneratorT()); + app->Add(new JFactoryGeneratorT()); + app->Add(new JFactoryGeneratorT()); + app->Add(new JFactoryGeneratorT()); + } +} + diff --git a/src/detectors/B0ECAL/CMakeLists.txt b/src/detectors/B0ECAL/CMakeLists.txt new file mode 100644 index 0000000000..5e0bd747ec --- /dev/null +++ b/src/detectors/B0ECAL/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.16) + +project(B0ECAL) + +# 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) + +print_header(">>>> P L U G I N : ${PLUGIN_NAME} <<<<") # Fancy printing + +# 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 +find_package(Eigen3 REQUIRED) +set(Eigen3_INCLUDE_DIR ${Eigen3_DIR}/../../../include/eigen3) + +plugin_add_dd4hep(${PLUGIN_NAME}) +plugin_add_event_model(${PLUGIN_NAME}) +plugin_include_directories(${PLUGIN_NAME} SYSTEM PUBLIC ${Eigen3_INCLUDE_DIR}) + +# 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} algorithms_calorimetry_library ) + + diff --git a/src/detectors/B0ECAL/CalorimeterHit_factory_B0ECalRecHits.h b/src/detectors/B0ECAL/CalorimeterHit_factory_B0ECalRecHits.h new file mode 100644 index 0000000000..bc714cf8a4 --- /dev/null +++ b/src/detectors/B0ECAL/CalorimeterHit_factory_B0ECalRecHits.h @@ -0,0 +1,99 @@ + +#pragma once + + +#include + +#include +#include +#include + +class CalorimeterHit_factory_B0ECalRecHits : public JFactoryT, CalorimeterHitReco { + +public: + //------------------------------------------ + // Constructor + CalorimeterHit_factory_B0ECalRecHits(){ + SetTag("B0ECalRecHits"); + } + + //------------------------------------------ + // Init + void Init() override{ + auto app = GetApplication(); + + m_input_tag = "B0ECalRawHits"; + + // digitization settings, must be consistent with digi class + m_capADC=16384;//{this, "capacityADC", 8096}; + m_dyRangeADC=20. * GeV;//{this, "dynamicRangeADC", 100. * MeV}; + m_pedMeanADC=100;//{this, "pedestalMean", 400}; + m_pedSigmaADC=1;//{this, "pedestalSigma", 3.2}; + m_resolutionTDC=1e-11;//{this, "resolutionTDC", 10 * ps}; + + // zero suppression values + m_thresholdFactor=4.0;//{this, "thresholdFactor", 0.0}; + m_thresholdValue=3.0;//{this, "thresholdValue", 0.0}; + + // energy correction with sampling fraction + m_sampFrac=0.998;//{this, "samplingFraction", 1.0}; + + // geometry service to get ids, ignored if no names provided + m_geoSvcName=""; + m_readout="B0ECalHits"; // from ATHENA's reconstruction.py + m_layerField=""; // from ATHENA's reconstruction.py (i.e. not defined there) + m_sectorField="sector"; // from ATHENA's reconstruction.py + + m_localDetElement=""; // from ATHENA's reconstruction.py (i.e. not defined there) + u_localDetFields={}; // from ATHENA's reconstruction.py (i.e. not defined there) + + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:input_tag", m_input_tag, "Name of input collection to use"); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:capacityADC", m_capADC); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:dynamicRangeADC", m_dyRangeADC); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:pedestalMean", m_pedMeanADC); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:pedestalSigma", m_pedSigmaADC); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:resolutionTDC", m_resolutionTDC); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:thresholdFactor", m_thresholdFactor); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:thresholdValue", m_thresholdValue); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:samplingFraction", m_sampFrac); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:geoServiceName", m_geoSvcName); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:readout", m_readout); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:layerField", m_layerField); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:sectorField", m_sectorField); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:localDetElement", m_localDetElement); + app->SetDefaultParameter("B0ECAL:B0ECalRecHits:localDetFields", u_localDetFields); + m_geoSvc = app->template GetService(); // TODO: implement named geometry service? + + std::string tag=this->GetTag(); + std::shared_ptr m_log = app->GetService()->logger(tag); + + // Get log level from user parameter or default + std::string log_level_str = "info"; + auto pm = app->GetJParameterManager(); + pm->SetDefaultParameter(tag + ":LogLevel", log_level_str, "verbosity: trace, debug, info, warn, err, critical, off"); + m_log->set_level(eicrecon::ParseLogLevel(log_level_str)); + AlgorithmInit(m_log); + } + + //------------------------------------------ + // ChangeRun + void ChangeRun(const std::shared_ptr &event) override{ + AlgorithmChangeRun(); + } + + //------------------------------------------ + // Process + void Process(const std::shared_ptr &event) override{ + // Prefill inputs + rawhits = event->Get(m_input_tag); + + // Call Process for generic algorithm + AlgorithmProcess(); + + // Hand owner of algorithm objects over to JANA + Set(hits); + hits.clear(); // not really needed, but better to not leave dangling pointers around + } + +}; + diff --git a/src/detectors/B0ECAL/Cluster_factory_B0ECalClusters.h b/src/detectors/B0ECAL/Cluster_factory_B0ECalClusters.h new file mode 100644 index 0000000000..91e9b304c8 --- /dev/null +++ b/src/detectors/B0ECAL/Cluster_factory_B0ECalClusters.h @@ -0,0 +1,97 @@ +// Copyright 2022, Thomas Britton +// Subject to the terms in the LICENSE file found in the top-level directory. +// + +#pragma once + + +#include + +#include +#include +#include +#include +#include + + + +class Cluster_factory_B0ECalClusters : public JFactoryT, CalorimeterClusterRecoCoG { + +public: + //------------------------------------------ + // Constructor + Cluster_factory_B0ECalClusters(){ + SetTag("B0ECalClusters"); + } + + //------------------------------------------ + // Init + void Init() override{ + auto app = GetApplication(); + //-------- Configuration Parameters ------------ + m_input_simhit_tag="B0ECalHits"; + m_input_protoclust_tag="B0ECalIslandProtoClusters"; + + m_sampFrac=1.0;//{this, "samplingFraction", 1.0}; + m_logWeightBase=3.6;//{this, "logWeightBase", 3.6}; + m_depthCorrection=0.0;//{this, "depthCorrection", 0.0}; + m_energyWeight="log";//{this, "energyWeight", "log"}; + m_moduleDimZName="";//{this, "moduleDimZName", ""}; + // Constrain the cluster position eta to be within + // the eta of the contributing hits. This is useful to avoid edge effects + // for endcaps. + m_enableEtaBounds=false;//{this, "enableEtaBounds", false}; + + + app->SetDefaultParameter("EEMC:B0ECalClusters:input_protoclust_tag", m_input_protoclust_tag, "Name of input collection to use"); + app->SetDefaultParameter("EEMC:B0ECalClusters:samplingFraction", m_sampFrac); + app->SetDefaultParameter("EEMC:B0ECalClusters:logWeightBase", m_logWeightBase); + app->SetDefaultParameter("EEMC:B0ECalClusters:depthCorrection", m_depthCorrection); + app->SetDefaultParameter("EEMC:B0ECalClusters:energyWeight", m_energyWeight); + app->SetDefaultParameter("EEMC:B0ECalClusters:moduleDimZName", m_moduleDimZName); + app->SetDefaultParameter("EEMC:B0ECalClusters:enableEtaBounds", m_enableEtaBounds); + + m_geoSvc = app->template GetService(); + + std::string tag=this->GetTag(); + std::shared_ptr m_log = app->GetService()->logger(tag); + + // Get log level from user parameter or default + std::string log_level_str = "info"; + auto pm = app->GetJParameterManager(); + pm->SetDefaultParameter(tag + ":LogLevel", log_level_str, "verbosity: trace, debug, info, warn, err, critical, off"); + m_log->set_level(eicrecon::ParseLogLevel(log_level_str)); + + + AlgorithmInit(m_log); + } + + //------------------------------------------ + // ChangeRun + void ChangeRun(const std::shared_ptr &event) override{ + AlgorithmChangeRun(); + } + + //------------------------------------------ + // Process + void Process(const std::shared_ptr &event) override{ + + + // Prefill inputs + m_inputSimhits=event->Get(m_input_simhit_tag); + m_inputProto=event->Get(m_input_protoclust_tag); + + // Call Process for generic algorithm + AlgorithmProcess(); + + + //outputs + + // Hand owner of algorithm objects over to JANA + Set(m_outputClusters); + event->Insert(m_outputAssociations, "B0ECalClusterAssociations"); + m_outputClusters.clear(); // not really needed, but better to not leave dangling pointers around + m_outputAssociations.clear(); + } +}; + diff --git a/src/detectors/B0ECAL/Cluster_factory_B0ECalMergedClusters.h b/src/detectors/B0ECAL/Cluster_factory_B0ECalMergedClusters.h new file mode 100644 index 0000000000..9b7f4b40d6 --- /dev/null +++ b/src/detectors/B0ECAL/Cluster_factory_B0ECalMergedClusters.h @@ -0,0 +1,80 @@ +// Copyright 2022, Thomas Britton +// Subject to the terms in the LICENSE file found in the top-level directory. +// + +#pragma once + +#include + +#include +#include +#include +#include +#include + + + +class Cluster_factory_B0ECalMergedClusters : public JFactoryT, CalorimeterClusterMerger { + +public: + //------------------------------------------ + // Constructor + Cluster_factory_B0ECalMergedClusters(){ + SetTag("B0ECalMergedClusters"); + } + + //------------------------------------------ + // Init + void Init() override{ + auto app = GetApplication(); + //-------- Configuration Parameters ------------ + m_input_tag="B0ECalClusters"; + m_inputAssociations_tag="B0ECalClusterAssociations"; + + std::string tag=this->GetTag(); + std::shared_ptr m_log = app->GetService()->logger(tag); + + app->SetDefaultParameter("EEMC:B0ECalMergedClusters:input_tag", m_input_tag, "Name of input collection to use"); + app->SetDefaultParameter("EEMC:B0ECalMergedClusters:inputAssociations_tag", m_inputAssociations_tag, "Name of input associations collection to use"); + + // Get log level from user parameter or default + std::string log_level_str = "info"; + auto pm = app->GetJParameterManager(); + pm->SetDefaultParameter(tag + ":LogLevel", log_level_str, "verbosity: trace, debug, info, warn, err, critical, off"); + m_log->set_level(eicrecon::ParseLogLevel(log_level_str)); + + AlgorithmInit(m_log); + } + + //------------------------------------------ + // ChangeRun + void ChangeRun(const std::shared_ptr &event) override{ + AlgorithmChangeRun(); + } + + //------------------------------------------ + // Process + void Process(const std::shared_ptr &event) override{ + + + // Prefill inputs + m_inputClusters=event->Get(m_input_tag); + m_inputAssociations=event->Get(m_inputAssociations_tag); + + // Call Process for generic algorithm + AlgorithmProcess(); + + //outputs + // Hand owner of algorithm objects over to JANA + Set(m_outputClusters); + event->Insert(m_outputAssociations, "B0ECalMergedClustersAssociations"); + m_outputClusters.clear(); // not really needed, but better to not leave dangling pointers around + m_outputAssociations.clear(); + } + +private: + // Name of input data type (collection) + std::string m_input_tag; + std::string m_inputAssociations_tag; +}; + diff --git a/src/detectors/B0ECAL/ProtoCluster_factory_B0ECalIslandProtoClusters.h b/src/detectors/B0ECAL/ProtoCluster_factory_B0ECalIslandProtoClusters.h new file mode 100644 index 0000000000..e5f0a83100 --- /dev/null +++ b/src/detectors/B0ECAL/ProtoCluster_factory_B0ECalIslandProtoClusters.h @@ -0,0 +1,87 @@ +// 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 + +class ProtoCluster_factory_B0ECalIslandProtoClusters : public JFactoryT, CalorimeterIslandCluster { + +public: + //------------------------------------------ + // Constructor + ProtoCluster_factory_B0ECalIslandProtoClusters(){ + SetTag("B0ECalIslandProtoClusters"); + } + + //------------------------------------------ + // Init + void Init() override{ + auto app = GetApplication(); + m_input_tag = "B0ECalRecHits"; + + m_splitCluster=false; // from ATHENA reconstruction.py + m_minClusterHitEdep=30.0 * MeV; // from ATHENA reconstruction.py + m_minClusterCenterEdep=1.0 * MeV; // from ATHENA reconstruction.py + + // neighbour checking distances + m_sectorDist=5.0 * cm; // from ATHENA reconstruction.py + u_localDistXY={}; //{this, "localDistXY", {}}; + u_localDistXZ={}; //{this, "localDistXZ", {}}; + u_localDistYZ={}; //{this, "localDistYZ", {}}; + u_globalDistRPhi={}; //{this, "globalDistRPhi", {}}; + u_globalDistEtaPhi={};//{this, "globalDistEtaPhi", {}}; + u_dimScaledLocalDistXY={1.8,1.8};// from ATHENA reconstruction.py + + app->SetDefaultParameter("B0ECAL:B0ECalIslandProtoClusters:input_tag", m_input_tag, "Name of input collection to use"); + app->SetDefaultParameter("B0ECAL:B0ECalIslandProtoClusters:splitCluster", m_splitCluster); + app->SetDefaultParameter("B0ECAL:B0ECalIslandProtoClusters:minClusterHitEdep", m_minClusterHitEdep); + app->SetDefaultParameter("B0ECAL:B0ECalIslandProtoClusters:minClusterCenterEdep", m_minClusterCenterEdep); + app->SetDefaultParameter("B0ECAL:B0ECalIslandProtoClusters:sectorDist", m_sectorDist); + app->SetDefaultParameter("B0ECAL:B0ECalIslandProtoClusters:localDistXY", u_localDistXY); + app->SetDefaultParameter("B0ECAL:B0ECalIslandProtoClusters:localDistXZ", u_localDistXZ); + app->SetDefaultParameter("B0ECAL:B0ECalIslandProtoClusters:localDistYZ", u_localDistYZ); + app->SetDefaultParameter("B0ECAL:B0ECalIslandProtoClusters:globalDistRPhi", u_globalDistRPhi); + app->SetDefaultParameter("B0ECAL:B0ECalIslandProtoClusters:globalDistEtaPhi", u_globalDistEtaPhi); + app->SetDefaultParameter("B0ECAL:B0ECalIslandProtoClusters:dimScaledLocalDistXY", u_dimScaledLocalDistXY); + m_geoSvc = app->template GetService(); + + std::string tag=this->GetTag(); + std::shared_ptr m_log = app->GetService()->logger(tag); + + // Get log level from user parameter or default + std::string log_level_str = "info"; + auto pm = app->GetJParameterManager(); + pm->SetDefaultParameter(tag + ":LogLevel", log_level_str, "verbosity: trace, debug, info, warn, err, critical, off"); + m_log->set_level(eicrecon::ParseLogLevel(log_level_str)); + AlgorithmInit(m_log); + } + + //------------------------------------------ + // ChangeRun + void ChangeRun(const std::shared_ptr &event) override{ + AlgorithmChangeRun(); + } + + //------------------------------------------ + // Process + void Process(const std::shared_ptr &event) override{ + // Prefill inputs + hits = event->Get(m_input_tag); + + // Call Process for generic algorithm + AlgorithmProcess(); + + // Hand owner of algorithm objects over to JANA + Set(protoClusters); + protoClusters.clear(); // not really needed, but better to not leave dangling pointers around + } +}; + diff --git a/src/detectors/B0ECAL/ProtoCluster_factory_B0ECalTruthProtoClusters.h b/src/detectors/B0ECAL/ProtoCluster_factory_B0ECalTruthProtoClusters.h new file mode 100644 index 0000000000..be1fcd95f2 --- /dev/null +++ b/src/detectors/B0ECAL/ProtoCluster_factory_B0ECalTruthProtoClusters.h @@ -0,0 +1,62 @@ +// Copyright 2022, David Lawrence +// Subject to the terms in the LICENSE file found in the top-level directory. +// + +#pragma once + +#include + +#include +#include +#include + + + +class ProtoCluster_factory_B0ECalTruthProtoClusters : public JFactoryT, CalorimeterTruthClustering { + +public: + //------------------------------------------ + // Constructor + ProtoCluster_factory_B0ECalTruthProtoClusters(){ + SetTag("B0ECalTruthProtoClusters"); + } + + //------------------------------------------ + // Init + void Init() override{ + auto app = GetApplication(); + m_inputHit_tag="B0ECalRecHits"; + m_inputMCHit_tag="B0ECalHits"; + + app->SetDefaultParameter("EEMC:B0ECalTruthProtoClusters:inputHit_tag", m_inputHit_tag, "Name of input collection to use"); + + AlgorithmInit(); + } + + //------------------------------------------ + // ChangeRun + void ChangeRun(const std::shared_ptr &event) override{ + AlgorithmChangeRun(); + } + + //------------------------------------------ + // Process + void Process(const std::shared_ptr &event) override{ + // Prefill inputs + m_inputHits = event->Get(m_inputHit_tag); + m_mcHits = event->Get(m_inputMCHit_tag); + + // Call Process for generic algorithm + AlgorithmProcess(); + + // Hand owner of algorithm objects over to JANA + Set(m_outputProtoClusters); + m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + } + +private: + // Name of input data type (collection) + std::string m_inputHit_tag; + std::string m_inputMCHit_tag; +}; + diff --git a/src/detectors/B0ECAL/RawCalorimeterHit_factory_B0ECalRawHits.h b/src/detectors/B0ECAL/RawCalorimeterHit_factory_B0ECalRawHits.h new file mode 100644 index 0000000000..361f73ea4b --- /dev/null +++ b/src/detectors/B0ECAL/RawCalorimeterHit_factory_B0ECalRawHits.h @@ -0,0 +1,103 @@ +// 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 +#include +#include +#include + +using namespace dd4hep; + + +class RawCalorimeterHit_factory_B0ECalRawHits : public JFactoryT, CalorimeterHitDigi { + +public: + + //------------------------------------------ + // Constructor + RawCalorimeterHit_factory_B0ECalRawHits() { + SetTag("B0ECalRawHits"); + } + + //------------------------------------------ + // Init + void Init() override { + auto app = GetApplication(); + + // Set default values for all config. parameters in CalorimeterHitDigi algorithm + m_input_tag = "B0ECalHits"; + u_eRes = {0.0,0.02,0.0}; + m_tRes = 0.0 * ns; + m_capADC = 16384; + m_dyRangeADC = 1 * GeV; + m_pedMeanADC = 100; + m_pedSigmaADC = 1; + m_resolutionTDC = 1e-11; + m_corrMeanScale = 1.0; + u_fields={}; + u_refs={}; + 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:input_tag", m_input_tag, "Name of input collection to use"); + 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:fieldRefNumbers", u_refs); + app->SetDefaultParameter("B0ECAL:B0ECalRawHits:geoServiceName", m_geoSvcName); + app->SetDefaultParameter("B0ECAL:B0ECalRawHits:readoutClass", m_readout); + + // Call Init for generic algorithm + std::string tag=this->GetTag(); + std::shared_ptr m_log = app->GetService()->logger(tag); + + // Get log level from user parameter or default + std::string log_level_str = "info"; + auto pm = app->GetJParameterManager(); + pm->SetDefaultParameter(tag + ":LogLevel", log_level_str, "verbosity: trace, debug, info, warn, err, critical, off"); + m_log->set_level(eicrecon::ParseLogLevel(log_level_str)); + AlgorithmInit(m_log); + } + + //------------------------------------------ + // ChangeRun + void ChangeRun(const std::shared_ptr &event) override { + AlgorithmChangeRun(); + } + + //------------------------------------------ + // Process + void Process(const std::shared_ptr &event) override { + // Prefill inputs + simhits = event->Get(m_input_tag); + + // Call Process for generic algorithm + AlgorithmProcess(); + + // Hand owner of algorithm objects over to JANA + Set(rawhits); + rawhits.clear(); // not really needed, but better to not leave dangling pointers around + } + +}; + diff --git a/src/detectors/B0ECAL/TruthCluster_factory_B0ECalTruthProtoClusters.h b/src/detectors/B0ECAL/TruthCluster_factory_B0ECalTruthProtoClusters.h new file mode 100644 index 0000000000..0dea5c6cc1 --- /dev/null +++ b/src/detectors/B0ECAL/TruthCluster_factory_B0ECalTruthProtoClusters.h @@ -0,0 +1,61 @@ +// Copyright 2022, David Lawrence +// Subject to the terms in the LICENSE file found in the top-level directory. +// + +#pragma once + +#include + +#include +#include +#include + +class TruthCluster_factory_B0ECalTruthProtoClusters : public JFactoryT, CalorimeterTruthClustering { + +public: + //------------------------------------------ + // Constructor + TruthCluster_factory_B0ECalTruthProtoClusters(){ + SetTag("B0ECalTruthProtoClusters"); + } + + //------------------------------------------ + // Init + void Init() override{ + auto app = GetApplication(); + m_inputHit_tag = "B0ECalTruthProtoClusters"; + m_inputMCHit_tag = "B0ECalHits"; + + app->SetDefaultParameter("EEMC:B0ECalTruthProtoClusters:inputHit_tag", m_inputHit_tag, "Name of input collection to use"); + + AlgorithmInit(); + } + + //------------------------------------------ + // ChangeRun + void ChangeRun(const std::shared_ptr &event) override{ + AlgorithmChangeRun(); + } + + //------------------------------------------ + // Process + void Process(const std::shared_ptr &event) override{ + // Prefill inputs + m_inputHits = event->Get(m_inputHit_tag); + m_mcHits = event->Get(m_inputMCHit_tag); + + // Call Process for generic algorithm + AlgorithmProcess(); + + // Hand owner of algorithm objects over to JANA + Set(m_outputProtoClusters); + m_outputProtoClusters.clear(); // not really needed, but better to not leave dangling pointers around + } + +private: + // Name of input data type (collection) + std::string m_inputHit_tag; + std::string m_inputMCHit_tag; + +}; + diff --git a/src/detectors/CMakeLists.txt b/src/detectors/CMakeLists.txt index ae3f1950f0..8c12e8b736 100644 --- a/src/detectors/CMakeLists.txt +++ b/src/detectors/CMakeLists.txt @@ -2,6 +2,7 @@ add_subdirectory(BEMC) add_subdirectory(EEMC) add_subdirectory(HCAL) add_subdirectory(ZDC) +add_subdirectory(B0ECAL) # Tracking detectors add_subdirectory(BTRK) # Barrel tracker diff --git a/src/tools/default_flags_table/reco_flags.py b/src/tools/default_flags_table/reco_flags.py index 7ab4fe98a7..9a4deb51ff 100644 --- a/src/tools/default_flags_table/reco_flags.py +++ b/src/tools/default_flags_table/reco_flags.py @@ -222,22 +222,13 @@ ('EEMC:EcalEndcapNTruthClusters:moduleDimZName', '', ''), ('EEMC:EcalEndcapNTruthClusters:samplingFraction', '0.03', '*'), + ('EEMC:EcalEndcapNClusters:input_protoclust_tag', 'EcalEndcapNHits', ''), + ('EEMC:EcalEndcapNClusters:samplingFraction', '1', ''), + ('EEMC:EcalEndcapNClusters:logWeightBase', '3.6', ''), ('EEMC:EcalEndcapNClusters:depthCorrection', '0', ''), - ('EEMC:EcalEndcapNClusters:dimScaledLocalDistXY', '1.8,1.8', '*'), - ('EEMC:EcalEndcapNClusters:enableEtaBounds', '0', ''), ('EEMC:EcalEndcapNClusters:energyWeight', 'log', ''), - ('EEMC:EcalEndcapNClusters:globalDistEtaPhi', '', ''), - ('EEMC:EcalEndcapNClusters:globalDistRPhi', '', ''), - ('EEMC:EcalEndcapNClusters:localDistXY', '', ''), - ('EEMC:EcalEndcapNClusters:localDistXZ', '', ''), - ('EEMC:EcalEndcapNClusters:localDistYZ', '', ''), - ('EEMC:EcalEndcapNClusters:logWeightBase', '3.6', ''), - ('EEMC:EcalEndcapNClusters:minClusterCenterEdep', '0.03', ''), - ('EEMC:EcalEndcapNClusters:minClusterHitEdep', '0.001', ''), ('EEMC:EcalEndcapNClusters:moduleDimZName', '', ''), - ('EEMC:EcalEndcapNClusters:samplingFraction', '1', ''), - ('EEMC:EcalEndcapNClusters:sectorDist', '5', ''), - ('EEMC:EcalEndcapNClusters:splitCluster', '0', ''), + ('EEMC:EcalEndcapNClusters:enableEtaBounds', '0', ''), # Positive Endcap ('EEMC:EcalEndcapPRawHits:capacityADC', 'capacityBitsADC=14', '*'), @@ -286,23 +277,6 @@ ('EEMC:EcalEndcapPTruthClusters:moduleDimZName', '', ''), ('EEMC:EcalEndcapPTruthClusters:samplingFraction', '1', ''), - ('EEMC:EcalEndcapPClusters:depthCorrection', '0', ''), - ('EEMC:EcalEndcapPClusters:dimScaledLocalDistXY', '1.8,1.8', ''), - ('EEMC:EcalEndcapPClusters:enableEtaBounds', '0', ''), - ('EEMC:EcalEndcapPClusters:energyWeight', 'log', ''), - ('EEMC:EcalEndcapPClusters:globalDistEtaPhi', '', ''), - ('EEMC:EcalEndcapPClusters:globalDistRPhi', '', ''), - ('EEMC:EcalEndcapPClusters:localDistXY', '', ''), - ('EEMC:EcalEndcapPClusters:localDistXZ', '', ''), - ('EEMC:EcalEndcapPClusters:localDistYZ', '', ''), - ('EEMC:EcalEndcapPClusters:logWeightBase', '3.6', ''), - ('EEMC:EcalEndcapPClusters:minClusterCenterEdep', '0.03', ''), - ('EEMC:EcalEndcapPClusters:minClusterHitEdep', '0.001', ''), - ('EEMC:EcalEndcapPClusters:moduleDimZName', '', ''), - ('EEMC:EcalEndcapPClusters:samplingFraction', '1', ''), - ('EEMC:EcalEndcapPClusters:sectorDist', '5', ''), - ('EEMC:EcalEndcapPClusters:splitCluster', '0', '*'), - # Positive Endcap insert ('EEMC:EcalEndcapPInsertRawHits:capacityADC', 'capacityBitsADC=14', '*'), ('EEMC:EcalEndcapPInsertRawHits:dynamicRangeADC', '3*GeV', '*'), @@ -350,6 +324,14 @@ ('EEMC:EcalEndcapPTruthClusters:moduleDimZName', '', ''), ('EEMC:EcalEndcapPTruthClusters:samplingFraction', '1', ''), + ('EEMC:EcalEndcapPInsertClusters:input_protoclust_tag', 'EcalEndcapPHits', ''), + ('EEMC:EcalEndcapPInsertClusters:samplingFraction', '1', ''), + ('EEMC:EcalEndcapPInsertClusters:logWeightBase', '3.6', ''), + ('EEMC:EcalEndcapPInsertClusters:depthCorrection', '0', ''), + ('EEMC:EcalEndcapPInsertClusters:energyWeight', 'log', ''), + ('EEMC:EcalEndcapPInsertClusters:moduleDimZName', '', ''), + ('EEMC:EcalEndcapPInsertClusters:enableEtaBounds', '0', ''), + ('EEMC:EcalEndcapPInsertClusters:depthCorrection', '0', ''), ('EEMC:EcalEndcapPInsertClusters:dimScaledLocalDistXY', '1.8,1.8', ''), ('EEMC:EcalEndcapPInsertClusters:enableEtaBounds', '0', ''), @@ -367,6 +349,56 @@ ('EEMC:EcalEndcapPInsertClusters:sectorDist', '5', ''), ('EEMC:EcalEndcapPInsertClusters:splitCluster', '0', '*'), + # B0ECAL - Far forward B0 Ecal + # ----------------- + ('B0ECAL:B0ECalRawHits:capacityADC', 'capacityBitsADC=14', '*'), + ('B0ECAL:B0ECalRawHits:dynamicRangeADC', '1*GeV', '*'), + ('B0ECAL:B0ECalRawHits:energyResolutions', '0.0,0.02,0.0', '*'), + ('B0ECAL:B0ECalRawHits:fieldRefNumbers', '', ''), + ('B0ECAL:B0ECalRawHits:geoServiceName', '', ''), + ('B0ECAL:B0ECalRawHits:pedestalMean', '100', '*'), + ('B0ECAL:B0ECalRawHits:pedestalSigma', '1', ''), + ('B0ECAL:B0ECalRawHits:readoutClass', '', ''), + ('B0ECAL:B0ECalRawHits:resolutionTDC', '1e-11', ''), + ('B0ECAL:B0ECalRawHits:scaleResponse', '1', ''), + ('B0ECAL:B0ECalRawHits:signalSumFields', '', ''), + ('B0ECAL:B0ECalRawHits:timeResolution', '0', ''), + + ('B0ECAL:B0ECalRecHits:capacityADC', 'capacityBitsADC=14', '*'), + ('B0ECAL:B0ECalRecHits:dynamicRangeADC', '20*GeV', '*'), + ('B0ECAL:B0ECalRecHits:geoServiceName', '', ''), + ('B0ECAL:B0ECalRecHits:layerField', '', ''), + ('B0ECAL:B0ECalRecHits:localDetElement', '', ''), + ('B0ECAL:B0ECalRecHits:localDetFields', '', ''), + ('B0ECAL:B0ECalRecHits:pedestalMean', '100', '*'), + ('B0ECAL:B0ECalRecHits:pedestalSigma', '1', '*'), + ('B0ECAL:B0ECalRecHits:readout', 'B0ECalHits', ''), + ('B0ECAL:B0ECalRecHits:resolutionTDC', '1e-11', ''), + ('B0ECAL:B0ECalRecHits:samplingFraction', '0.998', '*'), + ('B0ECAL:B0ECalRecHits:sectorField', 'sector', ''), + ('B0ECAL:B0ECalRecHits:thresholdFactor', '4', '*'), + ('B0ECAL:B0ECalRecHits:thresholdValue', '3', '*'), + + ('B0ECAL:B0ECalIslandProtoClusters:input_tag', 'B0ECalRecHits', ''), + ('B0ECAL:B0ECalIslandProtoClusters:splitCluster', '0', '*'), + ('B0ECAL:B0ECalIslandProtoClusters:minClusterHitEdep', '30*MeV', '*'), + ('B0ECAL:B0ECalIslandProtoClusters:minClusterCenterEdep', '1.0*MeV', '*'), + ('B0ECAL:B0ECalIslandProtoClusters:sectorDist', '5.0*cm', '*'), + ('B0ECAL:B0ECalIslandProtoClusters:localDistXY', '', ''), + ('B0ECAL:B0ECalIslandProtoClusters:localDistXZ', '', ''), + ('B0ECAL:B0ECalIslandProtoClusters:localDistYZ', '', ''), + ('B0ECAL:B0ECalIslandProtoClusters:globalDistRPhi', '', ''), + ('B0ECAL:B0ECalIslandProtoClusters:globalDistEtaPhi', '', ''), + ('B0ECAL:B0ECalIslandProtoClusters:dimScaledLocalDistXY', '1.8,1.8', '*'), + + ('B0ECAL:B0ECalClusters:input_protoclust_tag', 'B0ECalIslandProtoClusters', ''), + ('B0ECAL:B0ECalClusters:samplingFraction', '1', ''), + ('B0ECAL:B0ECalClusters:logWeightBase', '3.6', ''), + ('B0ECAL:B0ECalClusters:depthCorrection', '0', ''), + ('B0ECAL:B0ECalClusters:energyWeight', 'log', ''), + ('B0ECAL:B0ECalClusters:moduleDimZName', '', ''), + ('B0ECAL:B0ECalClusters:enableEtaBounds', '0', ''), + # HCAL Barrel # ----------- ('HCAL:HcalBarrelRawHits:capacityADC', 'capacityBitsADC=8', '*'), From eb6cb1643d72b56c523023fafa24432e989b6716 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Sat, 22 Oct 2022 13:27:25 -0400 Subject: [PATCH 3/7] Add B0 Ecal to standard eicrecon plugins and add rechits and clusters to standard save list. --- src/services/io/podio/JEventProcessorPODIO.cc | 2 ++ src/utilities/eicrecon/eicrecon.cc | 1 + 2 files changed, 3 insertions(+) diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index ceecbda911..e8ac90cb54 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -95,6 +95,8 @@ JEventProcessorPODIO::JEventProcessorPODIO() { // "HcalEndcapPTruthClusters", // This gives lots of errors from volume manager on "unknown identifier" "HcalBarrelTruthClusters", "EcalBarrelTruthClusters", + "B0ECalRecHits", + "B0ECalClusters", "ZDCEcalTruthClusters", "SmearedFarForwardParticles" }; diff --git a/src/utilities/eicrecon/eicrecon.cc b/src/utilities/eicrecon/eicrecon.cc index 5eeef6e351..25f149cdf9 100644 --- a/src/utilities/eicrecon/eicrecon.cc +++ b/src/utilities/eicrecon/eicrecon.cc @@ -25,6 +25,7 @@ std::vector EICRECON_DEFAULT_PLUGINS = { "tracking", "BEMC", "HCAL", + "B0ECAL", "ZDC", "BTRK", "BVTX", From 1e03973170b6a0d095a52411c67c337985e270cf Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Sat, 22 Oct 2022 14:57:51 -0400 Subject: [PATCH 4/7] Add mrad unit. --- src/tools/default_flags_table/reco_flags.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tools/default_flags_table/reco_flags.py b/src/tools/default_flags_table/reco_flags.py index 9a4deb51ff..757d97d491 100644 --- a/src/tools/default_flags_table/reco_flags.py +++ b/src/tools/default_flags_table/reco_flags.py @@ -796,6 +796,12 @@ km3 = kilometer3 pc = parsec +# Angle [A] +# +radian = 1. +mrad = radian/1000.0 +degree = 0.017453292519943*radian + # ======================================================================================================================================================== # The next code allows to execute this file From 1f81bddd2c55b782cba3f63e9f756aaa60983dd3 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Sat, 22 Oct 2022 15:49:05 -0400 Subject: [PATCH 5/7] Fix multi-value parameters trying to use units. Units should be pre-multiplied and than specified in comments. Otherwise, python stringifies them with parentheses and spaces. --- src/tools/default_flags_table/reco_flags.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/default_flags_table/reco_flags.py b/src/tools/default_flags_table/reco_flags.py index 757d97d491..a7e52abc1a 100644 --- a/src/tools/default_flags_table/reco_flags.py +++ b/src/tools/default_flags_table/reco_flags.py @@ -134,8 +134,8 @@ ('BEMC:EcalBarrelscFiMergedHits:refs', '1,1', ''), ('BEMC:EcalBarrelImagingProtoClusters:input_tag', 'EcalBarrelImagingRecHits', 'Name of input collection to use'), - ('BEMC:EcalBarrelImagingProtoClusters::localDistXY', '2.0*mm,2*mm', ''), - ('BEMC:EcalBarrelImagingProtoClusters::layerDistEtaPhi', '10*mrad,10*mrad', ''), + ('BEMC:EcalBarrelImagingProtoClusters::localDistXY', '2.0,2.0', '* [mm]'), + ('BEMC:EcalBarrelImagingProtoClusters::layerDistEtaPhi', '0.01,0.01', '* [radian]'), ('BEMC:EcalBarrelImagingProtoClusters::neighbourLayersRange', '2.0', ''), ('BEMC:EcalBarrelImagingProtoClusters::sectorDist', '3.0*cm', ''), ('BEMC:EcalBarrelImagingProtoClusters::minClusterHitEdep', '0.', ''), @@ -149,7 +149,7 @@ ('BEMC:EcalBarrelScFiProtoClusters:minClusterCenterEdep', '10.0*MeV', ''), ('BEMC:EcalBarrelScFiProtoClusters:sectorDist', '5.0*cm', ''), ('BEMC:EcalBarrelScFiProtoClusters:localDistXY', '', ''), - ('BEMC:EcalBarrelScFiProtoClusters:localDistXZ', '30*mm, 30*mm', ''), + ('BEMC:EcalBarrelScFiProtoClusters:localDistXZ', '30.0,30.0', '* [mm]'), ('BEMC:EcalBarrelScFiProtoClusters:localDistYZ', '', ''), ('BEMC:EcalBarrelScFiProtoClusters:globalDistRPhi', '', ''), ('BEMC:EcalBarrelScFiProtoClusters:globalDistEtaPhi', '', ''), From b42d6bdb359f72e9c36918c9c105826112e6d520 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Sun, 23 Oct 2022 11:21:15 -0400 Subject: [PATCH 6/7] Fix wrong value for EEMC:EcalEndcapNClusters:input_protoclust_tag. --- src/tools/default_flags_table/reco_flags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/default_flags_table/reco_flags.py b/src/tools/default_flags_table/reco_flags.py index a7e52abc1a..22ac011ef9 100644 --- a/src/tools/default_flags_table/reco_flags.py +++ b/src/tools/default_flags_table/reco_flags.py @@ -222,7 +222,7 @@ ('EEMC:EcalEndcapNTruthClusters:moduleDimZName', '', ''), ('EEMC:EcalEndcapNTruthClusters:samplingFraction', '0.03', '*'), - ('EEMC:EcalEndcapNClusters:input_protoclust_tag', 'EcalEndcapNHits', ''), + ('EEMC:EcalEndcapNClusters:input_protoclust_tag', 'EcalEndcapNIslandProtoClusters', ''), ('EEMC:EcalEndcapNClusters:samplingFraction', '1', ''), ('EEMC:EcalEndcapNClusters:logWeightBase', '3.6', ''), ('EEMC:EcalEndcapNClusters:depthCorrection', '0', ''), From 3bcf75ccc9b7a548c649031e71d9f8a70feb46e1 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Sun, 23 Oct 2022 11:22:15 -0400 Subject: [PATCH 7/7] Give much more informative error/warnings for local field decoding. --- .../calorimetry/CalorimeterHitReco.cc | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitReco.cc b/src/algorithms/calorimetry/CalorimeterHitReco.cc index 758531476d..b1f7d9211c 100644 --- a/src/algorithms/calorimetry/CalorimeterHitReco.cc +++ b/src/algorithms/calorimetry/CalorimeterHitReco.cc @@ -40,17 +40,29 @@ void CalorimeterHitReco::AlgorithmInit(std::shared_ptr& logger) id_dec = id_spec.decoder(); if (!m_sectorField.empty()) { sector_idx = id_dec->index(m_sectorField); - //LOG_INFO(default_cerr_logger) << "Find sector field " << m_sectorField << ", index = " << sector_idx << LOG_END; m_logger->info("Find sector field {}, index = {}", m_sectorField, sector_idx); } if (!m_layerField.empty()) { layer_idx = id_dec->index(m_layerField); - //LOG_INFO(default_cerr_logger) << "Find layer field " << m_layerField << ", index = " << sector_idx << LOG_END; m_logger->info("Find layer field {}, index = {}", m_layerField, sector_idx); } } catch (...) { - //LOG_ERROR(default_cerr_logger) << "Failed to load ID decoder for " << m_readout << LOG_END; - m_logger->error("Failed to load ID decoder for {}", m_readout); + if( !id_dec ) { + m_logger->error("Failed to load ID decoder for {}", m_readout); + std::stringstream readouts; + for (auto r: m_geoSvc->detector()->readouts()) readouts << "\"" << r.first << "\", "; + m_logger->warn("Available readouts: {}", readouts.str() ); + }else { + m_logger->warn("Failed to find field index for {}.", m_readout); + if (!m_sectorField.empty()) { m_logger->warn(" -- looking for sector field \"{}\".", m_sectorField); } + if (!m_layerField.empty()) { m_logger->warn(" -- looking for layer field \"{}\".", m_layerField); } + std::stringstream fields; + for (auto field: id_spec.decoder()->fields()) fields << "\"" << field.name() << "\", "; + m_logger->warn("Available fields: {}", fields.str() ); + m_logger->warn("n.b. The local position, sector id and layer id will not be correct for this."); + m_logger->warn("however, the position, energy, and time values should still be good."); + } + return; } @@ -59,10 +71,8 @@ void CalorimeterHitReco::AlgorithmInit(std::shared_ptr& logger) if (!m_localDetElement.empty()) { try { local = m_geoSvc->detector()->detector(m_localDetElement); - //LOG_INFO(default_cerr_logger) << "local coordinate system from DetElement " << m_localDetElement << LOG_END; m_logger->info("local coordinate system from DetElement {}", m_localDetElement); } catch (...) { - //LOG_ERROR(default_cerr_logger) << "failed to load local coordinate system from DetElement " << m_localDetElement << LOG_END; m_logger->error("failed to load local coordinate system from DetElement {}", m_localDetElement); return; }