LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
mag::MagneticField Class Reference

#include "MagneticField.h"

Public Member Functions

 MagneticField (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
 ~MagneticField ()
 
void reconfigure (fhicl::ParameterSet const &pset)
 
std::vector< MagneticFieldDescription > const & Fields () const
 
size_t NumFields () const
 
MagFieldMode_t const & UseField (size_t f) const
 
std::string const & MagnetizedVolume (size_t f) const
 
G4ThreeVector const FieldAtPoint (G4ThreeVector const &p=G4ThreeVector(0)) const
 
G4ThreeVector const UniformFieldInVolume (std::string const &volName) const
 

Private Attributes

std::vector< MagneticFieldDescriptionfFieldDescriptions
 Descriptions of the fields. More...
 

Detailed Description

Definition at line 47 of file MagneticField.h.

Constructor & Destructor Documentation

MagneticField::MagneticField ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry reg 
)

Definition at line 35 of file MagneticField_service.cc.

References reconfigure().

36  {
37  this->reconfigure(pset);
38  }
void reconfigure(fhicl::ParameterSet const &pset)
mag::MagneticField::~MagneticField ( )
inline

Definition at line 50 of file MagneticField.h.

50 {};

Member Function Documentation

G4ThreeVector const MagneticField::FieldAtPoint ( G4ThreeVector const &  p = G4ThreeVector(0)) const

Definition at line 81 of file MagneticField_service.cc.

References fFieldDescriptions.

82  {
83  // check that the input point is in the magnetized volume
84  // Use the gGeoManager to determine what node the point
85  // is in
86  double point[3] = { p.x(), p.y(), p.z() };
87 
88  // loop over the field descriptions to see if the point is in any of them
89  for(auto fd : fFieldDescriptions){
90  // we found a node, see if its name is the same as
91  // the volume with the field
92  if(fd.fGeoVol->Contains(point)) return fd.fField;
93  }
94 
95  // if we get here, we can't find a field
96  return G4ThreeVector(0);
97  }
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
Definition: MagneticField.h:70
std::vector<MagneticFieldDescription> const& mag::MagneticField::Fields ( ) const
inline

Definition at line 54 of file MagneticField.h.

Referenced by g4b::DetectorConstruction::Construct().

54 { return fFieldDescriptions; }
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
Definition: MagneticField.h:70
std::string const& mag::MagneticField::MagnetizedVolume ( size_t  f) const
inline

Definition at line 57 of file MagneticField.h.

References f.

57 { return fFieldDescriptions[f].fVolume; }
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
Definition: MagneticField.h:70
TFile f
Definition: plotHisto.C:6
size_t mag::MagneticField::NumFields ( ) const
inline

Definition at line 55 of file MagneticField.h.

55 { return fFieldDescriptions.size(); }
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
Definition: MagneticField.h:70
void MagneticField::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 41 of file MagneticField_service.cc.

References fFieldDescriptions, fhicl::ParameterSet::get(), and mag::kNoBFieldMode.

Referenced by MagneticField().

42  {
43  auto fieldDescriptions = pset.get<std::vector<fhicl::ParameterSet> >("FieldDescriptions");
44 
45  MagneticFieldDescription fieldDescription;
46  for(auto itr : fieldDescriptions){
47  fieldDescription.fMode = (mag::MagFieldMode_t)(itr.get<int>("UseField"));
48 
49  // if the mode is turned to off, no point looking for a volume or
50  // trying to put a description into the fFieldDescriptions data member.
51  // if all input field descriptions are set to fMode = kNoBFieldMode, then the
52  // methods to return the fields will not go into the loop over fFieldDescriptions
53  // and will just return a 0 field.
54  if(fieldDescription.fMode == mag::kNoBFieldMode) continue;
55 
56  fieldDescription.fVolume = itr.get<std::string>("MagnetizedVolume");
57  fieldDescription.fGeoVol = gGeoManager->FindVolumeFast(fieldDescription.fVolume.c_str());
58 
59  // check that we have a good volume
60  if( fieldDescription.fGeoVol == nullptr )
61  throw cet::exception("MagneticField")
62  << "cannot locat volume "
63  << fieldDescription.fVolume
64  << " in gGeoManager, bail";
65 
66  // These need to be read as types that FHICL know about, but they
67  // are used by Geant, so I store them in Geant4 types.
68  std::vector<double> field = itr.get<std::vector<double> >("ConstantField");
69 
70  // Force the dimension of the field definition
71  field.resize(3);
72  for(size_t i = 0; i < 3; ++i) fieldDescription.fField[i] = field[i];
73 
74  fFieldDescriptions.push_back(fieldDescription);
75  }
76 
77  return;
78  }
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
Definition: MagneticField.h:70
enum mag::MagneticFieldMode MagFieldMode_t
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
G4ThreeVector const MagneticField::UniformFieldInVolume ( std::string const &  volName) const

Definition at line 100 of file MagneticField_service.cc.

References DEFINE_ART_SERVICE, and fFieldDescriptions.

101  {
102  // if the input volume name is the same as the magnetized volume
103  // return the uniform field
104 
105  for(auto fd : fFieldDescriptions){
106  if (fd.fVolume.compare(volName) == 0) return fd.fField;
107  }
108 
109  // if we get here, we can't find a field
110  return G4ThreeVector(0);
111  }
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
Definition: MagneticField.h:70
MagFieldMode_t const& mag::MagneticField::UseField ( size_t  f) const
inline

Definition at line 56 of file MagneticField.h.

References f.

56 { return fFieldDescriptions[f].fMode; }
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
Definition: MagneticField.h:70
TFile f
Definition: plotHisto.C:6

Member Data Documentation

std::vector<MagneticFieldDescription> mag::MagneticField::fFieldDescriptions
private

Descriptions of the fields.

Definition at line 70 of file MagneticField.h.

Referenced by FieldAtPoint(), reconfigure(), and UniformFieldInVolume().


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