// @(#)root/geom:$Id$

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TGeoGlobalMagField.h"
#include "TVirtualMagField.h"

//______________________________________________________________________________
// TVirtualMagField - ABC for magnetic field. Derived classes are encouraged to
// use the TVirtualMagField named constructor and must implement the method:
//    Field(const Double_t *x, Double_t *B)
//
// A field object can be made global via:
//    TGlobalMagField::Instance()->SetField(field)         [1]
// A field which is made global is owned by the field manager. The used is not
// allowed to delete it directly anymore (otherwise a Fatal() is issued). Global
// field can be deleted by calling [1] with a different argument (which can be
// NULL). Otherwise the global field is deleted together with the field manager.
//
//______________________________________________________________________________

ClassImp(TVirtualMagField)

//______________________________________________________________________________
TVirtualMagField::~TVirtualMagField()
{
// Destructor. Unregisters the field.
   if (TGeoGlobalMagField::GetInstance()) {
      TVirtualMagField *global_field = TGeoGlobalMagField::GetInstance()->GetField();
      if (global_field == this)
         Fatal("~TVirtualMagField", "Not allowed to delete a field once set global. \
                \n To delete the field call: TGeoGlobalMagField::Instance()->SetField(NULL)");
   }
}

//______________________________________________________________________________
// TGeoUniformMagField - Implementation for uniform magnetic field.
//______________________________________________________________________________

ClassImp(TGeoUniformMagField)

//______________________________________________________________________________
TGeoUniformMagField::TGeoUniformMagField()
                    :TVirtualMagField()
{
// Default constructor;
   fB[0] = 0.;
   fB[1] = 0.;
   fB[2] = 0.;
}

//______________________________________________________________________________
TGeoUniformMagField::TGeoUniformMagField(Double_t Bx, Double_t By, Double_t Bz)
                    :TVirtualMagField("Uniform magnetic field")
{
// Default constructor;
   fB[0] = Bx;
   fB[1] = By;
   fB[2] = Bz;
}
 TVirtualMagField.cxx:1
 TVirtualMagField.cxx:2
 TVirtualMagField.cxx:3
 TVirtualMagField.cxx:4
 TVirtualMagField.cxx:5
 TVirtualMagField.cxx:6
 TVirtualMagField.cxx:7
 TVirtualMagField.cxx:8
 TVirtualMagField.cxx:9
 TVirtualMagField.cxx:10
 TVirtualMagField.cxx:11
 TVirtualMagField.cxx:12
 TVirtualMagField.cxx:13
 TVirtualMagField.cxx:14
 TVirtualMagField.cxx:15
 TVirtualMagField.cxx:16
 TVirtualMagField.cxx:17
 TVirtualMagField.cxx:18
 TVirtualMagField.cxx:19
 TVirtualMagField.cxx:20
 TVirtualMagField.cxx:21
 TVirtualMagField.cxx:22
 TVirtualMagField.cxx:23
 TVirtualMagField.cxx:24
 TVirtualMagField.cxx:25
 TVirtualMagField.cxx:26
 TVirtualMagField.cxx:27
 TVirtualMagField.cxx:28
 TVirtualMagField.cxx:29
 TVirtualMagField.cxx:30
 TVirtualMagField.cxx:31
 TVirtualMagField.cxx:32
 TVirtualMagField.cxx:33
 TVirtualMagField.cxx:34
 TVirtualMagField.cxx:35
 TVirtualMagField.cxx:36
 TVirtualMagField.cxx:37
 TVirtualMagField.cxx:38
 TVirtualMagField.cxx:39
 TVirtualMagField.cxx:40
 TVirtualMagField.cxx:41
 TVirtualMagField.cxx:42
 TVirtualMagField.cxx:43
 TVirtualMagField.cxx:44
 TVirtualMagField.cxx:45
 TVirtualMagField.cxx:46
 TVirtualMagField.cxx:47
 TVirtualMagField.cxx:48
 TVirtualMagField.cxx:49
 TVirtualMagField.cxx:50
 TVirtualMagField.cxx:51
 TVirtualMagField.cxx:52
 TVirtualMagField.cxx:53
 TVirtualMagField.cxx:54
 TVirtualMagField.cxx:55
 TVirtualMagField.cxx:56
 TVirtualMagField.cxx:57
 TVirtualMagField.cxx:58
 TVirtualMagField.cxx:59
 TVirtualMagField.cxx:60
 TVirtualMagField.cxx:61
 TVirtualMagField.cxx:62
 TVirtualMagField.cxx:63
 TVirtualMagField.cxx:64
 TVirtualMagField.cxx:65
 TVirtualMagField.cxx:66