diff --git a/Simulation/Tools/RD53BEncoding/src/RD53BEncodingAlg.cxx b/Simulation/Tools/RD53BEncoding/src/RD53BEncodingAlg.cxx index 28185b0d95928fdacf218377eff50115cbb58e4b..72294ba2a0d44dbca0542849b0414047c2e93481 100644 --- a/Simulation/Tools/RD53BEncoding/src/RD53BEncodingAlg.cxx +++ b/Simulation/Tools/RD53BEncoding/src/RD53BEncodingAlg.cxx @@ -55,7 +55,7 @@ StatusCode RD53BEncodingAlg::initialize() { StatusCode RD53BEncodingAlg::initializeStreams(const ToolHandleArray< RD53BEncodingTool >& encondingTools) { std::vector < std::vector < float > > barrel_module_z = {{0.}, {0.}, {0.}, {0.}, {0.}}; - std::vector < std::vector < float > > endcap_module_z = {{}, {}, {}, {}, {}}; + std::vector < std::vector < float > > endcap_module_z = {{}, {}, {}, {}, {}, {}, {}, {}}; InDetDD::SiDetectorElementCollection::const_iterator element; for (element = m_pixelManager->getDetectorElementBegin(); element != m_pixelManager->getDetectorElementEnd(); ++element) { @@ -85,8 +85,8 @@ StatusCode RD53BEncodingAlg::initializeStreams(const ToolHandleArray< RD53BEncod // using phi_module == 0 is an arbitrary choice if (pixPhiMod==0) { float module_z = (*element)->center().z(); - (*element)->isBarrel() ? barrel_module_z.at(pixLayerDisk).push_back(module_z) : endcap_module_z.at(pixLayerDisk).push_back(module_z); ATH_MSG_DEBUG("--> MODULES: " << pixBrlEc << "/" << pixLayerDisk << "/" << pixEtaMod << "/" << pixPhiMod << " --> " << module_z << "| chips: " << chips << " --> rows/cols: " << design->rowsPerCircuit() << "/" << design->columnsPerCircuit()); + (*element)->isBarrel() ? barrel_module_z.at(pixLayerDisk).push_back(module_z) : endcap_module_z.at(pixLayerDisk).push_back(module_z); } for (const ToolHandle<RD53BEncodingTool>& encodingTool : encondingTools) { @@ -99,7 +99,7 @@ StatusCode RD53BEncodingAlg::initializeStreams(const ToolHandleArray< RD53BEncod } } - + for (const ToolHandle<RD53BEncodingTool>& encodingTool : encondingTools) { // when booking the histograms, you pass as well the module position // it is then stored in the tools and is used to bin the histograms accordingly diff --git a/Simulation/Tools/RD53BEncoding/src/RD53BEncodingTool.cxx b/Simulation/Tools/RD53BEncoding/src/RD53BEncodingTool.cxx index 582c8a6e173bd55f105456abde58fb660e643277..1377c9e9bfc4c61c76a0e8fe3bb27fafcf235952 100644 --- a/Simulation/Tools/RD53BEncoding/src/RD53BEncodingTool.cxx +++ b/Simulation/Tools/RD53BEncoding/src/RD53BEncodingTool.cxx @@ -909,34 +909,63 @@ StatusCode RD53BEncodingTool::bookHistograms(std::vector < std::vector < float > m_bins[BARREL]={{0.,}, {0.,}, {0.,}, {0.,}, {0.,}}; m_bins[ENDCAP]={{200.,}, {200.,}, {1000.,}, {1000.,}, {1000.,}}; - for (unsigned int layer = 0; layer<5 ; layer++) { - // sorting the z values before calculating the bin ranges - std::sort(barrel_z.at(layer).begin(), barrel_z.at(layer).end()); - std::sort(endcap_z.at(layer).begin(), endcap_z.at(layer).end()); - // skipping first bin since it is 0. for the barrel - for (unsigned int z_bin = 1; z_bin<(barrel_z.at(layer).size()-1); z_bin++) { - m_bins[BARREL].at(layer).push_back(0.5*(barrel_z.at(layer).at(z_bin)+barrel_z.at(layer).at(z_bin+1))); + // this triggers the new identifier schema for new geometries. + unsigned int maxLayersBarrel = 0; + for (auto& module_positions : m_module_z_layer[BARREL]) + if (not module_positions.empty()) maxLayersBarrel++; + unsigned int maxLayersEndcap = 0; + for (auto& module_positions : m_module_z_layer[ENDCAP]) + if (not module_positions.empty()) maxLayersEndcap++; + + ATH_MSG_DEBUG("--> Using " << maxLayersBarrel << "/" << maxLayersEndcap << " layers..."); + + m_bins[BARREL] = {{0.,}, {0.,}, {0.,}, {0.,}, {0.,}}; + + if (maxLayersEndcap>m_bins[ENDCAP].size()) { + ATH_MSG_DEBUG("--> Resetting min value for bins..."); + m_bins[ENDCAP]={{200.,}, {200.,}, {350.,}, {1000.,}, {350.,}, {1000.,}, {350.,}, {1000.,}}; + } + + unsigned int maxLayers = std::max(maxLayersBarrel, maxLayersEndcap); + + for (unsigned int layer = 0; layer<maxLayers ; layer++) { + if (layer<maxLayersBarrel) { + ATH_MSG_DEBUG("--> BARREL: " << layer); + // sorting the z values before calculating the bin ranges + std::sort(barrel_z.at(layer).begin(), barrel_z.at(layer).end()); + // skipping first bin since it is 0. for the barrel + for (unsigned int z_bin = 1; z_bin<(barrel_z.at(layer).size()-1); z_bin++) { + m_bins[BARREL].at(layer).push_back(0.5*(barrel_z.at(layer).at(z_bin)+barrel_z.at(layer).at(z_bin+1))); + } + // add last values + double last_value = 2.*barrel_z.at(layer).back()-barrel_z.at(layer).at(barrel_z.at(layer).size()-2); + if (last_value<1500.) + m_bins[BARREL].at(layer).push_back(last_value); + m_bins[BARREL].at(layer).push_back(1500.); } - // add last values - double last_value = 2.*barrel_z.at(layer).back()-barrel_z.at(layer).at(barrel_z.at(layer).size()-2); - if (last_value<1500.) - m_bins[BARREL].at(layer).push_back(last_value); - m_bins[BARREL].at(layer).push_back(1500.); - for (unsigned int z_bin = 0; z_bin<(endcap_z.at(layer).size()-1); z_bin++) { - m_bins[ENDCAP].at(layer).push_back(0.5*(endcap_z.at(layer).at(z_bin)+endcap_z.at(layer).at(z_bin+1))); + if (layer<maxLayersEndcap) { + ATH_MSG_DEBUG("--> ENDCAP: " << layer); + // sorting the z values before calculating the bin ranges + std::sort(endcap_z.at(layer).begin(), endcap_z.at(layer).end()); + for (unsigned int z_bin = 0; z_bin<(endcap_z.at(layer).size()-1); z_bin++) { + m_bins[ENDCAP].at(layer).push_back(0.5*(endcap_z.at(layer).at(z_bin)+endcap_z.at(layer).at(z_bin+1))); + } + // add last values + double last_value = 2.*endcap_z.at(layer).back()-endcap_z.at(layer).at(endcap_z.at(layer).size()-2); + if (last_value<3000.) + m_bins[ENDCAP].at(layer).push_back(last_value); + m_bins[ENDCAP].at(layer).push_back(3000.); } - // add last values - last_value = 2.*endcap_z.at(layer).back()-endcap_z.at(layer).at(endcap_z.at(layer).size()-2); - if (last_value<3000.) - m_bins[ENDCAP].at(layer).push_back(last_value); - m_bins[ENDCAP].at(layer).push_back(3000.); } for (int region=0; region<N_REGIONS; region++) { - for (unsigned int layer=0; layer<5; layer++) { + for (unsigned int layer=0; layer<maxLayers; layer++) { + if (region==BARREL and layer>=maxLayersBarrel) + continue; + std::vector < double >& bins = m_bins[region].at(layer); m_p_streamlength_per_stream[layer][region] = new TProfile(("m_p_streamlength_per_stream_"+m_regionLabels[region]+"_"+std::to_string(layer)).c_str(), (m_regionLabels[region]+" Stream Length - Layer "+std::to_string(layer)+"; z[mm]; <stream length> [bits]").c_str(), int(bins.size()-1), &bins[0]); diff --git a/Simulation/Tools/RD53BEncoding/src/RD53BEncodingTool.h b/Simulation/Tools/RD53BEncoding/src/RD53BEncodingTool.h index b085adbafa512bcccb9572b54f90574ac5ad72d7..617e0288ff9e7d168db45def1e28dff2fbb70e5f 100644 --- a/Simulation/Tools/RD53BEncoding/src/RD53BEncodingTool.h +++ b/Simulation/Tools/RD53BEncoding/src/RD53BEncodingTool.h @@ -56,7 +56,7 @@ public: private: - const static int N_LAYERS=5; + const static int N_LAYERS=8; enum Region { INVALID_REGION=-1, BARREL, ENDCAP, N_REGIONS