Belle II Software  release-06-02-00
test_main.cc
Go to the documentation of this file.
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 
17 #include "gtest/gtest.h"
18 #include "framework/core/RandomNumbers.h"
19 #include <framework/logging/LogSystem.h>
20 #include <framework/logging/LogConfig.h>
21 #include <framework/dbobjects/MagneticField.h>
22 #include <framework/dbobjects/MagneticFieldComponentConstant.h>
23 #include <mdst/dbobjects/CollisionInvariantMass.h>
24 #include <mdst/dbobjects/CollisionBoostVector.h>
25 #include <mdst/dbobjects/BeamSpot.h>
26 #include <framework/database/DBStore.h>
27 
28 namespace {
33  class TestEventListener: public ::testing::EmptyTestEventListener {
34  public:
36  TestEventListener(bool debug): ::testing::EmptyTestEventListener(), m_enableDebug{debug} {}
37  private:
41  virtual void OnTestStart(const ::testing::TestInfo& test) final override
42  {
43  if (m_enableDebug) {
46  }
47  std::string name = test.test_case_name();
48  name += "/";
49  name += test.name();
52  field->addComponent(new Belle2::MagneticFieldComponentConstant({0, 0, 1.5 * Belle2::Unit::T}));
53  Belle2::DBStore::Instance().addConstantOverride("MagneticField", field, false);
54  auto* collisionInvariantMass = new Belle2::CollisionInvariantMass();
55  collisionInvariantMass->setMass(10.5738932579, 0, 0);
56  Belle2::DBStore::Instance().addConstantOverride("CollisionInvariantMass", collisionInvariantMass);
57  auto* collisionBoostVector = new Belle2::CollisionBoostVector();
58  collisionBoostVector->setBoost(TVector3(0.0414880886031, 0, 0.272492455429), TMatrixDSym(3));
59  Belle2::DBStore::Instance().addConstantOverride("CollisionBoostVector", collisionBoostVector);
60  auto* beamSpot = new Belle2::BeamSpot();
61  Belle2::DBStore::Instance().addConstantOverride("BeamSpot", beamSpot);
62  }
64  virtual void OnTestEnd(const ::testing::TestInfo&) final override
65  {
67  }
68 
70  bool m_enableDebug;
71  };
72 }
73 
75 int main(int argc, char** argv)
76 {
77  ::testing::InitGoogleTest(&argc, argv);
78  ::testing::UnitTest& unit_test = *::testing::UnitTest::GetInstance();
79  bool debug{false};
80  for (int i = 1; i < argc; ++i) {
81  if (std::string(argv[i]) == "--debug") debug = true;
82  }
83  unit_test.listeners().Append(new TestEventListener(debug));
84  return RUN_ALL_TESTS();
85 }
This class contains the beam spot position and size modeled as a gaussian distribution in space.
Definition: BeamSpot.h:22
This class contains the measured average boost vector vec(beta) = (beta_x, beta_y,...
This class contains the measured average center-of-mass energy, which is equal to the invariant mass ...
void setDebugLevel(int debugLevel)
Configure the debug messaging level.
Definition: LogConfig.h:98
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:26
void setLogLevel(ELogLevel logLevel)
Configure the log level.
Definition: LogConfig.cc:25
void resetLogging()
Reset logging system to defaults: empty all log messages and reset connections to the default.
Definition: LogSystem.cc:180
LogConfig * getLogConfig()
Returns global log system configuration.
Definition: LogSystem.h:78
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:31
Describe one component of the Geometry.
Magnetic field map.
Definition: MagneticField.h:33
static void initialize()
Initialize the random number generator with a unique random seed;.
static const double T
[tesla]
Definition: Unit.h:120
static DBStore & Instance()
Instance of a singleton DBStore.
Definition: DBStore.cc:26
void addConstantOverride(const std::string &name, TObject *obj, bool oneRun=false)
Add constant override payload.
Definition: DBStore.cc:194
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:75