Belle II Software development
SetRecoTrackMomentumModule.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 <alignment/modules/SetRecoTrackMomentum/SetRecoTrackMomentumModule.h>
10
11#include <framework/geometry/BFieldManager.h>
12#include <framework/geometry/B2Vector3.h>
13
14using namespace Belle2;
15
16//-----------------------------------------------------------------
17// Register the Module
18//-----------------------------------------------------------------
19REG_MODULE(SetRecoTrackMomentum);
20
21//-----------------------------------------------------------------
22// Implementation
23//-----------------------------------------------------------------
24
26{
27 // Set module properties
28 setDescription(R"DOC(Set momentum magnitude for RecoTracks seed to given value (for runs without magnetic field)
29
30 Take the momentum direction from seed and update its magnitude to artificial value for all RecoTracks - needed for tracks without magnetic field.
31 By default activated automatically, when zero B-field is detected at the origin
32 )DOC");
33
34 // Parameter definitions
35 addParam("automatic", m_automatic, "Detect the B-field at origin automatically - disable module if non-zero", true);
36 addParam("momentum", m_momentum, "Default momentum magnitude (GeV/c) to set for seed of RecoTracks", 10.);
37
38}
39
41{
43}
44
46{
47 // In automatic mode, do nothing if B-field > 0 at origin
48 if (m_automatic && BFieldManager::getInstance().getField(0., 0., 0.).R() > 1.e-14) {
49 return;
50 }
51
52 for (auto& track : m_tracks) {
53 B2Vector3D mom = track.getMomentumSeed();
54 mom = 1. / mom.Mag() * m_momentum * mom;
55
56 track.setPositionAndMomentum(track.getPositionSeed(), mom);
57 }
58}
59
60
double R
typedef autogenerated by FFTW
DataType Mag() const
The magnitude (rho in spherical coordinate system).
Definition: B2Vector3.h:159
static BFieldManager & getInstance()
Return the instance of the magnetic field manager.
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
virtual void initialize() override
Register input and output data.
bool m_automatic
Detect the B-field at origin automatically - disable module if non-zero.
virtual void event() override
Loop over RecoTracks and set the momentum magnitude.
double m_momentum
Default momentum magnitude (GeV/c) to set for RecoTracks.
SetRecoTrackMomentumModule()
Constructor: Sets the description, the properties and the parameters of the module.
StoreArray< RecoTrack > m_tracks
The array with RecoTracks to work with.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.