File indexing completed on 2026-04-01 07:48:50
0001
0002
0003
0004 #include "TrackerHitReconstruction.h"
0005
0006 #include <DD4hep/Objects.h>
0007 #include <Evaluator/DD4hepUnits.h>
0008 #include <Math/GenVector/Cartesian3D.h>
0009 #include <Math/GenVector/DisplacementVector3D.h>
0010 #include <algorithms/logger.h>
0011 #include <edm4eic/CovDiag3f.h>
0012 #include <edm4hep/Vector3f.h>
0013 #include <cstddef>
0014 #include <exception>
0015 #include <iterator>
0016 #include <vector>
0017
0018 namespace eicrecon {
0019
0020 namespace {
0021 inline double get_resolution(const double pixel_size) {
0022 constexpr const double sqrt_12 = 3.4641016151;
0023 return pixel_size / sqrt_12;
0024 }
0025 inline double get_variance(const double pixel_size) {
0026 const double res = get_resolution(pixel_size);
0027 return res * res;
0028 }
0029 }
0030
0031 void TrackerHitReconstruction::process(const Input& input, const Output& output) const {
0032 using dd4hep::mm;
0033
0034 const auto [raw_hits] = input;
0035 auto [rec_hits] = output;
0036
0037 for (const auto& raw_hit : *raw_hits) {
0038
0039 auto id = raw_hit.getCellID();
0040
0041
0042 dd4hep::Position pos;
0043 std::vector<double> dim;
0044 try {
0045 pos = m_converter->position(id);
0046 dim = m_converter->cellDimensions(id);
0047 } catch (const std::exception& e) {
0048 error("Failed to get position and dimension for cell ID {:x}: {}", id, e.what());
0049 continue;
0050 }
0051
0052
0053 if (level() == algorithms::LogLevel::kTrace) {
0054 trace("position x={:.2f} y={:.2f} z={:.2f} [mm]: ", pos.x() / mm, pos.y() / mm, pos.z() / mm);
0055 trace("dimension size: {}", dim.size());
0056 for (std::size_t j = 0; j < std::size(dim); ++j) {
0057 trace(" - dimension {:<5} size: {:.2}", j, dim[j]);
0058 }
0059 }
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 auto rec_hit = rec_hits->create(
0071 raw_hit.getCellID(),
0072 edm4hep::Vector3f{static_cast<float>(pos.x() / mm), static_cast<float>(pos.y() / mm),
0073 static_cast<float>(pos.z() / mm)},
0074 edm4eic::CovDiag3f{get_variance(dim[0] / mm),
0075 get_variance(dim[1] / mm),
0076 std::size(dim) > 2 ? get_variance(dim[2] / mm) : 0.},
0077 static_cast<float>((double)(raw_hit.getTimeStamp()) / 1000.0),
0078 m_cfg.timeResolution,
0079 static_cast<float>(raw_hit.getCharge() / 1.0e6),
0080 0.0F);
0081 rec_hit.setRawHit(raw_hit);
0082 }
0083 }
0084
0085 }