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/trackFindingCDC/filters/base/Filter.dcl.h>
11#include <tracking/trackFindingCDC/numerics/WithWeight.h>
12#include <tracking/trackFindingCDC/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 TrackFindingCDC::Filter<std::pair<const std::vector<TrackFindingCDC::WithWeight<const AState*>>, AState*>> {
48
49 public:
51 {
53 }
54
56 void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) override
57 {
58 m_advancer.exposeParameters(moduleParamList, prefix);
59 }
60
62 TrackFindingCDC::Weight operator()(const std::pair<const std::vector<TrackFindingCDC::WithWeight<const AState*>>, AState*>& pair)
63 override
64 {
65 m_advancer.setMaterialEffectsToParameterValue();
66
67 const std::vector<TrackFindingCDC::WithWeight<const AState*>>& previousStates = pair.first;
68 B2ASSERT("Can not extrapolate with nothing", not previousStates.empty());
69
70 const AState* lastState = previousStates.back();
71 AState* currentState = pair.second;
72
73 B2ASSERT("Can not extrapolate with nothing", lastState->mSoPSet());
74 genfit::MeasuredStateOnPlane mSoP = lastState->getMeasuredStateOnPlane();
75
76 double returnValue = NAN;
77 try {
78 genfit::SharedPlanePtr plane = currentState->getPlane(mSoP);
79 returnValue = m_advancer.extrapolateToPlane(mSoP, plane);
80 } catch (genfit::Exception& e) {
81 B2DEBUG(29, "Plane extraction failed: " << e.what());
82 }
83
84 if (not std::isnan(returnValue)) {
85 currentState->setMeasuredStateOnPlane(mSoP);
86 }
87
88 m_advancer.resetMaterialEffects();
89
90 return returnValue;
91 }
92
93 private:
95 AnAdvancer m_advancer;
96 };
98}
Filter which can be used on a pair of path (vector of states) and states, which will call the extrapo...
Definition: AdvanceFilter.h:45
TrackFindingCDC::Weight operator()(const std::pair< const std::vector< TrackFindingCDC::WithWeight< const AState * > >, AState * > &pair) override
Extrapolate and return the result. Update the mSoP of the new state.
Definition: AdvanceFilter.h:62
AnAdvancer m_advancer
The advancer to use.
Definition: AdvanceFilter.h:95
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the advancer.
Definition: AdvanceFilter.h:56
The Module parameter list class.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
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
Abstract base class for different kinds of events.