FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairConstFieldCreator.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 // -------------------------------------------------------------------------
9 // ----- FairConstFieldCreator header file -----
10 // ----- Created 12/11/2020 by R. Karabowicz -----
11 // -------------------------------------------------------------------------
12 
13 #include "FairConstFieldCreator.h"
14 
15 #include "FairConstField.h"
16 #include "FairConstPar.h"
17 #include "FairField.h"
18 #include "FairLogger.h"
19 #include "FairRunAna.h"
20 #include "FairRuntimeDb.h"
21 
22 static FairConstFieldCreator gFairConstFieldCreator;
23 
26  , fFieldPar(NULL)
27 {
28  fCreator = this;
29 }
30 
32 
34 {
36  FairRuntimeDb *RunDB = Run->GetRuntimeDb();
37  fFieldPar = (FairConstPar *)RunDB->getContainer("FairConstPar");
38 }
39 
41 {
42  FairField *fMagneticField = 0;
43 
44  if (!fFieldPar) {
45  LOG(error) << "No field parameters available!";
46  } else {
47  // Instantiate correct field type
48  Int_t fType = fFieldPar->GetType();
49  if (fType == 0)
50  fMagneticField = new FairConstField(fFieldPar);
51  else
52  LOG(warning) << "FairRunAna::GetField: Unknown field type " << fType;
53  LOG(info) << "New field at " << fMagneticField << ", type " << fType;
54  // Initialise field
55  if (fMagneticField) {
56  fMagneticField->Init();
57  fMagneticField->Print("");
58  }
59  }
60  return fMagneticField;
61 }
62 
FairFieldFactory * fCreator
list of container factories
Definition: FairRuntimeDb.h:24
ClassImp(FairEventBuilder)
FairParSet * getContainer(const Text_t *)
static FairRunAna * Instance()
Definition: FairRunAna.cxx:61
Int_t GetType() const
Definition: FairMapPar.h:38
FairRuntimeDb * GetRuntimeDb(void)
Definition: FairRun.h:80
virtual void Print(Option_t *) const
Definition: FairField.h:100
virtual FairField * createFairField()
virtual void Init()
Definition: FairField.h:53