LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
MagneticField.h
Go to the documentation of this file.
1 #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  {
38  G4ThreeVector fField;
40  TGeoVolume* fGeoVol;
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;
71 
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::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
Definition: MagneticField.h:70
#define DECLARE_ART_SERVICE(svc, scope)
Definition: ServiceMacros.h:91
std::vector< MagneticFieldDescription > const & Fields() const
Definition: MagneticField.h:54
TFile f
Definition: plotHisto.C:6
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
MagFieldMode_t const & UseField(size_t f) const
Definition: MagneticField.h:56
G4String fVolume
G4 volume containing the field.
Definition: MagneticField.h:39