delphi-edm4hep
DELPHI SDST/FDST -> EDM4hep converter
Loading...
Searching...
No Matches
AabtagTrackState.cpp
Go to the documentation of this file.
2
5
6#include "skelana/pscbsp.hpp"
7
8#include <algorithm>
9#include <array>
10#include <limits>
11
12namespace sk = skelana;
13
14namespace delphi_edm4hep::aabtag {
15
16namespace {
17constexpr double kCm2Mm = 10.0;
18constexpr float kNotMeasured = std::numeric_limits<float>::quiet_NaN();
19} // namespace
20
21std::unordered_map<int, int> lpaToTrack() {
22 std::unordered_map<int, int> out;
23 const auto status = eventStatus(sk::IERRBS, IBAD());
24 if (!status.valid || !status.algorithmInvoked) return out;
25 const int ntrk = std::clamp(NTRK(), 0, kMaxTracks);
26 for (int i = 1; i <= ntrk; ++i) out.emplace(IADTR(i), i);
27 return out;
28}
29
30edm4hep::TrackState vertexState(int i, int charge) {
31 edm4hep::TrackState st{};
32 st.location = edm4hep::TrackState::AtVertex;
33 // AAdcae (aabtagxx.car:12997) signs PARIMP positive when the vertex lies
34 // outside the track circle, which is -charge times the EDM4hep D0; EZED is
35 // vertex z minus track z, the negative of the EDM4hep Z0.
36 st.D0 = static_cast<float>(-charge * PARIMP(i) * kCm2Mm);
37 st.Z0 = static_cast<float>(-EZED(i) * kCm2Mm);
38 st.phi = kNotMeasured;
39 st.omega = kNotMeasured;
40 st.tanLambda = kNotMeasured;
41 st.time = kNotMeasured;
42 st.referencePoint = {static_cast<float>(POSVX(1) * kCm2Mm),
43 static_cast<float>(POSVX(2) * kCm2Mm),
44 static_cast<float>(POSVX(3) * kCm2Mm)};
45 // Only D0 and Z0 are measured; the rest stay NaN rather than zero, which
46 // would claim a measurement that was never made.
47 std::array<float, 21> cov;
48 cov.fill(kNotMeasured);
49 const float dD0 = static_cast<float>(SIGIMP(i) * kCm2Mm);
50 const float dZ0 = static_cast<float>(SIGZED(i) * kCm2Mm);
51 cov[0] = dD0 * dD0; // (D0, D0)
52 cov[9] = dZ0 * dZ0; // (Z0, Z0)
53 st.covMatrix = cov;
54 return st;
55}
56
57} // namespace delphi_edm4hep::aabtag
std::int32_t & NTRK()
std::int32_t & IBAD()
std::unordered_map< int, int > lpaToTrack()
constexpr EventStatus eventStatus(int beamSpotErrorCode, int rawBadEventCode)
std::int32_t & IADTR(int i)
edm4hep::TrackState vertexState(int i, int charge)
constexpr int kMaxTracks