FairShip
Loading...
Searching...
No Matches
ShipCompField Class Reference

Class that defines a magnetic field composed from many fields. More...

#include <ShipCompField.h>

Inheritance diagram for ShipCompField:
Collaboration diagram for ShipCompField:

Public Member Functions

 ShipCompField (const std::string &label, TVirtualMagField *firstField)
 Main constructor.
 
 ShipCompField (const std::string &label, TVirtualMagField *firstField, TVirtualMagField *secondField)
 Secondary constructor.
 
 ShipCompField (const std::string &label, const std::vector< TVirtualMagField * > &theFields)
 More general constructor.
 
virtual ~ShipCompField ()
 Destructor.
 
virtual void Field (const Double_t *position, Double_t *B)
 
size_t nComposite () const
 Get the number of fields in the composite.
 
std::span< TVirtualMagField *const > getCompFields () const
 Get the vector of fields.
 
 ClassDef (ShipCompField, 1)
 ClassDef for ROOT.
 

Private Member Functions

 ShipCompField (const ShipCompField &)=delete
 Deleted copy and assignment operators.
 
ShipCompFieldoperator= (const ShipCompField &)=delete
 

Private Attributes

std::vector< TVirtualMagField * > theFields_
 The vector of the various magnetic field pointers comprising the composite.
 

Detailed Description

Class that defines a magnetic field composed from many fields.

Author
John Back J.J.B.nosp@m.ack@.nosp@m.warwi.nosp@m.ck.a.nosp@m.c.uk

Definition at line 19 of file ShipCompField.h.

Constructor & Destructor Documentation

◆ ShipCompField() [1/4]

ShipCompField::ShipCompField ( const std::string &  label,
TVirtualMagField *  firstField 
)

Main constructor.

Parameters
[in]labelA descriptive name/title/label for the composite field
[in]firstFieldThe first magnetic field for the composite

Definition at line 14 of file ShipCompField.cxx.

16 : TVirtualMagField(label.c_str()), theFields_() {
17 theFields_.push_back(firstField);
18}
std::vector< TVirtualMagField * > theFields_
The vector of the various magnetic field pointers comprising the composite.
Definition: ShipCompField.h:80

◆ ShipCompField() [2/4]

ShipCompField::ShipCompField ( const std::string &  label,
TVirtualMagField *  firstField,
TVirtualMagField *  secondField 
)

Secondary constructor.

Parameters
[in]labelA descriptive name/title/label for the composite field
[in]firstFieldThe first magnetic field pointer for the composite
[in]secondFieldThe second magnetic field pointer for the composite

Definition at line 20 of file ShipCompField.cxx.

23 : TVirtualMagField(label.c_str()), theFields_() {
24 theFields_.push_back(firstField);
25 theFields_.push_back(secondField);
26}

◆ ShipCompField() [3/4]

ShipCompField::ShipCompField ( const std::string &  label,
const std::vector< TVirtualMagField * > &  theFields 
)

More general constructor.

Parameters
[in]labelA descriptive name/title/label for the composite field
[in]theFieldsA vector of magnetic field pointers for the composite

Definition at line 28 of file ShipCompField.cxx.

30 : TVirtualMagField(label.c_str()), theFields_(theFields) {}

◆ ~ShipCompField()

ShipCompField::~ShipCompField ( )
virtual

Destructor.

Definition at line 32 of file ShipCompField.cxx.

32 {
33 // The destructor does nothing since this class does not own
34 // the various TVirtualMagField pointers
35}

◆ ShipCompField() [4/4]

ShipCompField::ShipCompField ( const ShipCompField )
privatedelete

Deleted copy and assignment operators.

Member Function Documentation

◆ ClassDef()

ShipCompField::ClassDef ( ShipCompField  ,
 
)

ClassDef for ROOT.

◆ Field()

void ShipCompField::Field ( const Double_t *  position,
Double_t *  B 
)
virtual

The total magnetic field from all of the composite sources (linear superposition)

Parameters
[in]positionThe x,y,z global coordinates of the point
[out]BThe x,y,z components of the magnetic field

Definition at line 37 of file ShipCompField.cxx.

37 {
38 // Loop over the fields and do a simple linear superposition
39
40 // First initialise the field components to zero
41 B[0] = 0.0, B[1] = 0.0, B[2] = 0.0;
42
43 for (auto* theField : theFields_) {
44 if (theField) {
45 // std::cout<<"Finding field for "<<theField->GetName()<<std::endl;
46
47 // Find the magnetic field components for this part
48 Double_t BVect[3] = {0.0, 0.0, 0.0};
49 theField->Field(position, BVect);
50
51 // Simple linear superposition of the B field components
52 B[0] += BVect[0];
53 B[1] += BVect[1];
54 B[2] += BVect[2];
55
56 // std::cout<<"B = "<<BVect[0]<<", "<<BVect[1]<<", "<<BVect[2]<<std::endl;
57 // std::cout<<"BSum = "<<B[0]<<", "<<B[1]<<", "<<B[2]<<std::endl;
58 }
59 }
60}
Definition: diagrams_b.h:4

◆ getCompFields()

std::span< TVirtualMagField *const > ShipCompField::getCompFields ( ) const
inline

Get the vector of fields.

Returns
a non-owning view of the fields

Definition at line 66 of file ShipCompField.h.

66 {
67 return theFields_;
68 }

◆ nComposite()

size_t ShipCompField::nComposite ( ) const
inline

Get the number of fields in the composite.

Returns
the number of fields used in the composite

Definition at line 60 of file ShipCompField.h.

60{ return theFields_.size(); }

◆ operator=()

ShipCompField & ShipCompField::operator= ( const ShipCompField )
privatedelete

Member Data Documentation

◆ theFields_

std::vector<TVirtualMagField*> ShipCompField::theFields_
private

The vector of the various magnetic field pointers comprising the composite.

Definition at line 80 of file ShipCompField.h.


The documentation for this class was generated from the following files: