Belle II Software  release-08-01-10
RaveSetup.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 
10 #include <analysis/VertexFitting/RaveInterface/RaveSetup.h>
11 
12 #include <rave/VacuumPropagator.h>
13 #include <rave/MagneticField.h>
14 #include <rave/ConstantMagneticField.h>
15 #include <rave/VertexFactory.h>
16 #include <rave/KinematicTreeFactory.h>
17 
18 //stl stuff
19 #include <string>
20 using std::string;
21 #include <iostream>
22 
23 
24 using namespace Belle2;
25 using namespace analysis;
26 
28 {
29  static RaveSetup instance;
30  return &instance;
31 }
32 
33 void RaveSetup::initialize(int verbosity, double magneticField)
34 {
36  getRawInstance()->reset();
37  //now setup everything for the use of GFRave
38 // getRawInstance()->m_GFRaveVertexFactory = new GFRaveVertexFactory(verbosity, true);
39 
40 
41  getRawInstance()->m_raveVertexFactory = new rave::VertexFactory(rave::ConstantMagneticField(0, 0, magneticField),
42  rave::VacuumPropagator(), "kalman", verbosity);
43  getRawInstance()->m_raveKinematicTreeFactory = new rave::KinematicTreeFactory(rave::ConstantMagneticField(0, 0, magneticField),
44  rave::VacuumPropagator(), verbosity);
45  getRawInstance()->m_initialized = true;
46 }
47 
48 RaveSetup::RaveSetup(): m_useBeamSpot(false), m_raveVertexFactory(nullptr)/*, m_GFRaveVertexFactory(NULL)*/,
49  m_raveKinematicTreeFactory(nullptr), m_initialized(false)
50 {
51 }
52 
54 {
55  reset();
56 }
57 
59 {
60  //delete everything that could have potentially created with new in this class
61 
62  delete m_raveVertexFactory; // workaround to avoid crashes with V0 finder
63  m_raveVertexFactory = nullptr;
66  // delete m_GFRaveVertexFactory;
67 
68  m_initialized = false;
69 }
70 
71 
72 void RaveSetup::setBeamSpot(const B2Vector3D& beamSpot, const TMatrixDSym& beamSpotCov)
73 {
74  m_beamSpot = beamSpot;
75  m_beamSpotCov.ResizeTo(beamSpotCov);
76  m_beamSpotCov = beamSpotCov;
77  m_useBeamSpot = true;
78 }
79 
81 {
82  m_useBeamSpot = false;
83 }
84 
85 
86 
88 {
89  if (getRawInstance() not_eq nullptr) {
90  if (getRawInstance()->m_useBeamSpot == false) {
91  B2INFO("use beam spot is false");
92  } else {
93  B2INFO("use beam spot is true and beam spot position and covariance matrix are:");
95  getRawInstance()->m_beamSpotCov.Print();
96  }
97  B2INFO("the pointer to rave::VertexFactory is " << getRawInstance()->m_raveVertexFactory);
98  } else {
99  B2INFO("RaveSetup::initialize was not called. There is nothing to Print.");
100  }
101 }
std::string PrintString(unsigned precision=4) const
create a string containing vector in cartesian and spherical coordinates
Definition: B2Vector3.h:481
The RaveSetup class is part of the RaveInterface together with RaveVertexFitter It holds all global o...
Definition: RaveSetup.h:37
TMatrixDSym m_beamSpotCov
beam spot position covariance matrix.
Definition: RaveSetup.h:74
RaveSetup()
default constructor
Definition: RaveSetup.cc:48
void unsetBeamSpot()
unset beam spot constraint
Definition: RaveSetup.cc:80
rave::KinematicTreeFactory * m_raveKinematicTreeFactory
< The RAVE Kinematic Tree factory is the principal interface offered by the RAVE for kinematic vertex...
Definition: RaveSetup.h:81
bool m_useBeamSpot
flag determines if beam spot information should be used for vertex fit.
Definition: RaveSetup.h:72
static void initialize(int verbosity=1, double MagneticField=1.5)
Set everything up so everything needed for vertex fitting is there.
Definition: RaveSetup.cc:33
static RaveSetup * getRawInstance()
Same as getInstance(), but no check if the instance is initialised.
Definition: RaveSetup.cc:27
bool m_initialized
Has initialize() been called? unusable otherwise.
Definition: RaveSetup.h:83
B2Vector3D m_beamSpot
beam spot position.
Definition: RaveSetup.h:73
rave::VertexFactory * m_raveVertexFactory
The RAVE vertex factory is the principal interface offered by the RAVE vertex fitting library.
Definition: RaveSetup.h:77
static void Print()
Print() writes all RaveSetup member variables to the terminal
Definition: RaveSetup.cc:87
~RaveSetup()
default destructor
Definition: RaveSetup.cc:53
void setBeamSpot(const B2Vector3D &beamSpot, const TMatrixDSym &beamSpotCov)
The beam spot position and covariance is known you can set it here so that and a vertex in the beam s...
Definition: RaveSetup.cc:72
void reset()
frees memory allocated by initialize().
Definition: RaveSetup.cc:58
Abstract base class for different kinds of events.