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 317 of file L1TopoDataTypes.h.

317  {
318  return d*=factor;
319  }

◆ 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 285 of file L1TopoDataTypes.h.

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

◆ 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 321 of file L1TopoDataTypes.h.

321  {
322  return d*=factor;
323  }

◆ 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 267 of file L1TopoDataTypes.h.

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

◆ 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 275 of file L1TopoDataTypes.h.

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

◆ 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 271 of file L1TopoDataTypes.h.

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

◆ 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 279 of file L1TopoDataTypes.h.

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

◆ 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 228 of file L1TopoDataTypes.h.

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

◆ 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 251 of file L1TopoDataTypes.h.

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

◆ 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 259 of file L1TopoDataTypes.h.

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

◆ 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 255 of file L1TopoDataTypes.h.

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

◆ 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 263 of file L1TopoDataTypes.h.

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

◆ 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 240 of file L1TopoDataTypes.h.

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

◆ 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
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
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:122
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
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:256
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
CaloSwCorrectionsToPool.ll
ll
Definition: CaloSwCorrectionsToPool.py:48
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:157
DeMoScan.index
string index
Definition: DeMoScan.py:362
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