LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
mag::MagneticFieldStandard Class Reference

#include "MagneticFieldStandard.h"

Inheritance diagram for mag::MagneticFieldStandard:
mag::MagneticField

Public Member Functions

 MagneticFieldStandard (fhicl::ParameterSet const &pset)
 
 MagneticFieldStandard (MagneticFieldStandard const &)=delete
 
virtual ~MagneticFieldStandard ()=default
 
void reconfigure (fhicl::ParameterSet const &pset)
 
std::vector< MagneticFieldDescription > const & Fields () const override
 
size_t NumFields () const override
 
MagFieldMode_t const & UseField (size_t f) const override
 
std::string const & MagnetizedVolume (size_t f) const override
 
G4ThreeVector const FieldAtPoint (G4ThreeVector const &p=G4ThreeVector(0)) const override
 
G4ThreeVector const UniformFieldInVolume (std::string const &volName) const override
 

Private Attributes

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

Detailed Description

Definition at line 26 of file MagneticFieldStandard.h.

Constructor & Destructor Documentation

mag::MagneticFieldStandard::MagneticFieldStandard ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 26 of file MagneticFieldStandard.cxx.

References reconfigure().

27  {
28  this->reconfigure(pset);
29  }
void reconfigure(fhicl::ParameterSet const &pset)
mag::MagneticFieldStandard::MagneticFieldStandard ( MagneticFieldStandard const &  )
delete
virtual mag::MagneticFieldStandard::~MagneticFieldStandard ( )
virtualdefault

Member Function Documentation

G4ThreeVector const mag::MagneticFieldStandard::FieldAtPoint ( G4ThreeVector const &  p = G4ThreeVector(0)) const
overridevirtual

Implements mag::MagneticField.

Definition at line 68 of file MagneticFieldStandard.cxx.

References fFieldDescriptions.

69  {
70  // check that the input point is in the magnetized volume
71  // Use the gGeoManager to determine what node the point
72  // is in
73  double point[3] = { p.x(), p.y(), p.z() };
74  // loop over the field descriptions to see if the point is in any of them
75  for(auto fd : fFieldDescriptions){
76  // we found a node, see if its name is the same as
77  // the volume with the field
78  if(fd.fGeoVol->Contains(point)) return fd.fField;
79  }
80  // if we get here, we can't find a field
81  return G4ThreeVector(0);
82  }
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
std::vector<MagneticFieldDescription> const& mag::MagneticFieldStandard::Fields ( ) const
inlineoverridevirtual

Implements mag::MagneticField.

Definition at line 37 of file MagneticFieldStandard.h.

37 { return fFieldDescriptions; }
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
std::string const& mag::MagneticFieldStandard::MagnetizedVolume ( size_t  f) const
inlineoverridevirtual

Implements mag::MagneticField.

Definition at line 46 of file MagneticFieldStandard.h.

References f.

46 { return fFieldDescriptions[f].fVolume; }
TFile f
Definition: plotHisto.C:6
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
size_t mag::MagneticFieldStandard::NumFields ( ) const
inlineoverridevirtual

Implements mag::MagneticField.

Definition at line 40 of file MagneticFieldStandard.h.

40 { return fFieldDescriptions.size(); }
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
void mag::MagneticFieldStandard::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 32 of file MagneticFieldStandard.cxx.

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

Referenced by MagneticFieldStandard(), and mag::MagneticFieldServiceStandard::reconfigure().

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

Implements mag::MagneticField.

Definition at line 85 of file MagneticFieldStandard.cxx.

References fFieldDescriptions.

86  {
87  // if the input volume name is the same as the magnetized volume
88  // return the uniform field
89 
90  for(auto fd : fFieldDescriptions){
91  if (fd.fVolume.compare(volName) == 0) return fd.fField;
92  }
93 
94  // if we get here, we can't find a field
95  return G4ThreeVector(0);
96  }
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
MagFieldMode_t const& mag::MagneticFieldStandard::UseField ( size_t  f) const
inlineoverridevirtual

Implements mag::MagneticField.

Definition at line 43 of file MagneticFieldStandard.h.

References f.

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

Member Data Documentation

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

Descriptions of the fields.

Definition at line 60 of file MagneticFieldStandard.h.

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


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