Belle II Software  release-08-01-10
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/CollisionAxisCMS.h>
26 #include <mdst/dbobjects/BeamSpot.h>
27 #include <framework/database/DBStore.h>
28 
29 namespace {
34  class TestEventListener: public ::testing::EmptyTestEventListener {
35  public:
37  explicit TestEventListener(bool debug): ::testing::EmptyTestEventListener(), m_enableDebug{debug} {}
38  private:
42  virtual void OnTestStart(const ::testing::TestInfo& test) final override
43  {
44  if (m_enableDebug) {
47  }
48  std::string name = test.test_case_name();
49  name += "/";
50  name += test.name();
53  field->addComponent(new Belle2::MagneticFieldComponentConstant({0, 0, 1.5 * Belle2::Unit::T}));
54  Belle2::DBStore::Instance().addConstantOverride("MagneticField", field, false);
55 
56  // These 6 collision parameters correspond to following HER & LER momenta
57  // pHER = (0.290582573157898, 0, 6.99796952744559, 7.004)
58  // pLER = (0.166035330010433, 0, -3.99855423973071, 4.002)
59  // These are in BeamParameters (rev=59449 & rev=141509) which is default in main GT
60 
61  auto* collisionInvariantMass = new Belle2::CollisionInvariantMass();
62  collisionInvariantMass->setMass(10.579557836806245064, 0, 0);
63  Belle2::DBStore::Instance().addConstantOverride("CollisionInvariantMass", collisionInvariantMass);
64 
65  auto* collisionBoostVector = new Belle2::CollisionBoostVector();
66  collisionBoostVector->setBoost(TVector3(0.041488088603337358595, 0, 0.27252546681036521337), TMatrixDSym(3));
67  Belle2::DBStore::Instance().addConstantOverride("CollisionBoostVector", collisionBoostVector);
68 
69  auto* collisionAxisCMS = new Belle2::CollisionAxisCMS();
70  collisionAxisCMS->setAngles(0.0057699660560828307243, 0, TMatrixDSym(2));
71  collisionAxisCMS->setSpread(TMatrixDSym(2), 0, 0, 0);
72  Belle2::DBStore::Instance().addConstantOverride("CollisionAxisCMS", collisionAxisCMS);
73 
74  // "dummy" beam spot with center at (0,0,0)
75  auto* beamSpot = new Belle2::BeamSpot();
76  Belle2::DBStore::Instance().addConstantOverride("BeamSpot", beamSpot);
77 
78  }
80  virtual void OnTestEnd(const ::testing::TestInfo&) final override
81  {
83  }
84 
86  bool m_enableDebug;
87  };
88 }
89 
91 int main(int argc, char** argv)
92 {
93  ::testing::InitGoogleTest(&argc, argv);
94  ::testing::UnitTest& unit_test = *::testing::UnitTest::GetInstance();
95  bool debug{false};
96  for (int i = 1; i < argc; ++i) {
97  if (std::string(argv[i]) == "--debug") debug = true;
98  }
99  unit_test.listeners().Append(new TestEventListener(debug));
100  return RUN_ALL_TESTS();
101 }
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 values of the orientation of the collision axis in the CM system obt...
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:32
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:28
void addConstantOverride(const std::string &name, TObject *obj, bool oneRun=false)
Add constant override payload.
Definition: DBStore.cc:204
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:91