From 6dbff5482990c7d6006dfc83b3595be6e1f9f079 Mon Sep 17 00:00:00 2001 From: Rosen Matev Date: Thu, 14 Aug 2025 14:47:41 +0000 Subject: [PATCH] Merge branch 'jmarchan-addingGammaToEnergy' into 'master' Adding gamma to energy See merge request lhcb/Detector!783 (cherry picked from commit ba7bcf87c53f9a8415ef55cf2acac783efffd10e) 2dc9b4dc Adding gamma to energy eca037d7 pre-commit fixes 8eaba20e Move gammas to conditions ca74e823 pre-commit fixes b5d4daef Add Gammas conditions check 868073e2 pre-commit fixes e5b5a13d Remove changes in compact/components/ECAL/2024-v00.00/conditions.xml c4fc1433 Remove changes in compact/components/ECAL/trunk/conditions.xml 691f6f05 Apply 1 suggestion(s) to 1 file(s) 98cd2e2f Add Gammas to compact/components/ECAL/2024-v00.00/conditions.xml e07e931a Make Gammas condition optional Co-authored-by: Menglin Xu --- .../Calo/include/Detector/Calo/CellParam.h | 3 ++ .../include/Detector/Calo/DeCalorimeter.h | 1 + Detector/Calo/src/DeCalorimeter.cpp | 35 +++++++++++++++++++ .../ECAL/2024-v00.00/conditions.xml | 1 + compact/components/ECAL/trunk/conditions.xml | 1 + tests/ConditionsIOV/.schema.json | 3 +- .../Conditions/Ecal/Calibration.yml/0 | 3 ++ 7 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Detector/Calo/include/Detector/Calo/CellParam.h b/Detector/Calo/include/Detector/Calo/CellParam.h index 7f13b5b26b..d73adeb47c 100644 --- a/Detector/Calo/include/Detector/Calo/CellParam.h +++ b/Detector/Calo/include/Detector/Calo/CellParam.h @@ -82,6 +82,7 @@ namespace LHCb::Detector::Calo { double pileUpOffsetSPD() const { return m_offsetSPD; } double pileUpOffsetRMS() const { return m_eoffset; } double pileUpOffsetSPDRMS() const { return m_eoffsetSPD; } + double Gamma() const { return m_gamma; } const std::vector& pins() const { return m_pins; } const std::vector& leds() const { return m_leds; } @@ -142,6 +143,7 @@ namespace LHCb::Detector::Calo { m_offsetSPD = off; m_eoffsetSPD = eoff; } + void setGamma( double gamma ) { m_gamma = gamma; } std::string cellStatus() { if ( (CellQuality::Flag)m_quality == CellQuality::OK ) return CellQuality::qName( CellQuality::OK ); @@ -188,6 +190,7 @@ namespace LHCb::Detector::Calo { double m_eoffset{ 0.0 }; double m_offsetSPD{ 0.0 }; double m_eoffsetSPD{ 0.0 }; + double m_gamma{ 0.0 }; }; } // namespace LHCb::Detector::Calo diff --git a/Detector/Calo/include/Detector/Calo/DeCalorimeter.h b/Detector/Calo/include/Detector/Calo/DeCalorimeter.h index 2c5bfb5b75..9700914fa7 100644 --- a/Detector/Calo/include/Detector/Calo/DeCalorimeter.h +++ b/Detector/Calo/include/Detector/Calo/DeCalorimeter.h @@ -240,6 +240,7 @@ namespace LHCb::Detector::Calo { double gainError() const { return this->access()->gainError; } double getCalibration( const CellID& ID ) const { return this->access()->cells[ID].calibration(); } + double getGamma( const CellID& ID ) const { return this->access()->cells[ID].Gamma(); } // for simulation only int zSupMethod() const { return this->access()->zSupMethod; } diff --git a/Detector/Calo/src/DeCalorimeter.cpp b/Detector/Calo/src/DeCalorimeter.cpp index d48128bbed..6b015f070a 100644 --- a/Detector/Calo/src/DeCalorimeter.cpp +++ b/Detector/Calo/src/DeCalorimeter.cpp @@ -683,6 +683,41 @@ detail::DeCaloObject::DeCaloObject( dd4hep::DetElement const& de, dd4hep::cond:: dd4hep::printout( dd4hep::DEBUG, "DeCalorimeter", "Pileup offset added for %d channel(s)", countPU ); } + //---------------------------------------------- + // ** Gamma for ECAL energy + //---------------------------------------------- + if ( isEcal ) { + auto condgammas = ctxt.condition( hash_key( de, "Gammas" ), false ); + if ( !condgammas.isValid() ) { + dd4hep::printout( dd4hep::DEBUG, "DeCalorimeter", "Condition 'Gammas' is not defined, assuming 0.0" ); + } else { + const auto& gammas = condgammas.get(); + if ( gammas.is_null() ) { + dd4hep::printout( dd4hep::DEBUG, "DeCalorimeter", "Condition 'Gammas' is null, assuming 0.0" ); + } else { + auto cellsGammas = gammas["data"].get>>(); + dd4hep::printout( dd4hep::DEBUG, "DeCalorimeter", "Gammas for ECAL energy" ); + int countGammas = 0; + for ( auto& cellGammas : cellsGammas ) { + double cell = cellGammas[0]; + double gamma = cellGammas[1]; + LHCb::Detector::Calo::CellID id = LHCb::Detector::Calo::CellID( (int)cell ); + id.setCalo( index ); + if ( cells[id].valid() ) { + cells[id].setGamma( gamma ); + dd4hep::printout( dd4hep::DEBUG, "DeCalorimeter", "Added gamma for channel %s : gamma = %f", + id.asString().c_str(), gamma ); + } else { + dd4hep::printout( dd4hep::WARNING, "DeCalorimeter", "Trying to add gamma on non-valid channel : %s", + id.asString().c_str() ); + } + countGammas++; + } + dd4hep::printout( dd4hep::DEBUG, "DeCalorimeter", "Gamma added for %d channel(s)", countGammas ); + } + } + } + bool nominal = false; int countGain = 0; // Nominal Gain parameters diff --git a/compact/components/ECAL/2024-v00.00/conditions.xml b/compact/components/ECAL/2024-v00.00/conditions.xml index e1fb242e9c..5a0f267734 100644 --- a/compact/components/ECAL/2024-v00.00/conditions.xml +++ b/compact/components/ECAL/2024-v00.00/conditions.xml @@ -18,6 +18,7 @@ + diff --git a/compact/components/ECAL/trunk/conditions.xml b/compact/components/ECAL/trunk/conditions.xml index e1fb242e9c..5a0f267734 100644 --- a/compact/components/ECAL/trunk/conditions.xml +++ b/compact/components/ECAL/trunk/conditions.xml @@ -18,6 +18,7 @@ + diff --git a/tests/ConditionsIOV/.schema.json b/tests/ConditionsIOV/.schema.json index bc6ed3ac93..461400c57b 100644 --- a/tests/ConditionsIOV/.schema.json +++ b/tests/ConditionsIOV/.schema.json @@ -9,7 +9,8 @@ "LEDReference", "PileUpOffset", "Quality", - "Reco" + "Reco", + "Gammas" ], "Conditions/Ecal/ReadoutConf.yml": [ "Hardware", diff --git a/tests/ConditionsIOV/Conditions/Ecal/Calibration.yml/0 b/tests/ConditionsIOV/Conditions/Ecal/Calibration.yml/0 index bb1ed13181..f947db7a65 100644 --- a/tests/ConditionsIOV/Conditions/Ecal/Calibration.yml/0 +++ b/tests/ConditionsIOV/Conditions/Ecal/Calibration.yml/0 @@ -12083,3 +12083,6 @@ Quality: size: 2 Reco: ZShowerMax: -282.0 +Gammas: + data: [] + size: 2 -- GitLab