47 : ActsExamples::
IAlgorithm(
"PlanarSteppingAlgorithm", level),
50 throw std::invalid_argument(
"Missing input hits collection");
53 throw std::invalid_argument(
"Missing output clusters collection");
56 throw std::invalid_argument(
"Missing source links output collection");
59 throw std::invalid_argument(
60 "Missing digitization source links output collection");
63 throw std::invalid_argument(
"Missing measurements output collection");
66 throw std::invalid_argument(
67 "Missing hit-to-particles map output collection");
70 throw std::invalid_argument(
71 "Missing hit-to-simulated-hits map output collection");
74 throw std::invalid_argument(
"Missing tracking geometry");
77 throw std::invalid_argument(
"Missing planar module stepper");
80 throw std::invalid_argument(
"Missing random numbers tool");
103 dg.surface->associatedDetectorElement());
104 if (dg.detectorElement ==
nullptr) {
109 if (dg.digitizer ==
nullptr) {
120 const auto& simHits = m_inputSimHits(ctx);
125 std::vector<Acts::DigitizationSourceLink> digiSourceLinks;
131 clusters.reserve(simHits.size());
132 measurements.reserve(simHits.size());
133 hitParticlesMap.reserve(simHits.size());
134 hitSimHitsMap.reserve(simHits.size());
136 for (
auto&& [moduleGeoId, moduleSimHits] :
groupByModule(simHits)) {
138 const auto it = m_digitizables.find(moduleGeoId);
139 if (
it == m_digitizables.end()) {
143 const auto& dg =
it->second;
145 const auto invTransfrom = dg.surface->transform(ctx.
geoContext).inverse();
148 for (
auto ih = moduleSimHits.begin(); ih != moduleSimHits.end(); ++ih) {
149 const auto& simHit = *ih;
150 const auto simHitIdx = simHits.index_of(ih);
153 (invTransfrom * simHit.position()).head<2>();
154 Acts::Vector3 localDirection = invTransfrom.linear() * simHit.direction();
157 const auto thickness = dg.detectorElement->thickness();
158 const auto lorentzAngle = dg.digitizer->lorentzAngle();
159 auto lorentzShift =
thickness * std::tan(lorentzAngle);
160 lorentzShift *= -(dg.digitizer->readoutDirection());
162 std::vector<Acts::DigitizationStep> dSteps =
164 localIntersect, localDirection);
166 if (dSteps.empty()) {
174 double totalPath = 0.;
176 std::vector<Acts::DigitizationCell> usedCells;
177 usedCells.reserve(dSteps.size());
179 for (
auto dStep : dSteps) {
181 localX += dStep.stepLength * dStep.stepCellCenter.x();
182 localY += dStep.stepLength * dStep.stepCellCenter.y();
183 totalPath += dStep.stepLength;
185 dStep.stepCell.channel1,
190 localX += lorentzShift;
204 cov << 0.05, 0., 0., 0., 0.05, 0., 0., 0.,
209 digiSourceLinks.emplace_back(moduleGeoId,
210 std::vector<std::size_t>{simHitIdx});
215 localX, localY, simHit.time(),
std::move(usedCells));
222 sourceLinks.insert(sourceLinks.end(), sourceLink);
230 clusters.emplace_hint(clusters.end(), moduleGeoId,
std::move(cluster));
231 measurements.emplace_back(
std::move(meas));
233 hitParticlesMap.emplace_hint(hitParticlesMap.end(), hitIdx,
234 simHit.particleId());
235 hitSimHitsMap.emplace_hint(hitSimHitsMap.end(), hitIdx, simHitIdx);
239 ACTS_DEBUG(
"digitized " << simHits.size() <<
" hits into " << clusters.size()
242 m_outputClusters(ctx,
std::move(clusters));
243 m_outputSourceLinks(ctx,
std::move(sourceLinks));
244 m_outputDigiSourceLinks(ctx,
std::move(digiSourceLinks));
245 m_outputMeasurements(ctx,
std::move(measurements));
246 m_outputMeasurementParticlesMap(ctx,
std::move(hitParticlesMap));
247 m_outputMeasurementSimHitsMap(ctx,
std::move(hitSimHitsMap));