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

#include <Trigo.h>

Collaboration diagram for TSU::Trigo:

Static Public Member Functions

static int atan2leg (TSU::L1TopoDataTypes< 16, 0 > x, TSU::L1TopoDataTypes< 16, 0 > y)
static int atan2 (TSU::L1TopoDataTypes< 16, 0 > x, TSU::L1TopoDataTypes< 16, 0 > y)

Static Public Attributes

static const std::vector< std::string > Cosleg
static const std::vector< std::string > Sinleg
static const std::vector< std::string > Cos
static const std::vector< std::string > Sin
static const std::vector< int > CoslegInt = convertVector(TSU::Trigo::Cosleg)
static const std::vector< int > SinlegInt = convertVector(TSU::Trigo::Sinleg)
static const std::vector< int > CosInt = convertVector(TSU::Trigo::Cos)
static const std::vector< int > SinInt = convertVector(TSU::Trigo::Sin)

Detailed Description

Definition at line 21 of file Trigo.h.

Member Function Documentation

◆ atan2()

int TSU::Trigo::atan2 ( TSU::L1TopoDataTypes< 16, 0 > x,
TSU::L1TopoDataTypes< 16, 0 > y )
static

Definition at line 512 of file Trigo.cxx.

512 {
513 short int octant=0;
514 if((x.value()&(1<<16))&&(y.value()&(1<<16))){ // Ex and Ey negative
515 if(std::abs(y.to_float()) < std::abs(x.to_float())) octant = 4; //100
516 else octant = 5; // 101
517 } else if(x.value()&(1<<16)){
518 if(std::abs(y.to_float()) < std::abs(x.to_float())) octant = 3; //011
519 else octant = 2; // 010
520 } else if(y.value()&(1<<16)){
521 if(std::abs(y.to_float()) < std::abs(x.to_float())) octant = 7; //111
522 else octant = 6; // 110
523 } else { // Ex and Ey both positive
524 if(std::abs(y.to_float()) < std::abs(x.to_float())) octant = 0; //000
525 else octant = 1; // 001
526 }
527
528 auto signed_x_f = x;
529 auto signed_y_f = y;
530 if(octant==0||octant==3||octant==4||octant==7){
531 //signed_x_f = (abs(int(x)));
532 signed_x_f = x.abs();
533 signed_y_f = y.abs();
534 } else {
535 //signed_x_f = (abs(int(y)));
536 signed_x_f = y.abs();
537 signed_y_f = x.abs();
538 }
539
540 // For phi in the first sector (0.8 < phi < 1.6) store the possible values of the tan
541 const std::vector<std::string> atan2_thresholds =
542 {
543 "00000010010001101", // tan(0.85)=1.1383327132284393 rounded to 1.1376953125
544 "00000010100001010", // tan(0.9)=1.2601582175503392 rounded to 1.259765625
545 "00000010110010111", // tan(0.95)=1.398382589287699 rounded to 1.3974609375
546 "00000011000111010", // tan(1.0)=1.5574077246549023 rounded to 1.556640625
547 "00000011011111001", // tan(1.05)=1.7433153099831704 rounded to 1.7431640625
548 "00000011111011011", // tan(1.1)=1.9647596572486523 rounded to 1.9638671875
549 "00000100011110000", // tan(1.15)=2.2344969487553255 rounded to 2.234375
550 "00000101001001001", // tan(1.2)=2.5721516221263188 rounded to 2.5712890625
551 "00000110000001001", // tan(1.25)=3.0095696738628313 rounded to 3.0087890625
552 "00000111001101000", // tan(1.3)=3.6021024479679786 rounded to 3.6015625
553 "00001000111010010", // tan(1.35)=4.455221759562705 rounded to 4.455078125
554 "00001011100110001", // tan(1.4)=5.797883715482887 rounded to 5.7978515625
555 "00010000011110011", // tan(1.4500000000000002)=8.238092752965619 rounded to 8.2373046875
556 "00011100001100111", // tan(1.5)=14.101419947171719 rounded to 14.1005859375
557 "01100000001010000" // tan(1.55)=48.07848247921907 rounded to 48.078125
558 };
559
560 unsigned int thresholdsPassed = atan2_thresholds.size();
561 for(size_t j=0;j<atan2_thresholds.size(); ++j){
562 auto thresh = TSU::L1TopoDataTypes<17,10>(atan2_thresholds.at(j));
563 auto yy = signed_y_f*thresh;
564 if(! (signed_x_f.to_float() > yy.to_float()) ) {
565 //if the current threshold is not passed, then the previous one must have been the last one passed
566 //(no) off-by-one consideration: j starts at 0, so if the first threshold is already failed, that's just the number we're looking for
567 thresholdsPassed = j;
568 break;
569 }
570 }
571
572 //for first half of a quadrant fine steps are counted in downward
573 // (range: 15 downto 0)
574 unsigned int octant_fine = 16 - (thresholdsPassed + 1);
575
576 //for second half of a quadrant count fine steps upwards
577 // (range: 0 to 15)
578 unsigned int octant_fine2 = thresholdsPassed;
579
580 int intphi = octant << 4;
581 if(octant==0||octant==2||octant==4||octant==6){
582 intphi |= octant_fine;
583 } else {
584 intphi |= octant_fine2;
585 }
586
587 return intphi;
588}
#define y
#define x

◆ atan2leg()

int TSU::Trigo::atan2leg ( TSU::L1TopoDataTypes< 16, 0 > x,
TSU::L1TopoDataTypes< 16, 0 > y )
static

Definition at line 440 of file Trigo.cxx.

440 {
441 short int octant=0;
442 if((x.value()&(1<<16))&&(y.value()&(1<<16))){ // Ex and Ey negative
443 if(std::abs(y.to_float()) < std::abs(x.to_float())) octant = 4; //100
444 else octant = 5; // 101
445 } else if(x.value()&(1<<16)){
446 if(std::abs(y.to_float()) < std::abs(x.to_float())) octant = 3; //011
447 else octant = 2; // 010
448 } else if(y.value()&(1<<16)){
449 if(std::abs(y.to_float()) < std::abs(x.to_float())) octant = 7; //111
450 else octant = 6; // 110
451 } else { // Ex and Ey both positive
452 if(std::abs(y.to_float()) < std::abs(x.to_float())) octant = 0; //000
453 else octant = 1; // 001
454 }
455
456 auto signed_x_f = x;
457 auto signed_y_f = y;
458 if(octant==0||octant==3||octant==4||octant==7){
459 //signed_x_f = (abs(int(x)));
460 signed_x_f = x.abs();
461 signed_y_f = y.abs();
462 } else {
463 //signed_x_f = (abs(int(y)));
464 signed_x_f = y.abs();
465 signed_y_f = x.abs();
466 }
467
468 const std::vector<std::string> atan2_thresholds = {
469 "000010011101100", // 1.260 (0.9)
470 "000011000010101", // 1.557 (1.0)
471 "000011110101100", // 1.964 (1.1)
472 "000101000001100", // 2.572 (1.2)
473 "000111000010010", // 3.602 (1.3)
474 "001011010100101", // 5.797 (1.4)
475 "011011100010101"}; // 14.101 (1.5)
476 unsigned int flag = 0;
477 for(size_t j=0;j<atan2_thresholds.size(); ++j){
478 auto thresh = TSU::L1TopoDataTypes<15,10>(atan2_thresholds.at(j));
479 auto yy = signed_y_f*thresh;
480 if(signed_x_f.to_float() > yy.to_float()) flag = (flag | (1<<j));
481 }
482 unsigned int octant_fine = 0;
483 if(flag==0) octant_fine = 7;
484 else if(flag==1) octant_fine = 6;
485 else if(flag==3) octant_fine = 5;
486 else if(flag==7) octant_fine = 4;
487 else if(flag==15) octant_fine = 3;
488 else if(flag==31) octant_fine = 2;
489 else if(flag==63) octant_fine = 1;
490 else if(flag==127) octant_fine = 0;
491
492 unsigned int octant_fine2 = 0;
493 if(flag==0) octant_fine2 = 0;
494 else if(flag==1) octant_fine2 = 1;
495 else if(flag==3) octant_fine2 = 2;
496 else if(flag==7) octant_fine2 = 3;
497 else if(flag==15) octant_fine2 = 4;
498 else if(flag==31) octant_fine2 = 5;
499 else if(flag==63) octant_fine2 = 6;
500 else if(flag==127) octant_fine2 = 7;
501
502 int intphi = octant << 3;
503 if(octant==0||octant==2||octant==4||octant==6){
504 intphi |= octant_fine;
505 } else {
506 intphi |= octant_fine2;
507 }
508
509 return intphi;
510}
bool flag
Definition master.py:29

Member Data Documentation

◆ Cos

const std::vector< std::string > TSU::Trigo::Cos
static

Definition at line 100 of file Trigo.h.

◆ CosInt

const std::vector< int > TSU::Trigo::CosInt = convertVector(TSU::Trigo::Cos)
static

Definition at line 28 of file Trigo.h.

◆ Cosleg

const std::vector< std::string > TSU::Trigo::Cosleg
static

Definition at line 28 of file Trigo.h.

◆ CoslegInt

const std::vector< int > TSU::Trigo::CoslegInt = convertVector(TSU::Trigo::Cosleg)
static

Definition at line 26 of file Trigo.h.

◆ Sin

const std::vector< std::string > TSU::Trigo::Sin
static

Definition at line 305 of file Trigo.h.

324 {
325 struct Trigo{
326 static const std::vector<std::string> Cosleg;
327 static const std::vector<std::string> Sinleg;
328 static const std::vector<std::string> Cos;
329 static const std::vector<std::string> Sin;
330 static const std::vector<int> CoslegInt;
331 static const std::vector<int> SinlegInt;
332 static const std::vector<int> CosInt;
333 static const std::vector<int> SinInt;
334 static int atan2leg(TSU::L1TopoDataTypes<16,0> x, TSU::L1TopoDataTypes<16,0> y);
335 static int atan2(TSU::L1TopoDataTypes<16,0> x, TSU::L1TopoDataTypes<16,0> y);
336 };
337}
338#endif

◆ SinInt

const std::vector< int > TSU::Trigo::SinInt = convertVector(TSU::Trigo::Sin)
static

Definition at line 29 of file Trigo.h.

◆ Sinleg

const std::vector< std::string > TSU::Trigo::Sinleg
static

Definition at line 234 of file Trigo.h.

253 {
254 struct Trigo{
255 static const std::vector<std::string> Cosleg;
256 static const std::vector<std::string> Sinleg;
257 static const std::vector<std::string> Cos;
258 static const std::vector<std::string> Sin;
259 static const std::vector<int> CoslegInt;
260 static const std::vector<int> SinlegInt;
261 static const std::vector<int> CosInt;
262 static const std::vector<int> SinInt;
263 static int atan2leg(TSU::L1TopoDataTypes<16,0> x, TSU::L1TopoDataTypes<16,0> y);
264 static int atan2(TSU::L1TopoDataTypes<16,0> x, TSU::L1TopoDataTypes<16,0> y);
265 };
266}
267#endif

◆ SinlegInt

const std::vector< int > TSU::Trigo::SinlegInt = convertVector(TSU::Trigo::Sinleg)
static

Definition at line 27 of file Trigo.h.


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