SND@LHC Software
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)
 The total magnetic field from all of the composite sources (linear superposition)
 
size_t nComposite () const
 Get the number of fields in the composite.
 
std::vector< TVirtualMagField * > getCompFields () const
 Get the vector of fields.
 
 ClassDef (ShipCompField, 1)
 ClassDef for ROOT.
 

Private Member Functions

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

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 14 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/lable for the composite field
[in]firstFieldThe first magnetic field for the composite

Definition at line 10 of file ShipCompField.cxx.

11 :
12 TVirtualMagField(label.c_str()),
14{
15 theFields_.push_back(firstField);
16}
std::vector< TVirtualMagField * > theFields_
The vector of the various magnetic field pointers comprising the composite.

◆ ShipCompField() [2/4]

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

Secondary constructor.

Parameters
[in]labelA descriptive name/title/lable 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 18 of file ShipCompField.cxx.

20 :
21 TVirtualMagField(label.c_str()),
23{
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/lable for the composite field
[in]theFieldsA vector of magnetic field pointers for the composite

Definition at line 28 of file ShipCompField.cxx.

29 :
30 TVirtualMagField(label.c_str()),
31 theFields_(theFields)
32{
33}

◆ ~ShipCompField()

ShipCompField::~ShipCompField ( )
virtual

Destructor.

Definition at line 35 of file ShipCompField.cxx.

36{
37 // The destructor does nothing since this class does not own
38 // the various TVirtualMagField pointers
39}

◆ ShipCompField() [4/4]

ShipCompField::ShipCompField ( const ShipCompField )
private

Private 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 co-ordinates of the point
[out]BThe x,y,z components of the magnetic field

Definition at line 41 of file ShipCompField.cxx.

42{
43
44 // Loop over the fields and do a simple linear superposition
45
46 // First initialise the field components to zero
47 B[0] = 0.0, B[1] = 0.0, B[2] = 0.0;
48
49 std::vector<TVirtualMagField*>::const_iterator iter;
50 for (iter = theFields_.begin(); iter != theFields_.end(); ++iter) {
51
52 TVirtualMagField* theField = *iter;
53 if (theField) {
54
55 //std::cout<<"Finding field for "<<theField->GetName()<<std::endl;
56
57 // Find the magnetic field components for this part
58 Double_t BVect[3] = {0.0, 0.0, 0.0};
59 theField->Field(position, BVect);
60
61 // Simple linear superposition of the B field components
62 B[0] += BVect[0];
63 B[1] += BVect[1];
64 B[2] += BVect[2];
65
66 //std::cout<<"B = "<<BVect[0]<<", "<<BVect[1]<<", "<<BVect[2]<<std::endl;
67 //std::cout<<"BSum = "<<B[0]<<", "<<B[1]<<", "<<B[2]<<std::endl;
68
69 }
70
71 }
72
73}

◆ getCompFields()

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

Get the vector of fields.

Returns
the vector of fields

Definition at line 62 of file ShipCompField.h.

62{return theFields_;}

◆ 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 56 of file ShipCompField.h.

56{return theFields_.size();}

◆ operator=()

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

Member Data Documentation

◆ theFields_

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

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

Definition at line 76 of file ShipCompField.h.


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