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