delphi-edm4hep
DELPHI SDST/FDST -> EDM4hep converter
Loading...
Searching...
No Matches
TeadFdst.cpp
Go to the documentation of this file.
1// TeadFdstWriter — pass-2 implementation.
2//
3// LDTOP-10 chain (unassociated TE BANK 10), sub-banks 5 = TOF barrel,
4// 11 = HOF forward. Walk via LQ links: ltead = LQ(LDTOP-10);
5// lcur = LQ(ltead - 5) for the first TOF hit, then lcur = LQ(lcur)
6// until lcur=0.
7//
8// TOF barrel layout (sub-bank 5):
9// Q(+5) = R (constant 311.25 cm)
10// Q(+6) = R*phi (cm) → phi = R*phi / R
11// Q(+7) = Z (cm) ∈ [-347, +347]
12// Q(+10) = time (ns)
13//
14// HOF forward layout (sub-bank 11): standard TE format, (X, Y, Z)
15// direct; time NOT decoded at this DST level.
16
18
19#include "phdst/uxcom.hpp"
20#include "phdst/uxlink.hpp"
21
22#include <edm4hep/CalorimeterHitCollection.h>
23#include <edm4hep/MutableCalorimeterHit.h>
24
25#include <cmath>
26
27namespace ph = phdst;
28
30
31namespace {
32constexpr float kCm2Mm = 10.f;
33}
34
36{
37 edm4hep::CalorimeterHitCollection tof_col;
38 edm4hep::CalorimeterHitCollection hof_col;
39
40 const int LDTOP = ph::LDTOP;
41 if (LDTOP <= 0) {
42 put(std::move(tof_col), "TEAD", "TOFHits", Provenance::Transcribed);
43 put(std::move(hof_col), "TEAD", "HOFHits", Provenance::Transcribed);
44 return;
45 }
46
47 const int ltead = ph::LQ(LDTOP - 10);
48 if (ltead <= 0) {
49 put(std::move(tof_col), "TEAD", "TOFHits", Provenance::Transcribed);
50 put(std::move(hof_col), "TEAD", "HOFHits", Provenance::Transcribed);
51 return;
52 }
53
54 // sub-bank 5 = TOF barrel.
55 for (int lcur = ph::LQ(ltead - 5); lcur > 0; lcur = ph::LQ(lcur)) {
56 const float R = ph::Q(lcur + 5);
57 const float Rphi = ph::Q(lcur + 6);
58 const float Z = ph::Q(lcur + 7);
59 const float t_ns = ph::Q(lcur + 10);
60 const float phi = (R > 0.f) ? (Rphi / R) : 0.f;
61 const float X = R * std::cos(phi);
62 const float Y = R * std::sin(phi);
63 auto hit = tof_col.create();
64 hit.setEnergy(0.f); // TOF: no energy at this DST level
65 hit.setEnergyError(0.f);
66 hit.setTime(t_ns);
67 hit.setType(0);
68 hit.setPosition({ X * kCm2Mm, Y * kCm2Mm, Z * kCm2Mm });
69 }
70
71 // sub-bank 11 = HOF forward.
72 for (int lcur = ph::LQ(ltead - 11); lcur > 0; lcur = ph::LQ(lcur)) {
73 const float X = ph::Q(lcur + 5);
74 const float Y = ph::Q(lcur + 6);
75 const float Z = ph::Q(lcur + 7);
76 auto hit = hof_col.create();
77 hit.setEnergy(0.f);
78 hit.setEnergyError(0.f);
79 hit.setTime(0.f); // HOF time not decoded — see header
80 hit.setType(0);
81 hit.setPosition({ X * kCm2Mm, Y * kCm2Mm, Z * kCm2Mm });
82 }
83
84 put(std::move(tof_col), "TEAD", "TOFHits", Provenance::Transcribed);
85 put(std::move(hof_col), "TEAD", "HOFHits", Provenance::Transcribed);
86}
87
88} // namespace delphi_edm4hep::tead_fdst
const Coll & put(Coll &&coll, std::string_view bank, std::string_view readable, Provenance prov)
Definition PaWalk.h:21