EICrecon
JANA based reconstruction for the EPIC detector
Loading...
Searching...
No Matches
ReadoutGeo.h
Go to the documentation of this file.
1// Copyright (C) 2023, Christopher Dilks, Luigi Dello Stritto
2// Subject to the terms in the LICENSE file found in the top-level directory.
3//
4
5// helper functions for RICH readout
6
7#pragma once
8
9#include <DD4hep/DetElement.h>
10// DD4Hep
11#include <DD4hep/Detector.h>
12#include <DD4hep/Objects.h>
13#include <DDRec/CellIDPositionConverter.h>
14#include <DDSegmentation/BitFieldCoder.h>
15#include <Parsers/Primitives.h>
16#include <TRandomGen.h>
17#include <spdlog/logger.h>
18#include <functional>
19#include <gsl/pointers>
20#include <memory>
21#include <string>
22
23// local
24#include "RichGeo.h"
25
26namespace richgeo {
28public:
29 // constructor
30 ReadoutGeo(std::string detName_, std::string readoutClass_,
31 gsl::not_null<const dd4hep::Detector*> det_,
32 gsl::not_null<const dd4hep::rec::CellIDPositionConverter*> conv_,
33 std::shared_ptr<spdlog::logger> log_);
35
36 // define cellID encoding
37 CellIDType cellIDEncoding(int isec, int ipdu, int isipm, int x, int y) {
38 // encode cellID
39 dd4hep::rec::CellID cellID_dd4hep;
40 m_readoutCoder->set(cellID_dd4hep, "system", m_systemID);
41 m_readoutCoder->set(cellID_dd4hep, "sector", isec);
42 m_readoutCoder->set(cellID_dd4hep, "pdu", ipdu);
43 m_readoutCoder->set(cellID_dd4hep, "sipm", isipm);
44 m_readoutCoder->set(cellID_dd4hep, "x", x);
45 m_readoutCoder->set(cellID_dd4hep, "y", y);
46 CellIDType cellID(cellID_dd4hep); // in case DD4hep CellID type differs from EDM type
47 return cellID;
48 // m_log->trace(" x={:<2} y={:<2} => cellID={:#018X}", x, y, cellID);
49 }
50
51 // loop over readout pixels, executing `lambda(cellID)` on each
52 void VisitAllReadoutPixels(std::function<void(CellIDType)> lambda) { m_loopCellIDs(lambda); }
53
54 // generated k rng cell IDs, executing `lambda(cellID)` on each
55 void VisitAllRngPixels(std::function<void(CellIDType)> lambda, float p) {
56 m_rngCellIDs(lambda, p);
57 }
58
59 // pixel gap mask
60 bool PixelGapMask(CellIDType cellID, dd4hep::Position pos_hit_global) const;
61
62 // transform global position `pos` to sensor `id` frame position
63 // IMPORTANT NOTE: this has only been tested for the dRICH; if you use it, test it carefully...
64 dd4hep::Position GetSensorLocalPosition(CellIDType id, dd4hep::Position pos) const;
65
66 // set RNG seed
67 void SetSeed(unsigned long seed) { m_random.SetSeed(seed); }
68
69protected:
70 // common objects
71 std::shared_ptr<spdlog::logger> m_log;
72 std::string m_detName;
73 std::string m_readoutClass;
74 gsl::not_null<const dd4hep::Detector*> m_det;
75 gsl::not_null<const dd4hep::rec::CellIDPositionConverter*> m_conv;
76 dd4hep::DetElement m_detRich;
77 dd4hep::BitFieldCoder* m_readoutCoder;
84
85 // local function to loop over cellIDs; defined in initialization and called by `VisitAllReadoutPixels`
86 std::function<void(std::function<void(CellIDType)>)> m_loopCellIDs;
87 // local function to generate rng cellIDs; defined in initialization and called by `VisitAllRngPixels`
88 std::function<void(std::function<void(CellIDType)>, float)> m_rngCellIDs;
89
90private:
91 // random number generators
92 TRandomMixMax m_random;
93};
94} // namespace richgeo
Definition ReadoutGeo.h:27
dd4hep::BitFieldCoder * m_readoutCoder
Definition ReadoutGeo.h:77
gsl::not_null< const dd4hep::rec::CellIDPositionConverter * > m_conv
Definition ReadoutGeo.h:75
std::shared_ptr< spdlog::logger > m_log
Definition ReadoutGeo.h:71
void VisitAllReadoutPixels(std::function< void(CellIDType)> lambda)
Definition ReadoutGeo.h:52
std::function< void(std::function< void(CellIDType)>, float)> m_rngCellIDs
Definition ReadoutGeo.h:88
dd4hep::DetElement m_detRich
Definition ReadoutGeo.h:76
std::string m_readoutClass
Definition ReadoutGeo.h:73
~ReadoutGeo()
Definition ReadoutGeo.h:34
void VisitAllRngPixels(std::function< void(CellIDType)> lambda, float p)
Definition ReadoutGeo.h:55
void SetSeed(unsigned long seed)
Definition ReadoutGeo.h:67
bool PixelGapMask(CellIDType cellID, dd4hep::Position pos_hit_global) const
Definition ReadoutGeo.cc:121
std::function< void(std::function< void(CellIDType)>)> m_loopCellIDs
Definition ReadoutGeo.h:86
int m_num_pdus
Definition ReadoutGeo.h:80
int m_systemID
Definition ReadoutGeo.h:78
gsl::not_null< const dd4hep::Detector * > m_det
Definition ReadoutGeo.h:74
std::string m_detName
Definition ReadoutGeo.h:72
CellIDType cellIDEncoding(int isec, int ipdu, int isipm, int x, int y)
Definition ReadoutGeo.h:37
double m_pixel_size
Definition ReadoutGeo.h:83
int m_num_sec
Definition ReadoutGeo.h:79
dd4hep::Position GetSensorLocalPosition(CellIDType id, dd4hep::Position pos) const
Definition ReadoutGeo.cc:133
int m_num_px
Definition ReadoutGeo.h:82
int m_num_sipms_per_pdu
Definition ReadoutGeo.h:81
Definition ActsGeo.h:18
decltype(edm4hep::SimTrackerHitData::cellID) CellIDType
Definition RichGeo.h:14