ATLAS Offline Software
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 
27 namespace 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 
71  int m_magnet;
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
header
Definition: hcg.cxx:526
MagField::ForwardRegionFieldSvc::handle
void handle(const Incident &runIncident) override final
IIncidentListener interface methods.
Definition: ForwardRegionFieldSvc.cxx:108
MagField::ForwardRegionFieldSvc::s_Q5HKick
static const int s_Q5HKick
Definition: ForwardRegionFieldSvc.h:109
MagField::ForwardRegionFieldSvc::s_Q2HKick
static const int s_Q2HKick
Definition: ForwardRegionFieldSvc.h:102
MagField::ForwardRegionFieldSvc::getMagnetTransformParams
void getMagnetTransformParams(int beam, int magnet, G4ThreeVector Point, HepGeom::Point3D< double > &pointMagStart, HepGeom::Point3D< double > &pointMagEnd, double &rotZ) const
Definition: ForwardRegionFieldSvc.cxx:618
MagField::ForwardRegionFieldSvc::loadDataFile
std::vector< std::vector< std::string > > loadDataFile(const char *fileName, int cols)
Definition: ForwardRegionFieldSvc.cxx:508
MagField::ForwardRegionFieldSvc::m_magIndMQXA
double m_magIndMQXA[s_rowsMQXA][s_colsMQXA][2]
Definition: ForwardRegionFieldSvc.h:117
MagField::ForwardRegionFieldSvc::s_rowsMQXA
static const int s_rowsMQXA
Definition: ForwardRegionFieldSvc.h:112
MagField::ForwardRegionFieldSvc::m_properties
ToolHandle< IForwardRegionProperties > m_properties
Definition: ForwardRegionFieldSvc.h:132
MagField::ForwardRegionFieldSvc::s_Q4VKickB
static const int s_Q4VKickB
Definition: ForwardRegionFieldSvc.h:108
MagField::ForwardRegionFieldSvc::getMag
double getMag(int magnet, int beam) const
Definition: ForwardRegionFieldSvc.cxx:399
MagField::ForwardRegionFieldSvc::s_Q1VKick
static const int s_Q1VKick
Definition: ForwardRegionFieldSvc.h:101
MagField::ForwardRegionFieldSvc::s_Q2VKick
static const int s_Q2VKick
Definition: ForwardRegionFieldSvc.h:103
MagField::ForwardRegionFieldSvc::m_magnet
int m_magnet
Definition: ForwardRegionFieldSvc.h:71
xyz
#define xyz
MagField::ForwardRegionFieldSvc::ForwardRegionFieldSvc
ForwardRegionFieldSvc(const std::string &name, ISvcLocator *svc)
Constructor with parameters.
Definition: ForwardRegionFieldSvc.cxx:37
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
MagField::ForwardRegionFieldSvc::m_magData
double m_magData[4]
Definition: ForwardRegionFieldSvc.h:80
MagField::ForwardRegionFieldSvc::s_Q1
static const int s_Q1
Definition: ForwardRegionFieldSvc.h:91
MagField::ForwardRegionFieldSvc::s_D2
static const int s_D2
Definition: ForwardRegionFieldSvc.h:95
MagField::ForwardRegionFieldSvc::getMagInd
G4ThreeVector getMagInd(G4ThreeVector Point, int q, int beam) const
Non-inherited public methods FIXME - add new interface?
Definition: ForwardRegionFieldSvc.cxx:325
MagField::ForwardRegionFieldSvc::kLToB
double kLToB(double kL, double lenght, double momentum)
Definition: ForwardRegionFieldSvc.cxx:515
MagField::ForwardRegionFieldSvc::m_magIndMQXB
double m_magIndMQXB[s_rowsMQXB][s_colsMQXB][2]
Definition: ForwardRegionFieldSvc.h:118
MagField::ForwardRegionFieldSvc::m_magDataType
int m_magDataType
Definition: ForwardRegionFieldSvc.h:83
MagField::ForwardRegionFieldSvc::getFieldZR
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
Definition: ForwardRegionFieldSvc.cxx:135
MagField::ForwardRegionFieldSvc::s_colsMQXA
static const int s_colsMQXA
Definition: ForwardRegionFieldSvc.h:113
MagField::ForwardRegionFieldSvc::s_Q7
static const int s_Q7
Definition: ForwardRegionFieldSvc.h:99
MagField::ForwardRegionFieldSvc
Definition: ForwardRegionFieldSvc.h:29
MagField::ForwardRegionFieldSvc::s_colsMQXB
static const int s_colsMQXB
Definition: ForwardRegionFieldSvc.h:115
MagField::ForwardRegionFieldSvc::s_Q3
static const int s_Q3
Definition: ForwardRegionFieldSvc.h:93
MagField::ForwardRegionFieldSvc::m_MQXA_DataFile
std::string m_MQXA_DataFile
Definition: ForwardRegionFieldSvc.h:85
beamspotnt.cols
list cols
Definition: bin/beamspotnt.py:1114
MagField::ForwardRegionFieldSvc::s_Q2
static const int s_Q2
Definition: ForwardRegionFieldSvc.h:92
MagField::ForwardRegionFieldSvc::getField
virtual void getField(const double *xyz, double *bxyz, double *deriv=nullptr) const override final
IMagFieldSvc interface methods.
Definition: ForwardRegionFieldSvc.cxx:123
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
MagField::ForwardRegionFieldSvc::s_D1
static const int s_D1
Definition: ForwardRegionFieldSvc.h:94
_FWDMg_CONFIGURATION
Definition: IForwardRegionProperties.h:13
MagField::ForwardRegionFieldSvc::loadDataFileNLines
std::vector< std::vector< std::string > > loadDataFileNLines(const char *fileName, int cols, int N, std::string &header)
Definition: ForwardRegionFieldSvc.cxx:424
MagField::ForwardRegionFieldSvc::getMagNumFromName
int getMagNumFromName(const std::string &name) const
Definition: ForwardRegionFieldSvc.cxx:581
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
MagField::ForwardRegionFieldSvc::m_MQXB_DataFile
std::string m_MQXB_DataFile
Definition: ForwardRegionFieldSvc.h:86
MagField::ForwardRegionFieldSvc::s_Q6VKick
static const int s_Q6VKick
Definition: ForwardRegionFieldSvc.h:110
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MagField::ForwardRegionFieldSvc::getKick
G4ThreeVector getKick(int beam) const
Definition: ForwardRegionFieldSvc.cxx:405
MagField::ForwardRegionFieldSvc::s_Q1HKick
static const int s_Q1HKick
Definition: ForwardRegionFieldSvc.h:100
IMagFieldSvc.h
MagField::ForwardRegionFieldSvc::m_Config
FWDMg_CONFIGURATION m_Config
Definition: ForwardRegionFieldSvc.h:130
MagField::ForwardRegionFieldSvc::s_Q4VKickA
static const int s_Q4VKickA
Definition: ForwardRegionFieldSvc.h:106
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
MagField::ForwardRegionFieldSvc::m_magnets
std::vector< std::vector< std::string > > m_magnets
Definition: ForwardRegionFieldSvc.h:75
jobOptions.beam
beam
Definition: jobOptions.SuperChic_ALP2.py:16
MagField
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
Definition: ForwardRegionFieldSvc.h:27
MagField::ForwardRegionFieldSvc::s_Q4HKick
static const int s_Q4HKick
Definition: ForwardRegionFieldSvc.h:107
MagField::ForwardRegionFieldSvc::s_Q3HKick
static const int s_Q3HKick
Definition: ForwardRegionFieldSvc.h:104
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ChargedTracksWeightFilter::Spline::Point
Linear spline representation of a function used to calculate weights.
Definition: ChargedTracksWeightFilter.h:28
IForwardRegionProperties.h
MagField::ForwardRegionFieldSvc::InitMagData
void InitMagData()
Definition: ForwardRegionFieldSvc.cxx:213
MagField::ForwardRegionFieldSvc::getMagXOff
double getMagXOff(int magnet) const
Definition: ForwardRegionFieldSvc.cxx:411
MagField::ForwardRegionFieldSvc::getMagYOff
double getMagYOff(int magnet) const
Definition: ForwardRegionFieldSvc.cxx:417
MagField::ForwardRegionFieldSvc::s_Q4
static const int s_Q4
Definition: ForwardRegionFieldSvc.h:96
MagField::ForwardRegionFieldSvc::s_Q6
static const int s_Q6
Definition: ForwardRegionFieldSvc.h:98
extractSporadic.q
list q
Definition: extractSporadic.py:98
AthService.h
MagField::ForwardRegionFieldSvc::writeOutTwiss
void writeOutTwiss(const std::vector< std::vector< std::string >> &loadedTwissFile, int beam, const std::string &header)
Definition: ForwardRegionFieldSvc.cxx:520
MagField::ForwardRegionFieldSvc::InitMagDataFromTwiss
void InitMagDataFromTwiss(const std::vector< std::vector< std::string > > &loadedTwissFile, int beam, double momentum)
Definition: ForwardRegionFieldSvc.cxx:251
MagField::ForwardRegionFieldSvc::initialize
StatusCode initialize() override final
AthService interface methods.
Definition: ForwardRegionFieldSvc.cxx:95
MagField::ForwardRegionFieldSvc::s_rowsMQXB
static const int s_rowsMQXB
Definition: ForwardRegionFieldSvc.h:114
MagField::ForwardRegionFieldSvc::s_Q5
static const int s_Q5
Definition: ForwardRegionFieldSvc.h:97
MagField::ForwardRegionFieldSvc::s_Q3VKick
static const int s_Q3VKick
Definition: ForwardRegionFieldSvc.h:105
MagField::ForwardRegionFieldSvc::FieldValue
G4ThreeVector FieldValue(G4ThreeVector Point) const
Definition: ForwardRegionFieldSvc.cxx:140