EICrecon
JANA based reconstruction for the EPIC detector
Loading...
Searching...
No Matches
MPGDTrackerDigi.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// Copyright (C) 2022 - 2025 Whitney Armstrong, Wouter Deconinck, Sylvester Joosten, Dmitry Romanov, Yann Bedfer
3
4#pragma once
5
6#include <DD4hep/Detector.h>
7#include <DD4hep/Objects.h>
8#include <DD4hep/Segmentations.h>
9#include <Parsers/Primitives.h>
10#include <algorithms/algorithm.h>
11#include <edm4eic/EDM4eicVersion.h>
12#include <edm4eic/MCRecoTrackerHitAssociationCollection.h>
13#include <edm4eic/RawTrackerHitCollection.h>
14#include <edm4hep/EventHeaderCollection.h>
15#include <edm4hep/SimTrackerHitCollection.h>
16#include <stddef.h>
17#include <cstdint>
18#include <functional>
19#include <iterator>
20#include <map>
21#include <random>
22#include <string>
23#include <string_view>
24#include <utility>
25#include <vector>
26
30
31#if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
32#include <edm4eic/MCRecoTrackerHitLinkCollection.h>
33#endif
34
35namespace eicrecon {
36
37using MPGDTrackerDigiAlgorithm = algorithms::Algorithm<
38 algorithms::Input<edm4hep::EventHeaderCollection, edm4hep::SimTrackerHitCollection>,
39 algorithms::Output<edm4eic::RawTrackerHitCollection,
40#if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
41 edm4eic::MCRecoTrackerHitLinkCollection,
42#endif
43 edm4eic::MCRecoTrackerHitAssociationCollection>>;
44
46 public WithPodConfig<MPGDTrackerDigiConfig> {
47
48public:
49 MPGDTrackerDigi(std::string_view name)
51 name,
52 {"eventHeaderCollection", "inputHitCollection"},
53 {"outputRawHitCollection",
54#if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
55 "outputHitLinks",
56#endif
57 "outputHitAssociations"},
58 "2D-strip segmentation, apply threshold, digitize within ADC range, "
59 "convert time with smearing resolution."} {
60 }
61
62 void init() final;
63 void process(const Input&, const Output&) const final;
64
65private:
66 const algorithms::UniqueIDGenSvc& m_uid = algorithms::UniqueIDGenSvc::instance();
67
68 // IDDESCRIPTOR and SEGMENTATION
69 void parseIDDescriptor();
70 void parseSegmentation();
71 double m_gridAngle{0};
72
73 // COALESCE and EXTEND
74 bool cCoalesceExtend(const Input& input, int& idx, std::vector<std::uint64_t>& cIDs, double* lpos,
75 double& eDep, double& time) const;
76 bool bCoalesceExtend(const Input& input, int& idx, std::vector<std::uint64_t>& cIDs, double* lpos,
77 double& eDep, double& time) const;
78 unsigned int cTraversing(const double* lpos, const double* lmom, double path,
79 bool isSecondary, // Input subHit
80 double rMin, double rMax, // Current instance of SUBVOLUME
81 double dZ, double startPhi, double endPhi, // Module parameters
82 double lintos[][3], double louts[][3], double* lpini,
83 double* lpend) const;
84 unsigned int bTraversing(const double* lpos, const double* lmom, double ref2Cur, double path,
85 bool isSecondary, // Input subHit
86 double dZ, // Current instance of SUBVOLUME
87 double dX, double dY, // Module parameters
88 double lintos[][3], double louts[][3], double* lpini,
89 double* lpend) const;
90 void printSubHitList(const Input& input, std::vector<int>& subHitList) const;
91 unsigned int extendHit(dd4hep::CellID modID, std::vector<std::uint64_t>& cIDs, int direction,
92 double* lpini, double* lmini, double* lpend, double* lmend) const;
93 unsigned int cExtension(double const* lpos, double const* lmom, // Input subHit
94 double rT, // Target radius
95 int direction, double dZ, double startPhi,
96 double endPhi, // Module parameters
97 double* lext) const;
98 unsigned int bExtension(const double* lpos, const double* lmom, // Input subHit
99 double zT, // Target Z
100 int direction, double dX, double dY, // Module parameters
101 double* lext) const;
102 bool samePMO(const edm4hep::SimTrackerHit&, const edm4hep::SimTrackerHit&) const;
103 bool denyExtension(const edm4hep::SimTrackerHit& sim_hit, double depth) const;
104 void flagUnexpected(const edm4hep::EventHeader& event, int shape, double expected,
105 const edm4hep::SimTrackerHit& sim_hit, double* lpini, double* lpend,
106 double* lpos, double* lmom) const;
107 std::function<int(double)> m_toleranceFactor;
108
110 const dd4hep::Detector* m_detector{nullptr};
111 dd4hep::Segmentation m_seg;
112 // IDDescriptor
113 const dd4hep::BitFieldCoder* m_id_dec{nullptr};
114 static constexpr const char* m_fieldNames[5] = // "volume": excluding channel specification
115 {"system", "layer", "module", "sensor", "strip"};
116 // CellIDs specifying IDDescriptor fields.
117 dd4hep::CellID m_volumeBits{0}; // "volume" bits, as opposed to channel# bits
118 dd4hep::CellID m_moduleBits{0}; // "volume" cleared of its "strip" bits.
119 // Strip (standing here for "SUBVOLUME") related fields.
120 dd4hep::CellID m_stripBits{0}; // "strip" field
121 dd4hep::CellID m_pStripBit{0}; // 'p' strip
122 dd4hep::CellID m_nStripBit{0}; // 'n' strip
123 dd4hep::CellID m_stripIDs[5]; // Ordered from inner to outer
125 std::function<int(dd4hep::CellID)> m_stripRank;
126 std::function<int(dd4hep::CellID, dd4hep::CellID)> m_orientation;
127 std::function<bool(int, unsigned int)> m_isUpstream;
128 std::function<bool(int, unsigned int)> m_isDownstream;
129
130 // ***** CLUSTERIZATION
131 using Cluster = std::vector<std::pair<dd4hep::CellID, double>>;
132 int get2HitCluster(dd4hep::CellID refID, dd4hep::Position& locPos, double* surfPos,
133 int pn, // 'p' or 'n' strip
134 std::default_random_engine& generator, Cluster& cluster) const;
135 std::function<double(dd4hep::FieldID, double, double)> m_binToPosition;
137 struct StripParameters {
138 double pitch, offset, min, max;
139 size_t index;
140 };
141 std::map<dd4hep::CellID, StripParameters> m_stripParameters;
142 size_t m_stripIndices[2];
143 // Charge spreading
144 static constexpr double m_truncation = 3; // Truncation of Gaussian spreading
146 // Index into StripParameters map
147 dd4hep::CellID m_sensorStripBits{0};
148 dd4hep::CellID m_sensorOffset;
149 // Charge spreading
150 dd4hep::CellID m_stripIncs[2];
151
153 static constexpr unsigned int m_intoLower = 0x1;
154 static constexpr unsigned int m_outLower = 0x2;
155 static constexpr unsigned int m_intoUpper = 0x4;
156 static constexpr unsigned int m_outUpper = 0x8;
157 static constexpr unsigned int m_canReEnter = 0x100;
158 static constexpr unsigned int m_inconsistency = 0xff000;
159};
160
161} // namespace eicrecon
Definition MPGDTrackerDigi.h:46
MPGDTrackerDigi(std::string_view name)
Definition MPGDTrackerDigi.h:49
Definition WithPodConfig.h:22
Definition ActsSvc.h:11
-client
Definition CalorimeterClusterRecoCoG.cc:37
void flagUnexpected(const edm4hep::EventHeader &event, int shape, double expected, const edm4hep::SimTrackerHit &sim_hit, double *lpini, double *lpend, double *lpos, double *lmom)
algorithms::Algorithm< algorithms::Input< edm4hep::EventHeaderCollection, edm4hep::SimTrackerHitCollection >, algorithms::Output< edm4eic::RawTrackerHitCollection, edm4eic::MCRecoTrackerHitLinkCollection, edm4eic::MCRecoTrackerHitAssociationCollection > > MPGDTrackerDigiAlgorithm
Definition MPGDTrackerDigi.h:43