Belle II Software  release-05-02-19
SetRecoTrackMomentumModule.cc
1 /**************************************************************************
2 * BASF2 (Belle Analysis Framework 2) *
3 * Copyright(C) 2019 - Belle II Collaboration *
4 * *
5 * Author: The Belle II Collaboration *
6 * Contributors: tadeas *
7 * *
8 * This software is provided "as is" without any warranty. *
9 **************************************************************************/
10 
11 #include <alignment/modules/SetRecoTrackMomentum/SetRecoTrackMomentumModule.h>
12 
13 #include <framework/geometry/BFieldManager.h>
14 
15 using namespace Belle2;
16 
17 //-----------------------------------------------------------------
18 // Register the Module
19 //-----------------------------------------------------------------
20 REG_MODULE(SetRecoTrackMomentum)
21 
22 //-----------------------------------------------------------------
23 // Implementation
24 //-----------------------------------------------------------------
25 
27 {
28  // Set module properties
29  setDescription(R"DOC("Set momentum magnitude for RecoTracks seed to given value (for runs without magnetic field)
30 
31  Take the momentum direction from seed and update its magnitude to artificial value for all RecoTracks - needed for tracks without magnetic field.
32  By default activated automatically, when zero B-field is detected at the origin
33  )DOC");
34 
35  // Parameter definitions
36  addParam("automatic", m_automatic, "Detect the B-field at origin automatically - disable module if non-zero", true);
37  addParam("momentum", m_momentum, "Default momentum magnitude (GeV/c) to set for seed of RecoTracks", 10.);
38 
39 }
40 
42 {
43  m_tracks.isRequired();
44 }
45 
47 {
48  // In automatic mode, do nothing if B-field > 0 at origin
49  if (m_automatic && BFieldManager::getInstance().getField(B2Vector3D(0., 0., 0.)).Mag() > 1.e-14) {
50  return;
51  }
52 
53  for (auto& track : m_tracks) {
54  B2Vector3D mom = track.getMomentumSeed();
55  mom = 1. / mom.Mag() * m_momentum * mom;
56 
57  track.setPositionAndMomentum(track.getPositionSeed(), mom);
58  }
59 }
60 
61 
Belle2::BFieldManager::getInstance
static BFieldManager & getInstance()
Return the instance of the magnetic field manager.
Definition: BFieldManager.cc:15
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::SetRecoTrackMomentumModule::m_automatic
bool m_automatic
Detect the B-field at origin automatically - disable module if non-zero.
Definition: SetRecoTrackMomentumModule.h:57
Belle2::SetRecoTrackMomentumModule::initialize
virtual void initialize() override
Register input and output data.
Belle2::B2Vector3< double >
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::B2Vector3D
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:507
Belle2::SetRecoTrackMomentumModule::m_momentum
double m_momentum
Default momentum magnitude (GeV/c) to set for RecoTracks.
Definition: SetRecoTrackMomentumModule.h:58
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SetRecoTrackMomentumModule::event
virtual void event() override
Loop over RecoTracks and set the momentum magnitude.
Belle2::SetRecoTrackMomentumModule::m_tracks
StoreArray< RecoTrack > m_tracks
The array with RecoTracks to work with.
Definition: SetRecoTrackMomentumModule.h:59
Belle2::B2Vector3::Mag
DataType Mag() const
The magnitude (rho in spherical coordinate system).
Definition: B2Vector3.h:158
Belle2::SetRecoTrackMomentumModule
Set momentum magnitude for RecoTracks to given value (for runs without magnetic field)
Definition: SetRecoTrackMomentumModule.h:40