ATLAS Offline Software
Loading...
Searching...
No Matches
TSU::Kinematics Struct Reference

#include <Kinematics.h>

Collaboration diagram for TSU::Kinematics:

Static Public Member Functions

static unsigned int calcDeltaPhiBWLegacy (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcDeltaEtaBWLegacy (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcInvMassBWLegacy (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcTMassBWLegacy (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcDeltaR2BWLegacy (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static float calcCosLegacy (unsigned phi)
static float calcSinLegacy (unsigned phi)
static unsigned int calcDeltaPhiBW (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcDeltaEtaBW (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcInvMassBW (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcTMassBW (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcDeltaR2BW (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcXi1 (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2, unsigned ptShift, unsigned ptScale)
static unsigned int calcXi2 (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2, unsigned ptShift, unsigned ptScale)
static float calcCos (unsigned phi)
static float calcSin (unsigned phi)
static unsigned long quadraticSumBW (int i1, int i2)
 compute the sum in quadrature of two ints
static unsigned int calcDeltaPhiLegacy (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcDeltaEtaLegacy (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcDeltaR2Legacy (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcDeltaPhi (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcDeltaEta (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcInvMass (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcTMass (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
static unsigned int calcDeltaR2 (const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)

Detailed Description

Definition at line 18 of file Kinematics.h.

Member Function Documentation

◆ calcCos()

float TSU::Kinematics::calcCos ( unsigned phi)
static

Definition at line 199 of file Kinematics.cxx.

199 {
200 return static_cast<float>(TSU::L1TopoDataTypes<12,10>(TSU::Trigo::Cos.at(phi)));
201}
Scalar phi() const
phi method
static const std::vector< std::string > Cos
Definition Trigo.h:100

◆ calcCosLegacy()

float TSU::Kinematics::calcCosLegacy ( unsigned phi)
static

Definition at line 74 of file Kinematics.cxx.

74 {
75 return static_cast<float>(TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cosleg.at(phi)));
76}
static const std::vector< std::string > Cosleg
Definition Trigo.h:28

◆ calcDeltaEta()

unsigned int TSU::Kinematics::calcDeltaEta ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 239 of file Kinematics.cxx.

239 {
240 double deta = std::fabs( tob1->etaDouble() - tob2->etaDouble() );
241 return round( 40 * deta );
242}
double etaDouble() const
Definition GenericTOB.h:135
float round(const float toRound, const unsigned int decimals)
Definition Mdt.cxx:27

◆ calcDeltaEtaBW()

unsigned int TSU::Kinematics::calcDeltaEtaBW ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 92 of file Kinematics.cxx.

92 {
93 double deta = std::abs( tob1->eta() - tob2->eta() );
94 return deta;
95}
int eta() const
Definition GenericTOB.h:124

◆ calcDeltaEtaBWLegacy()

unsigned int TSU::Kinematics::calcDeltaEtaBWLegacy ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 29 of file Kinematics.cxx.

29 {
30 double deta = std::abs( tob1->eta() - tob2->eta() );
31 return deta;
32}

◆ calcDeltaEtaLegacy()

unsigned int TSU::Kinematics::calcDeltaEtaLegacy ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 217 of file Kinematics.cxx.

217 {
218 double deta = std::fabs( tob1->etaDouble() - tob2->etaDouble() );
219 return round( 10 * deta );
220}

◆ calcDeltaPhi()

unsigned int TSU::Kinematics::calcDeltaPhi ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 231 of file Kinematics.cxx.

231 {
232 double dphi = std::fabs( tob1->phiDouble() - tob2->phiDouble() );
233 if(dphi>M_PI)
234 dphi = 2*M_PI - dphi;
235
236 return round( 20 * dphi );
237}
#define M_PI
double phiDouble() const
Definition GenericTOB.h:136

◆ calcDeltaPhiBW()

unsigned int TSU::Kinematics::calcDeltaPhiBW ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 82 of file Kinematics.cxx.

82 {
83 int dphiB = std::abs( tob1->phi() - tob2->phi() );
84 if(dphiB>128)
85 dphiB = dphiB - 128;
86 if(dphiB>64)
87 dphiB = 128 - dphiB;
88
89 return dphiB ;
90}
int phi() const
Definition GenericTOB.h:125

◆ calcDeltaPhiBWLegacy()

unsigned int TSU::Kinematics::calcDeltaPhiBWLegacy ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 19 of file Kinematics.cxx.

19 {
20 int dphiB = std::abs( tob1->phi() - tob2->phi() );
21 if(dphiB>64)
22 dphiB = dphiB - 64;
23 if(dphiB>32)
24 dphiB = 64 - dphiB;
25
26 return dphiB ;
27}

◆ calcDeltaPhiLegacy()

unsigned int TSU::Kinematics::calcDeltaPhiLegacy ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 209 of file Kinematics.cxx.

209 {
210 double dphi = std::fabs( tob1->phiDouble() - tob2->phiDouble() );
211 if(dphi>M_PI)
212 dphi = 2*M_PI - dphi;
213
214 return round( 10 * dphi );
215}

◆ calcDeltaR2()

unsigned int TSU::Kinematics::calcDeltaR2 ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 266 of file Kinematics.cxx.

266 {
267 double deta = ( tob1->etaDouble() - tob2->etaDouble() );
268 double dphi = std::fabs( tob1->phiDouble() - tob2->phiDouble() );
269 if(dphi>M_PI)
270 dphi = 2*M_PI - dphi;
271
272 // Return (40*dR)^2 consistent with BW calculation
273 return round ( 40*40 * ((dphi)*(dphi) + (deta)*(deta) )) ;
274}

◆ calcDeltaR2BW()

unsigned int TSU::Kinematics::calcDeltaR2BW ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 131 of file Kinematics.cxx.

131 {
132 int detaB = std::abs( tob1->eta() - tob2->eta() );
133 int dphiB = std::abs( tob1->phi() - tob2->phi() );
134 if(dphiB>128) //Probably same error here as in DeltaPhiBW. Check
135 dphiB = dphiB - 128;
136 if(dphiB>64)
137 dphiB = 128 - dphiB;
138
139 // Use the same granularity for eta and phi (0.025) in dR calculation (need to multiply dphiB*2)
140 // Return (40*dR)^2
141 dphiB = 2*dphiB;
142 unsigned int bit_dr2 = dphiB*dphiB + detaB*detaB;
143 return bit_dr2;
144}

◆ calcDeltaR2BWLegacy()

unsigned int TSU::Kinematics::calcDeltaR2BWLegacy ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 62 of file Kinematics.cxx.

62 {
63 int detaB = std::abs( tob1->eta() - tob2->eta() );
64 int dphiB = std::abs( tob1->phi() - tob2->phi() );
65 if(dphiB>64) //Probably same error here as in DeltaPhiBW. Check
66 dphiB = dphiB - 64;
67 if(dphiB>32)
68 dphiB = 64 - dphiB;
69
70 unsigned int bit_dr2 = dphiB*dphiB + detaB*detaB;
71 return bit_dr2;
72}

◆ calcDeltaR2Legacy()

unsigned int TSU::Kinematics::calcDeltaR2Legacy ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 222 of file Kinematics.cxx.

222 {
223 double deta = ( tob1->etaDouble() - tob2->etaDouble() );
224 double dphi = std::fabs( tob1->phiDouble() - tob2->phiDouble() );
225 if(dphi>M_PI)
226 dphi = 2*M_PI - dphi;
227
228 return round ( 100 * ((dphi)*(dphi) + (deta)*(deta) )) ;
229}

◆ calcInvMass()

unsigned int TSU::Kinematics::calcInvMass ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 244 of file Kinematics.cxx.

244 {
245 double deta = std::fabs( tob1->etaDouble() - tob2->etaDouble() );
246 double dphi = std::fabs( tob1->phiDouble() - tob2->phiDouble() );
247 if(dphi>M_PI)
248 dphi = 2*M_PI - dphi;
249
250 double cosheta = cosh ( deta);
251 double cosphi = cos ( dphi);
252 double invmass2 = 2*tob1->Et()*tob2->Et()*(cosheta - cosphi);
253 return round( invmass2 );
254}
unsigned int Et() const
Definition GenericTOB.h:113

◆ calcInvMassBW()

unsigned int TSU::Kinematics::calcInvMassBW ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 97 of file Kinematics.cxx.

97 {
98
99 auto bit_cosheta = TSU::L1TopoDataTypes<25,10>(TSU::Hyperbolic::Cosh.at(std::abs(tob1->eta() - tob2->eta())));
100 //In case of EM objects / jets / taus the phi angle goes between 0 and 128 while muons are between -128 and 128, applying a shift to keep delta-phi in the allowed range.
101 //those cases should happen only in mixed EM/jets/tau plus mu triggers, if both phi's are in [0,2pi] will not get in
102 int phi_tob1 = tob1->phi();
103 int phi_tob2 = tob2->phi();
104 if ( std::abs(phi_tob1-phi_tob2)>=128 )
105 {
106 if(phi_tob1 >= 64) phi_tob1 = phi_tob1-128;
107 if(phi_tob2 >= 64) phi_tob2 = phi_tob2-128;
108 }
109 auto bit_cosphi = TSU::L1TopoDataTypes<12,10>(TSU::Trigo::Cos.at(std::abs( phi_tob1 - phi_tob2 )));
110 TSU::L1TopoDataTypes<15,0> bit_Et1(tob1->Et());
111 TSU::L1TopoDataTypes<15,0> bit_Et2(tob2->Et());
112 auto bit_invmass2 = bit_Et1*bit_Et2*(bit_cosheta - bit_cosphi)*2;
113
114 auto u_invmass2 = static_cast<unsigned long long>(bit_invmass2);
115
116 if (u_invmass2 > std::numeric_limits<int>::max())
117 {return std::numeric_limits<int>::max();}
118 else
119 {return u_invmass2;}
120}
static const std::vector< std::string > Cosh
Definition Hyperbolic.h:102

◆ calcInvMassBWLegacy()

unsigned int TSU::Kinematics::calcInvMassBWLegacy ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 34 of file Kinematics.cxx.

34 {
35
36 auto bit_cosheta = TSU::L1TopoDataTypes<19,7>(TSU::Hyperbolic::Coshleg.at(std::abs(tob1->eta() - tob2->eta())));
37 //In case of EM objects / jets / taus the phi angle goes between 0 and 64 while muons are between -32 and 32, applying a shift to keep delta-phi in the allowed range.
38 int phi_tob1 = tob1->phi();
39 int phi_tob2 = tob2->phi();
40 //those cases should happen only in mixed EM/jets/tau plus mu triggers, if both phi's are in [0,2pi] will not get in
41 if ( std::abs(phi_tob1-phi_tob2)>=64 )
42 {
43 if(phi_tob1 >= 32) phi_tob1 = phi_tob1-64;
44 if(phi_tob2 >= 32) phi_tob2 = phi_tob2-64;
45 }
46 auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cosleg.at(std::abs( phi_tob1 - phi_tob2 )));
47 TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
48 TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
49 auto bit_invmass2 = bit_Et1*bit_Et2*(bit_cosheta - bit_cosphi)*2;
50 return static_cast<unsigned>(bit_invmass2) ;
51}
static const std::vector< std::string > Coshleg
Definition Hyperbolic.h:17

◆ calcSin()

float TSU::Kinematics::calcSin ( unsigned phi)
static

Definition at line 203 of file Kinematics.cxx.

203 {
204 return static_cast<float>(TSU::L1TopoDataTypes<12,10>(TSU::Trigo::Sin.at(phi)));
205}
static const std::vector< std::string > Sin
Definition Trigo.h:305

◆ calcSinLegacy()

float TSU::Kinematics::calcSinLegacy ( unsigned phi)
static

Definition at line 78 of file Kinematics.cxx.

78 {
79 return static_cast<float>(TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Sinleg.at(phi)));
80}
static const std::vector< std::string > Sinleg
Definition Trigo.h:234

◆ calcTMass()

unsigned int TSU::Kinematics::calcTMass ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 256 of file Kinematics.cxx.

256 {
257 double dphi = std::fabs( tob1->phiDouble() - tob2->phiDouble() );
258 if(dphi>M_PI)
259 dphi = 2*M_PI - dphi;
260
261 double cosphi = cos ( dphi);
262 double tmass2 = 2*tob1->Et()*tob2->Et()*(1 - cosphi);
263 return round( tmass2 );
264}

◆ calcTMassBW()

unsigned int TSU::Kinematics::calcTMassBW ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 122 of file Kinematics.cxx.

122 {
123 auto bit_cosphi = TSU::L1TopoDataTypes<12,10>(TSU::Trigo::Cos.at(std::abs(tob1->phi() - tob2->phi())));
124 TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
125 TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
126 TSU::L1TopoDataTypes<22,0> bit_tmass2 = 2*bit_Et1*bit_Et2*(1. - bit_cosphi);
127 return static_cast<unsigned>(bit_tmass2) ;
128 // end bitwise implementation
129}

◆ calcTMassBWLegacy()

unsigned int TSU::Kinematics::calcTMassBWLegacy ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2 )
static

Definition at line 53 of file Kinematics.cxx.

53 {
54 auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cosleg.at(std::abs(tob1->phi() - tob2->phi())));
55 TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
56 TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
57 TSU::L1TopoDataTypes<22,0> bit_tmass2 = 2*bit_Et1*bit_Et2*(1. - bit_cosphi);
58 return static_cast<unsigned>(bit_tmass2) ;
59 // end bitwise implementation
60}

◆ calcXi1()

unsigned int TSU::Kinematics::calcXi1 ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2,
unsigned ptShift,
unsigned ptScale )
static

Definition at line 174 of file Kinematics.cxx.

174 {
175 //firmware: 19 bits unsigned + 1 sign bit due to L1TopoDataTypes assuming to be signed
176 TSU::L1TopoDataTypes<20,0> bit_Et1(static_cast<unsigned>(ptScale*tob1->Et()+ptShift));
177 TSU::L1TopoDataTypes<20,0> bit_Et2(static_cast<unsigned>(ptScale*tob2->Et()+ptShift));
178
179 //10 bits *unsigned* integer + 10 bits decimals + 1 sign bit since L1TopoDataTypes always assumes to represent signed values!
180 auto bit_eeta1 = TSU::L1TopoDataTypes<21,10>(TSU::Expo::E.at(tob1->eta()));
181 auto bit_eeta2 = TSU::L1TopoDataTypes<21,10>(TSU::Expo::E.at(tob2->eta()));
182
183 auto xi_bit = bit_Et1*bit_eeta1+bit_Et2*bit_eeta2;
184
185 return static_cast<unsigned>(xi_bit);
186}
static const std::unordered_map< int, std::string > E
Definition Expo.h:8

◆ calcXi2()

unsigned int TSU::Kinematics::calcXi2 ( const TCS::GenericTOB * tob1,
const TCS::GenericTOB * tob2,
unsigned ptShift,
unsigned ptScale )
static

Definition at line 188 of file Kinematics.cxx.

188 {
189 TSU::L1TopoDataTypes<20,0> bit_Et1(static_cast<unsigned>(ptScale*tob1->Et()+ptShift));
190 TSU::L1TopoDataTypes<20,0> bit_Et2(static_cast<unsigned>(ptScale*tob2->Et()+ptShift));
191 auto bit_eeta1 = TSU::L1TopoDataTypes<21,10>(TSU::Expo::E.at(-tob1->eta()));
192 auto bit_eeta2 = TSU::L1TopoDataTypes<21,10>(TSU::Expo::E.at(-tob2->eta()));
193
194 auto xi_bit = bit_Et1*bit_eeta1+bit_Et2*bit_eeta2;
195
196 return static_cast<unsigned>(xi_bit);
197}

◆ quadraticSumBW()

unsigned long TSU::Kinematics::quadraticSumBW ( int i1,
int i2 )
static

compute the sum in quadrature of two ints

This function includes an integer square root implementation using a bitwise iterative approach. Square root is computed bit-by-bit (highest significance bits first) and the result is adjusted up- or downwards in each iteration based on whether or not the current result under- or overestimates the value of the sum of squares.

That is the same way in which the sqrt int is implemented in firmware: processor/sources/common/libraries/L1TopoFunctions.vhd --> function sqrt(d : UNSIGNED) return UNSIGNED

Definition at line 146 of file Kinematics.cxx.

146 {
147 unsigned int ui1 = i1, ui2=i2;
148 unsigned int a = ui1*ui1 + ui2*ui2;
149
150 unsigned int result=0;
151 int left=0, right=0;
152 unsigned int r=0;
153 int sign=0;
154
155 //The values for halflength and bitmask enforce the
156 //bitwise overflow limit, not the precision of the chosen C++ parameters
157 int halflength = 16; //max 16
158 unsigned int bitmask = 0b11111111111111111111111111111111; //32 bits
159 bitmask >>= (32 - halflength*2); //does nothing unless halflength changes
160
161 for(int i = 0; i < halflength; i++){ //16-->4
162 right = 1 + (sign<<1) + (result<<2);
163 left = (r<<2) + (a >> (2*halflength-2));
164 a <<= 2;
165 a = a & bitmask;
166 r = sign ? (left + right) : (left - right);
167 sign = ((r & (1 << (halflength+1) )) > 0) ? 1 : 0;
168 result <<= 1;
169 if(sign==0) result += 1;
170 }
171 return result;
172}
static Double_t a
int sign(int a)
int r
Definition globals.cxx:22

The documentation for this struct was generated from the following files: