ATLAS Offline Software
PySubs.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 PySubs, which is used
8 // to modify PYSUBS common.
9 
10 #ifndef PySubs_h
11 #define PySubs_h
12 
13 #include <cstdint>
14 
15 extern "C" { uintptr_t pysubs_address_(); }
16 
17 class PySubs {
18 public:
19  PySubs();
20  ~PySubs();
21 
22  int& msel (void);
23  int& mselpd (void);
24  int& msub (int n);
25  int& kfin (int i, int j);
26  double& ckin (int n);
27 
28  void init (void);
29 
30  // return common array lengths
31  inline int lenMsub() const {return s_lenMsub;}
32  inline int leniKfin() const {return s_leniKfin;}
33  inline int lenjKfin() const {return s_lenjKfin;}
34  inline int lenCkin() const {return s_lenCkin;}
35 
36 private:
37 
38  // Lengths of the COMMONS
39  static const int s_lenMsub = 500;
40  static const int s_leniKfin = 2;
41  static const int s_lenjKfin = 81;
42  static const int s_lenCkin = 200;
43 
44  struct PYSUBS;
45  friend struct PYSUBS;
46 
47  struct PYSUBS
48  {
49  int msel;
50  int mselpd;
53  double ckin[s_lenCkin];
54  };
55 
56  int m_dummy;
57  double m_realdummy;
58  static PYSUBS* s_pysubs;
59 };
60 
61 // set pointer to zero at start
63 
64 inline void
66 { if (!s_pysubs) s_pysubs = reinterpret_cast<PYSUBS*>(pysubs_address_()); }
67 
68 inline
70  : m_dummy (-999),
71  m_realdummy (-999.)
72 {}
73 
74 inline
76 {}
77 
78 inline int&
80 {
81  init();
82  return s_pysubs->msel;
83 }
84 
85 inline int&
87 {
88  init();
89  return s_pysubs->mselpd;
90 }
91 
92 inline int&
94 {
95  init(); // check COMMON is initialized
96  if(n < 1 || n > lenMsub()) return m_dummy;
97  return s_pysubs->msub[n-1];
98 }
99 
100 inline int&
101 PySubs::kfin (int i, int j)
102 {
103  init(); // check COMMON is initialized
104  if( i < 1 || i > leniKfin() ||
105  j < 1 || j > lenjKfin() ) return m_dummy;
106 
107  return s_pysubs->kfin[j-1][i-1];
108 }
109 
110 inline double&
112 {
113  init(); // check COMMON is initialized
114  if(n < 1 || n > lenCkin()) return m_realdummy;
115  return s_pysubs->ckin[n-1];
116 }
117 
118 
119 #endif
PySubs::PySubs
PySubs()
Definition: PySubs.h:69
PySubs::~PySubs
~PySubs()
Definition: PySubs.h:75
PySubs::s_pysubs
static PYSUBS * s_pysubs
Definition: PySubs.h:58
PySubs::PYSUBS::ckin
double ckin[s_lenCkin]
Definition: PySubs.h:53
pysubs_address_
uintptr_t pysubs_address_()
PySubs::kfin
int & kfin(int i, int j)
Definition: PySubs.h:101
PySubs::s_lenMsub
static const int s_lenMsub
Definition: PySubs.h:39
PySubs::mselpd
int & mselpd(void)
Definition: PySubs.h:86
PySubs::ckin
double & ckin(int n)
Definition: PySubs.h:111
PySubs::lenMsub
int lenMsub() const
Definition: PySubs.h:31
PySubs::init
void init(void)
Definition: PySubs.h:65
PySubs::m_dummy
int m_dummy
Definition: PySubs.h:56
PySubs::s_leniKfin
static const int s_leniKfin
Definition: PySubs.h:40
PySubs::PYSUBS::msub
int msub[s_lenMsub]
Definition: PySubs.h:51
PySubs::s_lenCkin
static const int s_lenCkin
Definition: PySubs.h:42
lumiFormat.i
int i
Definition: lumiFormat.py:85
PySubs
Definition: PySubs.h:17
beamspotman.n
n
Definition: beamspotman.py:731
PySubs::leniKfin
int leniKfin() const
Definition: PySubs.h:32
PySubs::msel
int & msel(void)
Definition: PySubs.h:79
PySubs::PYSUBS::msel
int msel
Definition: PySubs.h:49
PySubs::PYSUBS::mselpd
int mselpd
Definition: PySubs.h:50
PySubs::lenjKfin
int lenjKfin() const
Definition: PySubs.h:33
PySubs::PYSUBS
Definition: PySubs.h:48
PySubs::s_lenjKfin
static const int s_lenjKfin
Definition: PySubs.h:41
PySubs::msub
int & msub(int n)
Definition: PySubs.h:93
PySubs::lenCkin
int lenCkin() const
Definition: PySubs.h:34
PySubs::PYSUBS::kfin
int kfin[s_lenjKfin][s_leniKfin]
Definition: PySubs.h:52
PySubs::m_realdummy
double m_realdummy
Definition: PySubs.h:57