Belle II Software  release-08-01-10
Advancer.cc
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 
9 #include <tracking/ckf/general/utilities/Advancer.h>
10 #include <tracking/ckf/general/utilities/SearchDirection.h>
11 
12 #include <framework/core/ModuleParamList.templateDetails.h>
13 
14 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
15 #include <framework/logging/Logger.h>
16 #include <genfit/MaterialEffects.h>
17 #include <genfit/Exception.h>
18 
19 using namespace Belle2;
20 using namespace TrackFindingCDC;
21 
23  const genfit::SharedPlanePtr& plane) const
24 {
25  setMaterialEffectsToParameterValue();
26 
27  double returnValue = NAN;
28  try {
29  const double extrapolatedS = measuredStateOnPlane.extrapolateToPlane(plane);
30 
31  if (arcLengthInRightDirection(extrapolatedS, m_param_direction)) {
32  returnValue = static_cast<double>(m_param_direction) * extrapolatedS;
33  }
34  } catch (const genfit::Exception& e) {
35  B2DEBUG(29, "Extrapolation failed: " << e.what());
36  }
37 
38  resetMaterialEffects();
39  return returnValue;
40 }
41 
43 {
44  genfit::MaterialEffects::getInstance()->setNoEffects(not m_param_useMaterialEffects);
45 }
46 
48 {
49  genfit::MaterialEffects::getInstance()->setNoEffects(false);
50 }
51 
52 void Advancer::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
53 {
54  moduleParamList->addParameter(prefixed(prefix, "useMaterialEffects"),
55  m_param_useMaterialEffects,
56  "Use the material effects during extrapolation.",
57  m_param_useMaterialEffects);
58 
59  moduleParamList->addParameter(prefixed(prefix, "direction"), m_param_directionAsString,
60  "The direction where the extrapolation will happen.");
61 }
62 
64 {
66 
67  m_param_direction = fromString(m_param_directionAsString);
68 }
void resetMaterialEffects() const
Call this to reset the material effects back to their default value (turned on).
Definition: Advancer.cc:47
double extrapolateToPlane(genfit::MeasuredStateOnPlane &measuredStateOnPlane, const genfit::SharedPlanePtr &plane) const
Extrapolate the mSoP of one plane to another plane and return the traveled distance or NAN,...
Definition: Advancer.cc:22
void initialize() final
Convert the string parameter to a valid forward backward information.
Definition: Advancer.cc:63
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the parameters.
Definition: Advancer.cc:52
void setMaterialEffectsToParameterValue() const
Call this to set the material effects handling accorinf to the given parameters.
Definition: Advancer.cc:42
The Module parameter list class.
virtual void initialize()
Receive signal before the start of the event processing.
Exception class for error handling in GENFIT (provides storage for diagnostic information)
Definition: Exception.h:48
#StateOnPlane with additional covariance matrix.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
constexpr bool arcLengthInRightDirection(double arcLength2D, TrackFindingCDC::EForwardBackward forwardBackward)
Given the calculated arc length between a start point and an end point, checks if the travelled path ...
TrackFindingCDC::EForwardBackward fromString(const std::string &directionString)
Helper function to turn a direction string into a valid forward backward information.
Abstract base class for different kinds of events.
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.