BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
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
15
16#ifndef BEAN
17#include "GaudiKernel/Service.h"
18//#include "GaudiKernel/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 extends<Service, IMagneticFieldSvc>,
42 virtual public IIncidentListener {
43//protected:
44public:
45 /// Standard Constructor.
46 /// @param name String with service name
47 /// @param svc Pointer to service locator interface
48 MagneticFieldSvc( const std::string& name, ISvcLocator* svc );
49
50 /// Virtual destructor.
51 virtual ~MagneticFieldSvc();
52
53public:
54
55 /// Initialise the service (Inherited Service overrides)
56 virtual StatusCode initialize();
57
59 void init_params(std::vector<double> current, std::vector<double> beamEnergy, int runNo);
60 /// Finalise the service.
61 virtual StatusCode finalize();
62
63 /** Query the available interfaces.
64 * @param riid Requested interface ID
65 * @param ppvInterface Pointer to requested interface
66 * @return StatusCode indicating SUCCESS or FAILURE.
67 */
68 //virtual StatusCode queryInterface( const InterfaceID& riid,
69 // void** ppvInterface );
70
71 /// Service type.
72 virtual const InterfaceID& type() const { return IMagneticFieldSvc::interfaceID(); };
73
74
75 // Incident handler
76 void handle(const Incident&);
77
78#else
79// -------------------------- BEAN ------------------------------------
80class MagneticFieldSvc {
81
82public:
83 static MagneticFieldSvc* instance() {
84 return (m_field) ? m_field : (m_field=new(std::nothrow)MagneticFieldSvc());
85 }
86
87private:
89 virtual ~MagneticFieldSvc();
90
91public:
92 void SetPath(std::string new_path) {path = new_path;}
93 std::string GetPath() {return path;}
94
95 void GridDistance( int gridDistance = 5) {m_gridDistance = gridDistance;}
96 void RunMode( int runmode = 2) {m_runmode = runmode;}
97 void IfRealField( bool ifRealField = true) {m_ifRealField = ifRealField;}
98 void OutLevel( int outlevel = 1) {m_outlevel = outlevel;}
99
100 void Cur_SCQ1_55( double Cur_SCQ1_55 = 349.4) {m_Cur_SCQ1_55 = Cur_SCQ1_55;}
101 void Cur_SCQ1_89( double Cur_SCQ1_89 = 426.2) {m_Cur_SCQ1_89 = Cur_SCQ1_89;}
102 void Cur_SCQ2_10( double Cur_SCQ2_10 = 474.2) {m_Cur_SCQ2_10 = Cur_SCQ2_10;}
103
104 void UseDBFlag( bool useDB = true) {m_useDB = useDB;}
105
106 /// Initialize
107 bool init_mucMagneticField();
108 virtual StatusCode initialize();
109 void init_params(int run);
110 void test (int run);
111 //void init_params(std::vector<double> current, std::vector<double> beamEnergy, int runNo);
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 //Not open map files for every run
153 std::string former_m_filename_TE;//("First Run");
154 std::string former_m_filename;//="First Run";
155
156 int m_runmode; ///< Run mode
157 int m_gridDistance; ///< grid distance of field map
158 int m_outlevel;
159 double m_scale;
160
161 double m_Cur_SCQ1_55;
162 double m_Cur_SCQ1_89;
163 double m_Cur_SCQ2_10;
164
165 std::vector<double> m_Q; ///< Field vector
166 std::vector<double> m_P; ///< Grid position
167 std::vector<double> m_Q_TE; ///< Field vector
168 std::vector<double> m_P_TE; ///< Grid position
169 std::vector<double> m_Q_1; ///< Field vector
170 std::vector<double> m_P_1; ///< Grid position
171 std::vector<double> m_Q_2; ///< Field vector
172 std::vector<double> m_P_2; ///< Grid position
173 double m_Dxyz[3]; ///< Steps in x, y and z
174 int m_Nxyz[3]; ///< Number of steps in x, y and z
175 double m_max_FL[3];
176 double m_min_FL[3];
177 //for tof and emc
178 double m_Dxyz_TE[3]; ///< Steps in x, y and z
179 int m_Nxyz_TE[3]; ///< Number of steps in x, y and z
180 double m_max_FL_TE[3];
181 double m_min_FL_TE[3];
182
183 double m_zOffSet; ///< The z offset
184 double m_zOffSet_TE; ///< The z offset
185 MucMagneticField* m_Mucfield;
186 double m_zfield;
187 bool m_ifRealField;
188
189 //property
190 bool m_useDB;
191
192 bool m_turnOffField;
193 bool m_uniField;
194public:
198 int runNo;
199
200#ifndef BEAN
201 IDataProviderSvc* m_eventSvc;
202#endif
203 //database
205 std::map<int, std::vector<double> > m_mapMagnetInfo;
206 std::map<int, std::vector<double> > m_mapBeamEnergy;
207 std::vector<double> beamEnergy;
208 std::vector<double> current;
209};
210
211#endif // MAGNETICFIELDSVC_H
std::string test
RunMode
Definition Goofy.h:11
HepGeom::Point3D< double > HepPoint3D
HepGeom::Vector3D< double > HepVector3D
FieldDBUtil::ConnectionDB * m_connect_run
virtual const InterfaceID & type() const
Service type.
std::map< int, std::vector< double > > m_mapMagnetInfo
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
std::vector< double > beamEnergy
virtual StatusCode initialize()
Initialise the service (Inherited Service overrides)
std::map< int, std::vector< double > > m_mapBeamEnergy
void handle(const Incident &)
virtual StatusCode uniFieldVector(const HepPoint3D &xyz, HepVector3D &fvec) const
MagneticFieldSvc(const std::string &name, ISvcLocator *svc)
std::vector< double > current
IDataProviderSvc * m_eventSvc
Forward and external declarations.