delphi-edm4hep
DELPHI SDST/FDST -> EDM4hep converter
Loading...
Searching...
No Matches
VftHits.cpp
Go to the documentation of this file.
1// VftHitsWriter — pass-1 implementation.
2//
3// PXTD layout (production DESCRIP, bank 42):
4// word 1 number of clusters
5// per cluster, 11 words then one word per pixel:
6// 1 module (crown + 1000 * raquette)
7// 2..4 x, y, z in the DELPHI frame, times 10000
8// 5,6 x, z in the module frame, times 10000
9// 7,8 errors on those two, times 10000
10// 9 TANAGRA identifier of the TK or TE
11// 10 pixels in the cluster + 100 * truth label
12// 11 TANAGRA identifier of the TDR
13// Stored lengths are in cm.
14
16
17#include "phdst/uxcom.hpp"
18#include "phdst/uxlink.hpp"
19
20#include <edm4hep/TrackerHitPlaneCollection.h>
21#include <podio/UserDataCollection.h>
22
23#include <cstdint>
24#include <limits>
25
26namespace ph = phdst;
27
29
30namespace {
31constexpr int kPxtdLink = 42; // LQ(LDTOP-42)
32constexpr int kWordsPerHit = 11;
33constexpr double kScale = 10000.0; // stored coordinates are scaled
34constexpr double kCm2Mm = 10.0;
35constexpr float kNotMeasured = std::numeric_limits<float>::quiet_NaN();
36
37double coord(int address) { return ph::IQ(address) / kScale * kCm2Mm; }
38} // namespace
39
41{
42 edm4hep::TrackerHitPlaneCollection hits;
43 podio::UserDataCollection<std::int32_t> cluster_size;
44 podio::UserDataCollection<std::int32_t> tanagra_id;
45
46 const int ldtop = ph::LDTOP;
47 // The bank is reachable only when the DTOP link area is long enough to
48 // hold its slot; older files stop short of it.
49 if (ldtop > 0 && ph::IQ(ldtop - 3) >= kPxtdLink) {
50 if (const int l = ph::LQ(ldtop - kPxtdLink); l > 0) {
51 const int blen = ph::IQ(l - 1);
52 const int nhit = ph::IQ(l + 1);
53 int w = 2;
54 for (int i = 0; i < nhit; ++i) {
55 if (w + kWordsPerHit - 1 > blen) break;
56 const int npix = ph::IQ(l + w + 9) % 100;
57
58 auto hit = hits.create();
59 hit.setCellID(static_cast<std::uint64_t>(ph::IQ(l + w)));
60 hit.setPosition({coord(l + w + 1), coord(l + w + 2), coord(l + w + 3)});
61 hit.setDu(static_cast<float>(coord(l + w + 6)));
62 hit.setDv(static_cast<float>(coord(l + w + 7)));
63 hit.setU({kNotMeasured, kNotMeasured});
64 hit.setV({kNotMeasured, kNotMeasured});
65
66 cluster_size.push_back(npix);
67 tanagra_id.push_back(ph::IQ(l + w + 8));
68
69 w += kWordsPerHit + npix;
70 }
71 }
72 }
73
74 // Emitted whether or not the file carries the bank, so the collection set
75 // does not vary between samples.
76 put(std::move(hits), "PXTD", "PixelHits", Provenance::Transcribed);
77 put(std::move(cluster_size), "PXTD", "PixelHits_ClusterSize", Provenance::Transcribed);
78 put(std::move(tanagra_id), "PXTD", "PixelHits_TanagraId", Provenance::Transcribed);
79}
80
81} // namespace delphi_edm4hep::vft_hits
const Coll & put(Coll &&coll, std::string_view bank, std::string_view readable, Provenance prov)
Definition PaWalk.h:21