From 4bfc5e6ddc29a915dafc87f6c98612b71556f3ed Mon Sep 17 00:00:00 2001 From: Archil Durglishvili Date: Mon, 2 Dec 2024 15:41:50 +0100 Subject: [PATCH] Added some sanity checks of the HCal xml --- .../src/FCCSWHCalPhiRow_k4geo.cpp | 42 ++++++++++++++++++- .../src/FCCSWHCalPhiTheta_k4geo.cpp | 34 ++++++++++++++- 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/detectorSegmentations/src/FCCSWHCalPhiRow_k4geo.cpp b/detectorSegmentations/src/FCCSWHCalPhiRow_k4geo.cpp index 09d644982..3bae5de42 100644 --- a/detectorSegmentations/src/FCCSWHCalPhiRow_k4geo.cpp +++ b/detectorSegmentations/src/FCCSWHCalPhiRow_k4geo.cpp @@ -83,11 +83,51 @@ void FCCSWHCalPhiRow_k4geo::calculateLayerRadii() const { // check if all necessary variables are available if(m_detLayout==-1 || m_offsetZ.empty() || m_widthZ.empty() || m_offsetR.empty() || m_numLayers.empty() || m_dRlayer.empty()) { - dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!", + dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!\n%s", "One of the variables is missing: detLayout | offset_z | width_z | offset_r | numLayers | dRlayer"); return; } + // some sanity checks of the xml + if( m_offsetZ.size() != m_offsetR.size() ) + { + dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!\n%s", + "Number of elements in offsetZ and offsetR must be the same!"); + return; + } + if( m_widthZ.size() != m_offsetR.size() ) + { + dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!\n%s", + "Number of elements in widthZ and offsetR must be the same!"); + return; + } + if( m_detLayout == 0 && m_offsetZ.size() != 1) + { + dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!\n%s", + "Number of elements in offsetZ/offsetR/widthZ must be 1 for the Barrel!"); + return; + } + if( m_numLayers.size() % m_offsetZ.size() != 0 ) + { + dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!\n%s", + "Number of elements in numLayers must be multiple of offsetZ.size()!"); + return; + } + if( m_dRlayer.size() != m_numLayers.size()/m_offsetZ.size() ) + { + dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!\n%s", + "Number of elements in dRlayer must be equal to numLayers.size()/offsetZ.size()!"); + return; + } + uint nlayers = 0; + for(auto n : m_numLayers) nlayers+=n; + if( m_gridSizeRow.size() != nlayers ) + { + dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!\n%s", + "Number of elements in gridSizeRow must be equal to sum of contents of numLayers!"); + return; + } + if(m_detLayout==0) dd4hep::printout(dd4hep::INFO, "FCCSWHCalPhiRow_k4geo","Barrel configuration found!"); else dd4hep::printout(dd4hep::INFO, "FCCSWHCalPhiRow_k4geo","EndCap configuration found!"); diff --git a/detectorSegmentations/src/FCCSWHCalPhiTheta_k4geo.cpp b/detectorSegmentations/src/FCCSWHCalPhiTheta_k4geo.cpp index 07770e633..08346e4f6 100644 --- a/detectorSegmentations/src/FCCSWHCalPhiTheta_k4geo.cpp +++ b/detectorSegmentations/src/FCCSWHCalPhiTheta_k4geo.cpp @@ -79,11 +79,43 @@ void FCCSWHCalPhiTheta_k4geo::defineCellsInRZplan() const { // check if all necessary variables are available if(m_detLayout==-1 || m_offsetZ.empty() || m_widthZ.empty() || m_offsetR.empty() || m_numLayers.empty() || m_dRlayer.empty()) { - dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!", + dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!\n%s", "One of the variables is missing: detLayout | offset_z | width_z | offset_r | numLayers | dRlayer"); return; } + // some sanity checks of the xml + if( m_offsetZ.size() != m_offsetR.size() ) + { + dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!\n%s", + "Number of elements in offsetZ and offsetR must be the same!"); + return; + } + if( m_widthZ.size() != m_offsetR.size() ) + { + dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!\n%s", + "Number of elements in widthZ and offsetR must be the same!"); + return; + } + if( m_detLayout == 0 && m_offsetZ.size() != 1) + { + dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!\n%s", + "Number of elements in offsetZ/offsetR/widthZ must be 1 for the Barrel!"); + return; + } + if( m_numLayers.size() % m_offsetZ.size() != 0 ) + { + dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!\n%s", + "Number of elements in numLayers must be multiple of offsetZ.size()!"); + return; + } + if( m_dRlayer.size() != m_numLayers.size()/m_offsetZ.size() ) + { + dd4hep::printout(dd4hep::ERROR, "FCCSWHCalPhiRow_k4geo","Please check the readout description in the XML file!\n%s", + "Number of elements in dRlayer must be equal to numLayers.size()/offsetZ.size()!"); + return; + } + if(m_detLayout==0) dd4hep::printout(dd4hep::INFO, "FCCSWHCalPhiRow_k4geo","Barrel configuration found!"); else dd4hep::printout(dd4hep::INFO, "FCCSWHCalPhiRow_k4geo","EndCap configuration found!");