Belle II Software development
AdvanceFilter.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/trackingUtilities/filters/base/Filter.dcl.h>
11#include <tracking/trackingUtilities/numerics/WithWeight.h>
12#include <tracking/trackingUtilities/numerics/Weight.h>
13
14#include <genfit/MeasuredStateOnPlane.h>
15#include <genfit/Exception.h>
16#include <framework/logging/Logger.h>
17
18#include <vector>
19#include <string>
20
21namespace Belle2 {
26 class ModuleParamList;
27
43 template <class AState, class AnAdvancer>
44 class AdvanceFilter : public
45 TrackingUtilities::Filter<std::pair<const std::vector<TrackingUtilities::WithWeight<const AState*>>, AState*>> {
48
49 public:
50 AdvanceFilter() : Super()
51 {
53 }
54
56 void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) override
57 {
58 m_advancer.exposeParameters(moduleParamList, prefix);
59 }
60
62 TrackingUtilities::Weight operator()(const std::pair<const std::vector<TrackingUtilities::WithWeight<const AState*>>, AState*>&
63 pair)
64 override
65 {
66 m_advancer.setMaterialEffectsToParameterValue();
67
68 const std::vector<TrackingUtilities::WithWeight<const AState*>>& previousStates = pair.first;
69 B2ASSERT("Can not extrapolate with nothing", not previousStates.empty());
70
71 const AState* lastState = previousStates.back();
72 AState* currentState = pair.second;
73
74 B2ASSERT("Can not extrapolate with nothing", lastState->mSoPSet());
75 genfit::MeasuredStateOnPlane mSoP = lastState->getMeasuredStateOnPlane();
76
77 double returnValue = NAN;
78 try {
79 genfit::SharedPlanePtr plane = currentState->getPlane(mSoP);
80 returnValue = m_advancer.extrapolateToPlane(mSoP, plane);
81 } catch (genfit::Exception& e) {
82 B2DEBUG(29, "Plane extraction failed: " << e.what());
83 }
84
85 if (not std::isnan(returnValue)) {
86 currentState->setMeasuredStateOnPlane(mSoP);
87 }
88
89 m_advancer.resetMaterialEffects();
90
91 return returnValue;
92 }
93
94 private:
96 AnAdvancer m_advancer;
97 };
98
99}
TrackingUtilities::Weight operator()(const std::pair< const std::vector< TrackingUtilities::WithWeight< const AState * > >, AState * > &pair) override
Extrapolate and return the result. Update the mSoP of the new state.
AnAdvancer m_advancer
The advancer to use.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the advancer.
TrackingUtilities::Filter< std::pair< const std::vector< TrackingUtilities::WithWeight< const AState * > >, AState * > > Super
Type of the base class.
The Module parameter list class.
Base class for filters on a generic object type.
Definition Filter.dcl.h:31
A mixin class to attach a weight to an object.
Definition WithWeight.h:24
STL class.
Abstract base class for different kinds of events.