EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HiStrng.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HiStrng.h
1 
2 #ifndef HiStrng_h
3 #define HiStrng_h
4 
5 extern "C" { void* histrng_address_(void); }
11 class HiStrng {
12 public:
13  HiStrng();
14  ~HiStrng();
15 
16  int& nfp (int i, int j);
17  float& pp (int i, int j);
18  int& nft (int i, int j);
19  float& pt (int i, int j);
20 
21  void init (void);
22 
23  // return common array lengths
24  inline int lenI() const {return _lenI;}
25  inline int lenJ() const {return _lenJ;}
26 
27 private:
28 
29  // Lengths of array in HiMain2 common
30  static const int _lenI = 300;
31  static const int _lenJ = 15;
32 
33  struct HISTRNG;
34  friend struct HISTRNG;
35 
36  struct HISTRNG
37  {
38  int nfp [_lenJ][_lenI];
39  float pp [_lenJ][_lenI];
40  int nft [_lenJ][_lenI];
41  float pt [_lenJ][_lenI];
42  };
43 
44  int _dummy;
45  float _realdummy;
46 
47  static HISTRNG* _histrng;
48 };
49 
50 // set pointer to zero at start
52 
53 inline void
55 { if (!_histrng) _histrng = static_cast<HISTRNG*>(histrng_address_()); }
56 
57 // Constructor
58 inline
60  : _dummy (-999),
61  _realdummy (-999.)
62 {}
63 
64 // Destructor
65 inline
67 {}
68 
69 inline int&
70 HiStrng::nfp (int i, int j)
71 {
72  init(); // check COMMON is initialized
73  if( i < 1 || i > lenI() ||
74  j < 1 || j > lenJ() ) return _dummy;
75 
76  return _histrng->nfp[j-1][i-1];
77 }
78 
79 inline float&
80 HiStrng::pp (int i, int j)
81 {
82  init(); // check COMMON is initialized
83  if( i < 1 || i > lenI() ||
84  j < 1 || j > lenJ() ) return _realdummy;
85 
86  return _histrng->pp[j-1][i-1];
87 }
88 
89 inline int&
90 HiStrng::nft (int i, int j)
91 {
92  init(); // check COMMON is initialized
93  if( i < 1 || i > lenI() ||
94  j < 1 || j > lenJ() ) return _dummy;
95 
96  return _histrng->nft[j-1][i-1];
97 }
98 
99 inline float&
100 HiStrng::pt (int i, int j)
101 {
102  init(); // check COMMON is initialized
103  if( i < 1 || i > lenI() ||
104  j < 1 || j > lenJ() ) return _realdummy;
105 
106  return _histrng->pt[j-1][i-1];
107 }
108 
109 #endif