From 18ecc6882546c9dec3f27565990ee6d029fc5055 Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Fri, 8 May 2026 09:47:20 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20CodeRabbit=20Chat:=20Implement?= =?UTF-8?q?=20requested=20code=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/FastCaloSim/Core/TFCSBinnedShower.h | 1 - .../TFCSLateralShapeParametrizationHitBase.h | 2 +- source/Core/TFCSBinnedShower.cxx | 9 ++++----- source/Core/TFCSBinnedShowerBase.cxx | 1 - source/Core/TFCSBinnedShowerONNX.cxx | 17 ++++++++++------- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/FastCaloSim/Core/TFCSBinnedShower.h b/include/FastCaloSim/Core/TFCSBinnedShower.h index 39df6e7..9961399 100644 --- a/include/FastCaloSim/Core/TFCSBinnedShower.h +++ b/include/FastCaloSim/Core/TFCSBinnedShower.h @@ -15,7 +15,6 @@ #include "FastCaloSim/Core/TFCSLateralShapeParametrizationHitBase.h" #include "FastCaloSim/Core/TFCSParametrizationBinnedChain.h" #include "FastCaloSim/Core/TFCSSimulationState.h" -#include "TFCSBinnedShowerBase.h" class CaloGeo; diff --git a/include/FastCaloSim/Core/TFCSLateralShapeParametrizationHitBase.h b/include/FastCaloSim/Core/TFCSLateralShapeParametrizationHitBase.h index 0ac8475..6e1e8a2 100644 --- a/include/FastCaloSim/Core/TFCSLateralShapeParametrizationHitBase.h +++ b/include/FastCaloSim/Core/TFCSLateralShapeParametrizationHitBase.h @@ -121,7 +121,7 @@ class TFCSLateralShapeParametrizationHitBase inline const auto& center_z() const { return m_center_z; } inline const auto& center_eta() const { return m_center_eta; } inline const auto& center_phi() const { return m_center_phi; } - inline const auto& idx() { return m_hit_index; }; + inline const auto& idx() const { return m_hit_index; }; inline void setCenter_r(float r) { m_center_r = r; } inline void setCenter_z(float z) { m_center_z = z; } diff --git a/source/Core/TFCSBinnedShower.cxx b/source/Core/TFCSBinnedShower.cxx index 89fcc94..9f2b133 100644 --- a/source/Core/TFCSBinnedShower.cxx +++ b/source/Core/TFCSBinnedShower.cxx @@ -809,7 +809,7 @@ void TFCSBinnedShower::load_sub_bin_distribution(const std::string& filename) m_use_upscaling = true; TFile* file = TFile::Open(filename.c_str(), "READ"); if (!file || file->IsZombie()) { - std::cerr << "Failed to open file: " << filename << std::endl; + FCS_MSG_ERROR("Failed to open file: " << filename); return; } @@ -861,13 +861,12 @@ void TFCSBinnedShower::load_sub_bin_distribution(const std::string& filename) data.push_back(std::move(layer_vec)); } - // Example output for (size_t i = 0; i < energies.size(); ++i) { - std::cout << "Energy index " << i << ": " << energies[i] << " GeV\n"; + FCS_MSG_DEBUG("Energy index " << i << ": " << energies[i] << " GeV"); for (size_t j = 0; j < data[i].size(); ++j) { if (!data[i][j].empty()) { - std::cout << " Layer " << j << " Shape: (" << data[i][j].size() << ", " - << data[i][j][0].size() << ")\n"; + FCS_MSG_DEBUG(" Layer " << j << " Shape: (" << data[i][j].size() + << ", " << data[i][j][0].size() << ")"); } } } diff --git a/source/Core/TFCSBinnedShowerBase.cxx b/source/Core/TFCSBinnedShowerBase.cxx index dfc6bae..69c3d19 100644 --- a/source/Core/TFCSBinnedShowerBase.cxx +++ b/source/Core/TFCSBinnedShowerBase.cxx @@ -51,7 +51,6 @@ FCSReturnCode TFCSBinnedShowerBase::simulate( // layer 6 is EME2 reference_layer_index = 6; } - // TODO: What about the endcap? eta_center = extrapol->eta(reference_layer_index, Cell::SubPos::MID); phi_center = extrapol->phi(reference_layer_index, Cell::SubPos::MID); diff --git a/source/Core/TFCSBinnedShowerONNX.cxx b/source/Core/TFCSBinnedShowerONNX.cxx index 1c89ba8..624e480 100644 --- a/source/Core/TFCSBinnedShowerONNX.cxx +++ b/source/Core/TFCSBinnedShowerONNX.cxx @@ -171,7 +171,6 @@ void TFCSBinnedShowerONNX::load_bin_boundaries(const std::string& filename, } } -// TODO: Could probably be removed in the end void TFCSBinnedShowerONNX::Streamer(TBuffer& R__b) { // Stream an object of class TFCSBinnedShowerONNX @@ -343,7 +342,12 @@ std::tuple TFCSBinnedShowerONNX::get_coordinates( simulstate, R_min, R_max, alpha_min, alpha_max, layer_index, bin_index); } - float R = CLHEP::RandFlat::shoot(simulstate.randomEngine(), R_min, R_max); + float R; + if (TMath::Abs(R_max - R_min) > std::numeric_limits::epsilon()) { + R = CLHEP::RandFlat::shoot(simulstate.randomEngine(), R_min, R_max); + } else { + R = R_min; // If the range is too small, just use the minimum value + } float alpha = CLHEP::RandFlat::shoot(simulstate.randomEngine(), alpha_min, alpha_max); @@ -537,7 +541,7 @@ void TFCSBinnedShowerONNX::load_sub_bin_distribution( m_use_upscaling = true; TFile* file = TFile::Open(filename.c_str(), "READ"); if (!file || file->IsZombie()) { - std::cerr << "Failed to open file: " << filename << std::endl; + FCS_MSG_ERROR("Failed to open file: " << filename); return; } @@ -589,13 +593,12 @@ void TFCSBinnedShowerONNX::load_sub_bin_distribution( data.push_back(std::move(layer_vec)); } - // Example output for (size_t i = 0; i < energies.size(); ++i) { - std::cout << "Energy index " << i << ": " << energies[i] << " GeV\n"; + FCS_MSG_DEBUG("Energy index " << i << ": " << energies[i] << " GeV"); for (size_t j = 0; j < data[i].size(); ++j) { if (!data[i][j].empty()) { - std::cout << " Layer " << j << " Shape: (" << data[i][j].size() << ", " - << data[i][j][0].size() << ")\n"; + FCS_MSG_DEBUG(" Layer " << j << " Shape: (" << data[i][j].size() + << ", " << data[i][j][0].size() << ")"); } } }