15#include "phdst/functions.hpp"
16#include "phdst/phciii.hpp"
17#include "phdst/uxcom.hpp"
18#include "phdst/uxlink.hpp"
19#include "skelana/pscbsp.hpp"
20#include "skelana/pscevt.hpp"
29extern "C" void bpilot_(
float* btesla,
float* bgevcm);
34extern "C" void dstqid_(
char* tag, std::size_t len);
37namespace sk = skelana;
40std::string processingTag() {
43 std::string tag(buf,
sizeof(buf));
44 tag.erase(tag.find_last_not_of(
' ') + 1);
50[[noreturn]]
void refuse(
const std::string& what) {
51 throw std::runtime_error(what +
" (run " + std::to_string(ph::IIIRUN)
52 +
", event " + std::to_string(ph::IIIEVT) +
')');
58void checkEventIsUsable() {
63 if (ph::IPHPIC(
"DANA", 0) <= 0) {
64 refuse(
"DANA pilot blocklet absent, so the centre-of-mass energy would be "
65 "SKELANA's 91.250 GeV fallback rather than a stored value");
70 if (sk::ECMAS <= 0.f) {
71 refuse(
"centre-of-mass energy is " + std::to_string(sk::ECMAS) +
" GeV");
81 constexpr float kCm2Mm = 10.0f;
85 stored(
"runNumber", ph::IIIRUN);
86 stored(
"eventNumber", ph::IIIEVT);
87 stored(
"fileSeq", ph::IIFILE);
88 stored(
"date", ph::IIIDAT);
89 stored(
"time", ph::IIITIM);
90 stored(
"fillNumber", ph::IIFILL);
91 stored(
"experiment", ph::IIIEXP);
92 stored(
"dstVersion", sk::ISVER);
97 stored(
"dstProcessingTag", processingTag());
98 stored(
"pxdstVersion", ph::LDTOP > 0 ? ph::IQ(ph::LDTOP + 3) : 0);
104 stored(
"ECMS", sk::ECMAS);
108 float btesla = 0.f, bgevcm = 0.f;
110 stored(
"BField", btesla);
111 stored(
"BFieldGevPerCm", bgevcm);
119 counted(
"hadronicTagTeam4", sk::IHAD4);
120 counted(
"nChargedTeam4", sk::NCTR4);
121 counted(
"nCharged", sk::NCTRK);
122 counted(
"nNeutral", sk::NNTRK);
123 counted(
"EChargedTotal", sk::ECHAR);
124 counted(
"ENeutralEM", sk::EMNEU);
125 counted(
"ENeutralHad", sk::EHNEU);
133 auto bs = [&](
float cm) {
134 return usable ? cm * kCm2Mm : std::numeric_limits<float>::quiet_NaN();
137 beamspot(
"BeamSpotX", bs(sk::XYZBS(1)));
138 beamspot(
"BeamSpotY", bs(sk::XYZBS(2)));
139 beamspot(
"BeamSpotZ", bs(sk::XYZBS(3)));
140 beamspot(
"BeamSpotSigmaX", bs(sk::DXYZBS(1)));
141 beamspot(
"BeamSpotSigmaY", bs(sk::DXYZBS(2)));
142 beamspot(
"BeamSpotSigmaZ", bs(sk::DXYZBS(3)));
143 beamspot(
"BeamSpotErrorCode", sk::IERRBS);
void bpilot_(float *btesla, float *bgevcm)
void dstqid_(char *tag, std::size_t len)
ParameterGroup parameters(std::string_view bank, Provenance prov)
constexpr bool positionUsable(int errorCode)