Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:16:38

0001 
0002 #ifndef HiStrng_h
0003 #define HiStrng_h
0004 
0005 extern "C" { void* histrng_address_(void); }
0006 /**
0007 @class HiStrng
0008 @brief       Class definition for HiStrng, which is used
0009       to modify the Hijing HISTRNG common.
0010 */
0011 class HiStrng {
0012 public:
0013     HiStrng();
0014     ~HiStrng();
0015     
0016     int&        nfp (int i, int j);
0017     float&      pp  (int i, int j);
0018     int&        nft (int i, int j);
0019     float&      pt  (int i, int j);
0020     
0021     void    init    (void);
0022 
0023     // return common array lengths
0024     inline int  lenI() const {return _lenI;}
0025     inline int  lenJ() const {return _lenJ;}
0026 
0027 private: 
0028 
0029     // Lengths of array in HiMain2 common
0030     static const int _lenI  = 300;
0031     static const int _lenJ  = 15;
0032 
0033     struct HISTRNG;
0034     friend struct HISTRNG;
0035 
0036     struct HISTRNG
0037     {
0038     int nfp [_lenJ][_lenI];
0039     float   pp  [_lenJ][_lenI];
0040     int nft [_lenJ][_lenI];
0041     float   pt  [_lenJ][_lenI];
0042     };
0043 
0044     int  _dummy;
0045     float  _realdummy;
0046 
0047     static HISTRNG* _histrng;
0048 };
0049 
0050 // set pointer to zero at start
0051 HiStrng::HISTRNG* HiStrng::_histrng =0;
0052 
0053 inline void
0054 HiStrng::init(void)
0055 { if (!_histrng) _histrng = static_cast<HISTRNG*>(histrng_address_()); }
0056 
0057 // Constructor
0058 inline
0059 HiStrng::HiStrng()
0060     : _dummy        (-999),
0061       _realdummy    (-999.)
0062 {}
0063 
0064 // Destructor
0065 inline
0066 HiStrng::~HiStrng()
0067 {}
0068 
0069 inline int&
0070 HiStrng::nfp    (int i, int j)
0071 {
0072     init(); // check COMMON is initialized
0073     if( i < 1 || i > lenI() ||
0074     j < 1 || j > lenJ() ) return _dummy;
0075 
0076     return _histrng->nfp[j-1][i-1];
0077 }
0078 
0079 inline float&
0080 HiStrng::pp (int i, int j)
0081 {
0082     init(); // check COMMON is initialized
0083     if( i < 1 || i > lenI() ||
0084     j < 1 || j > lenJ() ) return _realdummy;
0085 
0086     return _histrng->pp[j-1][i-1];
0087 }
0088 
0089 inline int&
0090 HiStrng::nft    (int i, int j)
0091 {
0092     init(); // check COMMON is initialized
0093     if( i < 1 || i > lenI() ||
0094     j < 1 || j > lenJ() ) return _dummy;
0095 
0096     return _histrng->nft[j-1][i-1];
0097 }
0098 
0099 inline float&
0100 HiStrng::pt (int i, int j)
0101 {
0102     init(); // check COMMON is initialized
0103     if( i < 1 || i > lenI() ||
0104     j < 1 || j > lenJ() ) return _realdummy;
0105 
0106     return _histrng->pt[j-1][i-1];
0107 }
0108 
0109 #endif