BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
InstallArea/include/MagneticField/MagneticField/MagneticFieldSvc.h
Go to the documentation of this file.
1#ifndef MAGNETICFIELDSVC_H
2#define MAGNETICFIELDSVC_H
3
4// Include files
5#include <vector>
6#include <string>
7#include "CLHEP/Geometry/Vector3D.h"
8#include "CLHEP/Geometry/Point3D.h"
9#ifndef ENABLE_BACKWARDS_COMPATIBILITY
10// backwards compatibility will be enabled ONLY in CLHEP 1.9
13#endif
14#include "MagneticField/ConnectionDB.h"
15
16#ifndef BEAN
17#include "GaudiKernel/Service.h"
18//#include "GaudiKernel/IMagneticFieldSvc.h"
19#include "MagneticField/IMagneticFieldSvc.h"
20#include "GaudiKernel/IIncidentListener.h"
21using namespace CLHEP;
22
23// Forward declarations
24template <class TYPE> class SvcFactory;
25
28class IDataProviderSvc;
29#else
31typedef bool StatusCode;
32#endif
33
34/** @class MagneticFieldSvc MagneticFieldSvc.h
35 * A service for finding the magnetic field vector at a given
36 * point in space.
37 *
38 */
39
40#ifndef BEAN
41class MagneticFieldSvc : public Service,
42 virtual public IMagneticFieldSvc,
43 virtual public IIncidentListener {
44
45protected:
46
47 /// Standard Constructor.
48 /// @param name String with service name
49 /// @param svc Pointer to service locator interface
50 MagneticFieldSvc( const std::string& name, ISvcLocator* svc );
51
52 /// Virtual destructor.
53 virtual ~MagneticFieldSvc();
54
55public:
56
57 /// Initialise the service (Inherited Service overrides)
58 virtual StatusCode initialize();
59
60 void init_params();
61
62 /// Finalise the service.
63 virtual StatusCode finalize();
64
65 /** Query the available interfaces.
66 * @param riid Requested interface ID
67 * @param ppvInterface Pointer to requested interface
68 * @return StatusCode indicating SUCCESS or FAILURE.
69 */
70 virtual StatusCode queryInterface( const InterfaceID& riid,
71 void** ppvInterface );
72
73 /// Service type.
74 virtual const InterfaceID& type() const { return IMagneticFieldSvc::interfaceID(); };
75
76
77 // Incident handler
78 void handle(const Incident&);
79
80#else
81// -------------------------- BEAN ------------------------------------
82class MagneticFieldSvc {
83
84public:
85 static MagneticFieldSvc* instance() {
86 return (m_field) ? m_field : (m_field=new(std::nothrow)MagneticFieldSvc());
87 }
88
89private:
91 virtual ~MagneticFieldSvc();
92
93public:
94 void SetPath(std::string new_path) {path = new_path;}
95 std::string GetPath() {return path;}
96
97 void GridDistance( int gridDistance = 5) {m_gridDistance = gridDistance;}
98 void RunMode( int runmode = 2) {m_runmode = runmode;}
99 void IfRealField( bool ifRealField = true) {m_ifRealField = ifRealField;}
100 void OutLevel( int outlevel = 1) {m_outlevel = outlevel;}
101
102 void Cur_SCQ1_55( double Cur_SCQ1_55 = 349.4) {m_Cur_SCQ1_55 = Cur_SCQ1_55;}
103 void Cur_SCQ1_89( double Cur_SCQ1_89 = 426.2) {m_Cur_SCQ1_89 = Cur_SCQ1_89;}
104 void Cur_SCQ2_10( double Cur_SCQ2_10 = 474.2) {m_Cur_SCQ2_10 = Cur_SCQ2_10;}
105
106 void UseDBFlag( bool useDB = true) {m_useDB = useDB;}
107
108 /// Initialise
109 bool init_mucMagneticField();
110 virtual StatusCode initialize();
111 void init_params(int run);
112
113 // handler for new run
114 void handle(int new_run);
115#endif
116
117 /** IMagneticFieldSvc interface.
118 * @param[in] xyz Point at which magnetic field vector will be given
119 * @param[out] fvec Magnectic field vector.
120 * @return StatusCode SUCCESS if calculation was performed.
121 */
122 virtual StatusCode fieldVector( const HepPoint3D& xyz,
123 HepVector3D& fvec ) const;
124
125 virtual StatusCode uniFieldVector( const HepPoint3D& xyz,
126 HepVector3D& fvec ) const;
127
128 virtual double getReferField();
129
130 virtual bool ifRealField() const;
131
132
133private:
134#ifndef BEAN
135 /// Allow SvcFactory to instantiate the service.
136 friend class SvcFactory<MagneticFieldSvc>;
137#else
138 static MagneticFieldSvc* m_field;
139#endif
140
141 /// Fills Q, the field vector
142 void fieldGrid( const HepPoint3D& xyz, HepVector3D& fvec ) const;
143 void fieldGrid_TE( const HepPoint3D& xyz, HepVector3D& fvec ) const;
144
145 StatusCode parseFile( ); ///< Reads the field map from file
146 StatusCode parseFile_TE( ); ///< Reads the field map from file
147
148 std::string path; // path to data files
149
150 std::string m_filename; ///< Magnetic field file name
151 std::string m_filename_TE; ///< Magnetic field file name
152 int m_runmode; ///< Run mode
153 int m_gridDistance; ///< grid distance of field map
154 int m_outlevel;
155 double m_scale;
156
157 double m_Cur_SCQ1_55;
158 double m_Cur_SCQ1_89;
159 double m_Cur_SCQ2_10;
160
161 std::vector<double> m_Q; ///< Field vector
162 std::vector<double> m_P; ///< Grid position
163 std::vector<double> m_Q_TE; ///< Field vector
164 std::vector<double> m_P_TE; ///< Grid position
165 std::vector<double> m_Q_1; ///< Field vector
166 std::vector<double> m_P_1; ///< Grid position
167 std::vector<double> m_Q_2; ///< Field vector
168 std::vector<double> m_P_2; ///< Grid position
169 double m_Dxyz[3]; ///< Steps in x, y and z
170 int m_Nxyz[3]; ///< Number of steps in x, y and z
171 double m_max_FL[3];
172 double m_min_FL[3];
173 //for tof and emc
174 double m_Dxyz_TE[3]; ///< Steps in x, y and z
175 int m_Nxyz_TE[3]; ///< Number of steps in x, y and z
176 double m_max_FL_TE[3];
177 double m_min_FL_TE[3];
178
179 double m_zOffSet; ///< The z offset
180 double m_zOffSet_TE; ///< The z offset
181 MucMagneticField* m_Mucfield;
182 double m_zfield;
183 bool m_ifRealField;
184
185 //property
186 bool m_useDB;
187
188 bool m_turnOffField;
189 bool m_uniField;
190
191#ifndef BEAN
192 IDataProviderSvc* m_eventSvc;
193#endif
194
195 //database
196 FieldDBUtil::ConnectionDB* m_connect_run;
197};
198
199#endif // MAGNETICFIELDSVC_H
RunMode
Definition: Goofy.h:11
static const InterfaceID & interfaceID()
Retrieve interface ID.
virtual const InterfaceID & type() const
Service type.
virtual double getReferField()
virtual StatusCode fieldVector(const HepPoint3D &xyz, HepVector3D &fvec) const
virtual ~MagneticFieldSvc()
Virtual destructor.
virtual StatusCode finalize()
Finalise the service.
virtual bool ifRealField() const
virtual StatusCode initialize()
Initialise the service (Inherited Service overrides)
void handle(const Incident &)
virtual StatusCode uniFieldVector(const HepPoint3D &xyz, HepVector3D &fvec) const
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)