CbmRoot
CbmFieldCreator.cxx
Go to the documentation of this file.
1 #include "CbmFieldCreator.h"
2 
3 #include "CbmBsField.h" // for CbmBsField
4 #include "CbmFieldConst.h" // for CbmFieldConst
5 #include "CbmFieldMap.h" // for CbmFieldMap
6 #include "CbmFieldMapDistorted.h" // for CbmFieldMapDistorted
7 #include "CbmFieldMapSym1.h" // for CbmFieldMapSym1
8 #include "CbmFieldMapSym2.h" // for CbmFieldMapSym2
9 #include "CbmFieldMapSym3.h" // for CbmFieldMapSym3
10 #include "CbmFieldPar.h" // for CbmFieldPar, kTypeDistorted
11 
12 #include <FairField.h> // for FairField
13 #include <FairFieldFactory.h> // for FairFieldFactory
14 #include <FairRunAna.h> // for FairRunAna
15 #include <FairRuntimeDb.h> // for FairRuntimeDb
16 
17 #include <RtypesCore.h> // for Int_t
18 
19 #include <iostream> // for operator<<, basic_ostream, endl
20 
21 using std::cerr;
22 using std::cout;
23 using std::endl;
24 
26 
27 CbmFieldCreator::CbmFieldCreator() : FairFieldFactory(), fFieldPar(nullptr) {
28  fCreator = this;
29 }
30 
32 
34  FairRunAna* Run = FairRunAna::Instance();
35  FairRuntimeDb* RunDB = Run->GetRuntimeDb();
36  fFieldPar = (CbmFieldPar*) RunDB->getContainer("CbmFieldPar");
37 }
38 
40  FairField* fMagneticField = 0;
41 
42  if (!fFieldPar) {
43  cerr << "-E- No field parameters available!" << endl;
44  } else {
45  // Instantiate correct field type
46  Int_t fType = fFieldPar->GetType();
47  if (fType == 0)
48  fMagneticField = new CbmFieldConst(fFieldPar);
49  else if (fType == 1)
50  fMagneticField = new CbmFieldMap(fFieldPar);
51  else if (fType == 2)
52  fMagneticField = new CbmFieldMapSym2(fFieldPar);
53  else if (fType == 3)
54  fMagneticField = new CbmFieldMapSym3(fFieldPar);
55  else if (fType == kTypeDistorted)
56  fMagneticField = new CbmFieldMapDistorted(fFieldPar);
57  else if (fType == 5)
58  fMagneticField = new CbmFieldMapSym1(fFieldPar);
59  else if (fType == 6)
60  fMagneticField = new CbmBsField(fFieldPar);
61  else
62  cerr << "-W- FairRunAna::GetField: Unknown field type " << fType << endl;
63  cout << "New field at " << fMagneticField << ", type " << fType << endl;
64  // Initialise field
65  if (fMagneticField) {
66  fMagneticField->Init();
67  fMagneticField->Print("");
68  }
69  }
70  return fMagneticField;
71 }
72 
73 
CbmFieldMapSym3
Definition: CbmFieldMapSym3.h:35
CbmBsField
Definition: CbmBsField.h:33
CbmFieldMapDistorted
Definition: CbmFieldMapDistorted.h:20
CbmFieldMapSym2
Definition: CbmFieldMapSym2.h:35
CbmFieldConst.h
CbmFieldCreator::fFieldPar
CbmFieldPar * fFieldPar
Definition: CbmFieldCreator.h:27
CbmFieldCreator::createFairField
virtual FairField * createFairField()
Definition: CbmFieldCreator.cxx:39
CbmFieldMap
Definition: CbmFieldMap.h:34
CbmFieldMapSym1
Definition: CbmFieldMapSym1.h:33
gCbmFieldCreator
static CbmFieldCreator gCbmFieldCreator
Definition: CbmFieldCreator.cxx:25
CbmFieldPar.h
CbmFieldCreator
Definition: CbmFieldCreator.h:17
CbmFieldCreator.h
CbmFieldMapSym3.h
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmFieldCreator::SetParm
virtual void SetParm()
Definition: CbmFieldCreator.cxx:33
CbmFieldCreator::CbmFieldCreator
CbmFieldCreator()
Definition: CbmFieldCreator.cxx:27
CbmFieldMapDistorted.h
CbmFieldPar::GetType
Int_t GetType() const
Definition: CbmFieldPar.h:57
CbmBsField.h
kTypeDistorted
const int kTypeDistorted
Definition: CbmFieldPar.h:29
CbmFieldConst
Definition: CbmFieldConst.h:28
CbmFieldMapSym2.h
CbmFieldMap.h
CbmFieldPar
Definition: CbmFieldPar.h:31
CbmFieldCreator::~CbmFieldCreator
virtual ~CbmFieldCreator()
Definition: CbmFieldCreator.cxx:31
CbmFieldMapSym1.h