File indexing completed on 2024-06-18 07:05:52
0001
0002
0003
0004 #include <DD4hep/Detector.h>
0005 #include <DD4hep/IDDescriptor.h>
0006 #include <DD4hep/Readout.h>
0007 #include <DD4hep/Segmentations.h>
0008 #include <algorithms/geo.h>
0009 #include <algorithms/random.h>
0010 #include <algorithms/service.h>
0011 #include <catch2/generators/catch_generators_random.hpp>
0012 #include <catch2/interfaces/catch_interfaces_reporter.hpp>
0013 #include <catch2/reporters/catch_reporter_event_listener.hpp>
0014 #include <catch2/reporters/catch_reporter_registrars.hpp>
0015 #include <services/evaluator/EvaluatorSvc.h>
0016 #include <services/pid_lut/PIDLookupTableSvc.h>
0017 #include <stddef.h>
0018 #include <cstdint>
0019 #include <memory>
0020 #include <string>
0021 #include <utility>
0022
0023 class algorithmsInitListener : public Catch::EventListenerBase {
0024 public:
0025 using Catch::EventListenerBase::EventListenerBase;
0026
0027 std::unique_ptr<const dd4hep::Detector> m_detector{nullptr};
0028
0029 void testRunStarting(Catch::TestRunInfo const&) override {
0030 auto detector = dd4hep::Detector::make_unique("");
0031 dd4hep::Readout readout(std::string("MockCalorimeterHits"));
0032 dd4hep::IDDescriptor id_desc("MockCalorimeterHits", "system:8,layer:8,x:8,y:8");
0033 readout.setIDDescriptor(id_desc);
0034 detector->add(id_desc);
0035 detector->add(readout);
0036
0037 dd4hep::Readout readoutTracker(std::string("MockTrackerHits"));
0038 dd4hep::IDDescriptor id_desc_tracker("MockTrackerHits", "system:8,layer:8,x:8,y:8");
0039
0040 dd4hep::Segmentation segmentation("CartesianGridXY","TrackerHitsSeg", id_desc_tracker.decoder());
0041 readoutTracker.setIDDescriptor(id_desc_tracker);
0042 readoutTracker.setSegmentation(segmentation);
0043 detector->add(id_desc_tracker);
0044 detector->add(readoutTracker);
0045
0046 m_detector = std::move(detector);
0047
0048 auto& serviceSvc = algorithms::ServiceSvc::instance();
0049 [[maybe_unused]] auto& geoSvc = algorithms::GeoSvc::instance();
0050 serviceSvc.setInit<algorithms::GeoSvc>([this](auto&& g) {
0051 g.init(this->m_detector.get());
0052 });
0053
0054 [[maybe_unused]] auto& randomSvc = algorithms::RandomSvc::instance();
0055 auto seed = Catch::Generators::Detail::getSeed();
0056 serviceSvc.setInit<algorithms::RandomSvc>([seed](auto&& r) {
0057 r.setProperty("seed", static_cast<size_t>(seed));
0058 r.init();
0059 });
0060
0061 auto& evaluatorSvc = eicrecon::EvaluatorSvc::instance();
0062 serviceSvc.add<eicrecon::EvaluatorSvc>(&evaluatorSvc);
0063
0064 auto& lutSvc = eicrecon::PIDLookupTableSvc::instance();
0065 serviceSvc.add<eicrecon::PIDLookupTableSvc>(&lutSvc);
0066
0067 serviceSvc.init();
0068 }
0069 };
0070
0071 CATCH_REGISTER_LISTENER(algorithmsInitListener)