delphi-edm4hep
DELPHI SDST/FDST -> EDM4hep converter
Loading...
Searching...
No Matches
Tof.cpp
Go to the documentation of this file.
1// TofWriter — implementation. Runs in both passes.
2//
3// Per dst_content.txt p.30 + dstana/.../toflibxx.car (verified ground
4// truth from the legacy delphi_fdst_pad_dump): PA.TOF layout is
5// Q(ltof+1) module label (= 9)
6// Q(ltof+2) counter number (raw, not exported here)
7// Q(ltof+3) NDSTCO (not used)
8// Q(ltof+4) R coordinate (raw; semantics flagged)
9// Q(ltof+5) Z coordinate (cm, physical)
10// Q(ltof+6) Time of flight (XTOF, ns) <-- exported as param[0]
11// Q(ltof+7) Error on time (ETOF, ns) <-- exported as param[1]
12// Q(ltof+10) ZXTOF extrapolated Z (cm, since v2.55; raw)
13
15
17
18#include <edm4hep/MutableParticleID.h>
19#include <edm4hep/ParticleIDCollection.h>
20#include <edm4hep/ReconstructedParticleCollection.h>
21
22#include <cstdint>
23
24namespace ph = phdst;
25
26namespace delphi_edm4hep::tof {
27
28namespace {
29constexpr std::int32_t kAlgoTof = 5;
30}
31
33{
34 edm4hep::ParticleIDCollection col;
35
36 pawalk::forEachPA([&](int lpa, int paIdx) {
37 const int ltof = pawalk::lphpa("TOF", lpa);
38 if (ltof <= 0) return;
39 const auto particle = particleForPa(paIdx);
40 if (!particle) return;
41
42 const float time_ns = ph::Q(ltof + 6);
43 const float sigma_ns = ph::Q(ltof + 7);
44
45 auto pid = col.create();
46 pid.setAlgorithmType(kAlgoTof);
47 pid.addToParameters(time_ns);
48 pid.addToParameters(sigma_ns);
49 pid.setParticle(*particle);
50 });
51
52 put(std::move(col), "TOF", "TimeOfFlight", Provenance::Transcribed);
53}
54
55} // namespace delphi_edm4hep::tof
std::optional< edm4hep::ReconstructedParticle > particleForPa(int paIdx) const
const Coll & put(Coll &&coll, std::string_view bank, std::string_view readable, Provenance prov)
void emit() override
Definition Tof.cpp:32
void forEachPA(F &&fn)
Definition PaWalk.h:67
int lphpa(const char *iddp, int lpa, int nump=0)
Definition PaWalk.h:34
Definition PaWalk.h:21