delphi-edm4hep
DELPHI SDST/FDST -> EDM4hep converter
Loading...
Searching...
No Matches
EltrSdst.cpp
Go to the documentation of this file.
1// EltrSdstWriter — pass-1 implementation.
2//
3// PA.ELTR (label 28) layout mirrors PA.TRAC:
4// +2 d0 (cm) +3 z0 (cm) +4 theta (rad) +5 phi (rad) +6 1/R (1/cm)
5// +7..+21 15-element lower-tri weight matrix
6// converted to an EDM4hep helix AtIP TrackState via the shared
7// delphi_edm4hep::perigee helpers.
8
10
13
14#include <edm4hep/TrackCollection.h>
15#include <edm4hep/TrackState.h>
16#include <podio/UserDataCollection.h>
17
18#include <array>
19#include <cstdint>
20
21namespace ph = phdst;
22
24
26{
27 edm4hep::TrackCollection trkCol;
28 podio::UserDataCollection<std::int32_t> idxCol;
29
30 if (!ctx_.tracking) {
31 put(std::move(trkCol), "ELTR", "RefitTracks", Provenance::Transcribed);
32 put(std::move(idxCol), "ELTR", "RefitTracks_ParticleIndex",
34 return;
35 }
36 const auto& tracking = *ctx_.tracking;
37
38 pawalk::forEachPA([&](int lpa, int paIdx) {
39 const int leltr = pawalk::lphpa("ELTR", lpa);
40 if (leltr <= 0) return;
41
42 const float d0 = ph::Q(leltr + 2);
43 const float z0 = ph::Q(leltr + 3);
44 const float theta = ph::Q(leltr + 4);
45 const float phi = ph::Q(leltr + 5);
46 const float invR = ph::Q(leltr + 6);
47 std::array<float, 15> Wraw{};
48 for (int k = 0; k < 15; ++k) Wraw[k] = ph::Q(leltr + 7 + k);
49
50 const auto helix = Helix::fromPerigee(d0, z0, theta, phi, invR, &Wraw);
51 if (!helix.valid()) return; // degenerate sin(theta)
52
53 auto trk = trkCol.create();
54 trk.addToTrackStates(helix.toTrackState(edm4hep::TrackState::AtIP));
55
56 const int p_idx =
57 (paIdx >= 0 && paIdx < static_cast<int>(tracking.pa_to_particle.size()))
58 ? tracking.pa_to_particle[paIdx] : -1;
59 idxCol.push_back(p_idx);
60 });
61
62 put(std::move(trkCol), "ELTR", "RefitTracks", Provenance::Transcribed);
63 put(std::move(idxCol), "ELTR", "RefitTracks_ParticleIndex",
65}
66
67} // namespace delphi_edm4hep::eltr_sdst
const Coll & put(Coll &&coll, std::string_view bank, std::string_view readable, Provenance prov)
static Helix fromPerigee(float d0, float z0, float theta, float phi, float invR, const std::array< float, 15 > *W=nullptr)
Definition Helix.cpp:109
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