#include "TROOT.h"
#include "TGeoGlobalMagField.h"
ClassImp(TGeoGlobalMagField)
TGeoGlobalMagField *TGeoGlobalMagField::fgInstance = NULL;
TGeoGlobalMagField::TGeoGlobalMagField()
{
fField = NULL;
fLock = kFALSE;
if (fgInstance) {
TVirtualMagField *field = fgInstance->GetField();
if (field)
Fatal("TGeoGlobalMagField", "A global field manager already existing and containing a field. \
\n If you want a new global field please set it via: \
\n TGeoGlobalMagField::Instance()->SetField(myField).");
else
Warning("TGeoGlobalMagField", "A global field manager already existing. Please access via: \
\n TGeoGlobalMagField::Instance().");
delete fgInstance;
}
gROOT->GetListOfGeometries()->Add(this);
fgInstance = this;
}
TGeoGlobalMagField::~TGeoGlobalMagField()
{
gROOT->GetListOfGeometries()->Remove(this);
if (fField) {
TVirtualMagField *field = fField;
fField = NULL;
delete field;
}
fgInstance = NULL;
}
void TGeoGlobalMagField::SetField(TVirtualMagField *field)
{
if (field==fField) return;
if (fField) {
if (fLock) {
Error("SetField", "Global field is already set to <%s> and locked", fField->GetName());
return;
}
Info("SetField", "Previous magnetic field <%s> will be deleted", fField->GetName());
TVirtualMagField *oldfield = fField;
fField = NULL;
delete oldfield;
}
fField = field;
if (fField) Info("SetField", "Global magnetic field set to <%s>", fField->GetName());
}
TGeoGlobalMagField *TGeoGlobalMagField::GetInstance()
{
return fgInstance;
}
TGeoGlobalMagField *TGeoGlobalMagField::Instance()
{
if (fgInstance) return fgInstance;
return new TGeoGlobalMagField();
}
void TGeoGlobalMagField::Lock()
{
if (!fField) {
Warning("Lock", "Cannot lock global magnetic field since this was not set yet");
return;
}
fLock = kTRUE;
Info("Lock", "Global magnetic field <%s> is now locked", fField->GetName());
}
TGeoGlobalMagField.cxx:10 TGeoGlobalMagField.cxx:11 TGeoGlobalMagField.cxx:12 TGeoGlobalMagField.cxx:13 TGeoGlobalMagField.cxx:14 TGeoGlobalMagField.cxx:15 TGeoGlobalMagField.cxx:16 TGeoGlobalMagField.cxx:17 TGeoGlobalMagField.cxx:18 TGeoGlobalMagField.cxx:19 TGeoGlobalMagField.cxx:20 TGeoGlobalMagField.cxx:21 TGeoGlobalMagField.cxx:22 TGeoGlobalMagField.cxx:23 TGeoGlobalMagField.cxx:24 TGeoGlobalMagField.cxx:25 TGeoGlobalMagField.cxx:26 TGeoGlobalMagField.cxx:27 TGeoGlobalMagField.cxx:28 TGeoGlobalMagField.cxx:29 TGeoGlobalMagField.cxx:30 TGeoGlobalMagField.cxx:31 TGeoGlobalMagField.cxx:32 TGeoGlobalMagField.cxx:33 TGeoGlobalMagField.cxx:34 TGeoGlobalMagField.cxx:35 TGeoGlobalMagField.cxx:36 TGeoGlobalMagField.cxx:37 TGeoGlobalMagField.cxx:38 TGeoGlobalMagField.cxx:39 TGeoGlobalMagField.cxx:40 TGeoGlobalMagField.cxx:41 TGeoGlobalMagField.cxx:42 TGeoGlobalMagField.cxx:43 TGeoGlobalMagField.cxx:44 TGeoGlobalMagField.cxx:45 TGeoGlobalMagField.cxx:46 TGeoGlobalMagField.cxx:47 TGeoGlobalMagField.cxx:48 TGeoGlobalMagField.cxx:49 TGeoGlobalMagField.cxx:50 TGeoGlobalMagField.cxx:51 TGeoGlobalMagField.cxx:52 TGeoGlobalMagField.cxx:53 TGeoGlobalMagField.cxx:54 TGeoGlobalMagField.cxx:55 TGeoGlobalMagField.cxx:56 TGeoGlobalMagField.cxx:57 TGeoGlobalMagField.cxx:58 TGeoGlobalMagField.cxx:59 TGeoGlobalMagField.cxx:60 TGeoGlobalMagField.cxx:61 TGeoGlobalMagField.cxx:62 TGeoGlobalMagField.cxx:63 TGeoGlobalMagField.cxx:64 TGeoGlobalMagField.cxx:65 TGeoGlobalMagField.cxx:66 TGeoGlobalMagField.cxx:67 TGeoGlobalMagField.cxx:68 TGeoGlobalMagField.cxx:69 TGeoGlobalMagField.cxx:70 TGeoGlobalMagField.cxx:71 TGeoGlobalMagField.cxx:72 TGeoGlobalMagField.cxx:73 TGeoGlobalMagField.cxx:74 TGeoGlobalMagField.cxx:75 TGeoGlobalMagField.cxx:76 TGeoGlobalMagField.cxx:77 TGeoGlobalMagField.cxx:78 TGeoGlobalMagField.cxx:79 TGeoGlobalMagField.cxx:80 TGeoGlobalMagField.cxx:81 TGeoGlobalMagField.cxx:82 TGeoGlobalMagField.cxx:83 TGeoGlobalMagField.cxx:84 TGeoGlobalMagField.cxx:85 TGeoGlobalMagField.cxx:86 TGeoGlobalMagField.cxx:87 TGeoGlobalMagField.cxx:88 TGeoGlobalMagField.cxx:89 TGeoGlobalMagField.cxx:90 TGeoGlobalMagField.cxx:91 TGeoGlobalMagField.cxx:92 TGeoGlobalMagField.cxx:93 TGeoGlobalMagField.cxx:94 TGeoGlobalMagField.cxx:95 TGeoGlobalMagField.cxx:96 TGeoGlobalMagField.cxx:97 TGeoGlobalMagField.cxx:98 TGeoGlobalMagField.cxx:99 TGeoGlobalMagField.cxx:100 TGeoGlobalMagField.cxx:101 TGeoGlobalMagField.cxx:102 TGeoGlobalMagField.cxx:103 TGeoGlobalMagField.cxx:104 TGeoGlobalMagField.cxx:105 TGeoGlobalMagField.cxx:106 TGeoGlobalMagField.cxx:107 TGeoGlobalMagField.cxx:108 TGeoGlobalMagField.cxx:109 TGeoGlobalMagField.cxx:110 TGeoGlobalMagField.cxx:111 TGeoGlobalMagField.cxx:112 TGeoGlobalMagField.cxx:113 TGeoGlobalMagField.cxx:114