ATLAS Offline Software
PyPars.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 PyPars which is used
8 // to modify PYPARS common.
9 
10 #ifndef PyPars_h
11 #define PyPars_h
12 
13 #include <cstdint>
14 
15 extern "C" { uintptr_t pypars_address_(); }
16 
17 class PyPars {
18 public:
19  PyPars();
20  ~PyPars();
21 
22  int& mstp (int n);
23  double& parp (int n);
24  int& msti (int n);
25  double& pari (int n);
26 
27  void init (void);
28 
29  // return common array lengths
30  inline int lenMstp() const {return s_lenMstp;}
31  inline int lenParp() const {return s_lenParp;}
32  inline int lenMsti() const {return s_lenMsti;}
33  inline int lenPari() const {return s_lenPari;}
34 
35 private:
36 
37  // Lengths of the COMMONS
38  static const int s_lenMstp = 200;
39  static const int s_lenParp = 200;
40  static const int s_lenMsti = 200;
41  static const int s_lenPari = 200;
42 
43  struct PYPARS;
44  friend struct PYPARS;
45 
46  struct PYPARS
47  {
49  double parp[s_lenParp];
51  double pari[s_lenPari];
52  };
53 
54  int m_dummy;
55  double m_realdummy;
56  static PYPARS* s_pypars;
57 };
58 
59 // set pointer to zero at start
61 
62 inline void
64 { if (!s_pypars) s_pypars = reinterpret_cast<PYPARS*>(pypars_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 > lenMstp()) return m_dummy;
81  return s_pypars->mstp[n-1];
82 }
83 
84 inline double&
86 {
87  init(); // check COMMON is initialized
88  if(n < 1 || n > lenParp()) return m_realdummy;
89  return s_pypars->parp[n-1];
90 }
91 
92 inline int&
94 {
95  init(); // check COMMON is initialized
96  if(n < 1 || n > lenMsti()) return m_dummy;
97  return s_pypars->msti[n-1];
98 }
99 
100 inline double&
102 {
103  init(); // check COMMON is initialized
104  if(n < 1 || n > lenPari()) return m_realdummy;
105  return s_pypars->pari[n-1];
106 }
107 
108 #endif
PyPars::lenMsti
int lenMsti() const
Definition: PyPars.h:32
PyPars::mstp
int & mstp(int n)
Definition: PyPars.h:77
PyPars::lenMstp
int lenMstp() const
Definition: PyPars.h:30
PyPars::s_lenMstp
static const int s_lenMstp
Definition: PyPars.h:38
PyPars::msti
int & msti(int n)
Definition: PyPars.h:93
PyPars::~PyPars
~PyPars()
Definition: PyPars.h:73
PyPars::parp
double & parp(int n)
Definition: PyPars.h:85
PyPars::init
void init(void)
Definition: PyPars.h:63
PyPars::pari
double & pari(int n)
Definition: PyPars.h:101
PyPars::lenParp
int lenParp() const
Definition: PyPars.h:31
PyPars::PYPARS::mstp
int mstp[s_lenMstp]
Definition: PyPars.h:48
PyPars::s_lenMsti
static const int s_lenMsti
Definition: PyPars.h:40
pypars_address_
uintptr_t pypars_address_()
PyPars::PyPars
PyPars()
Definition: PyPars.h:67
beamspotman.n
n
Definition: beamspotman.py:731
PyPars::s_lenParp
static const int s_lenParp
Definition: PyPars.h:39
PyPars::PYPARS::pari
double pari[s_lenPari]
Definition: PyPars.h:51
PyPars::lenPari
int lenPari() const
Definition: PyPars.h:33
PyPars::PYPARS
Definition: PyPars.h:47
PyPars
Definition: PyPars.h:17
PyPars::s_lenPari
static const int s_lenPari
Definition: PyPars.h:41
PyPars::PYPARS::msti
int msti[s_lenMsti]
Definition: PyPars.h:50
PyPars::m_realdummy
double m_realdummy
Definition: PyPars.h:55
PyPars::s_pypars
static PYPARS * s_pypars
Definition: PyPars.h:56
PyPars::PYPARS::parp
double parp[s_lenParp]
Definition: PyPars.h:49
PyPars::m_dummy
int m_dummy
Definition: PyPars.h:54