Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:33

0001 // @(#)root/geom:$Id$
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 
0011 #ifndef ROOT_TVirtualMagField
0012 #define ROOT_TVirtualMagField
0013 
0014 #include "TNamed.h"
0015 
0016 class TVirtualMagField : public TNamed {
0017 public:
0018    TVirtualMagField() : TNamed() {}
0019    TVirtualMagField(const char *name) : TNamed(name, "") {}
0020    ~TVirtualMagField() override;
0021 
0022    virtual void Field(const Double_t *x, Double_t *B) = 0;
0023 
0024    ClassDefOverride(TVirtualMagField, 1) // Abstract base field class
0025 };
0026 
0027 ////////////////////////////////////////////////////////////////////////////
0028 //                                                                        //
0029 // TGeoUniformMagField - Uniform magnetic field class.                    //
0030 //                                                                        //
0031 ////////////////////////////////////////////////////////////////////////////
0032 
0033 class TGeoUniformMagField : public TVirtualMagField {
0034 private:
0035    Double_t fB[3]; // Magnetic field vector
0036 
0037 protected:
0038    TGeoUniformMagField(const TGeoUniformMagField &) = delete;
0039    TGeoUniformMagField &operator=(const TGeoUniformMagField &) = delete;
0040 
0041 public:
0042    TGeoUniformMagField();
0043    TGeoUniformMagField(Double_t Bx, Double_t By, Double_t Bz);
0044    ~TGeoUniformMagField() override {}
0045 
0046    void Field(const Double_t * /*x*/, Double_t *B) override
0047    {
0048       B[0] = fB[0];
0049       B[1] = fB[1];
0050       B[2] = fB[2];
0051    }
0052 
0053    const Double_t *GetFieldValue() const { return &fB[0]; }
0054    void SetFieldValue(Double_t Bx, Double_t By, Double_t Bz)
0055    {
0056       fB[0] = Bx;
0057       fB[1] = By;
0058       fB[2] = Bz;
0059    }
0060 
0061    ClassDefOverride(TGeoUniformMagField, 1) // Uniform magnetic field
0062 };
0063 
0064 #endif