File indexing completed on 2024-09-28 07:03:04
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <DD4hep/DetElement.h>
0010
0011 #include <DD4hep/Detector.h>
0012 #include <DD4hep/Objects.h>
0013 #include <DDRec/CellIDPositionConverter.h>
0014 #include <DDSegmentation/BitFieldCoder.h>
0015 #include <Parsers/Primitives.h>
0016 #include <TRandomGen.h>
0017 #include <spdlog/logger.h>
0018 #include <functional>
0019 #include <gsl/pointers>
0020 #include <memory>
0021 #include <string>
0022
0023
0024 #include "RichGeo.h"
0025
0026 namespace richgeo {
0027 class ReadoutGeo {
0028 public:
0029
0030
0031 ReadoutGeo(std::string detName_, gsl::not_null<const dd4hep::Detector*> det_, gsl::not_null<const dd4hep::rec::CellIDPositionConverter*> conv_, std::shared_ptr<spdlog::logger> log_);
0032 ~ReadoutGeo() {}
0033
0034
0035 CellIDType cellIDEncoding(int isec, int ipdu, int isipm, int x, int y)
0036 {
0037
0038 dd4hep::rec::CellID cellID_dd4hep;
0039 m_readoutCoder->set(cellID_dd4hep, "system", m_systemID);
0040 m_readoutCoder->set(cellID_dd4hep, "sector", isec);
0041 m_readoutCoder->set(cellID_dd4hep, "pdu", ipdu);
0042 m_readoutCoder->set(cellID_dd4hep, "sipm", isipm);
0043 m_readoutCoder->set(cellID_dd4hep, "x", x);
0044 m_readoutCoder->set(cellID_dd4hep, "y", y);
0045 CellIDType cellID(cellID_dd4hep);
0046 return cellID;
0047
0048 }
0049
0050
0051 void VisitAllReadoutPixels(std::function<void(CellIDType)> lambda) { m_loopCellIDs(lambda); }
0052
0053
0054 void VisitAllRngPixels(std::function<void(CellIDType)> lambda, float p) { m_rngCellIDs(lambda, p); }
0055
0056
0057 bool PixelGapMask(CellIDType cellID, dd4hep::Position pos_hit_global);
0058
0059
0060
0061 dd4hep::Position GetSensorLocalPosition(CellIDType id, dd4hep::Position pos);
0062
0063
0064 void SetSeed(unsigned long seed) { m_random.SetSeed(seed); }
0065
0066 protected:
0067
0068
0069 std::shared_ptr<spdlog::logger> m_log;
0070 std::string m_detName;
0071 gsl::not_null<const dd4hep::Detector*> m_det;
0072 gsl::not_null<const dd4hep::rec::CellIDPositionConverter*> m_conv;
0073 dd4hep::DetElement m_detRich;
0074 dd4hep::BitFieldCoder* m_readoutCoder;
0075 int m_systemID;
0076 int m_num_sec;
0077 int m_num_pdus;
0078 int m_num_sipms_per_pdu;
0079 int m_num_px;
0080 double m_pixel_size;
0081
0082
0083 std::function< void(std::function<void(CellIDType)>) > m_loopCellIDs;
0084
0085 std::function< void(std::function<void(CellIDType)>, float) > m_rngCellIDs;
0086
0087 private:
0088
0089
0090 TRandomMixMax m_random;
0091
0092 };
0093 }