Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-09 08:30:24

0001 // Copyright (C) 2022, 2023, Christopher Dilks
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 
0004 // bind IRT and DD4hep geometries for the RICHes
0005 #pragma once
0006 
0007 #include <DD4hep/DetElement.h>
0008 #include <DD4hep/Detector.h>
0009 #include <DD4hep/Objects.h>
0010 #include <DDRec/CellIDPositionConverter.h>
0011 #include <DDRec/DetectorData.h>
0012 #include <IRT/CherenkovDetector.h>
0013 #include <IRT/CherenkovDetectorCollection.h>
0014 #include <Math/GenVector/Cartesian3D.h>
0015 #include <Math/GenVector/DisplacementVector3D.h>
0016 #include <spdlog/logger.h>
0017 #include <gsl/pointers>
0018 #include <memory>
0019 #include <string>
0020 #include <unordered_map>
0021 
0022 // local
0023 #include "RichGeo.h"
0024 
0025 namespace richgeo {
0026 class IrtGeo {
0027 public:
0028   // constructor: creates IRT-DD4hep bindings using main `Detector` handle `*det_`
0029   IrtGeo(std::string detName_, gsl::not_null<const dd4hep::Detector*> det_,
0030          gsl::not_null<const dd4hep::rec::CellIDPositionConverter*> conv_,
0031          std::shared_ptr<spdlog::logger> log_);
0032   virtual ~IrtGeo();
0033 
0034   // access the full IRT geometry
0035   CherenkovDetectorCollection* GetIrtDetectorCollection() const { return m_irtDetectorCollection; }
0036 
0037 protected:
0038   // protected methods
0039   virtual void DD4hep_to_IRT() = 0; // given DD4hep geometry, produce IRT geometry
0040   void
0041   SetReadoutIDToPositionLambda(); // define the `cell ID -> pixel position` converter, correcting to sensor surface
0042   void SetRefractiveIndexTable(); // fill table of refractive indices
0043   // read `VariantParameters` for a vector
0044   template <class VecT>
0045   VecT GetVectorFromVariantParameters(dd4hep::rec::VariantParameters* pars, std::string key) const {
0046     return VecT(pars->get<double>(key + "_x"), pars->get<double>(key + "_y"),
0047                 pars->get<double>(key + "_z"));
0048   }
0049 
0050   // inputs
0051   std::string m_detName;
0052 
0053   // DD4hep geometry handles
0054   gsl::not_null<const dd4hep::Detector*> m_det;
0055   dd4hep::DetElement m_detRich;
0056   dd4hep::Position m_posRich;
0057 
0058   // cell ID conversion
0059   gsl::not_null<const dd4hep::rec::CellIDPositionConverter*> m_converter;
0060   std::unordered_map<int, richgeo::Sensor> m_sensor_info; // sensor ID -> sensor info
0061 
0062   // IRT geometry handles
0063   CherenkovDetectorCollection* m_irtDetectorCollection{};
0064   CherenkovDetector* m_irtDetector{};
0065 
0066   // logger
0067   std::shared_ptr<spdlog::logger> m_log;
0068 
0069 private:
0070   // set all geometry handles
0071   void Bind();
0072 };
0073 } // namespace richgeo