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.");
50 const auto& bestCDCT0 =
m_eventT0->getBestCDCTemporaryEventT0();
51 if ((*bestCDCT0).algorithm ==
"chi2") {
52 B2DEBUG(20,
"Using CDC chi2 EventT0.");
55 B2DEBUG(20,
"Current EventT0 is based on CDC, but it's not the chi2 value. Continue Search.");
61 const auto& bestECLT0 =
m_eventT0->getBestECLTemporaryEventT0();
62 const auto& cdcT0Candidates =
m_eventT0->getTemporaryEventT0s(Const::CDC);
63 const auto& hitBasedCDCT0Candidate = std::find_if(cdcT0Candidates.begin(), cdcT0Candidates.end(), [](
const auto & a) { return a.algorithm ==
"hit based";});
71 if (bestECLT0 and hitBasedCDCT0Candidate != cdcT0Candidates.end()) {
72 B2DEBUG(20,
"Combining ECL EventT0 and CDC hit based EventT0.");
76 }
else if (bestECLT0 and hitBasedCDCT0Candidate == cdcT0Candidates.end()) {
77 B2DEBUG(20,
"Using ECL EventT0, as CDC hit based EventT0 is not available.");
80 }
else if (hitBasedCDCT0Candidate != cdcT0Candidates.end() and not bestECLT0) {
81 B2DEBUG(20,
"Using CDC hit based EventT0, as ECL EventT0 is not available.");
82 m_eventT0->setEventT0(*hitBasedCDCT0Candidate);
85 B2DEBUG(20,
"There is no EventT0 from neither \n" \
86 " * the SVD based algorithm\n" \
87 " * the CDC based chi^2 algorithm\n" \
88 " * the CDC based hit-based algorithm\n" \
89 " * the ECL algorithm.\n" \
90 "Thus, no EventT0 value can be calculated.");
98 if (measurements.size() == 0) {
99 B2FATAL(
"Need at least one EvenT0 Measurement to do a sensible combination.");
102 double eventT0 = 0.0f;
103 double preFactor = 0.0f;
107 for (
auto const& meas : measurements) {
108 usedDetectorSet += meas.detectorSet;
109 const double oneOverUncertaintySquared = 1.0f / std::pow(meas.eventT0Uncertainty, 2.0);
110 eventT0 += meas.eventT0 * oneOverUncertaintySquared;
111 preFactor += oneOverUncertaintySquared;
114 eventT0 /= preFactor;
115 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.