delphi-edm4hep
DELPHI SDST/FDST -> EDM4hep converter
Loading...
Searching...
No Matches
SticShower.cpp
Go to the documentation of this file.
1// SticShowerWriter — runs in both passes.
2//
3// Reads the SKELANA PSCSTC common (skelana/pscemf_hpc_hac_stic.hpp). The
4// common is a fixed table with one row per VECP track, not a list of showers:
5// QSTIC(1..3, i) energy, theta, phi (real)
6// KSTIC(4..9, i) towers, large-veto tag, combined-veto tag,
7// veto multiplicity A and B, Si-strip vertex (integer)
8// It is zeroed every event, so a track whose row is all zero has no shower.
9// NSTIC counts the rows that were filled; it is not an array length.
10//
11// SKELANA fills the common from either STIC(19), the fullDST module, when the
12// PA carries it, or SSTC(33), the shortDST condensation, otherwise (PSHSTC,
13// skelana.car:6394). On the SSTC path words 1..3 are the track's MAIN-module
14// kinematics rather than STIC measurements, word 4 uses a different scale,
15// word 5 is a photon/electron code, and 7..8 stay zero.
16//
17// The collection name follows the pass (SSTC on sDST, STIC on fDST), not the
18// module that supplied the values.
19
21
22#include "skelana/pscemf_hpc_hac_stic.hpp" // NSTIC, KSTIC, QSTIC, LENSTC
23#include "skelana/pscvec.hpp" // LVPART, NVECP
24
25#include <edm4hep/ClusterCollection.h>
26#include <edm4hep/MutableCluster.h>
27
28#include <algorithm>
29#include <cstdint>
30
31namespace sk = skelana;
32
34
35namespace {
36constexpr std::int32_t kTypeBitStic = 0x8; // bit 3 (0=HPC,1=EMF,2=HCAL,3=STIC)
37} // namespace
38
40{
41 edm4hep::ClusterCollection col;
42
43 // Pass 1 reads the shortDST module SSTC; the fullDST carries STIC.
44 const char* bank = fromFullDst() ? "STIC" : "SSTC";
45
46 const int last = std::min(sk::NVECP, sk::MTRACK);
47 for (int i = sk::LVPART; i <= last; ++i) {
48 bool filled = false;
49 for (int k = 1; k <= sk::LENSTC; ++k) filled = filled || sk::KSTIC(k, i) != 0;
50 if (!filled) continue;
51
52 auto clu = col.create();
53 clu.setType(kTypeBitStic);
54 clu.setEnergy(sk::QSTIC(1, i));
55 clu.setITheta(sk::QSTIC(2, i));
56 clu.setIPhi (sk::QSTIC(3, i));
57 // Words 4..9, integer throughout.
58 for (int k = 4; k <= sk::LENSTC; ++k) {
59 clu.addToShapeParameters(static_cast<float>(sk::KSTIC(k, i)));
60 }
61
62 // Attach the shower to the particle built from the same VECP slot. Only
63 // pass 1 carries that map; pass-2 clusters are left unattached.
64 if (ctx_.tracking) {
65 auto& tracking = *ctx_.tracking;
66 if (i < static_cast<int>(tracking.vecp_to_particle.size())) {
67 const int p = tracking.vecp_to_particle[i];
68 if (p >= 0) tracking.particle_handles[p].addToClusters(clu);
69 }
70 }
71 }
72
73 put(std::move(col), bank, "Showers", Provenance::Derived);
74}
75
76} // namespace delphi_edm4hep::stic_shower
const Coll & put(Coll &&coll, std::string_view bank, std::string_view readable, Provenance prov)