ATLAS Offline Software
PyDat1.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //
6 // Description:
7 // Class definition for PyDat1 which is used
8 // to modify PYDAT1 common.
9 
10 #ifndef PyDat1_h
11 #define PyDat1_h
12 
13 #include <cstdint>
14 
15 extern "C" { uintptr_t pydat1_address_(); }
16 
17 class PyDat1 {
18 public:
19  PyDat1();
20  ~PyDat1();
21 
22  int& mstu (int n);
23  double& paru (int n);
24  int& mstj (int n);
25  double& parj (int n);
26 
27  void init (void);
28 
29  // return common array lengths
30  inline int lenMstu() const {return s_lenMstu;}
31  inline int lenParu() const {return s_lenParu;}
32  inline int lenMstj() const {return s_lenMstj;}
33  inline int lenParj() const {return s_lenParj;}
34 
35 private:
36 
37  // Lengths of the COMMONS
38  static const int s_lenMstu = 200;
39  static const int s_lenParu = 200;
40  static const int s_lenMstj = 200;
41  static const int s_lenParj = 200;
42 
43  struct PYDAT1;
44  friend struct PYDAT1;
45 
46  struct PYDAT1
47  {
49  double paru[s_lenParu];
51  double parj[s_lenParj];
52  };
53 
54  int m_dummy;
55  double m_realdummy;
56  static PYDAT1* s_pydat1;
57 };
58 
59 // set pointer to zero at start
61 
62 inline void
64 { if (!s_pydat1) s_pydat1 = reinterpret_cast<PYDAT1*>(pydat1_address_()); }
65 
66 inline
68  : m_dummy (-999),
69  m_realdummy (-999.)
70 {}
71 
72 inline
74 {}
75 
76 inline int&
78 {
79  init(); // check COMMON is initialized
80  if(n < 1 || n > lenMstu()) return m_dummy;
81  return s_pydat1->mstu[n-1];
82 }
83 
84 inline double&
86 {
87  init(); // check COMMON is initialized
88  if(n < 1 || n > lenParu()) return m_realdummy;
89  return s_pydat1->paru[n-1];
90 }
91 
92 inline int&
94 {
95  init(); // check COMMON is initialized
96  if(n < 1 || n > lenMstj()) return m_dummy;
97  return s_pydat1->mstj[n-1];
98 }
99 
100 inline double&
102 {
103  init(); // check COMMON is initialized
104  if(n < 1 || n > lenParj()) return m_realdummy;
105  return s_pydat1->parj[n-1];
106 }
107 
108 #endif
PyDat1::PYDAT1::mstj
int mstj[s_lenMstj]
Definition: PyDat1.h:50
PyDat1::init
void init(void)
Definition: PyDat1.h:63
PyDat1::PYDAT1::mstu
int mstu[s_lenMstu]
Definition: PyDat1.h:48
pydat1_address_
uintptr_t pydat1_address_()
PyDat1::mstu
int & mstu(int n)
Definition: PyDat1.h:77
PyDat1::lenMstj
int lenMstj() const
Definition: PyDat1.h:32
PyDat1::s_lenParj
static const int s_lenParj
Definition: PyDat1.h:41
PyDat1::s_lenParu
static const int s_lenParu
Definition: PyDat1.h:39
PyDat1::lenMstu
int lenMstu() const
Definition: PyDat1.h:30
PyDat1
Definition: PyDat1.h:17
PyDat1::s_lenMstu
static const int s_lenMstu
Definition: PyDat1.h:38
beamspotman.n
n
Definition: beamspotman.py:731
PyDat1::~PyDat1
~PyDat1()
Definition: PyDat1.h:73
PyDat1::m_dummy
int m_dummy
Definition: PyDat1.h:54
PyDat1::m_realdummy
double m_realdummy
Definition: PyDat1.h:55
PyDat1::parj
double & parj(int n)
Definition: PyDat1.h:101
PyDat1::PYDAT1::parj
double parj[s_lenParj]
Definition: PyDat1.h:51
PyDat1::mstj
int & mstj(int n)
Definition: PyDat1.h:93
PyDat1::PYDAT1::paru
double paru[s_lenParu]
Definition: PyDat1.h:49
PyDat1::lenParu
int lenParu() const
Definition: PyDat1.h:31
PyDat1::s_pydat1
static PYDAT1 * s_pydat1
Definition: PyDat1.h:56
PyDat1::PyDat1
PyDat1()
Definition: PyDat1.h:67
PyDat1::lenParj
int lenParj() const
Definition: PyDat1.h:33
PyDat1::PYDAT1
Definition: PyDat1.h:47
PyDat1::paru
double & paru(int n)
Definition: PyDat1.h:85
PyDat1::s_lenMstj
static const int s_lenMstj
Definition: PyDat1.h:40