35 B2DEBUG(20,
"EventT0 object not created, cannot do EventT0 combination");
45 if (
m_eventT0->getTemporaryEventT0s().empty()) {
46 B2DEBUG(20,
"No temporary EventT0s available, can't chose the best one.");
55 B2DEBUG(20,
"EventT0 already based on SVD information, nothing to do.");
66 if (
m_eventT0->hasTemporaryEventT0(Const::SVD)) {
67 const auto& bestSVDT0 =
m_eventT0->getBestSVDTemporaryEventT0();
69 B2DEBUG(20,
"EventT0 is set to SVD EventT0.");
83 const auto& bestCDCT0 =
m_eventT0->getBestCDCTemporaryEventT0();
84 if ((*bestCDCT0).algorithm ==
"chi2") {
85 B2DEBUG(20,
"Using CDC chi2 EventT0.");
93 B2DEBUG(20,
"Current EventT0 is based on CDC, but it's not the chi2 value. Continue Search.");
99 const auto& bestECLT0 =
m_eventT0->getBestECLTemporaryEventT0();
100 const auto& cdcT0Candidates =
m_eventT0->getTemporaryEventT0s(Const::CDC);
101 const auto& hitBasedCDCT0Candidate = std::find_if(cdcT0Candidates.begin(), cdcT0Candidates.end(), [](
const auto & a) { return a.algorithm ==
"hit based";});
109 if (bestECLT0 and hitBasedCDCT0Candidate != cdcT0Candidates.end()) {
110 B2DEBUG(20,
"Combining ECL EventT0 and CDC hit based EventT0.");
120 }
else if (bestECLT0 and hitBasedCDCT0Candidate == cdcT0Candidates.end()) {
121 B2DEBUG(20,
"Using ECL EventT0, as CDC hit based EventT0 is not available.");
129 }
else if (hitBasedCDCT0Candidate != cdcT0Candidates.end() and not bestECLT0) {
130 B2DEBUG(20,
"Using CDC hit based EventT0, as ECL EventT0 is not available.");
131 m_eventT0->setEventT0(*hitBasedCDCT0Candidate);
139 B2DEBUG(20,
"There is no EventT0 from neither \n" \
140 " * the SVD based algorithm\n" \
141 " * the CDC based chi^2 algorithm\n" \
142 " * the CDC based hit-based algorithm\n" \
143 " * the ECL algorithm.\n" \
144 "Thus, no EventT0 value can be calculated.");
153 if (measurements.size() == 0) {
154 B2FATAL(
"Need at least one EvenT0 Measurement to do a sensible combination.");
157 double eventT0 = 0.0f;
158 double preFactor = 0.0f;
162 for (
auto const& meas : measurements) {
163 usedDetectorSet += meas.detectorSet;
164 const double oneOverUncertaintySquared = 1.0f /
square(meas.eventT0Uncertainty);
165 eventT0 += meas.eventT0 * oneOverUncertaintySquared;
166 preFactor += oneOverUncertaintySquared;
169 eventT0 /= preFactor;
170 const auto eventT0unc = std::sqrt(1.0f / preFactor);