Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-07-03 07:05:27

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 
0029       // constructor: creates IRT-DD4hep bindings using main `Detector` handle `*det_`
0030       IrtGeo(std::string detName_, gsl::not_null<const dd4hep::Detector*> det_, gsl::not_null<const dd4hep::rec::CellIDPositionConverter*> conv_, std::shared_ptr<spdlog::logger> log_);
0031       virtual ~IrtGeo();
0032 
0033       // access the full IRT geometry
0034       CherenkovDetectorCollection *GetIrtDetectorCollection() { return m_irtDetectorCollection; }
0035 
0036     protected:
0037 
0038       // protected methods
0039       virtual void DD4hep_to_IRT() = 0;    // given DD4hep geometry, produce IRT geometry
0040       void SetReadoutIDToPositionLambda(); // define the `cell ID -> pixel position` converter, correcting to sensor surface
0041       void SetRefractiveIndexTable();      // fill table of refractive indices
0042       // read `VariantParameters` for a vector
0043       template<class VecT>
0044         VecT GetVectorFromVariantParameters(dd4hep::rec::VariantParameters *pars, std::string key) {
0045           return VecT(pars->get<double>(key+"_x"), pars->get<double>(key+"_y"), pars->get<double>(key+"_z"));
0046         }
0047 
0048       // inputs
0049       std::string m_detName;
0050 
0051       // DD4hep geometry handles
0052       gsl::not_null<const dd4hep::Detector*> m_det;
0053       dd4hep::DetElement m_detRich;
0054       dd4hep::Position   m_posRich;
0055 
0056       // cell ID conversion
0057       gsl::not_null<const dd4hep::rec::CellIDPositionConverter*> m_converter;
0058       std::unordered_map<int,richgeo::Sensor> m_sensor_info; // sensor ID -> sensor info
0059 
0060       // IRT geometry handles
0061       CherenkovDetectorCollection *m_irtDetectorCollection;
0062       CherenkovDetector           *m_irtDetector;
0063 
0064       // logger
0065       std::shared_ptr<spdlog::logger> m_log;
0066 
0067     private:
0068 
0069       // set all geometry handles
0070       void Bind();
0071   };
0072 }