Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion RecFCCeeCalorimeter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,21 @@ add_test(NAME FCCeeCalo_DigitizationWhiteningFilter
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/Testing/Temporary
)
set_test_env(FCCeeCalo_DigitizationWhiteningFilter)
set_tests_properties(FCCeeCalo_DigitizationWhiteningFilter PROPERTIES FIXTURES_REQUIRED ALLEGRO_sim_files)
set_tests_properties(FCCeeCalo_DigitizationWhiteningFilter PROPERTIES FIXTURES_REQUIRED ALLEGRO_sim_files)


if(BUILD_TESTING)
gaudi_add_module( k4RecFCCeeCalorimeterTests
SOURCES tests/src/TubeLayerModuleThetaCaloToolTestAlg.cpp
LINK k4FWCore::k4FWCore
k4FWCore::k4Interface
Gaudi::GaudiKernel
RecCaloCommon
)

add_test( NAME TubeLayerModuleThetaCaloTool_test
COMMAND k4run ${PROJECT_SOURCE_DIR}/RecFCCeeCalorimeter/tests/options/TubeLayerModuleThetaCaloTool_test.py
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/Testing/Temporary
)
set_test_env( TubeLayerModuleThetaCaloTool_test )
endif()
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "TubeLayerModuleThetaCaloTool.h"
#include "RecCaloCommon/IDMapIndexer.h"

// dd4hep
#include "DD4hep/Detector.h"
Expand All @@ -7,12 +8,16 @@
// k4geo
#include "detectorCommon/DetUtils_k4geo.h"

#include <stdexcept>


DECLARE_COMPONENT(TubeLayerModuleThetaCaloTool)


StatusCode TubeLayerModuleThetaCaloTool::collectCells(std::vector<CellID>& cells) const
{
cells.reserve (2041344);
Comment thread
scott-snyder marked this conversation as resolved.

// Get the total number of active volumes in the geometry
unsigned int numLayers = m_activeVolumesNumber;
info() << "Number of active layers " << numLayers << endmsg;
Expand Down Expand Up @@ -72,3 +77,27 @@ StatusCode TubeLayerModuleThetaCaloTool::collectCells(std::vector<CellID>& cells

return StatusCode::SUCCESS;
}


/** Return a new indexer object for this subdetector.
*/
std::unique_ptr<k4::recCalo::ICaloIndexer>
TubeLayerModuleThetaCaloTool::indexer() const
{
using Indexer_t = k4::recCalo::IDMapIndexer<3>;
dd4hep::IDDescriptor idSpec = readout().idSpec();
std::vector<Indexer_t::FieldDesc_t> fields
{ Indexer_t::IDMap_t::makeDesc (*idSpec.field("layer")),
Indexer_t::IDMap_t::makeDesc (*idSpec.field("theta")),
Indexer_t::IDMap_t::makeDesc (*idSpec.field("module")) };

const dd4hep::BitFieldElement& sysField = *idSpec.field("system");
if (sysField.offset() != 0) {
throw std::runtime_error ("Bad system field offset; must be zero");
}

// Allegro Ecal requires ~ 15M for indexing. Hint 16.
return std::make_unique<Indexer_t> (this->id(),
sysField.width(),
fields, cellIDs(), 16*1024*1024);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class TubeLayerModuleThetaCaloTool : public CalorimeterToolBase {
virtual ~TubeLayerModuleThetaCaloTool() = default;


/** Return a new indexer object for this subdetector.
*/
virtual std::unique_ptr<k4::recCalo::ICaloIndexer> indexer() const override final;


protected:
/** Fill vector with all existing cells for this geometry.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# File: RecFCCeeCalorimeter/tests/options/TubeLayerModuleThetaCaloTool_test.py
# Author: scott snyder <snyder@bnl.gov>
# Date: Jan, 2026
# Purpose: Test for TubeLayerModuleThetaCaloTool
#

import os
import Configurables as C

compactFile = 'ALLEGRO_o1_v03.xml'
pathToDetector = os.environ.get('K4GEO','') + '/FCCee/ALLEGRO/compact/' + os.path.splitext(compactFile)[0]

geoSvc = C.GeoSvc('GeoSvc',
detectors = [os.path.join (pathToDetector, compactFile)])

caloTool = C.TubeLayerModuleThetaCaloTool \
('ecalBarrelGeometryTool',
readoutName = 'ECalBarrelModuleThetaMerged',
activeVolumeName = "LAr_sensitive",
activeFieldName = "layer",
activeVolumesNumber = 11,
fieldNames = ["system"],
fieldValues = [4]) # ECAL_Barrel


appmgr = C.ApplicationMgr \
(TopAlg = [C.k4__recCalo__TubeLayerModuleThetaCaloToolTestAlg(CalorimeterTool = caloTool)],
ExtSvc = [geoSvc])
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* @file RecFCCeeCalorimeter/tests/src/TubeLayerModuleThetaCaloToolTestAlg.cpp
* @author scott snyder <snyder@bnl.gov>
* @date Jan, 2026
* @brief Test for TubeLayerModuleThetaCaloToolTest
*/

#undef NDEBUG
#include "RecCaloCommon/ICalorimeterTool.h"
#include "k4FWCore/GaudiChecks.h"
#include "GaudiKernel/Algorithm.h"
#include "GaudiKernel/ToolHandle.h"
#include <span>
#include <cassert>


namespace k4::recCalo {


class TubeLayerModuleThetaCaloToolTestAlg
: public Algorithm
{
using Algorithm::Algorithm;

virtual StatusCode initialize() override;
virtual StatusCode execute() override;

private:
ToolHandle<k4::recCalo::ICalorimeterTool> m_tool
{ this, "CalorimeterTool", "TubeLayerModuleThetaCaloTool", "" };
};


DECLARE_COMPONENT(k4::recCalo::TubeLayerModuleThetaCaloToolTestAlg);


StatusCode TubeLayerModuleThetaCaloToolTestAlg::initialize()
{
K4_GAUDI_CHECK( m_tool.retrieve() );
K4_GAUDI_CHECK( m_tool->readoutName() == "ECalBarrelModuleThetaMerged" );
K4_GAUDI_CHECK( m_tool->id() == 4 );

std::span<const uint64_t> ids = m_tool->cellIDs();
size_t ncells = ids.size();
K4_GAUDI_CHECK( ncells == 2041344 );

std::unique_ptr<ICaloIndexer> indexer = m_tool->indexer();
K4_GAUDI_CHECK( indexer != nullptr );
K4_GAUDI_CHECK( indexer->detIDBits() == 4 );

K4_GAUDI_CHECK( indexer->cellIDs().size() == ncells );
for (size_t i = 0; i < ncells; i++) {
K4_GAUDI_CHECK( ids[i] == indexer->cellIDs()[i] );
K4_GAUDI_CHECK( indexer->index(ids[i]) == i );
}

return StatusCode::SUCCESS;
}


StatusCode TubeLayerModuleThetaCaloToolTestAlg::execute()
{
return StatusCode::SUCCESS;
}


} // namespace k4::recCalo
Loading