Belle II Software development
GridEventTimeExtractor.icc.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <tracking/eventTimeExtraction/findlets/GridEventTimeExtractor.dcl.h>
11#include <tracking/eventTimeExtraction/findlets/BaseEventTimeExtractor.icc.h>
12#include <tracking/eventTimeExtraction/utilities/TimeExtractionUtils.h>
13#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
14#include <framework/core/ModuleParamList.h>
15#include <framework/logging/Logger.h>
16
17namespace Belle2 {
22 template <class AFindlet>
27
28 template <class AFindlet>
29 void GridEventTimeExtractor<AFindlet>::apply(std::vector<RecoTrack*>& recoTracks)
30 {
31 m_wasSuccessful = false;
32
36
37 const double eventT0Delta = (m_param_maximalT0Value - m_param_minimalT0Value) / static_cast<double>(m_param_gridSteps);
38
39 for (unsigned int gridIndex = 0; gridIndex <= m_param_gridSteps; gridIndex++) {
40 const double eventT0Hypothesis = eventT0Delta * static_cast<double>(gridIndex) + m_param_minimalT0Value;
41
42 m_eventT0->setEventT0(EventT0::EventT0Component(eventT0Hypothesis, NAN, Const::CDC, "grid"));
44
45 for (unsigned int iteration = 0; iteration < m_param_iterations; iteration++) {
46 // The findlet will set the final event t0, but will probably not add any temporary event t0s, which is fine as we will do so.
47 m_findlet.apply(recoTracks);
48
49 if (m_findlet.wasSuccessful()) {
51 } else if (m_param_abortOnUnsuccessfulStep) {
52 B2DEBUG(25, "Aborting because time extraction was not successful.");
53 break;
54 }
55 }
56 }
57
58 if (not m_eventT0WithQuality.empty()) {
59 m_wasSuccessful = true;
60 // Look for the best event t0 (with the smallest chi2)
61 const auto& bestChi2 = std::max_element(m_eventT0WithQuality.begin(), m_eventT0WithQuality.end(),
62 [](const auto & lhs, const auto & rhs) {
63 return lhs.quality < rhs.quality;
64 });
65 m_eventT0->setEventT0(*bestChi2);
66 } else {
67 // We have changes the event t0, so lets switch it back
68 resetEventT0();
69 }
70 }
71
72 template <class AFindlet>
73 void GridEventTimeExtractor<AFindlet>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
74 {
75 Super::exposeParameters(moduleParamList, prefix);
76
77 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "iterations"),
79 "How many iterations should be done?",
81 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "abortOnUnsuccessfulStep"),
83 "Abort on a single unsuccessful step. Otherwise, the success is defined by the last step",
85 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "maximalT0Value"),
87 "Maximal Grid Value of the T0 extraction",
89 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "minimalT0Value"),
91 "Maximal Grid Value of the T0 extraction",
93 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "gridSteps"),
95 "Number of steps in the grid",
97
98 m_findlet.exposeParameters(moduleParamList, TrackFindingCDC::prefixed("sub", prefix));
99 }
100
101
101}
bool m_param_abortOnUnsuccessfulStep
Parameter: abort if a single iteration is not working.
std::vector< EventT0::EventT0Component > m_eventT0WithQuality
Pool for the event t0s with chi2.
The Module parameter list class.
static void addEventT0WithQuality(const std::vector< RecoTrack * > &recoTracks, StoreObjPtr< EventT0 > &eventT0, std::vector< EventT0::EventT0Component > &eventT0WithQualityIndex)
Append an event-t0 value with quality information.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
GridEventTimeExtractor()
Add the subfindlet as listener.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override final
Expose the parameters.
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
void apply(std::vector< RecoTrack * > &recoTracks) override final
Timing extraction for this findlet.
Abstract base class for different kinds of events.
Structure for storing the extracted event t0s together with its detector and its uncertainty.
Definition EventT0.h:33