ATLAS Offline Software
Classes | Typedefs | Functions
TSU Namespace Reference

Classes

struct  Expo
 
struct  Hyperbolic
 
struct  Kinematics
 
class  L1TopoDataTypes
 
struct  Trigo
 

Typedefs

typedef unsigned long long T
 

Functions

int toTopoInteger (float value, unsigned int resolution)
 
unsigned int toTopoPhi (float phi)
 
int toTopoEta (float eta)
 
int toSigned (unsigned bits, unsigned length)
 
int toSigned (const std::string &bits)
 
T convert (const unsigned long long &v, const unsigned &in_p, const unsigned int &in_f, const unsigned int &out_p, const unsigned int &out_f)
 
T complement (const T &v, const unsigned int &p)
 
std::string to_binary (T value, const unsigned int &p)
 
float to_float (const T &va, const unsigned int &p, const unsigned int &f)
 
template<unsigned P1, unsigned F1, unsigned P2, unsigned F2>
L1TopoDataTypes<((P1-F1) >P2-F2) ?(P1-F1) :(P2-F2))+((F1 > F2) ? F1 :F2),(F1 > F2) ? F1 :F2 > operator+ (const L1TopoDataTypes< P1, F1 > &lhs, const L1TopoDataTypes< P2, F2 > &rhs)
 
template<unsigned P1, unsigned F1, unsigned P2, unsigned F2>
L1TopoDataTypes<((P1-F1) >P2-F2) ?(P1-F1) :(P2-F2))+((F1 > F2) ? F1 :F2),(F1 > F2) ? F1 :F2 > operator- (const L1TopoDataTypes< P1, F1 > lhs, const L1TopoDataTypes< P2, F2 > rhs)
 
template<unsigned P1, unsigned F1>
L1TopoDataTypes< P1+1, F1 > operator- (const double &lhs, const L1TopoDataTypes< P1, F1 > &rhs)
 
template<unsigned P1, unsigned F1>
L1TopoDataTypes< P1+1, F1 > operator- (const L1TopoDataTypes< P1, F1 > &lhs, const double &rhs)
 
template<unsigned P1, unsigned F1>
L1TopoDataTypes< P1+1, F1 > operator- (const int &lhs, const L1TopoDataTypes< P1, F1 > &rhs)
 
template<unsigned P1, unsigned F1>
L1TopoDataTypes< P1+1, F1 > operator- (const L1TopoDataTypes< P1, F1 > &lhs, const int &rhs)
 
template<unsigned P1, unsigned F1>
L1TopoDataTypes< P1+1, F1 > operator+ (const double &lhs, const L1TopoDataTypes< P1, F1 > &rhs)
 
template<unsigned P1, unsigned F1>
L1TopoDataTypes< P1+1, F1 > operator+ (const L1TopoDataTypes< P1, F1 > &lhs, const double &rhs)
 
template<unsigned P1, unsigned F1>
L1TopoDataTypes< P1+1, F1 > operator+ (const int &lhs, const L1TopoDataTypes< P1, F1 > &rhs)
 
template<unsigned P1, unsigned F1>
L1TopoDataTypes< P1+1, F1 > operator+ (const L1TopoDataTypes< P1, F1 > &lhs, const int &rhs)
 
template<unsigned P1, unsigned F1, unsigned P2, unsigned F2>
L1TopoDataTypes<(P1+P2-1 > MAXBITS) ? MAXBITS :P1+P2-1,(P1+P2-1 > MAXBITS) ?(F2 >F1 ? F2 -((P1+P2-1) - MAXBITS) :F1 -((P1+P2-1) - MAXBITS)) :((F1 > F2) ? F1 :F2)> operator* (const L1TopoDataTypes< P1, F1 > lhs, const L1TopoDataTypes< P2, F2 > rhs)
 
template<unsigned P, unsigned FF>
TSU::L1TopoDataTypes< P, FF > operator* (const int &factor, TSU::L1TopoDataTypes< P, FF > d)
 
template<unsigned P, unsigned FF>
TSU::L1TopoDataTypes< P, FF > operator* (TSU::L1TopoDataTypes< P, FF > d, const int &factor)
 

Typedef Documentation

◆ T

typedef unsigned long long TSU::T

Definition at line 35 of file L1TopoDataTypes.h.

Function Documentation

◆ complement()

TSU::T TSU::complement ( const T v,
const unsigned int &  p 
)

Definition at line 18 of file L1TopoDataTypes.cxx.

18  {
19  T res=0;
20  for(unsigned int j=0;j<p;++j){
21  res += v & (1ull << j) ? 0 : (1ull << j);
22  }
23  res += 1;
24  return res;
25 }

◆ convert()

T TSU::convert ( const unsigned long long &  v,
const unsigned &  in_p,
const unsigned int &  in_f,
const unsigned int &  out_p,
const unsigned int &  out_f 
)

◆ operator*() [1/3]

template<unsigned P, unsigned FF>
TSU::L1TopoDataTypes<P,FF> TSU::operator* ( const int &  factor,
TSU::L1TopoDataTypes< P, FF >  d 
)

Definition at line 316 of file L1TopoDataTypes.h.

316  {
317  return d*=factor;
318  }

◆ operator*() [2/3]

template<unsigned P1, unsigned F1, unsigned P2, unsigned F2>
L1TopoDataTypes<(P1+P2-1 > MAXBITS) ? MAXBITS : P1+P2-1, (P1+P2-1 > MAXBITS) ? (F2>F1 ? F2 - ((P1+P2-1) - MAXBITS) : F1 - ((P1+P2-1) - MAXBITS)) : ((F1 > F2) ? F1 : F2)> TSU::operator* ( const L1TopoDataTypes< P1, F1 >  lhs,
const L1TopoDataTypes< P2, F2 >  rhs 
)

Definition at line 284 of file L1TopoDataTypes.h.

284  : P1+P2-1, (P1+P2-1 > MAXBITS) ? (F2>F1 ? F2 - ((P1+P2-1) - MAXBITS) : F1 - ((P1+P2-1) - MAXBITS)) : ((F1 > F2) ? F1 : F2)> operator*(const L1TopoDataTypes<P1,F1> lhs, const L1TopoDataTypes<P2,F2> rhs){
285  const unsigned int frac = (P1+P2-1 > MAXBITS) ? (F2>F1 ? F2 - ((P1+P2-1) - MAXBITS) : F1 - ((P1+P2-1) - MAXBITS)) : ((F1 > F2) ? F1 : F2);
286  const unsigned int digit = ((P1+P2-1 > MAXBITS) ? (MAXBITS - frac) : (P1+P2-1 - frac)) - 1;
287  const unsigned int prec = frac + digit + 1;
288  T lhsconvert = lhs.m_tvalue;
289  T rhsconvert = rhs.m_tvalue;
290  // check if either value is negative and work with the absolute value
291  if((lhs.m_tvalue >> (P1-1ull)) & 1ull){
292  lhsconvert = complement(lhsconvert,P1);
293  }
294  if((rhs.m_tvalue >> (P2-1ull)) & 1ull){
295  rhsconvert = complement(rhsconvert,P2);
296  }
297  // map numbers into Q1+digit.frac
298  T lhsconvint = convert(lhsconvert,P1,F1,P1-F1,0);
299  T rhsconvint = convert(rhsconvert,P2,F2,P2-F2,0);
300  T lhsconvfrac = convert(lhsconvert,P1,F1,F1+1,F1);
301  T rhsconvfrac = convert(rhsconvert,P2,F2,F2+1,F2);
302  T prod_int = lhsconvint*rhsconvint; // PREC = P1-F1+P2-F2-1, F = 0
303  T prod_frac = lhsconvfrac*rhsconvfrac; // PREC = F1 + F2 + 1, F = F1 + F2
304  T prod_mix1 = lhsconvint*rhsconvfrac; // PREC = P1 - F1 + F2, F = F2
305  T prod_mix2 = lhsconvfrac*rhsconvint; // PREC = P2 - F2 + F1, F = F1
306  L1TopoDataTypes<prec,frac> result(prod_int<<frac);
307  result += (prod_frac>>(F1+F2-frac));
308  result += (prod_mix1>>((F2>frac ? F2 - frac : 0)));
309  result += (prod_mix2>>((F1>frac ? F1 - frac : 0)));
310  if(!(((lhs.m_tvalue >> (P1-1ull)) & 1ull) ^ ((rhs.m_tvalue >> (P2-1ull)) & 1ull))){
311  return result;
312  } else
313  return -result;
314  }

◆ operator*() [3/3]

template<unsigned P, unsigned FF>
TSU::L1TopoDataTypes<P,FF> TSU::operator* ( TSU::L1TopoDataTypes< P, FF >  d,
const int &  factor 
)

Definition at line 320 of file L1TopoDataTypes.h.

320  {
321  return d*=factor;
322  }

◆ operator+() [1/5]

template<unsigned P1, unsigned F1>
L1TopoDataTypes<P1+1,F1> TSU::operator+ ( const double &  lhs,
const L1TopoDataTypes< P1, F1 > &  rhs 
)

Definition at line 266 of file L1TopoDataTypes.h.

266  {
267  return L1TopoDataTypes<P1+1,F1>(lhs + rhs.to_float());
268  }

◆ operator+() [2/5]

template<unsigned P1, unsigned F1>
L1TopoDataTypes<P1+1,F1> TSU::operator+ ( const int &  lhs,
const L1TopoDataTypes< P1, F1 > &  rhs 
)

Definition at line 274 of file L1TopoDataTypes.h.

274  {
275  return L1TopoDataTypes<P1+1,F1>(lhs + rhs.to_float());
276  }

◆ operator+() [3/5]

template<unsigned P1, unsigned F1>
L1TopoDataTypes<P1+1,F1> TSU::operator+ ( const L1TopoDataTypes< P1, F1 > &  lhs,
const double &  rhs 
)

Definition at line 270 of file L1TopoDataTypes.h.

270  {
271  return L1TopoDataTypes<P1+1,F1>(lhs.to_float() + rhs);
272  }

◆ operator+() [4/5]

template<unsigned P1, unsigned F1>
L1TopoDataTypes<P1+1,F1> TSU::operator+ ( const L1TopoDataTypes< P1, F1 > &  lhs,
const int &  rhs 
)

Definition at line 278 of file L1TopoDataTypes.h.

278  {
279  return L1TopoDataTypes<P1+1,F1>(lhs.to_float() + rhs);
280  }

◆ operator+() [5/5]

template<unsigned P1, unsigned F1, unsigned P2, unsigned F2>
L1TopoDataTypes<((P1-F1) >P2-F2) ? (P1-F1) : (P2-F2)) + ((F1 > F2) ? F1 : F2), (F1 > F2) ? F1 : F2> TSU::operator+ ( const L1TopoDataTypes< P1, F1 > &  lhs,
const L1TopoDataTypes< P2, F2 > &  rhs 
)

Definition at line 227 of file L1TopoDataTypes.h.

227  : (P2-F2)) + ((F1 > F2) ? F1 : F2), (F1 > F2) ? F1 : F2> operator+(const L1TopoDataTypes<P1,F1>& lhs, const L1TopoDataTypes<P2,F2>& rhs){
228  const unsigned int frac = (F1 > F2) ? F1 : F2;
229  const unsigned int digit = ((P1-F1) > (P2-F2)) ? (P1-F1) - 1 : (P2-F2) - 1;
230  const unsigned int prec = frac + digit + 1;
231  T lhsconvert = convert(lhs.m_tvalue,P1,F1,prec,frac);
232  T rhsconvert = convert(rhs.m_tvalue,P2,F2,prec,frac);
233  L1TopoDataTypes<prec,frac> res(lhsconvert+rhsconvert);
234 
235  return res;
236  }

◆ operator-() [1/5]

template<unsigned P1, unsigned F1>
L1TopoDataTypes<P1+1,F1> TSU::operator- ( const double &  lhs,
const L1TopoDataTypes< P1, F1 > &  rhs 
)

Definition at line 250 of file L1TopoDataTypes.h.

250  {
251  return L1TopoDataTypes<P1+1,F1>(lhs - rhs.to_float());
252  }

◆ operator-() [2/5]

template<unsigned P1, unsigned F1>
L1TopoDataTypes<P1+1,F1> TSU::operator- ( const int &  lhs,
const L1TopoDataTypes< P1, F1 > &  rhs 
)

Definition at line 258 of file L1TopoDataTypes.h.

258  {
259  return L1TopoDataTypes<P1+1,F1>(lhs - rhs.to_float());
260  }

◆ operator-() [3/5]

template<unsigned P1, unsigned F1>
L1TopoDataTypes<P1+1,F1> TSU::operator- ( const L1TopoDataTypes< P1, F1 > &  lhs,
const double &  rhs 
)

Definition at line 254 of file L1TopoDataTypes.h.

254  {
255  return L1TopoDataTypes<P1+1,F1>(lhs.to_float() - rhs);
256  }

◆ operator-() [4/5]

template<unsigned P1, unsigned F1>
L1TopoDataTypes<P1+1,F1> TSU::operator- ( const L1TopoDataTypes< P1, F1 > &  lhs,
const int &  rhs 
)

Definition at line 262 of file L1TopoDataTypes.h.

262  {
263  return L1TopoDataTypes<P1+1,F1>(lhs.to_float() - rhs);
264  }

◆ operator-() [5/5]

template<unsigned P1, unsigned F1, unsigned P2, unsigned F2>
L1TopoDataTypes<((P1-F1) >P2-F2) ? (P1-F1) : (P2-F2)) + ((F1 > F2) ? F1 : F2), (F1 > F2) ? F1 : F2> TSU::operator- ( const L1TopoDataTypes< P1, F1 >  lhs,
const L1TopoDataTypes< P2, F2 >  rhs 
)

Definition at line 239 of file L1TopoDataTypes.h.

239  : (P2-F2)) + ((F1 > F2) ? F1 : F2), (F1 > F2) ? F1 : F2> operator-(const L1TopoDataTypes<P1,F1> lhs, const L1TopoDataTypes<P2,F2> rhs){
240  const unsigned int frac = (F1 > F2) ? F1 : F2;
241  const unsigned int digit = ((P1-F1) > (P2-F2)) ? (P1-F1) - 1 : (P2-F2) - 1;
242  const unsigned int prec = frac + digit + 1;
243  T lhsconvert = convert(lhs.m_tvalue,P1,F1,prec,frac);
244  T rhsconvert = convert(rhs.m_tvalue,P2,F2,prec,frac);
245  L1TopoDataTypes<prec,frac> res(lhsconvert+complement(rhsconvert,prec));
246 
247  return res;
248  }

◆ to_binary()

std::string TSU::to_binary ( T  value,
const unsigned int &  p 
)

Definition at line 42 of file L1TopoDataTypes.cxx.

42  {
43  std::string pat(p,'0');
44  unsigned int idx = p-1;
45  while(b){
46  pat[idx] = (b & 1ull) ? '1' : '0';
47  b = b >> 1ull;
48  --idx;
49  }
50  return pat;
51 }

◆ to_float()

float TSU::to_float ( const T va,
const unsigned int &  p,
const unsigned int &  f 
)

Definition at line 53 of file L1TopoDataTypes.cxx.

53  {
54  // Find sign
55  float res = ((value>>(m-1ull))&1ull) ? -(1ll<<(m-n)) : 0.;
56  // Get integer part
57  res += (value>>n)&((1ull<<(m-n))-1ull) ? float((value>>n)&((1ull<<(m-n))-1ull)) : 0;
58  // Do the fractional part
59  for(unsigned int j=0;j<n;++j){
60  res += (value & (1ull << (n-1ull-j))) ? 1./(2ull<<(j)) : 0;
61  }
62  return res;
63 }

◆ toSigned() [1/2]

int TSU::toSigned ( const std::string &  bits)

Definition at line 40 of file Conversions.cxx.

40  {
41  return TSU::toSigned(std::stoi(bits, nullptr, 2), bits.length());
42 }

◆ toSigned() [2/2]

int TSU::toSigned ( unsigned  bits,
unsigned  length 
)

Definition at line 32 of file Conversions.cxx.

32  {
33  if ( ((bits >> (length-1)) & 1) == 0) { //sign bit not set
34  return bits & ((1<<length)-1);
35  }
36  //sign bit set, convert assuming twos complement
37  return (bits & ((1<<length)-1)) - (1<<length);
38 }

◆ toTopoEta()

int TSU::toTopoEta ( float  eta)

Definition at line 27 of file Conversions.cxx.

27  {
28  return toTopoInteger(eta, TSU::etaIntegerResolution);
29 }

◆ toTopoInteger()

int TSU::toTopoInteger ( float  value,
unsigned int  resolution 
)

Definition at line 7 of file Conversions.cxx.

7  {
8  float tmp = value*resolution;
9  float index;
10  if ( (abs(tmp)-0.5)/2. == std::round((abs(tmp)-0.5)/2.) ) {
11  if ( tmp>0 ) { index = std::floor(tmp); }
12  else { index = std::ceil(tmp); }
13  } else {
14  index = std::round(tmp);
15  }
16 
17  return static_cast<int>(index);
18 }

◆ toTopoPhi()

unsigned int TSU::toTopoPhi ( float  phi)

Definition at line 20 of file Conversions.cxx.

20  {
21  if (phi < 0) { phi += 2*M_PI; } //Convert to [0,2pi) range so phi can eventually be treated as unsigned
22  phi *= TSU::phiRescaleFactor;
23  int phiInt = toTopoInteger(phi, TSU::phiIntegerResolution) % 128;
24  return static_cast<unsigned int>(phiInt);
25 }
get_generator_info.result
result
Definition: get_generator_info.py:21
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
detail::ll
long long ll
Definition: PrimitiveHelpers.h:46
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
TSU::toSigned
int toSigned(unsigned bits, unsigned length)
Definition: Conversions.cxx:32
index
Definition: index.py:1
hist_file_dump.d
d
Definition: hist_file_dump.py:137
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
M_PI
#define M_PI
Definition: ActiveFraction.h:11
athena.value
value
Definition: athena.py:124
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
Dedxcorrection::resolution
double resolution[nGasTypes][nParametersResolution]
Definition: TRT_ToT_Corrections.h:46
MAXBITS
#define MAXBITS
Definition: L1TopoDataTypes.h:19
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TSU::toTopoInteger
int toTopoInteger(float value, unsigned int resolution)
Definition: Conversions.cxx:7
beamspotman.n
n
Definition: beamspotman.py:731
checkxAOD.frac
frac
Definition: Tools/PyUtils/bin/checkxAOD.py:259
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
dso-stats.pat
pat
Definition: dso-stats.py:39
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
python.PyAthena.v
v
Definition: PyAthena.py:154
DeMoScan.index
string index
Definition: DeMoScan.py:364
TSU::convert
T convert(const unsigned long long &v, const unsigned &in_p, const unsigned int &in_f, const unsigned int &out_p, const unsigned int &out_f)
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TSU::complement
T complement(const T &v, const unsigned int &p)
Definition: L1TopoDataTypes.cxx:18
jobOptions.prec
prec
Definition: jobOptions.Superchic_UPC_yyMuMu.py:20
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
readCCLHist.float
float
Definition: readCCLHist.py:83
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
detail::ull
unsigned long long ull
Definition: PrimitiveHelpers.h:44