ATLAS Offline Software
Loading...
Searching...
No Matches
ForwardRegionFieldSvc.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6// ForwardRegionFieldSvc.h, (c) ATLAS Detector software
8
9#ifndef FORWARDREGIONMGFIELD_FORWARDREGIONFIELDFIELDSVC_H
10#define FORWARDREGIONMGFIELD_FORWARDREGIONFIELDFIELDSVC_H 1
11
12//CLHEP includes
13#include "CLHEP/Geometry/Point3D.h"
14
15//Geant4 includes
16#include "G4ThreeVector.hh"
17
18// FrameWork includes
20#include "GaudiKernel/ToolHandle.h"
21#include "GaudiKernel/IIncidentListener.h"
22
24// MagField includes
26
27namespace MagField {
28
29 class ForwardRegionFieldSvc : public extends<AthService, IMagFieldSvc, IIncidentListener> {
31 // Public methods:
33 public:
35 ForwardRegionFieldSvc(const std::string& name,ISvcLocator* svc);
36
38 StatusCode initialize() override final;
39
41 void handle(const Incident& runIncident) override final;
42
47 virtual void getField(const double *xyz, double *bxyz, double *deriv = nullptr) const override final;
48
53 virtual void getFieldZR(const double *xyz, double *bxyz, double *deriv = nullptr) const override final;
54
56 // get magnetic induction vector in certain point inside Q1-Q3 quadrupoles (uses bilinear interpolation), q=0 - Q1, q=1 - Q2, q=2 - Q3
57 G4ThreeVector getMagInd(G4ThreeVector Point, int q, int beam) const;
58
59 double getMag(int magnet, int beam) const;
60
61 G4ThreeVector getKick(int beam) const;
62
63 double getMagXOff(int magnet) const;
64
65 double getMagYOff(int magnet) const;
66
67 private:
68
69 G4ThreeVector FieldValue(G4ThreeVector Point) const;
70
72
73 void InitMagData();
74
75 std::vector<std::vector<std::string> > m_magnets;
76
77 // array for storing magnets data
78 // dipoles/quadrupoles: field/gradient beam 1 | field/gradient beam 2 | x offset | y offset
79 // kickers: B_x beam 1 | B_x beam 2 | B_y beam 1 | B_y beam 2
80 double m_magData[4];
81
82 // switch for magnetic data input file type: 0 = magnets.dat, 1 = twiss file
84
85 std::string m_MQXA_DataFile; // @TODO DOCUMENT
86 std::string m_MQXB_DataFile; // @TODO DOCUMENT
87
88 //std::string m_twissFileB1, m_twissFileB2;
89
90 // file indexes
91 static const int s_Q1 = 0;
92 static const int s_Q2 = 1;
93 static const int s_Q3 = 2;
94 static const int s_D1 = 3;
95 static const int s_D2 = 4;
96 static const int s_Q4 = 5;
97 static const int s_Q5 = 6;
98 static const int s_Q6 = 7;
99 static const int s_Q7 = 8;
100 static const int s_Q1HKick = 9;
101 static const int s_Q1VKick = 10;
102 static const int s_Q2HKick = 11;
103 static const int s_Q2VKick = 12;
104 static const int s_Q3HKick = 13;
105 static const int s_Q3VKick = 14;
106 static const int s_Q4VKickA = 15;
107 static const int s_Q4HKick = 16;
108 static const int s_Q4VKickB = 17;
109 static const int s_Q5HKick = 18;
110 static const int s_Q6VKick = 19;
111 //mapfile parameters
112 static const int s_rowsMQXA = 97;
113 static const int s_colsMQXA = 97;
114 static const int s_rowsMQXB = 89;
115 static const int s_colsMQXB = 89;
116
119
120 // Load data from file into 2D array of strings
121 std::vector<std::vector<std::string> > loadDataFile(const char * fileName, int cols);
122 std::vector<std::vector<std::string> > loadDataFileNLines(const char * fileName, int cols, int N, std::string& header);
123
124 // Calculate magnetic induction value / gradient from K*L values
125 double kLToB(double kL, double lenght, double momentum);
126
127 void InitMagDataFromTwiss(const std::vector<std::vector<std::string> >& loadedTwissFile, int beam, double momentum);
128
129 // property configuration
131
132 ToolHandle<IForwardRegionProperties> m_properties;
133
134// G4ThreeVector applyDisplacement(G4ThreeVector Point, G4ThreeVector field, int beam) const;
135
136 void writeOutTwiss(const std::vector<std::vector<std::string>>& loadedTwissFile, int beam, const std::string& header);
137 void getMagnetTransformParams(int beam, int magnet, G4ThreeVector Point, HepGeom::Point3D<double> &pointMagStart,HepGeom::Point3D<double> &pointMagEnd, double &rotZ) const;
138 int getMagNumFromName(const std::string& name) const;
139
140
141 };
142}
143#endif // FORWARDREGIONMGFIELD_FORWARDREGIONFIELDFIELDSVC_H
ChargedTracksWeightFilter::Spline::Point Point
struct _FWDMg_CONFIGURATION FWDMg_CONFIGURATION
#define xyz
std::vector< std::vector< std::string > > loadDataFileNLines(const char *fileName, int cols, int N, std::string &header)
double m_magIndMQXB[s_rowsMQXB][s_colsMQXB][2]
int getMagNumFromName(const std::string &name) const
std::vector< std::vector< std::string > > m_magnets
virtual void getField(const double *xyz, double *bxyz, double *deriv=nullptr) const override final
IMagFieldSvc interface methods.
double getMag(int magnet, int beam) const
double m_magIndMQXA[s_rowsMQXA][s_colsMQXA][2]
ForwardRegionFieldSvc(const std::string &name, ISvcLocator *svc)
Constructor with parameters.
void writeOutTwiss(const std::vector< std::vector< std::string > > &loadedTwissFile, int beam, const std::string &header)
void handle(const Incident &runIncident) override final
IIncidentListener interface methods.
ToolHandle< IForwardRegionProperties > m_properties
std::vector< std::vector< std::string > > loadDataFile(const char *fileName, int cols)
G4ThreeVector FieldValue(G4ThreeVector Point) const
void InitMagDataFromTwiss(const std::vector< std::vector< std::string > > &loadedTwissFile, int beam, double momentum)
double kLToB(double kL, double lenght, double momentum)
StatusCode initialize() override final
AthService interface methods.
void getMagnetTransformParams(int beam, int magnet, G4ThreeVector Point, HepGeom::Point3D< double > &pointMagStart, HepGeom::Point3D< double > &pointMagEnd, double &rotZ) const
G4ThreeVector getMagInd(G4ThreeVector Point, int q, int beam) const
Non-inherited public methods FIXME - add new interface?
G4ThreeVector getKick(int beam) const
virtual void getFieldZR(const double *xyz, double *bxyz, double *deriv=nullptr) const override final
get B field value on the z-r plane at given position
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)