11 #include <reconstruction/modules/EventT0Combiner/EventT0Combiner.h>
21 setDescription(
"Module to combine the EventT0 values from multiple sub-detectors");
23 addParam(
"combinationLogic", m_paramCombinationMode,
"Method of how the final T0 is selected.\n"
24 "Currently '" + m_combinationModePreferCDC +
"' and '" + m_combinationModeCombineCDCandECL +
"' is available\n" +
25 m_combinationModePreferCDC +
": the CDC t0 value (if available) will be set as the final T0 value."
26 "Only if no CDC value could be found "
27 "(which is very rare for BBBar events, and around 5% of low multiplicity events), the best ECL value will be set\n" +
28 m_combinationModeCombineCDCandECL +
": In this mode, the CDC t0 value (if available) will be used to "
29 "select the ECL t0 information which is closest in time "
30 "to the best CDC value and this two values will be combined to one final value.",
31 m_combinationModePreferCDC);
33 setPropertyFlags(c_ParallelProcessingCertified);
39 B2DEBUG(20,
"EventT0 object not created, cannot do EventT0 combination");
44 auto cdcHypos =
m_eventT0->getTemporaryEventT0s(Const::EDetector::CDC);
46 if (cdcHypos.size() == 0) {
47 B2DEBUG(20,
"No CDC time hypothesis available, stopping");
52 const auto cdcBestT0 = cdcHypos.back();
54 B2DEBUG(20,
"Best CDC time hypothesis t0 = " << cdcBestT0.eventT0 <<
" +- " << cdcBestT0.eventT0Uncertainty);
58 B2DEBUG(20,
"Setting CDC time hypothesis t0 = " << cdcBestT0.eventT0 <<
" +- " << cdcBestT0.eventT0Uncertainty <<
59 " as new final value.");
64 auto eclHypos =
m_eventT0->getTemporaryEventT0s(Const::EDetector::ECL);
66 if (eclHypos.size() == 0) {
67 B2DEBUG(20,
"No ECL t0 hypothesis available, exiting");
72 double bestDistance = std::numeric_limits<double>::max();
73 bool foundMatch =
false;
74 for (
auto const& eclHypo : eclHypos) {
76 double dist = std::abs(eclHypo.eventT0 - cdcBestT0.eventT0);
77 B2DEBUG(20,
"Checking compatibility of ECL t0 = " << eclHypo.eventT0 <<
" +- " << eclHypo.eventT0Uncertainty <<
" distance = " <<
79 if (dist < bestDistance) {
80 eclBestMatch = eclHypo;
92 B2DEBUG(20,
"Combined T0 from CDC and ECL is t0 = " << combined.eventT0 <<
" +- " << combined.eventT0Uncertainty);
98 B2DEBUG(20,
"No sufficient match found between CDC and ECL timing, setting best CDC t0 = " << cdcBestT0.eventT0 <<
" +- " <<
99 cdcBestT0.eventT0Uncertainty);
108 if (measurements.size() == 0) {
109 B2FATAL(
"Need at least one EvenT0 Measurement to do a sensible combination.");
112 double eventT0 = 0.0f;
113 double preFactor = 0.0f;
117 for (
auto const& meas : measurements) {
118 usedDetectorSet += meas.detectorSet;
119 const double oneOverUncertaintySquared = 1.0f / std::pow(meas.eventT0Uncertainty, 2.0);
120 eventT0 += meas.eventT0 * oneOverUncertaintySquared;
121 preFactor += oneOverUncertaintySquared;
124 eventT0 /= preFactor;
125 const auto eventT0unc = std::sqrt(1.0f / preFactor);