MagneticField.h
Go to the documentation of this file.
1 /// \file MagneticField.h
2 /// \brief Describe the magnetic field structure of a detector
3 ///
4 /// \version $Id: MagneticField.h,v 1.3 2012-09-21 02:46:38 greenc Exp $
5 /// \author dmckee@phys.ksu.edu
6 //////////////////////////////////////////////////////////////////////////
7 /// \namespace mag
8 /// A namespace for simulated magnetic fields
9 //////////////////////////////////////////////////////////////////////////
10 #ifndef MAG_MAGNETICFIELD_H
11 #define MAG_MAGNETICFIELD_H
12 
13 #include <string>
14 
15 #include "TGeoVolume.h"
16 
17 // Geant4 includes
18 #include "Geant4/G4ThreeVector.hh"
19 
20 // Framework includes
21 #include "fhiclcpp/ParameterSet.h"
25 
26 namespace mag {
27 
28  typedef enum MagneticFieldMode {
29  kAutomaticBFieldMode=-1, // Used by DriftElectronsAlg
30  kNoBFieldMode=0, // no field
31  kConstantBFieldMode=1 // constant field
32  /*, kFieldMapMode, ... */
34 
36  {
37  MagFieldMode_t fMode; ///< type of field used
38  G4ThreeVector fField; ///< description of the field (uniform only)
39  G4String fVolume; ///< G4 volume containing the field
40  TGeoVolume* fGeoVol; ///< pointer to TGeoVolume with the field
41  };
42 
43  // Specifies the magnetic field over all space
44  //
45  // The default implementation, however, uses a nearly trivial,
46  // non-physical hack.
47  class MagneticField {
48  public:
51 
52  void reconfigure(fhicl::ParameterSet const& pset);
53 
54  std::vector<MagneticFieldDescription> const& Fields() const { return fFieldDescriptions; }
55  size_t NumFields() const { return fFieldDescriptions.size(); }
56  MagFieldMode_t const& UseField(size_t f) const { return fFieldDescriptions[f].fMode; }
57  std::string const& MagnetizedVolume(size_t f) const { return fFieldDescriptions[f].fVolume; }
58 
59  // return the field at a particular point
60  G4ThreeVector const FieldAtPoint(G4ThreeVector const& p=G4ThreeVector(0)) const;
61 
62  // This method will only return a uniform field based on the input
63  // volume name. If the input volume does not have a uniform field
64  // caveat emptor
65  G4ThreeVector const UniformFieldInVolume(std::string const& volName) const;
66 
67  private:
68  // The simplest implmentation has a constant field inside a named
69  // detector volume
70  std::vector<MagneticFieldDescription> fFieldDescriptions; ///< Descriptions of the fields
71 
72  ///\todo Need to add ability to read in a field from a database
73  };
74 
75 }
76 
78 #endif // MAG_MAGNETICFIELD_H
G4ThreeVector fField
description of the field (uniform only)
Definition: MagneticField.h:38
MagneticFieldMode
Definition: MagneticField.h:28
std::string string
Definition: nybbler.cc:12
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
Definition: MagneticField.h:70
#define DECLARE_ART_SERVICE(svc, scope)
Definition: ServiceMacros.h:86
std::vector< MagneticFieldDescription > const & Fields() const
Definition: MagneticField.h:54
TGeoVolume * fGeoVol
pointer to TGeoVolume with the field
Definition: MagneticField.h:40
size_t NumFields() const
Definition: MagneticField.h:55
MagFieldMode_t fMode
type of field used
Definition: MagneticField.h:37
std::string const & MagnetizedVolume(size_t f) const
Definition: MagneticField.h:57
enum mag::MagneticFieldMode MagFieldMode_t
p
Definition: test.py:223
MagFieldMode_t const & UseField(size_t f) const
Definition: MagneticField.h:56
G4String fVolume
G4 volume containing the field.
Definition: MagneticField.h:39