Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HiParnt.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HiParnt.h
1 
2 #ifndef HiParnt_h
3 #define HiParnt_h
4 
5 extern "C" { void* hiparnt_address_(void); }
6 
12 class HiParnt {
13 public:
14  HiParnt();
15  ~HiParnt();
16 
17  float& hipr1 (int n);
18  int& ihpr2 (int n);
19  float& hint1 (int n);
20  int& ihnt2 (int n);
21 
22  void init (void);
23 
24  // return common array lengths
25  inline int lenHipr1() const {return _lenHipr1;}
26  inline int lenIhpr2() const {return _lenIhpr2;}
27  inline int lenHint1() const {return _lenHint1;}
28  inline int lenIhnt2() const {return _lenIhnt2;}
29 
30 private:
31 
32  // Lengths of the COMMONS
33  static const int _lenHipr1 = 100;
34  static const int _lenIhpr2 = 50;
35  static const int _lenHint1 = 100;
36  static const int _lenIhnt2 = 50;
37 
38  struct HIPARNT;
39  friend struct HIPARNT;
40 
41  struct HIPARNT
42  {
43  float hipr1[_lenHipr1];
44  int ihpr2[_lenIhpr2];
45  float hint1[_lenHint1];
46  int ihnt2[_lenIhnt2];
47  };
48 
49  int _dummy;
50  float _realdummy;
51  static HIPARNT* _hiparnt;
52 };
53 
54 // set pointer to zero at start
56 
57 inline void
59 { if (!_hiparnt) _hiparnt = static_cast<HIPARNT*>(hiparnt_address_()); }
60 
61 inline
63  : _dummy (-999),
64  _realdummy (-999.)
65 {}
66 
67 inline
69 {}
70 
71 inline float&
73 {
74  init(); // check COMMON is initialized
75  if(n < 1 || n > lenHipr1()) return _realdummy;
76  return _hiparnt->hipr1[n-1];
77 }
78 
79 inline int&
81 {
82  init(); // check COMMON is initialized
83  if(n < 1 || n > lenIhpr2()) return _dummy;
84  return _hiparnt->ihpr2[n-1];
85 }
86 
87 inline float&
89 {
90  init(); // check COMMON is initialized
91  if(n < 1 || n > lenHint1()) return _realdummy;
92  return _hiparnt->hint1[n-1];
93 }
94 
95 // access ihnt2 in common
96 inline int&
98 {
99  init(); // check COMMON is initialized
100  if(n < 1 || n > lenIhnt2()) return _dummy;
101  return _hiparnt->ihnt2[n-1];
102 }
103 
104 #endif