Belle II Software  release-05-02-19
AdvanceFilter.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/filters/base/Filter.dcl.h>
13 #include <tracking/trackFindingCDC/numerics/WithWeight.h>
14 #include <tracking/trackFindingCDC/numerics/Weight.h>
15 
16 #include <genfit/MeasuredStateOnPlane.h>
17 #include <genfit/Exception.h>
18 #include <framework/logging/Logger.h>
19 
20 #include <vector>
21 #include <string>
22 
23 namespace Belle2 {
28  class ModuleParamList;
29 
45  template <class AState, class AnAdvancer>
46  class AdvanceFilter : public
47  TrackFindingCDC::Filter<std::pair<const std::vector<TrackFindingCDC::WithWeight<const AState*>>, AState*>> {
49  using Super = TrackFindingCDC::Filter<std::pair<const std::vector<TrackFindingCDC::WithWeight<const AState*>>, AState*>>;
50 
51  public:
52  AdvanceFilter() : Super()
53  {
55  }
56 
58  void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) override
59  {
60  m_advancer.exposeParameters(moduleParamList, prefix);
61  }
62 
64  TrackFindingCDC::Weight operator()(const std::pair<const std::vector<TrackFindingCDC::WithWeight<const AState*>>, AState*>& pair)
65  override
66  {
67  m_advancer.setMaterialEffectsToParameterValue();
68 
69  const std::vector<TrackFindingCDC::WithWeight<const AState*>>& previousStates = pair.first;
70  B2ASSERT("Can not extrapolate with nothing", not previousStates.empty());
71 
72  const AState* lastState = previousStates.back();
73  AState* currentState = pair.second;
74 
75  B2ASSERT("Can not extrapolate with nothing", lastState->mSoPSet());
76  genfit::MeasuredStateOnPlane mSoP = lastState->getMeasuredStateOnPlane();
77 
78  double returnValue = NAN;
79  try {
80  genfit::SharedPlanePtr plane = currentState->getPlane(mSoP);
81  returnValue = m_advancer.extrapolateToPlane(mSoP, plane);
82  } catch (genfit::Exception& e) {
83  B2DEBUG(50, "Plane extraction failed: " << e.what());
84  }
85 
86  if (not std::isnan(returnValue)) {
87  currentState->setMeasuredStateOnPlane(mSoP);
88  }
89 
90  m_advancer.resetMaterialEffects();
91 
92  return returnValue;
93  }
94 
95  private:
97  AnAdvancer m_advancer;
98  };
100 }
genfit::Exception
Exception class for error handling in GENFIT (provides storage for diagnostic information)
Definition: Exception.h:48
genfit::SharedPlanePtr
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
Definition: SharedPlanePtr.h:40
Belle2::AdvanceFilter::m_advancer
AnAdvancer m_advancer
The advancer to use.
Definition: AdvanceFilter.h:105
genfit::MeasuredStateOnPlane
#StateOnPlane with additional covariance matrix.
Definition: MeasuredStateOnPlane.h:39
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::addProcessingSignalListener
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Definition: CompositeProcessingSignalListener.cc:57
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::AdvanceFilter::operator()
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:72
Belle2::AdvanceFilter::Super
TrackFindingCDC::Filter< std::pair< const std::vector< TrackFindingCDC::WithWeight< const AState * > >, AState * > > Super
Type of the base class.
Definition: AdvanceFilter.h:57
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::AdvanceFilter::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the advancer.
Definition: AdvanceFilter.h:66