ATLAS Offline Software
Static Public Member Functions | Static Public Attributes | List of all members
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 28 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 flag = 0;
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()) flag = (flag | (1<<j));
565  }
566  unsigned int octant_fine = 0;
567  if(flag==0) octant_fine = 15;
568  else if(flag==1) octant_fine = 14;
569  else if(flag==3) octant_fine = 13;
570  else if(flag==7) octant_fine = 12;
571  else if(flag==15) octant_fine = 11;
572  else if(flag==31) octant_fine = 10;
573  else if(flag==63) octant_fine = 9;
574  else if(flag==127) octant_fine = 8;
575  else if(flag==255) octant_fine = 7;
576  else if(flag==511) octant_fine = 6;
577  else if(flag==1023) octant_fine = 5;
578  else if(flag==2047) octant_fine = 4;
579  else if(flag==3071) octant_fine = 3;
580  else if(flag==5119) octant_fine = 2;
581  else if(flag==9215) octant_fine = 1;
582  else if(flag==17407) octant_fine = 0;
583 
584  unsigned int octant_fine2 = 0;
585  if(flag==0) octant_fine2 = 0;
586  else if(flag==1) octant_fine2 = 1;
587  else if(flag==3) octant_fine2 = 2;
588  else if(flag==7) octant_fine2 = 3;
589  else if(flag==15) octant_fine2 = 4;
590  else if(flag==31) octant_fine2 = 5;
591  else if(flag==63) octant_fine2 = 6;
592  else if(flag==127) octant_fine2 = 7;
593  else if(flag==255) octant_fine2 = 8;
594  else if(flag==511) octant_fine2 = 9;
595  else if(flag==1023) octant_fine2 = 10;
596  else if(flag==2047) octant_fine2 = 11;
597  else if(flag==3071) octant_fine2 = 12;
598  else if(flag==5119) octant_fine2 = 13;
599  else if(flag==9215) octant_fine2 = 14;
600  else if(flag==17407) octant_fine2 = 15;
601 
602  int intphi = octant << 3;
603  if(octant==0||octant==2||octant==4||octant==6){
604  intphi |= octant_fine;
605  } else {
606  intphi |= octant_fine2;
607  }
608 
609  return intphi;
610 }

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

Member Data Documentation

◆ Cos

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

Definition at line 38 of file Trigo.h.

◆ CosInt

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

Definition at line 42 of file Trigo.h.

◆ Cosleg

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

Definition at line 36 of file Trigo.h.

◆ CoslegInt

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

Definition at line 40 of file Trigo.h.

◆ Sin

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

Definition at line 39 of file Trigo.h.

◆ SinInt

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

Definition at line 43 of file Trigo.h.

◆ Sinleg

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

Definition at line 37 of file Trigo.h.

◆ SinlegInt

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

Definition at line 41 of file Trigo.h.


The documentation for this struct was generated from the following files:
PlotCalibFromCool.yy
yy
Definition: PlotCalibFromCool.py:714
physval_make_web_display.thresh
thresh
Definition: physval_make_web_display.py:36
x
#define x
TSU::L1TopoDataTypes
Definition: L1TopoDataTypes.h:51
master.flag
bool flag
Definition: master.py:29
y
#define y