ATLAS Offline Software
Loading...
Searching...
No Matches
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)
bool isAmbiguousAt (TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)
bool isAmbiguousTruncation (TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)
bool isAmbiguousAnywhere (TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)
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)

Variables

static constexpr float phiRescaleFactor = 3.2/M_PI
static constexpr unsigned int phiIntegerResolution = 20
static constexpr unsigned int etaIntegerResolution = 40

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}
std::pair< std::vector< unsigned int >, bool > res
unsigned long long T

◆ 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 )

◆ isAmbiguousAnywhere()

bool TSU::isAmbiguousAnywhere ( TCS::TOBArray const * tobs,
size_t pos,
unsigned minEt = 0 )

Definition at line 37 of file Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Helpers.cxx.

37 {
38 // checks if anywhere in a sorted list of TOBs there is a consecutive
39 // pair of TOBs for which the purely ET based sorting is ambiguous.
40 // An ambiguity is also indicated if the list is already flagged as
41 // being ambiguous (due to an earlier truncation with the last TOB
42 // in the list having the same ET as the first dropped TOB) and all
43 // elements of the presented list are to be used as indicated by 'nMax'
44 // ambiguities due to TOBs with ET <= minEt are ignored
45
46 // forward the ambiguity flag if the list has been truncated upstream
47 // such that it has the same (or smaller) length as we would trim it
48 // down to and thereby flagged as being ambiguous (for its last element)
49 if ((*list).size() <= nMax && ( (list->size() > 0) && ( (*(--list->end()))->Et() > minEt ) ) && (*list).ambiguityFlag()) {
50 return true;
51 }
52 // comparing each TOB with the subsequent one
53 if ((*list).size() < 1 || nMax < 1) { return false; }
54 for (size_t i=0; i < std::min((*list).size(), nMax) - 1; ++i) {
55 if (TSU::isAmbiguousAt(list, i, minEt)) {
56 return true;
57 }
58 }
59 return false;
60}
bool isAmbiguousAt(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)

◆ isAmbiguousAt()

bool TSU::isAmbiguousAt ( TCS::TOBArray const * tobs,
size_t pos,
unsigned minEt = 0 )

Definition at line 9 of file Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Helpers.cxx.

9 {
10 // checks if the sorting of two TOBs at positions 'pos' and 'pos+1'
11 // is ambiguous, i.e., if they have the same ET values
12 // ambiguities due to TOBs with ET <= minEt are ignored
13
14 // if there is no other TOB after the one in question
15 // then there is no ambiguity (or we cannot tell anymore
16 // in case the array was previously truncated already
17 if (tobs->size() <= pos+1) { return false; }
18 if ((*tobs)[pos].Et() <= minEt) { return false; }
19 if ((*tobs)[pos].Et() == (*tobs)[pos+1].Et()) { return true; }
20 return false;
21}

◆ isAmbiguousTruncation()

bool TSU::isAmbiguousTruncation ( TCS::TOBArray const * tobs,
size_t pos,
unsigned minEt = 0 )

Definition at line 23 of file Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Helpers.cxx.

23 {
24 // checks if the truncation of the given, sorted list after nMax elements
25 // results in an ambiguous set of TOBs due to the last element of the list
26 // having the same ET value as the first one to be dropped
27 // also accounts for ambiguity flags previously set on the list
28 // (due to earlier truncations) if the value of nMax implies that all list
29 // elements are to be used/retained
30 // ambiguities due to TOBs with ET <= minEt are ignored
31 if ((*list).size() <= nMax && ( (list->size() > 0) && ( (*(--list->end()))->Et() > minEt ) ) && (*list).ambiguityFlag()) {
32 return true;
33 }
34 return TSU::isAmbiguousAt(list, nMax-1);
35}

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

298 {
299 return d*=factor;
300 }

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

266 : 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){
267 constexpr unsigned int frac = (P1+P2-1 > MAXBITS) ? (F2>F1 ? F2 - ((P1+P2-1) - MAXBITS) : F1 - ((P1+P2-1) - MAXBITS)) : ((F1 > F2) ? F1 : F2);
268 constexpr unsigned int digit = ((P1+P2-1 > MAXBITS) ? (MAXBITS - frac) : (P1+P2-1 - frac)) - 1;
269 constexpr unsigned int prec = frac + digit + 1;
270 T lhsconvert = lhs.m_tvalue;
271 T rhsconvert = rhs.m_tvalue;
272 // check if either value is negative and work with the absolute value
273 if((lhs.m_tvalue >> (P1-1ull)) & 1ull){
274 lhsconvert = complement(lhsconvert,P1);
275 }
276 if((rhs.m_tvalue >> (P2-1ull)) & 1ull){
277 rhsconvert = complement(rhsconvert,P2);
278 }
279 // map numbers into Q1+digit.frac
280 T lhsconvint = convert(lhsconvert,P1,F1,P1-F1,0);
281 T rhsconvint = convert(rhsconvert,P2,F2,P2-F2,0);
282 T lhsconvfrac = convert(lhsconvert,P1,F1,F1+1,F1);
283 T rhsconvfrac = convert(rhsconvert,P2,F2,F2+1,F2);
284 T prod_int = lhsconvint*rhsconvint; // PREC = P1-F1+P2-F2-1, F = 0
285 T prod_frac = lhsconvfrac*rhsconvfrac; // PREC = F1 + F2 + 1, F = F1 + F2
286 T prod_mix1 = lhsconvint*rhsconvfrac; // PREC = P1 - F1 + F2, F = F2
287 T prod_mix2 = lhsconvfrac*rhsconvint; // PREC = P2 - F2 + F1, F = F1
288 L1TopoDataTypes<prec,frac> result(prod_int<<frac);
289 result += (prod_frac>>(F1+F2-frac));
290 result += (prod_mix1>>((F2>frac ? F2 - frac : 0)));
291 result += (prod_mix2>>((F1>frac ? F1 - frac : 0)));
292 if(!(((lhs.m_tvalue >> (P1-1ull)) & 1ull) ^ ((rhs.m_tvalue >> (P2-1ull)) & 1ull))){
293 return result;
294 } else
295 return -result;
296 }
#define MAXBITS
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)

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

302 {
303 return d*=factor;
304 }

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

248 {
249 return L1TopoDataTypes<P1+1,F1>(lhs + static_cast<float>(rhs));
250 }

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

256 {
257 return L1TopoDataTypes<P1+1,F1>(lhs + static_cast<float>(rhs));
258 }

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

252 {
253 return L1TopoDataTypes<P1+1,F1>(static_cast<float>(lhs) + rhs);
254 }

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

260 {
261 return L1TopoDataTypes<P1+1,F1>(static_cast<float>(lhs) + rhs);
262 }

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

209 : (P2-F2)) + ((F1 > F2) ? F1 : F2), (F1 > F2) ? F1 : F2> operator+(const L1TopoDataTypes<P1,F1>& lhs, const L1TopoDataTypes<P2,F2>& rhs){
210 constexpr unsigned int frac = (F1 > F2) ? F1 : F2;
211 constexpr unsigned int digit = ((P1-F1) > (P2-F2)) ? (P1-F1) - 1 : (P2-F2) - 1;
212 constexpr unsigned int prec = frac + digit + 1;
213 T lhsconvert = convert(lhs.m_tvalue,P1,F1,prec,frac);
214 T rhsconvert = convert(rhs.m_tvalue,P2,F2,prec,frac);
215 L1TopoDataTypes<prec,frac> res(lhsconvert+rhsconvert);
216
217 return res;
218 }

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

232 {
233 return L1TopoDataTypes<P1+1,F1>(lhs - static_cast<float>(rhs));
234 }

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

240 {
241 return L1TopoDataTypes<P1+1,F1>(lhs - static_cast<float>(rhs));
242 }

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

236 {
237 return L1TopoDataTypes<P1+1,F1>(static_cast<float>(lhs) - rhs);
238 }

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

244 {
245 return L1TopoDataTypes<P1+1,F1>(static_cast<float>(lhs) - rhs);
246 }

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

221 : (P2-F2)) + ((F1 > F2) ? F1 : F2), (F1 > F2) ? F1 : F2> operator-(const L1TopoDataTypes<P1,F1>& lhs, const L1TopoDataTypes<P2,F2>& rhs){
222 constexpr unsigned int frac = (F1 > F2) ? F1 : F2;
223 constexpr unsigned int digit = ((P1-F1) > (P2-F2)) ? (P1-F1) - 1 : (P2-F2) - 1;
224 constexpr unsigned int prec = frac + digit + 1;
225 T lhsconvert = convert(lhs.m_tvalue,P1,F1,prec,frac);
226 T rhsconvert = convert(rhs.m_tvalue,P2,F2,prec,frac);
227 L1TopoDataTypes<prec,frac> res(lhsconvert+complement(rhsconvert,prec));
228
229 return res;
230 }

◆ 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}
int toSigned(unsigned bits, unsigned length)

◆ 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}
double length(const pvec &v)

◆ toTopoEta()

int TSU::toTopoEta ( float eta)

Definition at line 27 of file Conversions.cxx.

27 {
29}
Scalar eta() const
pseudorapidity method
int toTopoInteger(float value, unsigned int resolution)
static constexpr unsigned int etaIntegerResolution
Definition Conversions.h:15

◆ 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}
str index
Definition DeMoScan.py:362
Definition index.py:1

◆ 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
23 int phiInt = toTopoInteger(phi, TSU::phiIntegerResolution) % 128;
24 return static_cast<unsigned int>(phiInt);
25}
#define M_PI
Scalar phi() const
phi method
static constexpr unsigned int phiIntegerResolution
Definition Conversions.h:14
static constexpr float phiRescaleFactor
Definition Conversions.h:13

Variable Documentation

◆ etaIntegerResolution

unsigned int TSU::etaIntegerResolution = 40
staticconstexpr

Definition at line 15 of file Conversions.h.

◆ phiIntegerResolution

unsigned int TSU::phiIntegerResolution = 20
staticconstexpr

Definition at line 14 of file Conversions.h.

◆ phiRescaleFactor

float TSU::phiRescaleFactor = 3.2/M_PI
staticconstexpr

Definition at line 13 of file Conversions.h.