ATLAS Offline Software
HiStrng.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 #ifndef HiStrng_h
7 #define HiStrng_h
8 
9 #include <cstdint>
10 
11 extern "C" { uintptr_t histrng_address_(); }
17 class HiStrng {
18 public:
19  HiStrng();
20  ~HiStrng();
21 
22  int& nfp (int i, int j);
23  float& pp (int i, int j);
24  int& nft (int i, int j);
25  float& pt (int i, int j);
26 
27  void init (void);
28 
29  // return common array lengths
30  inline int lenI() const {return s_lenI;}
31  inline int lenJ() const {return s_lenJ;}
32 
33 private:
34 
35  // Lengths of array in HiMain2 common
36  static const int s_lenI = 300;
37  static const int s_lenJ = 15;
38 
39  struct HISTRNG;
40  friend struct HISTRNG;
41 
42  struct HISTRNG
43  {
44  int nfp [s_lenJ][s_lenI];
45  float pp [s_lenJ][s_lenI];
46  int nft [s_lenJ][s_lenI];
47  float pt [s_lenJ][s_lenI];
48  };
49 
50  int m_dummy;
51  float m_realdummy;
52 
53  static HISTRNG* s_histrng;
54 };
55 
56 // set pointer to zero at start
58 
59 inline void
61 { if (!s_histrng) s_histrng = reinterpret_cast<HISTRNG*>(histrng_address_()); }
62 
63 // Constructor
64 inline
66  : m_dummy (-999),
67  m_realdummy (-999.)
68 {}
69 
70 // Destructor
71 inline
73 {}
74 
75 inline int&
76 HiStrng::nfp (int i, int j)
77 {
78  init(); // check COMMON is initialized
79  if( i < 1 || i > lenI() ||
80  j < 1 || j > lenJ() ) return m_dummy;
81 
82  return s_histrng->nfp[j-1][i-1];
83 }
84 
85 inline float&
86 HiStrng::pp (int i, int j)
87 {
88  init(); // check COMMON is initialized
89  if( i < 1 || i > lenI() ||
90  j < 1 || j > lenJ() ) return m_realdummy;
91 
92  return s_histrng->pp[j-1][i-1];
93 }
94 
95 inline int&
96 HiStrng::nft (int i, int j)
97 {
98  init(); // check COMMON is initialized
99  if( i < 1 || i > lenI() ||
100  j < 1 || j > lenJ() ) return m_dummy;
101 
102  return s_histrng->nft[j-1][i-1];
103 }
104 
105 inline float&
106 HiStrng::pt (int i, int j)
107 {
108  init(); // check COMMON is initialized
109  if( i < 1 || i > lenI() ||
110  j < 1 || j > lenJ() ) return m_realdummy;
111 
112  return s_histrng->pt[j-1][i-1];
113 }
114 
115 #endif
HiStrng::s_lenI
static const int s_lenI
Definition: HiStrng.h:36
HiStrng::nft
int & nft(int i, int j)
Definition: HiStrng.h:96
HiStrng
Class definition for HiStrng, which is used to modify the Hijing HISTRNG common.
Definition: HiStrng.h:17
HiStrng::HISTRNG::nft
int nft[s_lenJ][s_lenI]
Definition: HiStrng.h:46
histrng_address_
uintptr_t histrng_address_()
HiStrng::init
void init(void)
Definition: HiStrng.h:60
HiStrng::HISTRNG
Definition: HiStrng.h:43
HiStrng::HISTRNG::pt
float pt[s_lenJ][s_lenI]
Definition: HiStrng.h:47
HiStrng::~HiStrng
~HiStrng()
Definition: HiStrng.h:72
HiStrng::pp
float & pp(int i, int j)
Definition: HiStrng.h:86
HiStrng::HISTRNG::pp
float pp[s_lenJ][s_lenI]
Definition: HiStrng.h:45
HiStrng::pt
float & pt(int i, int j)
Definition: HiStrng.h:106
lumiFormat.i
int i
Definition: lumiFormat.py:85
HiStrng::s_lenJ
static const int s_lenJ
Definition: HiStrng.h:37
HiStrng::HiStrng
HiStrng()
Definition: HiStrng.h:65
HiStrng::nfp
int & nfp(int i, int j)
Definition: HiStrng.h:76
HiStrng::m_dummy
int m_dummy
Definition: HiStrng.h:50
HiStrng::HISTRNG::nfp
int nfp[s_lenJ][s_lenI]
Definition: HiStrng.h:44
HiStrng::m_realdummy
float m_realdummy
Definition: HiStrng.h:51
HiStrng::lenJ
int lenJ() const
Definition: HiStrng.h:31
HiStrng::s_histrng
static HISTRNG * s_histrng
Definition: HiStrng.h:53
HiStrng::lenI
int lenI() const
Definition: HiStrng.h:30