Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:02:11

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 Wouter Deconinck, Sylvester Joosten
0003 //
0004 // DD4hep Geometry service exposing a detector(), world(), and cellIDPositionConverter()
0005 // Meant to be set by the calling framework, but can also load DD4hep itself
0006 // when given a compact file as Property.
0007 //
0008 #pragma once
0009 
0010 #include <gsl/gsl>
0011 #include <memory>
0012 
0013 #include "DDRec/CellIDPositionConverter.h"
0014 #include <DD4hep/Detector.h>
0015 
0016 #include <algorithms/logger.h>
0017 #include <algorithms/service.h>
0018 
0019 namespace algorithms {
0020 
0021 class GeoSvc : public LoggedService<GeoSvc> {
0022 public:
0023   // Initialize the geometry service, to be called after with a global detector
0024   // pointer (will not re-initialize), or after at least the detectors property was specified
0025   // (will load XML and then fully initialize)
0026   void init(const dd4hep::Detector* = nullptr);
0027 
0028   // TODO check const-ness
0029   gsl::not_null<const dd4hep::Detector*> detector() const { return m_detector; }
0030   dd4hep::DetElement world() const { return detector()->world(); }
0031   gsl::not_null<const dd4hep::rec::CellIDPositionConverter*> cellIDPositionConverter() const {
0032     return m_converter.get();
0033   }
0034 
0035 private:
0036   const dd4hep::Detector* m_detector = nullptr;
0037   std::unique_ptr<const dd4hep::Detector> m_detector_ptr;
0038   std::unique_ptr<const dd4hep::rec::CellIDPositionConverter> m_converter;
0039 
0040   // Configuration variables. These only need to be specified if we are actually running
0041   // in "standalone" mode (hence they're optional)
0042   Property<std::vector<std::string>> m_xml_list{
0043       this, "detectors", {}, "List of DD4hep compact files for standalone operation"};
0044 
0045   ALGORITHMS_DEFINE_LOGGED_SERVICE(GeoSvc)
0046 };
0047 
0048 } // namespace algorithms