Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TestConstField.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TestConstField.cpp
1 #include <gtest/gtest.h>
2 
3 #include <TVector3.h>
4 
5 #include <Exception.h>
6 #include <ConstField.h>
7 #include <FieldManager.h>
8 
9 namespace genfit {
10 
12  protected:
13  };
14 
15  TEST_F (ConstFieldUninitializedTests, UninitializedBehaviour) {
16  EXPECT_EQ(false, genfit::FieldManager::getInstance()->isInitialized());
17  EXPECT_THROW(genfit::FieldManager::getInstance()->getField(), std::runtime_error);
18  EXPECT_THROW(genfit::FieldManager::getInstance()->checkInitialized(), std::runtime_error);
19  EXPECT_THROW(genfit::FieldManager::getInstance()->getFieldVal(TVector3(1, 1, 1)), std::runtime_error);
20  }
21 
22 
24  protected:
25  virtual void SetUp() {
26  const double bFieldZ = 20; // kGauss. Is 1.5T
27  m_constField = new genfit::ConstField(0., 0., bFieldZ);
29  }
30  virtual void TearDown() {
32 
33  }
35  };
36 
37  TEST_F (ConstFieldInitializedTests, InitializedBehaviour) {
38  EXPECT_EQ(true, genfit::FieldManager::getInstance()->isInitialized());
39  EXPECT_NO_THROW(genfit::FieldManager::getInstance()->checkInstanciated());
41  EXPECT_EQ(TVector3(0, 0, 20), genfit::FieldManager::getInstance()->getFieldVal(TVector3(1, 1, 1)));
42  }
43 
44 }