9 #include <reconstruction/modules/EventT0Combiner/EventT0Combiner.h>
19 setDescription(
"Module to combine the EventT0 values from multiple sub-detectors");
21 addParam(
"combinationLogic", m_paramCombinationMode,
"Method of how the final T0 is selected.\n"
22 "Currently '" + m_combinationModePreferCDC +
"' and '" + m_combinationModeCombineCDCandECL +
"' is available\n" +
23 m_combinationModePreferCDC +
": the CDC t0 value (if available) will be set as the final T0 value."
24 "Only if no CDC value could be found "
25 "(which is very rare for BBBar events, and around 5% of low multiplicity events), the best ECL value will be set\n" +
26 m_combinationModeCombineCDCandECL +
": In this mode, the CDC t0 value (if available) will be used to "
27 "select the ECL t0 information which is closest in time "
28 "to the best CDC value and this two values will be combined to one final value.",
29 m_combinationModePreferCDC);
31 setPropertyFlags(c_ParallelProcessingCertified);
37 B2DEBUG(20,
"EventT0 object not created, cannot do EventT0 combination");
42 auto cdcHypos =
m_eventT0->getTemporaryEventT0s(Const::EDetector::CDC);
44 if (cdcHypos.size() == 0) {
45 B2DEBUG(20,
"No CDC time hypothesis available, stopping");
50 const auto cdcBestT0 = cdcHypos.back();
52 B2DEBUG(20,
"Best CDC time hypothesis t0 = " << cdcBestT0.eventT0 <<
" +- " << cdcBestT0.eventT0Uncertainty);
56 B2DEBUG(20,
"Setting CDC time hypothesis t0 = " << cdcBestT0.eventT0 <<
" +- " << cdcBestT0.eventT0Uncertainty <<
57 " as new final value.");
62 auto eclHypos =
m_eventT0->getTemporaryEventT0s(Const::EDetector::ECL);
64 if (eclHypos.size() == 0) {
65 B2DEBUG(20,
"No ECL t0 hypothesis available, exiting");
70 double bestDistance = std::numeric_limits<double>::max();
71 bool foundMatch =
false;
72 for (
auto const& eclHypo : eclHypos) {
74 double dist = std::abs(eclHypo.eventT0 - cdcBestT0.eventT0);
75 B2DEBUG(20,
"Checking compatibility of ECL t0 = " << eclHypo.eventT0 <<
" +- " << eclHypo.eventT0Uncertainty <<
" distance = " <<
77 if (dist < bestDistance) {
78 eclBestMatch = eclHypo;
90 B2DEBUG(20,
"Combined T0 from CDC and ECL is t0 = " << combined.eventT0 <<
" +- " << combined.eventT0Uncertainty);
96 B2DEBUG(20,
"No sufficient match found between CDC and ECL timing, setting best CDC t0 = " << cdcBestT0.eventT0 <<
" +- " <<
97 cdcBestT0.eventT0Uncertainty);
106 if (measurements.size() == 0) {
107 B2FATAL(
"Need at least one EvenT0 Measurement to do a sensible combination.");
110 double eventT0 = 0.0f;
111 double preFactor = 0.0f;
115 for (
auto const& meas : measurements) {
116 usedDetectorSet += meas.detectorSet;
117 const double oneOverUncertaintySquared = 1.0f / std::pow(meas.eventT0Uncertainty, 2.0);
118 eventT0 += meas.eventT0 * oneOverUncertaintySquared;
119 preFactor += oneOverUncertaintySquared;
122 eventT0 /= preFactor;
123 const auto eventT0unc = std::sqrt(1.0f / preFactor);
The DetectorSet class for sets of detector IDs in the form of EDetector values.
Module to combine the EventT0 values from multiple sub-detectors.
std::string m_paramCombinationMode
Mode to combine the t0 values of the sub-detectors.
StoreObjPtr< EventT0 > m_eventT0
Access to global EventT0 which will be read and updated.
void event() override
This method is called for each event.
const std::string m_combinationModeCombineCDCandECL
In this mode, the CDC t0 value (if available) will be used to select the ECL t0 information which is ...
const std::string m_combinationModePreferCDC
In this mode, the CDC t0 value (if available) will be set as the final T0 value.
EventT0::EventT0Component computeCombination(std::vector< EventT0::EventT0Component > measurements) const
computes the new average between multiple, un-correlated sub-detector measurements
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.
Structure for storing the extracted event t0s together with its detector and its uncertainty.
double eventT0
Storage of the T0 estimation.
double eventT0Uncertainty
Storage of the uncertainty of the T0 estimation.