Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:13:09

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022, 2023 Whitney Armstrong, Wouter Deconinck, David Lawrence
0003 //
0004 
0005 #pragma once
0006 
0007 #include <DD4hep/Detector.h>
0008 #include <DDRec/CellIDPositionConverter.h>
0009 #include <JANA/JApplicationFwd.h>
0010 #include <JANA/JServiceFwd.h>
0011 #include <spdlog/logger.h>
0012 #include <gsl/pointers>
0013 #include <memory>
0014 #include <mutex>
0015 #include <string>
0016 #include <vector>
0017 
0018 class DD4hep_service : public JService {
0019 public:
0020   DD4hep_service(JApplication* app) : m_app(app) {}
0021   virtual ~DD4hep_service();
0022 
0023   virtual gsl::not_null<const dd4hep::Detector*> detector();
0024   virtual gsl::not_null<const dd4hep::rec::CellIDPositionConverter*> converter();
0025 
0026 protected:
0027   void Initialize();
0028 
0029 private:
0030   DD4hep_service() = default;
0031   void acquire_services(JServiceLocator*) override;
0032 
0033   std::once_flag init_flag;
0034   JApplication* m_app                                                            = nullptr;
0035   std::unique_ptr<const dd4hep::Detector> m_dd4hepGeo                            = nullptr;
0036   std::unique_ptr<const dd4hep::rec::CellIDPositionConverter> m_cellid_converter = nullptr;
0037   std::vector<std::string> m_xml_files;
0038 
0039   /// Ensures there is a geometry file that should be opened
0040   static std::string resolveFileName(const std::string& filename, char* detector_path_env);
0041 
0042   std::shared_ptr<spdlog::logger> m_log;
0043 };