From 47b0cdff2db150746cf857ea71955e4934d3d614 Mon Sep 17 00:00:00 2001 From: chchatte92 Date: Wed, 11 Oct 2023 00:04:52 +0200 Subject: [PATCH 01/12] Modified to extract sensor normalZ --- src/services/geometry/richgeo/IrtGeoDRICH.cc | 42 ++++++++++++++++++-- src/services/geometry/richgeo/IrtGeoDRICH.h | 2 +- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/services/geometry/richgeo/IrtGeoDRICH.cc b/src/services/geometry/richgeo/IrtGeoDRICH.cc index 26596a4686..9669d01d4c 100644 --- a/src/services/geometry/richgeo/IrtGeoDRICH.cc +++ b/src/services/geometry/richgeo/IrtGeoDRICH.cc @@ -2,7 +2,7 @@ // Subject to the terms in the LICENSE file found in the top-level directory. #include "IrtGeoDRICH.h" - +#include void richgeo::IrtGeoDRICH::DD4hep_to_IRT() { // begin envelope @@ -87,7 +87,6 @@ void richgeo::IrtGeoDRICH::DD4hep_to_IRT() { // sector loop for (int isec = 0; isec < nSectors; isec++) { std::string secName = "sec" + std::to_string(isec); - // mirrors auto mirrorRadius = m_det->constant("DRICH_mirror_radius") / dd4hep::mm; dd4hep::Position mirrorCenter( @@ -186,7 +185,44 @@ void richgeo::IrtGeoDRICH::DD4hep_to_IRT() { // define the `cell ID -> pixel position` converter SetReadoutIDToPositionLambda(); } - +TVector3 richgeo::IrtGeoDRICH::GetSensorSurface(CellIDType id){ + printf("This is just a test\n"); + auto nSectors= m_det->constant("DRICH_num_sectors"); + TVector3 normX(1, 0, 0); // normal vectors + TVector3 normY(0, -1, 0); + TVector3 sensorNorm; + auto cellMask = uint64_t(std::stoull(m_det->constant("DRICH_cell_mask"))); + for (int isec = 0; isec < nSectors; isec++) { + std::string secName = "sec" + std::to_string(isec); + auto sensorThickness = m_det->constant("DRICH_sensor_thickness") / dd4hep::mm; + auto sensorSize = m_det->constant("DRICH_sensor_size") / dd4hep::mm; + for(auto const& [de_name, detSensor] : m_detRich.children()) { + if(de_name.find("sensor_de_"+secName)!=std::string::npos) { + // get sensor info + const auto sensorID = detSensor.id(); + const auto detSensorPars = detSensor.extension(true); + if(detSensorPars==nullptr) + throw std::runtime_error(fmt::format("sensor '{}' does not have VariantParameters", de_name)); + // - sensor surface position + auto posSensor = GetVectorFromVariantParameters(detSensorPars, "pos") / dd4hep::mm; + // - sensor orientation + auto normXdir = GetVectorFromVariantParameters(detSensorPars, "normX"); + auto normYdir = GetVectorFromVariantParameters(detSensorPars, "normY"); + auto normZdir = normXdir.Cross(normYdir); // sensor surface normal + // - surface offset, used to convert sensor volume centroid to sensor surface centroid + auto surfaceOffset = normZdir.Unit() * (0.5*sensorThickness); + sensorNorm.SetX(static_cast(normZdir.x())); + sensorNorm.SetY(static_cast(normZdir.y())); + sensorNorm.SetZ(static_cast(normZdir.z())); + auto sID = id & cellMask; + if(sensorID == sID){ + //std::cout<<"x,y,z: "< det_, gsl::not_null conv_, std::shared_ptr log_) : IrtGeo("DRICH",det_,conv_,log_) { DD4hep_to_IRT(); } ~IrtGeoDRICH(); - + TVector3 GetSensorSurface(CellIDType); protected: void DD4hep_to_IRT() override; From a2be1ba2e255471ad531e0de184655672f3c447c Mon Sep 17 00:00:00 2001 From: chchatte92 Date: Wed, 11 Oct 2023 19:14:26 +0200 Subject: [PATCH 02/12] Fix: Removed Sensor Looping, Cleanup --- src/services/geometry/richgeo/IrtGeoDRICH.cc | 46 ++++++-------------- src/services/geometry/richgeo/RichGeo.h | 1 + 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/src/services/geometry/richgeo/IrtGeoDRICH.cc b/src/services/geometry/richgeo/IrtGeoDRICH.cc index 9669d01d4c..6e6864abf4 100644 --- a/src/services/geometry/richgeo/IrtGeoDRICH.cc +++ b/src/services/geometry/richgeo/IrtGeoDRICH.cc @@ -2,7 +2,6 @@ // Subject to the terms in the LICENSE file found in the top-level directory. #include "IrtGeoDRICH.h" -#include void richgeo::IrtGeoDRICH::DD4hep_to_IRT() { // begin envelope @@ -142,8 +141,8 @@ void richgeo::IrtGeoDRICH::DD4hep_to_IRT() { sensor_info.size = sensorSize; sensor_info.surface_centroid = posSensor; sensor_info.surface_offset = surfaceOffset; + sensor_info.surface_normZdir = normZdir; m_sensor_info.insert({ sensorID, sensor_info }); - // create the optical surface m_sensorFlatSurface = new FlatSurface( TVector3(posSensor.x(), posSensor.y(), posSensor.z()), @@ -186,42 +185,23 @@ void richgeo::IrtGeoDRICH::DD4hep_to_IRT() { SetReadoutIDToPositionLambda(); } TVector3 richgeo::IrtGeoDRICH::GetSensorSurface(CellIDType id){ - printf("This is just a test\n"); auto nSectors= m_det->constant("DRICH_num_sectors"); TVector3 normX(1, 0, 0); // normal vectors TVector3 normY(0, -1, 0); TVector3 sensorNorm; auto cellMask = uint64_t(std::stoull(m_det->constant("DRICH_cell_mask"))); - for (int isec = 0; isec < nSectors; isec++) { - std::string secName = "sec" + std::to_string(isec); - auto sensorThickness = m_det->constant("DRICH_sensor_thickness") / dd4hep::mm; - auto sensorSize = m_det->constant("DRICH_sensor_size") / dd4hep::mm; - for(auto const& [de_name, detSensor] : m_detRich.children()) { - if(de_name.find("sensor_de_"+secName)!=std::string::npos) { - // get sensor info - const auto sensorID = detSensor.id(); - const auto detSensorPars = detSensor.extension(true); - if(detSensorPars==nullptr) - throw std::runtime_error(fmt::format("sensor '{}' does not have VariantParameters", de_name)); - // - sensor surface position - auto posSensor = GetVectorFromVariantParameters(detSensorPars, "pos") / dd4hep::mm; - // - sensor orientation - auto normXdir = GetVectorFromVariantParameters(detSensorPars, "normX"); - auto normYdir = GetVectorFromVariantParameters(detSensorPars, "normY"); - auto normZdir = normXdir.Cross(normYdir); // sensor surface normal - // - surface offset, used to convert sensor volume centroid to sensor surface centroid - auto surfaceOffset = normZdir.Unit() * (0.5*sensorThickness); - sensorNorm.SetX(static_cast(normZdir.x())); - sensorNorm.SetY(static_cast(normZdir.y())); - sensorNorm.SetZ(static_cast(normZdir.z())); - auto sID = id & cellMask; - if(sensorID == sID){ - //std::cout<<"x,y,z: "<m_sensor_info; + auto sID = id & cellMask; + auto sensor_info_it = sensor_info.find(sID); + + auto sensor_obj = sensor_info_it->second; + auto normZdir = sensor_obj.surface_normZdir; + + sensorNorm.SetX(static_cast(normZdir.x())); + sensorNorm.SetY(static_cast(normZdir.y())); + sensorNorm.SetZ(static_cast(normZdir.z())); + //std::cout< Date: Wed, 11 Oct 2023 17:15:07 +0000 Subject: [PATCH 03/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/services/geometry/richgeo/IrtGeoDRICH.cc | 4 ++-- src/services/geometry/richgeo/RichGeo.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/geometry/richgeo/IrtGeoDRICH.cc b/src/services/geometry/richgeo/IrtGeoDRICH.cc index 6e6864abf4..10ea526ab1 100644 --- a/src/services/geometry/richgeo/IrtGeoDRICH.cc +++ b/src/services/geometry/richgeo/IrtGeoDRICH.cc @@ -141,7 +141,7 @@ void richgeo::IrtGeoDRICH::DD4hep_to_IRT() { sensor_info.size = sensorSize; sensor_info.surface_centroid = posSensor; sensor_info.surface_offset = surfaceOffset; - sensor_info.surface_normZdir = normZdir; + sensor_info.surface_normZdir = normZdir; m_sensor_info.insert({ sensorID, sensor_info }); // create the optical surface m_sensorFlatSurface = new FlatSurface( @@ -196,7 +196,7 @@ TVector3 richgeo::IrtGeoDRICH::GetSensorSurface(CellIDType id){ auto sensor_obj = sensor_info_it->second; auto normZdir = sensor_obj.surface_normZdir; - + sensorNorm.SetX(static_cast(normZdir.x())); sensorNorm.SetY(static_cast(normZdir.y())); sensorNorm.SetZ(static_cast(normZdir.z())); diff --git a/src/services/geometry/richgeo/RichGeo.h b/src/services/geometry/richgeo/RichGeo.h index 91486550ce..4f8c0705dc 100644 --- a/src/services/geometry/richgeo/RichGeo.h +++ b/src/services/geometry/richgeo/RichGeo.h @@ -24,7 +24,7 @@ namespace richgeo { double size; dd4hep::Position surface_centroid; dd4hep::Direction surface_offset; // surface centroid = volume centroid + `surface_offset` - dd4hep::Direction surface_normZdir; //normal Z direction of surface + dd4hep::Direction surface_normZdir; //normal Z direction of surface }; // logging From bdd0d88865b45a881e2330a3eb43d1a8b63c4fab Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Wed, 11 Oct 2023 07:21:43 -0400 Subject: [PATCH 04/12] TrackPropagation_factory: HcalBarrel_ID -> HCalBarrel_ID (#1070) Fixes: 6bef773f ('feat: add system and layer ID to Acts::Surface GeometryIdentifier') https://github.com/eic/EICrecon/actions/runs/6478157904/job/17589778133?pr=1069#step:5:605 > Error: [JEventProcessorPODIO] [error] Omitting PODIO collection 'CalorimeterTrackProjections' due to exception: getRefChild: Failed to find child with name: HcalBarrel_ID Map contains 1759 elements: ... --- src/global/tracking/TrackPropagation_factory.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/global/tracking/TrackPropagation_factory.cc b/src/global/tracking/TrackPropagation_factory.cc index 74a787d9a6..387f57013a 100644 --- a/src/global/tracking/TrackPropagation_factory.cc +++ b/src/global/tracking/TrackPropagation_factory.cc @@ -139,7 +139,7 @@ void eicrecon::TrackPropagation_factory::SetPropagationSurfaces() { auto OHCAL_Trf = transform * Acts::Translation3(Acts::Vector3(0, 0, 0)); auto OHCAL_prop_surface1 = Acts::Surface::makeShared(OHCAL_Trf, OHCAL_R, OHCAL_halfz); auto OHCAL_prop_surface2 = Acts::Surface::makeShared(OHCAL_Trf, OHCAL_R + HCAL_avgClusterDepth, OHCAL_halfz); - auto OHCAL_system_id = m_geoSvc->detector()->constant("HcalBarrel_ID"); + auto OHCAL_system_id = m_geoSvc->detector()->constant("HCalBarrel_ID"); OHCAL_prop_surface1->assignGeometryId(Acts::GeometryIdentifier().setExtra(OHCAL_system_id).setLayer(1)); OHCAL_prop_surface2->assignGeometryId(Acts::GeometryIdentifier().setExtra(OHCAL_system_id).setLayer(2)); m_target_surface_list.push_back(OHCAL_prop_surface1); From 97f2916ec146721134e8dd963cda70e43dfd78d9 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Sat, 14 Oct 2023 14:29:06 -0500 Subject: [PATCH 05/12] feat: fill Acts::GeometryIdentfier extra field with DD4hep detector ID (#1058) ### Briefly, what does this PR introduce? This sets up the Acts::GeometryIdentifierHook to get the DD4hep detector ID on geometry conversion. Also: makes the material decorator local instead of class member. ### 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 - [ ] Changes have been communicated to collaborators ### Does this PR introduce breaking changes? What changes might users need to make to their code? No. ### Does this PR change default behavior? No. --- .../tracking/ActsGeometryProvider.cc | 19 ++++++++++++++++--- .../tracking/ActsGeometryProvider.h | 3 --- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/algorithms/tracking/ActsGeometryProvider.cc b/src/algorithms/tracking/ActsGeometryProvider.cc index c917690c16..bde17b0115 100644 --- a/src/algorithms/tracking/ActsGeometryProvider.cc +++ b/src/algorithms/tracking/ActsGeometryProvider.cc @@ -113,17 +113,29 @@ void ActsGeometryProvider::initialize(const dd4hep::Detector* dd4hep_geo, // } // Load ACTS materials maps + std::shared_ptr materialDeco{nullptr}; if (!material_file.empty()) { m_init_log->info("loading materials map from file: '{}'", material_file); // Set up the converter first Acts::MaterialMapJsonConverter::Config jsonGeoConvConfig; // Set up the json-based decorator - m_materialDeco = std::make_shared(jsonGeoConvConfig, material_file,acts_init_log_level); + materialDeco = std::make_shared(jsonGeoConvConfig, material_file,acts_init_log_level); } else { m_init_log->warn("no ACTS materials map has been loaded"); - m_materialDeco = std::make_shared(); + materialDeco = std::make_shared(); } + // Geometry identifier hook to write detector ID to extra field + Acts::GeometryIdentifierHook geometryIdHook = [](Acts::GeometryIdentifier identifier, const Acts::Surface& surface) { + const auto* dd4hep_det_element = + dynamic_cast(surface.associatedDetectorElement()); + if (dd4hep_det_element == nullptr) { + return identifier; + } + // set 8-bit extra field to 8-bit DD4hep detector ID + return identifier.setExtra(0xff & dd4hep_det_element->identifier()); + }; + // Convert DD4hep geometry to ACTS m_init_log->info("Converting DD4Hep geometry to ACTS..."); Acts::BinningType bTypePhi = Acts::equidistant; @@ -146,7 +158,8 @@ void ActsGeometryProvider::initialize(const dd4hep::Detector* dd4hep_geo, defaultLayerThickness, sortDetElementsByID, m_trackingGeoCtx, - m_materialDeco); + materialDeco, + geometryIdHook); } catch(std::exception &ex) { m_init_log->error("Error during DD4Hep -> ACTS geometry conversion. See error reason below..."); diff --git a/src/algorithms/tracking/ActsGeometryProvider.h b/src/algorithms/tracking/ActsGeometryProvider.h index d983cf61ea..cd650bf800 100644 --- a/src/algorithms/tracking/ActsGeometryProvider.h +++ b/src/algorithms/tracking/ActsGeometryProvider.h @@ -98,9 +98,6 @@ class ActsGeometryProvider { /// ACTS Tracking Geometry std::shared_ptr m_trackingGeo{nullptr}; - /// ACTS Material Decorator - std::shared_ptr m_materialDeco{nullptr}; - /// ACTS surface lookup container for hit surfaces that generate smeared hits VolumeSurfaceMap m_surfaces; From 70d8caf855ea8344c7adc43667ba7e3183181928 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Tue, 17 Oct 2023 09:12:11 -0500 Subject: [PATCH 06/12] fix: support fmt v10 and C++20 (#1073) ### Briefly, what does this PR introduce? These are the first commits in #1072 which should be entirely compatible with the current version of Acts v21.1.1, fmt v9, and C++17. Note: this adds C++20 compatibility in EICrecon code (C++20 adds constexpr support for several fmt functions, which imposes conditions on the inputs we pass to them), but it does not mean that this PR allows one to compile EIC with C++20. The Acts dependency of v21.1.1 only allows C++17 support. ### What kind of change does this PR introduce? - [x] Bug fix (issue: not compatible with EICrecon) - [ ] 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 - [ ] Changes have been communicated to collaborators ### Does this PR introduce breaking changes? What changes might users need to make to their code? No. ### Does this PR change default behavior? No. --- CMakeLists.txt | 2 +- cmake/jana_plugin.cmake | 2 +- src/algorithms/pid/IrtCherenkovParticleID.cc | 2 +- src/algorithms/pid/ParticlesWithPID.cc | 31 ++++++++--------- src/extensions/spdlog/SpdlogExtensions.h | 2 +- src/extensions/spdlog/SpdlogToActs.h | 4 +-- src/services/geometry/acts/ACTSGeo_service.cc | 4 +-- src/services/geometry/richgeo/IrtGeo.cc | 2 +- src/services/geometry/richgeo/RichGeo.h | 34 ++++++------------- .../geometry/richgeo/RichGeo_service.cc | 2 +- .../tracking_test/TrackingTest_processor.cc | 2 +- 11 files changed, 37 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae60849bfe..bd53dcbc12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,7 +113,7 @@ add_compile_definitions(HAVE_PODIO) # PODIO, EDM4HEP, EDM4EIC event models find_package(Eigen3 REQUIRED) find_package(podio REQUIRED) -find_package(EDM4HEP REQUIRED) +find_package(EDM4HEP 0.7.1 REQUIRED) find_package(EDM4EIC 2.1 REQUIRED) # Guidelines Support Library diff --git a/cmake/jana_plugin.cmake b/cmake/jana_plugin.cmake index 2da32755df..7ff25e5ac4 100644 --- a/cmake/jana_plugin.cmake +++ b/cmake/jana_plugin.cmake @@ -29,7 +29,7 @@ macro(plugin_add _name) find_package(spdlog REQUIRED) # include fmt by default - find_package(fmt REQUIRED) + find_package(fmt 9.0.0 REQUIRED) # include gsl by default find_package(Microsoft.GSL CONFIG) diff --git a/src/algorithms/pid/IrtCherenkovParticleID.cc b/src/algorithms/pid/IrtCherenkovParticleID.cc index 4001ac7ace..81efafb01e 100644 --- a/src/algorithms/pid/IrtCherenkovParticleID.cc +++ b/src/algorithms/pid/IrtCherenkovParticleID.cc @@ -52,7 +52,7 @@ void eicrecon::IrtCherenkovParticleID::AlgorithmInit( for(auto [rad_name,irt_rad] : m_irt_det->Radiators()) { if(rad_name!="Filter") { m_pid_radiators.insert({ std::string(rad_name), irt_rad }); - m_log->debug("- {}", rad_name); + m_log->debug("- {}", rad_name.Data()); } } diff --git a/src/algorithms/pid/ParticlesWithPID.cc b/src/algorithms/pid/ParticlesWithPID.cc index 291dee986c..4873555452 100644 --- a/src/algorithms/pid/ParticlesWithPID.cc +++ b/src/algorithms/pid/ParticlesWithPID.cc @@ -3,7 +3,6 @@ #include "ParticlesWithPID.h" -#include #include @@ -36,14 +35,14 @@ namespace eicrecon { for (const auto &trajectory: *trajectories) { for (const auto &trk: trajectory.getTrackParameters()) { - const auto mom = edm4eic::sphericalToVector(1.0 / std::abs(trk.getQOverP()), trk.getTheta(), + const auto mom = edm4hep::utils::sphericalToVector(1.0 / std::abs(trk.getQOverP()), trk.getTheta(), trk.getPhi()); const auto charge_rec = trk.getCharge(); m_log->debug("Match: [id] [mom] [theta] [phi] [charge] [PID]"); m_log->debug(" Track : {:<4} {:<8.3f} {:<8.3f} {:<8.2f} {:<4}", - trk.getObjectID().index, edm4eic::magnitude(mom), edm4eic::anglePolar(mom), edm4eic::angleAzimuthal(mom), charge_rec); + trk.getObjectID().index, edm4hep::utils::magnitude(mom), edm4hep::utils::anglePolar(mom), edm4hep::utils::angleAzimuthal(mom), charge_rec); // utility variables for matching int best_match = -1; @@ -53,7 +52,7 @@ namespace eicrecon { const auto &p = mc_part.getMomentum(); m_log->trace(" MCParticle with id={:<4} mom={:<8.3f} charge={}", mc_part.getObjectID().index, - edm4eic::magnitude(p), mc_part.getCharge()); + edm4hep::utils::magnitude(p), mc_part.getCharge()); // Check if used if (mc_prt_is_consumed[ip]) { @@ -79,14 +78,14 @@ namespace eicrecon { continue; } - const auto p_mag = edm4eic::magnitude(p); - const auto p_phi = edm4eic::angleAzimuthal(p); - const auto p_eta = edm4eic::eta(p); - const double dp_rel = std::abs((edm4eic::magnitude(mom) - p_mag) / p_mag); + const auto p_mag = edm4hep::utils::magnitude(p); + const auto p_phi = edm4hep::utils::angleAzimuthal(p); + const auto p_eta = edm4hep::utils::eta(p); + const double dp_rel = std::abs((edm4hep::utils::magnitude(mom) - p_mag) / p_mag); // check the tolerance for sin(dphi/2) to avoid the hemisphere problem and allow // for phi rollovers - const double dsphi = std::abs(sin(0.5 * (edm4eic::angleAzimuthal(mom) - p_phi))); - const double deta = std::abs((edm4eic::eta(mom) - p_eta)); + const double dsphi = std::abs(sin(0.5 * (edm4hep::utils::angleAzimuthal(mom) - p_phi))); + const double deta = std::abs((edm4hep::utils::eta(mom) - p_eta)); bool is_matching = dp_rel < m_cfg.momentumRelativeTolerance && deta < m_cfg.etaTolerance && @@ -95,11 +94,11 @@ namespace eicrecon { // Matching kinematics with the static variables doesn't work at low angles and within beam divergence // TODO - Maybe reconsider variables used or divide into regions // Backward going - if ((p_eta < -5) && (edm4eic::eta(mom) < -5)) { + if ((p_eta < -5) && (edm4hep::utils::eta(mom) < -5)) { is_matching = true; } // Forward going - if ((p_eta > 5) && (edm4eic::eta(mom) > 5)) { + if ((p_eta > 5) && (edm4hep::utils::eta(mom) > 5)) { is_matching = true; } @@ -139,7 +138,7 @@ namespace eicrecon { } rec_part.setType(static_cast(best_match >= 0 ? 0 : -1)); // @TODO: determine type codes - rec_part.setEnergy((float) std::hypot(edm4eic::magnitude(mom), mass)); + rec_part.setEnergy((float) std::hypot(edm4hep::utils::magnitude(mom), mass)); rec_part.setMomentum(mom); rec_part.setReferencePoint(referencePoint); rec_part.setCharge(charge_rec); @@ -172,9 +171,9 @@ namespace eicrecon { const auto &mcpart = (*mc_particles)[best_match]; const auto &p = mcpart.getMomentum(); - const auto p_mag = edm4eic::magnitude(p); - const auto p_phi = edm4eic::angleAzimuthal(p); - const auto p_theta = edm4eic::anglePolar(p); + const auto p_mag = edm4hep::utils::magnitude(p); + const auto p_phi = edm4hep::utils::angleAzimuthal(p); + const auto p_theta = edm4hep::utils::anglePolar(p); m_log->debug(" MCPart: {:<4} {:<8.3f} {:<8.3f} {:<8.2f} {:<6}", mcpart.getObjectID().index, p_mag, p_theta, p_phi, mcpart.getCharge(), mcpart.getPDG()); diff --git a/src/extensions/spdlog/SpdlogExtensions.h b/src/extensions/spdlog/SpdlogExtensions.h index 195f4ce810..aeaeb8117f 100644 --- a/src/extensions/spdlog/SpdlogExtensions.h +++ b/src/extensions/spdlog/SpdlogExtensions.h @@ -52,7 +52,7 @@ namespace eicrecon { break; } - auto err_msg = fmt::format("ParseLogLevel don't know this log level: '{}'", input); + auto err_msg = fmt::format("ParseLogLevel don't know this log level: '{}'", fmt::underlying(input)); throw JException(err_msg); } } diff --git a/src/extensions/spdlog/SpdlogToActs.h b/src/extensions/spdlog/SpdlogToActs.h index 395847e8d0..fa98311e12 100644 --- a/src/extensions/spdlog/SpdlogToActs.h +++ b/src/extensions/spdlog/SpdlogToActs.h @@ -39,7 +39,7 @@ inline Acts::Logging::Level SpdlogToActsLevel(spdlog::level::level_enum input) { try { return kSpdlogToActsLevel.left.at(input); } catch (...) { - auto err_msg = fmt::format("SpdlogToActsLevel don't know this log level: '{}'", input); + auto err_msg = fmt::format("SpdlogToActsLevel don't know this log level: '{}'", fmt::underlying(input)); throw JException(err_msg); } } @@ -48,7 +48,7 @@ inline spdlog::level::level_enum ActsToSpdlogLevel(Acts::Logging::Level input) { try { return kSpdlogToActsLevel.right.at(input); } catch (...) { - auto err_msg = fmt::format("ActsToSpdlogLevel don't know this log level: '{}'", input); + auto err_msg = fmt::format("ActsToSpdlogLevel don't know this log level: '{}'", fmt::underlying(input)); throw JException(err_msg); } } diff --git a/src/services/geometry/acts/ACTSGeo_service.cc b/src/services/geometry/acts/ACTSGeo_service.cc index afa925fc12..1394ae0a65 100644 --- a/src/services/geometry/acts/ACTSGeo_service.cc +++ b/src/services/geometry/acts/ACTSGeo_service.cc @@ -72,14 +72,14 @@ void ACTSGeo_service::acquire_services(JServiceLocator * srv_locator) { std::string log_level_str = log_service->getDefaultLevelStr(); m_app->SetDefaultParameter("acts:LogLevel", log_level_str, "log_level: trace, debug, info, warn, error, critical, off"); m_log->set_level(eicrecon::ParseLogLevel(log_level_str)); - m_log->info("Acts GENERAL log level is set to {} ({})", log_level_str, m_log->level()); + m_log->info("Acts GENERAL log level is set to {} ({})", log_level_str, fmt::underlying(m_log->level())); // ACTS init log level (geometry conversion): m_init_log = log_service->logger("acts_init"); std::string init_log_level_str = eicrecon::LogLevelToString(m_log->level()); // set general acts log level, if not given by user m_app->SetDefaultParameter("acts:InitLogLevel", init_log_level_str, "log_level: trace, debug, info, warn, error, critical, off"); m_init_log->set_level(eicrecon::ParseLogLevel(init_log_level_str)); - m_init_log->info("Acts INIT log level is set to {} ({})", log_level_str, m_init_log->level()); + m_init_log->info("Acts INIT log level is set to {} ({})", log_level_str, fmt::underlying(m_init_log->level())); // DD4Hep geometry auto dd4hep_service = srv_locator->get(); diff --git a/src/services/geometry/richgeo/IrtGeo.cc b/src/services/geometry/richgeo/IrtGeo.cc index 3e8ff9f882..056328c5bb 100644 --- a/src/services/geometry/richgeo/IrtGeo.cc +++ b/src/services/geometry/richgeo/IrtGeo.cc @@ -59,7 +59,7 @@ void richgeo::IrtGeo::SetReadoutIDToPositionLambda() { void richgeo::IrtGeo::SetRefractiveIndexTable() { m_log->debug("{:-^60}"," Refractive Index Tables "); for(auto rad_obj : m_irtDetector->Radiators()) { - m_log->debug("{}:", rad_obj.first); + m_log->debug("{}:", rad_obj.first.Data()); auto *const rad = rad_obj.second; const auto *rindex_matrix = m_det->material(rad->GetAlternativeMaterialName()).property("RINDEX"); for(unsigned row=0; rowGetRows(); row++) { diff --git a/src/services/geometry/richgeo/RichGeo.h b/src/services/geometry/richgeo/RichGeo.h index 4f8c0705dc..8c7bd4265d 100644 --- a/src/services/geometry/richgeo/RichGeo.h +++ b/src/services/geometry/richgeo/RichGeo.h @@ -27,21 +27,6 @@ namespace richgeo { dd4hep::Direction surface_normZdir; //normal Z direction of surface }; - // logging - // ----------------------------------------------------------------------- - /* print an error using `spdlog`, if available, otherwise use `std::cerr` - * - this should only be called by static `richgeo` methods here, where we are not guaranteed to - * have an instance of `spdlog::logger` available - */ - template - static void PrintError(std::shared_ptr m_log, std::string fmt_message, VALS... values) { - auto message = fmt::format(fmt_message, values...); - if(m_log!=nullptr) - m_log->error(message); - else - std::cerr << "ERROR: " << message << std::endl; - } - // radiators // ----------------------------------------------------------------------- /* in many places in the reconstruction, we need to track which radiator @@ -54,37 +39,40 @@ namespace richgeo { }; // return radiator name associated with index - static std::string RadiatorName(int num, std::shared_ptr m_log=nullptr) { + static std::string RadiatorName(int num, std::shared_ptr m_log = nullptr) { if(num==kAerogel) return "Aerogel"; else if(num==kGas) return "Gas"; else { - PrintError(m_log, "unknown radiator number {}", num); + if (m_log) m_log->error("unknown radiator number {}", num); + else std::cerr << "ERROR: unknown radiator number " << num << std::endl; return "UNKNOWN_RADIATOR"; } } // return radiator index associated with name - static int RadiatorNum(std::string name, std::shared_ptr m_log=nullptr) { + static int RadiatorNum(std::string name, std::shared_ptr m_log = nullptr) { if(name=="Aerogel") return kAerogel; else if(name=="Gas") return kGas; else { - PrintError(m_log, "unknown radiator name {}", name); + if (m_log) m_log->error("unknown radiator name {}", name); + else std::cerr << "ERROR: unknown radiator name " << name << std::endl; return -1; } } - static int RadiatorNum(const char * name) { - return RadiatorNum(std::string(name)); + static int RadiatorNum(const char * name, std::shared_ptr m_log = nullptr) { + return RadiatorNum(std::string(name), m_log); } // search string `input` for a radiator name; return corresponding index - static int ParseRadiatorName(std::string input, std::shared_ptr m_log=nullptr) { + static int ParseRadiatorName(std::string input, std::shared_ptr m_log = nullptr) { if (input.find("aerogel")!=std::string::npos) return kAerogel; else if (input.find("Aerogel")!=std::string::npos) return kAerogel; else if (input.find("gas")!=std::string::npos) return kGas; else if (input.find("Gas")!=std::string::npos) return kGas; else { - PrintError(m_log, "failed to parse '{}' for radiator name", input); + if (m_log) m_log->error("failed to parse '{}' for radiator name", input); + else std::cerr << "ERROR: failed to parse '" << input << "' for radiator name" << std::endl; return -1; } } diff --git a/src/services/geometry/richgeo/RichGeo_service.cc b/src/services/geometry/richgeo/RichGeo_service.cc index 3c16463959..dd8be3a7dd 100644 --- a/src/services/geometry/richgeo/RichGeo_service.cc +++ b/src/services/geometry/richgeo/RichGeo_service.cc @@ -12,7 +12,7 @@ void RichGeo_service::acquire_services(JServiceLocator *srv_locator) { std::string log_level_str = "info"; m_app->SetDefaultParameter("richgeo:LogLevel", log_level_str, "Log level for RichGeo_service"); m_log->set_level(eicrecon::ParseLogLevel(log_level_str)); - m_log->debug("RichGeo log level is set to {} ({})", log_level_str, m_log->level()); + m_log->debug("RichGeo log level is set to {} ({})", log_level_str, fmt::underlying(m_log->level())); // DD4Hep geometry service auto dd4hep_service = srv_locator->get(); diff --git a/src/tests/tracking_test/TrackingTest_processor.cc b/src/tests/tracking_test/TrackingTest_processor.cc index dd85a500b4..19bcf64ebb 100644 --- a/src/tests/tracking_test/TrackingTest_processor.cc +++ b/src/tests/tracking_test/TrackingTest_processor.cc @@ -134,7 +134,7 @@ void TrackingTest_processor::ProcessTrackingMatching(const std::shared_ptrdebug(" {:<6} {:<6} {:>8.2f} {:>8.2f} {:>8.2f} {:>8.2f}", assoc.getSimID(), assoc.getRecID(), sim.getPDG(), rec.getPDG()); + m_log->debug(" {:<6} {:<6} {:>8d} {:>8d}", assoc.getSimID(), assoc.getRecID(), sim.getPDG(), rec.getPDG()); } // m_log->debug("Particles [objID] [PDG] [simE] [recE] [simPDG] [recPDG]"); From ce84899e31de08444c177b68ec769cdaec932bf2 Mon Sep 17 00:00:00 2001 From: Chandradoy Chatterjee Date: Mon, 23 Oct 2023 11:36:42 +0200 Subject: [PATCH 07/12] Update src/services/geometry/richgeo/IrtGeoDRICH.h Method name changed to `GetSensorSurfaceNorm` Co-authored-by: Christopher Dilks --- src/services/geometry/richgeo/IrtGeoDRICH.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/geometry/richgeo/IrtGeoDRICH.h b/src/services/geometry/richgeo/IrtGeoDRICH.h index 05f82fb6fd..2c7ed11391 100644 --- a/src/services/geometry/richgeo/IrtGeoDRICH.h +++ b/src/services/geometry/richgeo/IrtGeoDRICH.h @@ -13,7 +13,7 @@ namespace richgeo { IrtGeoDRICH(gsl::not_null det_, gsl::not_null conv_, std::shared_ptr log_) : IrtGeo("DRICH",det_,conv_,log_) { DD4hep_to_IRT(); } ~IrtGeoDRICH(); - TVector3 GetSensorSurface(CellIDType); + TVector3 GetSensorSurfaceNorm(CellIDType); protected: void DD4hep_to_IRT() override; From 77edde9c213923f191097f35aa3edb4648da6778 Mon Sep 17 00:00:00 2001 From: chchatte92 Date: Mon, 23 Oct 2023 12:11:40 +0200 Subject: [PATCH 08/12] Fix: removed reused variables --- src/services/geometry/richgeo/IrtGeoDRICH.cc | 22 +++++++++----------- src/services/geometry/richgeo/RichGeo.h | 1 - 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/services/geometry/richgeo/IrtGeoDRICH.cc b/src/services/geometry/richgeo/IrtGeoDRICH.cc index 10ea526ab1..4c984d8e87 100644 --- a/src/services/geometry/richgeo/IrtGeoDRICH.cc +++ b/src/services/geometry/richgeo/IrtGeoDRICH.cc @@ -141,7 +141,6 @@ void richgeo::IrtGeoDRICH::DD4hep_to_IRT() { sensor_info.size = sensorSize; sensor_info.surface_centroid = posSensor; sensor_info.surface_offset = surfaceOffset; - sensor_info.surface_normZdir = normZdir; m_sensor_info.insert({ sensorID, sensor_info }); // create the optical surface m_sensorFlatSurface = new FlatSurface( @@ -184,22 +183,21 @@ void richgeo::IrtGeoDRICH::DD4hep_to_IRT() { // define the `cell ID -> pixel position` converter SetReadoutIDToPositionLambda(); } -TVector3 richgeo::IrtGeoDRICH::GetSensorSurface(CellIDType id){ - auto nSectors= m_det->constant("DRICH_num_sectors"); - TVector3 normX(1, 0, 0); // normal vectors - TVector3 normY(0, -1, 0); +TVector3 richgeo::IrtGeoDRICH::GetSensorSurfaceNorm(CellIDType id){ TVector3 sensorNorm; auto cellMask = uint64_t(std::stoull(m_det->constant("DRICH_cell_mask"))); auto sensor_info = this->m_sensor_info; auto sID = id & cellMask; auto sensor_info_it = sensor_info.find(sID); - - auto sensor_obj = sensor_info_it->second; - auto normZdir = sensor_obj.surface_normZdir; - - sensorNorm.SetX(static_cast(normZdir.x())); - sensorNorm.SetY(static_cast(normZdir.y())); - sensorNorm.SetZ(static_cast(normZdir.z())); + if(sensor_info_it!=sensor_info.end()){ + auto sensor_obj = sensor_info_it->second; + auto normZdir = sensor_obj.surface_offset.Unit(); + sensorNorm.SetX(static_cast(normZdir.x())); + sensorNorm.SetY(static_cast(normZdir.y())); + sensorNorm.SetZ(static_cast(normZdir.z())); + } + else + m_log->error("Cannot find sensor {} in IrtGeoDRICH::GetSensorSurface", id); //std::cout< Date: Wed, 25 Oct 2023 14:02:11 +0200 Subject: [PATCH 09/12] exception thrown when sensor not found --- src/services/geometry/richgeo/IrtGeoDRICH.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/services/geometry/richgeo/IrtGeoDRICH.cc b/src/services/geometry/richgeo/IrtGeoDRICH.cc index 4c984d8e87..c31fa90397 100644 --- a/src/services/geometry/richgeo/IrtGeoDRICH.cc +++ b/src/services/geometry/richgeo/IrtGeoDRICH.cc @@ -196,9 +196,11 @@ TVector3 richgeo::IrtGeoDRICH::GetSensorSurfaceNorm(CellIDType id){ sensorNorm.SetY(static_cast(normZdir.y())); sensorNorm.SetZ(static_cast(normZdir.z())); } - else + else{ + throw std::runtime_error("sensor not found in IrtGeoDRIC::GetSensorSurfaceNormal"); m_log->error("Cannot find sensor {} in IrtGeoDRICH::GetSensorSurface", id); - //std::cout< Date: Tue, 31 Oct 2023 12:00:18 +0100 Subject: [PATCH 10/12] fix: IrtGeoDRICH with iwyu_fixes.patch --- src/services/geometry/richgeo/IrtGeoDRICH.cc | 21 ++++++++++++++++++++ src/services/geometry/richgeo/IrtGeoDRICH.h | 12 +++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/services/geometry/richgeo/IrtGeoDRICH.cc b/src/services/geometry/richgeo/IrtGeoDRICH.cc index c31fa90397..02a113d711 100644 --- a/src/services/geometry/richgeo/IrtGeoDRICH.cc +++ b/src/services/geometry/richgeo/IrtGeoDRICH.cc @@ -2,6 +2,27 @@ // Subject to the terms in the LICENSE file found in the top-level directory. #include "IrtGeoDRICH.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + void richgeo::IrtGeoDRICH::DD4hep_to_IRT() { // begin envelope diff --git a/src/services/geometry/richgeo/IrtGeoDRICH.h b/src/services/geometry/richgeo/IrtGeoDRICH.h index 2c7ed11391..fb12ca79df 100644 --- a/src/services/geometry/richgeo/IrtGeoDRICH.h +++ b/src/services/geometry/richgeo/IrtGeoDRICH.h @@ -4,7 +4,19 @@ // bind IRT and DD4hep geometries for the dRICH #pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "IrtGeo.h" +#include "services/geometry/richgeo/RichGeo.h" namespace richgeo { class IrtGeoDRICH : public IrtGeo { From 813b5da40cd736f1650c49e245a43af473b9737a Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Tue, 31 Oct 2023 16:42:09 -0500 Subject: [PATCH 11/12] fix: remove commented line --- src/services/geometry/richgeo/IrtGeoDRICH.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/services/geometry/richgeo/IrtGeoDRICH.cc b/src/services/geometry/richgeo/IrtGeoDRICH.cc index 90b30295e1..7fa2a606f5 100644 --- a/src/services/geometry/richgeo/IrtGeoDRICH.cc +++ b/src/services/geometry/richgeo/IrtGeoDRICH.cc @@ -220,7 +220,6 @@ TVector3 richgeo::IrtGeoDRICH::GetSensorSurfaceNorm(CellIDType id){ throw std::runtime_error("sensor not found in IrtGeoDRIC::GetSensorSurfaceNormal"); m_log->error("Cannot find sensor {} in IrtGeoDRICH::GetSensorSurface", id); } - //std::cout< Date: Tue, 31 Oct 2023 16:42:48 -0500 Subject: [PATCH 12/12] fix: reorder print before throw --- src/services/geometry/richgeo/IrtGeoDRICH.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/geometry/richgeo/IrtGeoDRICH.cc b/src/services/geometry/richgeo/IrtGeoDRICH.cc index 7fa2a606f5..58910ca367 100644 --- a/src/services/geometry/richgeo/IrtGeoDRICH.cc +++ b/src/services/geometry/richgeo/IrtGeoDRICH.cc @@ -217,8 +217,8 @@ TVector3 richgeo::IrtGeoDRICH::GetSensorSurfaceNorm(CellIDType id){ sensorNorm.SetZ(static_cast(normZdir.z())); } else{ - throw std::runtime_error("sensor not found in IrtGeoDRIC::GetSensorSurfaceNormal"); m_log->error("Cannot find sensor {} in IrtGeoDRICH::GetSensorSurface", id); + throw std::runtime_error("sensor not found in IrtGeoDRIC::GetSensorSurfaceNormal"); } return sensorNorm; }