ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TrigConf::L1PSNumber Class Reference

#include <L1PSNumber.h>

Collaboration diagram for TrigConf::L1PSNumber:

Public Member Functions

 L1PSNumber ()
 
 L1PSNumber (const float ps)
 Constructor from float. More...
 
 L1PSNumber (const int64_t ps)
 Constructor, with 64 bit integer. More...
 
 L1PSNumber (const int ps)
 Simple constructor, sets only int. More...
 
 L1PSNumber (const int nn, const unsigned int mm, unsigned const int dd, const int ss)
 Constructor from N,M,D and S. More...
 
std::string write ()
 Writes nicely the ps value. More...
 
unsigned int getN () const
 
unsigned int getM () const
 
unsigned int getD () const
 
int getSign () const
 
float getFloatPrescale () const
 
int64_t getInt64 () const
 
int getInt32 () const
 

Static Public Member Functions

static int64_t decodeFloat (const float psF)
 Calculates the NMD combination nearest to psF. More...
 
static int64_t encodeNMD (const int nn, const unsigned int mm, const unsigned int dd)
 Returns INT64_T prescale number with the correct sign as it is stored in DB. More...
 

Private Member Functions

bool validate (const int nn, const unsigned int mm, const unsigned int dd, const int ss)
 Checks whether the m_n,m_m,m_d combination is valid, i.e. More...
 
void setInt64 (const int64_t tmpLong)
 Sets the N,M,D values from a Int64_t prescale value. More...
 

Static Private Member Functions

static int64_t makeLong (unsigned int n, unsigned int m, unsigned int d)
 Returns the POSITIVE int64_t of 3 ints. More...
 

Private Attributes

unsigned int m_n
 
unsigned int m_m
 
unsigned int m_d
 
int m_s
 
float m_psFloat
 
int64_t m_psLong
 

Static Private Attributes

static const uint32_t NMASK = 0x00FFFFFF
 
static const uint32_t MMASK = 0xF0000000
 
static const uint32_t DMASK = 0x0F000000
 
static const int MSHIFT = 28
 
static const int DSHIFT = 24
 
static const int s_auxLength = 79
 
static const unsigned int s_psAuxValues [79][2]
 Help array containing the allowed MD combinations (for N=1). More...
 

Detailed Description

Definition at line 33 of file L1PSNumber.h.

Constructor & Destructor Documentation

◆ L1PSNumber() [1/5]

TrigConf::L1PSNumber::L1PSNumber ( )

Definition at line 31 of file L1PSNumber.cxx.

31  {
32  m_n = 1;
33  m_m = 1;
34  m_d = 1;
35  m_s = -1;
36  m_psFloat = -1.0;
37  m_psLong = -1;
38  }

◆ L1PSNumber() [2/5]

TrigConf::L1PSNumber::L1PSNumber ( const float  ps)

Constructor from float.

Definition at line 83 of file L1PSNumber.cxx.

83  {
84  int64_t i64 = decodeFloat(ps);
85  setInt64(i64);
86  }

◆ L1PSNumber() [3/5]

TrigConf::L1PSNumber::L1PSNumber ( const int64_t  ps)

Constructor, with 64 bit integer.

Definition at line 64 of file L1PSNumber.cxx.

64  {
66  }

◆ L1PSNumber() [4/5]

TrigConf::L1PSNumber::L1PSNumber ( const int  ps)

Simple constructor, sets only int.

Definition at line 43 of file L1PSNumber.cxx.

43  {
44  if (ps >= 1) {
45  m_n = ps;
46  m_s = 1;
47  } else if (ps < 1 && ps>-1) {
48  //invalid ps, set to default -1
49  m_n = 1;
50  m_s = -1;
51  } else {
52  m_n = -ps;
53  m_s = -1;
54  }
55  m_m = 0;
56  m_d = 0;
57  m_psFloat = (float) m_n;
58  m_psLong = (int64_t) m_n;
59  }

◆ L1PSNumber() [5/5]

TrigConf::L1PSNumber::L1PSNumber ( const int  nn,
const unsigned int  mm,
unsigned const int  dd,
const int  ss = 1 
)

Constructor from N,M,D and S.

Definition at line 71 of file L1PSNumber.cxx.

72  {
73  if (validate(nn, mm, dd, ss)) {
75  } else {
76  m_psLong = -1;
77  }
78  }

Member Function Documentation

◆ decodeFloat()

int64_t TrigConf::L1PSNumber::decodeFloat ( const float  psF)
static

Calculates the NMD combination nearest to psF.

Returns the int64_t representation of NMD.

Definition at line 167 of file L1PSNumber.cxx.

167  {
168  int64_t ret = -1;
169  int tmpN = (int) psF;
170  float psOne = psF / (float) tmpN;
171  float diff = 10;
172  unsigned int mm = 0;
173  unsigned int dd = 0;
174  float tmpPS;
175  float tmpDiff;
176  // If the number is larger than 2^24 ret -1.
177  if (std::abs(tmpN) <= (int)NMASK) {
178  // if psF is Int, ret psF.
179  if (tmpN == psF) {
180  ret = (int64_t) psF;
181  } else {
182  // Check the nearest Combination of N,M & D.
183  for (int i = 0; i < s_auxLength; i++) {
184  unsigned int tmpM = s_psAuxValues[i][0];
185  unsigned int tmpD = s_psAuxValues[i][1];
186  tmpPS = (float) ((tmpM + tmpD + 1.0) / (tmpM + 1.0));
187  tmpDiff = fabs(tmpPS - psOne);
188  if (tmpPS * tmpN >= tmpN + 1) {
189  break;
190  }
191  if (tmpDiff < diff) {
192  diff = tmpDiff;
193  mm = tmpM;
194  dd = tmpD;
195  }
196  }
197  ret = L1PSNumber::encodeNMD(tmpN, mm, dd);
198  }
199  }
200  return ret;
201  }

◆ encodeNMD()

int64_t TrigConf::L1PSNumber::encodeNMD ( const int  nn,
const unsigned int  mm,
const unsigned int  dd 
)
static

Returns INT64_T prescale number with the correct sign as it is stored in DB.

Definition at line 207 of file L1PSNumber.cxx.

208  {
209  int64_t ret = -1;
210  unsigned int nTemp = 1;
211  int sTemp = 1;
212  if (nn < 0) {
213  nTemp = -nn;
214  sTemp = -1;
215  } else {
216  nTemp = nn;
217  sTemp = 1;
218  }
219  ret = L1PSNumber::makeLong(nTemp, mm, dd);
220  ret = sTemp*ret;
221  return ret;
222  }

◆ getD()

unsigned int TrigConf::L1PSNumber::getD ( ) const
inline

Definition at line 74 of file L1PSNumber.h.

74 { return m_d; };

◆ getFloatPrescale()

float TrigConf::L1PSNumber::getFloatPrescale ( ) const
inline

Definition at line 76 of file L1PSNumber.h.

76 { return m_psFloat; };

◆ getInt32()

int TrigConf::L1PSNumber::getInt32 ( ) const
inline

Definition at line 78 of file L1PSNumber.h.

78 { return m_n*m_s; };

◆ getInt64()

int64_t TrigConf::L1PSNumber::getInt64 ( ) const
inline

Definition at line 77 of file L1PSNumber.h.

77 { return m_psLong; };

◆ getM()

unsigned int TrigConf::L1PSNumber::getM ( ) const
inline

Definition at line 73 of file L1PSNumber.h.

73 { return m_m; };

◆ getN()

unsigned int TrigConf::L1PSNumber::getN ( ) const
inline

Definition at line 72 of file L1PSNumber.h.

72 { return m_n; };

◆ getSign()

int TrigConf::L1PSNumber::getSign ( ) const
inline

Definition at line 75 of file L1PSNumber.h.

75 { return m_s; };

◆ makeLong()

int64_t TrigConf::L1PSNumber::makeLong ( unsigned int  nn,
unsigned int  mm,
unsigned int  dd 
)
staticprivate

Returns the POSITIVE int64_t of 3 ints.

Takes care that no number is longer than it should.

Definition at line 228 of file L1PSNumber.cxx.

229  {
230  int64_t ret;
231  ret = (mm & 0xF);
232  ret = (ret << MSHIFT);
233  ret = (ret | ((dd & 0xF) << DSHIFT));
234  ret = (ret | (nn & NMASK));
235  return ret;
236  }

◆ setInt64()

void TrigConf::L1PSNumber::setInt64 ( const int64_t  prescaleBitArray)
private

Sets the N,M,D values from a Int64_t prescale value.

Parameters
prescaleArraythe prescale as a long.

Decodeonly if ps > 0. Else PS=1.

Definition at line 124 of file L1PSNumber.cxx.

124  {
125  unsigned int nTemp = 1;
126  unsigned int mTemp = 0;
127  unsigned int dTemp = 0;
128  int sTemp = -1;
129 
130  uint32_t psTemp = 1;
131  // m_psLong = -1;
132  // Take care of the sign.
133  if (prescaleBitArray < 0) {
134  sTemp = -1;
135  psTemp = (uint32_t) (-1 * prescaleBitArray);
136  } else {
137  sTemp = 1;
138  psTemp = (uint32_t) prescaleBitArray;
139  }
143  nTemp = psTemp&NMASK;
144  mTemp = ((psTemp & MMASK) >> MSHIFT);
145  dTemp = ((psTemp & DMASK) >> DSHIFT);
146  L1PSNumber::validate(nTemp, mTemp, dTemp, sTemp);
147  m_psLong = prescaleBitArray;
148  }

◆ validate()

bool TrigConf::L1PSNumber::validate ( const int  nn,
const unsigned int  mm,
const unsigned int  dd,
const int  ss = 1 
)
private

Checks whether the m_n,m_m,m_d combination is valid, i.e.

whether m_n >= 1 && 1 < (m_m+m_d+1)/(m_m+1) < 2. Sets N, M, D & m_psFloat.

Definition at line 93 of file L1PSNumber.cxx.

93  {
94  bool ret = false;
95  if (nn <= -1 || nn >= 1) {
96  if (nn < 0) {
97  m_n = -nn;
98  m_s = -1;
99  } else if (nn >= 1) {
100  m_n = nn;
101  m_s = ss;
102  }
103  m_m = mm;
104  m_d = dd;
105  m_psFloat = (float) m_s * m_n * (m_m + m_d + 1.0) / (m_m + 1.0);
106  ret = true;
107  } else {
108  m_n = 1;
109  m_s = -1;
110  m_m = 0;
111  m_d = 0;
112  m_psFloat = -1.0;
113  ret = false;
114  }
115  return ret;
116  }

◆ write()

std::string TrigConf::L1PSNumber::write ( )

Writes nicely the ps value.

Definition at line 153 of file L1PSNumber.cxx.

153  {
154  std::stringstream ss;
155  if (m_m == 0 && m_d == 0) {
156  ss << getInt32();
157  } else {
158  ss << m_psFloat;
159  }
160  return ss.str();
161  }

Member Data Documentation

◆ DMASK

const uint32_t TrigConf::L1PSNumber::DMASK = 0x0F000000
staticprivate

Definition at line 44 of file L1PSNumber.h.

◆ DSHIFT

const int TrigConf::L1PSNumber::DSHIFT = 24
staticprivate

Definition at line 46 of file L1PSNumber.h.

◆ m_d

unsigned int TrigConf::L1PSNumber::m_d
private

Definition at line 37 of file L1PSNumber.h.

◆ m_m

unsigned int TrigConf::L1PSNumber::m_m
private

Definition at line 36 of file L1PSNumber.h.

◆ m_n

unsigned int TrigConf::L1PSNumber::m_n
private

Definition at line 35 of file L1PSNumber.h.

◆ m_psFloat

float TrigConf::L1PSNumber::m_psFloat
private

Definition at line 39 of file L1PSNumber.h.

◆ m_psLong

int64_t TrigConf::L1PSNumber::m_psLong
private

Definition at line 40 of file L1PSNumber.h.

◆ m_s

int TrigConf::L1PSNumber::m_s
private

Definition at line 38 of file L1PSNumber.h.

◆ MMASK

const uint32_t TrigConf::L1PSNumber::MMASK = 0xF0000000
staticprivate

Definition at line 43 of file L1PSNumber.h.

◆ MSHIFT

const int TrigConf::L1PSNumber::MSHIFT = 28
staticprivate

Definition at line 45 of file L1PSNumber.h.

◆ NMASK

const uint32_t TrigConf::L1PSNumber::NMASK = 0x00FFFFFF
staticprivate

Definition at line 42 of file L1PSNumber.h.

◆ s_auxLength

const int TrigConf::L1PSNumber::s_auxLength = 79
staticprivate

Definition at line 55 of file L1PSNumber.h.

◆ s_psAuxValues

const unsigned int TrigConf::L1PSNumber::s_psAuxValues
staticprivate

Help array containing the allowed MD combinations (for N=1).

These will be iterated in L1PSNumber::decodeFloat() to find the best aproximation.

Definition at line 56 of file L1PSNumber.h.


The documentation for this class was generated from the following files:
TrigConf::L1PSNumber::s_auxLength
static const int s_auxLength
Definition: L1PSNumber.h:55
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
mc.diff
diff
Definition: mc.SFGenPy8_MuMu_DD.py:14
TrigConf::L1PSNumber::MMASK
static const uint32_t MMASK
Definition: L1PSNumber.h:43
TrigConf::L1PSNumber::s_psAuxValues
static const unsigned int s_psAuxValues[79][2]
Help array containing the allowed MD combinations (for N=1).
Definition: L1PSNumber.h:56
TrigConf::L1PSNumber::m_s
int m_s
Definition: L1PSNumber.h:38
TrigConf::L1PSNumber::setInt64
void setInt64(const int64_t tmpLong)
Sets the N,M,D values from a Int64_t prescale value.
Definition: L1PSNumber.cxx:124
TrigConf::L1PSNumber::m_psLong
int64_t m_psLong
Definition: L1PSNumber.h:40
TrigConf::L1PSNumber::m_m
unsigned int m_m
Definition: L1PSNumber.h:36
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigConf::L1PSNumber::m_psFloat
float m_psFloat
Definition: L1PSNumber.h:39
TrigConf::L1PSNumber::DMASK
static const uint32_t DMASK
Definition: L1PSNumber.h:44
TrigConf::L1PSNumber::m_n
unsigned int m_n
Definition: L1PSNumber.h:35
TrigConf::L1PSNumber::encodeNMD
static int64_t encodeNMD(const int nn, const unsigned int mm, const unsigned int dd)
Returns INT64_T prescale number with the correct sign as it is stored in DB.
Definition: L1PSNumber.cxx:207
library_scraper.dd
list dd
Definition: library_scraper.py:46
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
TrigConf::L1PSNumber::MSHIFT
static const int MSHIFT
Definition: L1PSNumber.h:45
TrigConf::L1PSNumber::m_d
unsigned int m_d
Definition: L1PSNumber.h:37
TrigConf::L1PSNumber::decodeFloat
static int64_t decodeFloat(const float psF)
Calculates the NMD combination nearest to psF.
Definition: L1PSNumber.cxx:167
TrigConf::L1PSNumber::NMASK
static const uint32_t NMASK
Definition: L1PSNumber.h:42
TrigConf::L1PSNumber::validate
bool validate(const int nn, const unsigned int mm, const unsigned int dd, const int ss)
Checks whether the m_n,m_m,m_d combination is valid, i.e.
Definition: L1PSNumber.cxx:93
TrigConf::L1PSNumber::makeLong
static int64_t makeLong(unsigned int n, unsigned int m, unsigned int d)
Returns the POSITIVE int64_t of 3 ints.
Definition: L1PSNumber.cxx:228
readCCLHist.float
float
Definition: readCCLHist.py:83
TrigConf::L1PSNumber::getInt32
int getInt32() const
Definition: L1PSNumber.h:78
TrigConf::L1PSNumber::DSHIFT
static const int DSHIFT
Definition: L1PSNumber.h:46