9#include <reconstruction/modules/EventT0Combiner/EventT0Combiner.h>
19 setDescription(
"Module to combine the EventT0 values from multiple sub-detectors");
27 B2DEBUG(20,
"EventT0 object not created, cannot do EventT0 combination");
34 if (
m_eventT0->getTemporaryEventT0s().empty()) {
35 B2DEBUG(20,
"No temporary EventT0s available, can't chose the best one.");
41 B2DEBUG(20,
"EventT0 already based on SVD information, nothing to do.");
47 if (
m_eventT0->hasTemporaryEventT0(Const::SVD)) {
48 const auto& bestSVDT0 =
m_eventT0->getBestSVDTemporaryEventT0();
50 B2DEBUG(20,
"EventT0 is set to SVD EventT0.");
59 const auto& bestCDCT0 =
m_eventT0->getBestCDCTemporaryEventT0();
60 if ((*bestCDCT0).algorithm ==
"chi2") {
61 B2DEBUG(20,
"Using CDC chi2 EventT0.");
64 B2DEBUG(20,
"Current EventT0 is based on CDC, but it's not the chi2 value. Continue Search.");
70 const auto& bestECLT0 =
m_eventT0->getBestECLTemporaryEventT0();
71 const auto& cdcT0Candidates =
m_eventT0->getTemporaryEventT0s(Const::CDC);
72 const auto& hitBasedCDCT0Candidate = std::find_if(cdcT0Candidates.begin(), cdcT0Candidates.end(), [](
const auto & a) { return a.algorithm ==
"hit based";});
80 if (bestECLT0 and hitBasedCDCT0Candidate != cdcT0Candidates.end()) {
81 B2DEBUG(20,
"Combining ECL EventT0 and CDC hit based EventT0.");
85 }
else if (bestECLT0 and hitBasedCDCT0Candidate == cdcT0Candidates.end()) {
86 B2DEBUG(20,
"Using ECL EventT0, as CDC hit based EventT0 is not available.");
89 }
else if (hitBasedCDCT0Candidate != cdcT0Candidates.end() and not bestECLT0) {
90 B2DEBUG(20,
"Using CDC hit based EventT0, as ECL EventT0 is not available.");
91 m_eventT0->setEventT0(*hitBasedCDCT0Candidate);
94 B2DEBUG(20,
"There is no EventT0 from neither \n" \
95 " * the SVD based algorithm\n" \
96 " * the CDC based chi^2 algorithm\n" \
97 " * the CDC based hit-based algorithm\n" \
98 " * the ECL algorithm.\n" \
99 "Thus, no EventT0 value can be calculated.");
107 if (measurements.size() == 0) {
108 B2FATAL(
"Need at least one EvenT0 Measurement to do a sensible combination.");
111 double eventT0 = 0.0f;
112 double preFactor = 0.0f;
116 for (
auto const& meas : measurements) {
117 usedDetectorSet += meas.detectorSet;
118 const double oneOverUncertaintySquared = 1.0f / std::pow(meas.eventT0Uncertainty, 2.0);
119 eventT0 += meas.eventT0 * oneOverUncertaintySquared;
120 preFactor += oneOverUncertaintySquared;
123 eventT0 /= preFactor;
124 const auto eventT0unc = std::sqrt(1.0f / preFactor);
The DetectorSet class for sets of detector IDs in the form of EDetector values.
StoreObjPtr< EventT0 > m_eventT0
Access to global EventT0 which will be read and updated.
void event() override
This method is called for each event.
EventT0::EventT0Component computeCombination(std::vector< EventT0::EventT0Component > measurements) const
computes the new average between multiple, un-correlated sub-detector measurements
EventT0CombinerModule()
Default constructor.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
#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.