BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
MagneticField/MagneticField-00-02-04/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.
54
55public:
56
57 /// Initialise the service (Inherited Service overrides)
58 virtual StatusCode initialize();
59
61 void init_params(std::vector<double> current, std::vector<double> beamEnergy, int runNo);
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 /// Initialize
109 bool init_mucMagneticField();
110 virtual StatusCode initialize();
111 void init_params(int run);
112 void test (int run);
113 //void init_params(std::vector<double> current, std::vector<double> beamEnergy, int runNo);
114
115 // handler for new run
116 void handle(int new_run);
117#endif
118
119 /** IMagneticFieldSvc interface.
120 * @param[in] xyz Point at which magnetic field vector will be given
121 * @param[out] fvec Magnectic field vector.
122 * @return StatusCode SUCCESS if calculation was performed.
123 */
124 virtual StatusCode fieldVector( const HepPoint3D& xyz,
125 HepVector3D& fvec ) const;
126
127 virtual StatusCode uniFieldVector( const HepPoint3D& xyz,
128 HepVector3D& fvec ) const;
129
130 virtual double getReferField();
131
132 virtual bool ifRealField() const;
133
134
135private:
136#ifndef BEAN
137 /// Allow SvcFactory to instantiate the service.
138 friend class SvcFactory<MagneticFieldSvc>;
139#else
140 static MagneticFieldSvc* m_field;
141#endif
142
143 /// Fills Q, the field vector
144 void fieldGrid( const HepPoint3D& xyz, HepVector3D& fvec ) const;
145 void fieldGrid_TE( const HepPoint3D& xyz, HepVector3D& fvec ) const;
146
147 StatusCode parseFile( ); ///< Reads the field map from file
148 StatusCode parseFile_TE( ); ///< Reads the field map from file
149
150 std::string path; // path to data files
151
152 std::string m_filename; ///< Magnetic field file name
153 std::string m_filename_TE; ///< Magnetic field file name
154 //Not open map files for every run
155 std::string former_m_filename_TE;//("First Run");
156 std::string former_m_filename;//="First Run";
157
158 int m_runmode; ///< Run mode
159 int m_gridDistance; ///< grid distance of field map
160 int m_outlevel;
161 double m_scale;
162
163 double m_Cur_SCQ1_55;
164 double m_Cur_SCQ1_89;
165 double m_Cur_SCQ2_10;
166
167 std::vector<double> m_Q; ///< Field vector
168 std::vector<double> m_P; ///< Grid position
169 std::vector<double> m_Q_TE; ///< Field vector
170 std::vector<double> m_P_TE; ///< Grid position
171 std::vector<double> m_Q_1; ///< Field vector
172 std::vector<double> m_P_1; ///< Grid position
173 std::vector<double> m_Q_2; ///< Field vector
174 std::vector<double> m_P_2; ///< Grid position
175 double m_Dxyz[3]; ///< Steps in x, y and z
176 int m_Nxyz[3]; ///< Number of steps in x, y and z
177 double m_max_FL[3];
178 double m_min_FL[3];
179 //for tof and emc
180 double m_Dxyz_TE[3]; ///< Steps in x, y and z
181 int m_Nxyz_TE[3]; ///< Number of steps in x, y and z
182 double m_max_FL_TE[3];
183 double m_min_FL_TE[3];
184
185 double m_zOffSet; ///< The z offset
186 double m_zOffSet_TE; ///< The z offset
187 MucMagneticField* m_Mucfield;
188 double m_zfield;
189 bool m_ifRealField;
190
191 //property
192 bool m_useDB;
193
194 bool m_turnOffField;
195 bool m_uniField;
196public:
197 bool m_readOneTime;
198 int m_runFrom;
199 int m_runTo;
200 int runNo;
201
202#ifndef BEAN
203 IDataProviderSvc* m_eventSvc;
204#endif
205 //database
207 std::map<int, std::vector<double> > m_mapMagnetInfo;
208 std::map<int, std::vector<double> > m_mapBeamEnergy;
209 std::vector<double> beamEnergy;
210 std::vector<double> current;
211};
212
213#endif // MAGNETICFIELDSVC_H
std::string test
Definition: CalibModel.cxx:43
RunMode
Definition: Goofy.h:11
static const InterfaceID & interfaceID()
Retrieve interface ID.
virtual StatusCode finalize()
Finalise the service.
virtual const InterfaceID & type() const
Service type.
virtual StatusCode uniFieldVector(const HepPoint3D &xyz, HepVector3D &fvec) const
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
virtual StatusCode initialize()
Initialise the service (Inherited Service overrides)
virtual StatusCode fieldVector(const HepPoint3D &xyz, HepVector3D &fvec) const
virtual StatusCode initialize()
Initialise the service (Inherited Service overrides)
void handle(const Incident &)
virtual ~MagneticFieldSvc()
Virtual destructor.
MagneticFieldSvc(const std::string &name, ISvcLocator *svc)
virtual bool ifRealField() const
void init_params(std::vector< double > current, std::vector< double > beamEnergy, int runNo)
virtual double getReferField()
Forward and external declarations.
Definition: CalibDataSvc.h:35