CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
trklet::TrackletLUT Class Reference

#include <TrackletLUT.h>

Public Types

enum  MatchType {
  barrelphi, barrelz, disk2Sphi, disk2Sr,
  diskPSphi, diskPSr
}
 
enum  VMRTableType {
  me, disk, inner, inneroverlap,
  innerthird
}
 

Public Member Functions

void initBendMatch (unsigned int layerdisk)
 
void initmatchcut (unsigned int layerdisk, MatchType type, unsigned int region)
 
void initPhiCorrTable (unsigned int layerdisk, unsigned int rbits)
 
void initProjectionBend (double k_phider, unsigned int idisk, unsigned int nrbits, unsigned int nphiderbits)
 
void initteptlut (bool fillInner, bool fillTEMem, unsigned int iSeed, unsigned int layerdisk1, unsigned int layerdisk2, unsigned int innerphibits, unsigned int outerphibits, double innerphimin, double innerphimax, double outerphimin, double outerphimax, const std::string &innermem, const std::string &outermem)
 
void initTPlut (bool fillInner, unsigned int iSeed, unsigned int layerdisk1, unsigned int layerdisk2, unsigned int nbitsfinephidiff, unsigned int iTP)
 
void initTPregionlut (unsigned int iSeed, unsigned int layerdisk1, unsigned int layerdisk2, unsigned int iAllStub, unsigned int nbitsfinephidiff, unsigned int nbitsfinephi, const TrackletLUT &tplutinner, unsigned int iTP)
 
void initVMRTable (unsigned int layerdisk, VMRTableType type, int region=-1)
 
int lookup (unsigned int index) const
 
TrackletLUToperator= (const TrackletLUT &other)
 
unsigned int size () const
 
 TrackletLUT (const Settings &settings)
 
void writeTable () const
 
 ~TrackletLUT ()=default
 

Private Member Functions

int getphiCorrValue (unsigned int layerdisk, unsigned int ibend, unsigned int irbin, double rmean, double dr, double drmax) const
 
int getVMRLookup (unsigned int layerdisk, double z, double r, double dz, double dr, int iseed=-1) const
 

Private Attributes

std::string name_
 
unsigned int nbits_
 
bool positive_
 
const Settingssettings_
 
std::vector< int > table_
 

Detailed Description

Definition at line 12 of file TrackletLUT.h.

Member Enumeration Documentation

◆ MatchType

◆ VMRTableType

Constructor & Destructor Documentation

◆ TrackletLUT()

TrackletLUT::TrackletLUT ( const Settings settings)

Definition at line 12 of file TrackletLUT.cc.

12 : settings_(settings) {}
const Settings & settings_
Definition: TrackletLUT.h:85

◆ ~TrackletLUT()

trklet::TrackletLUT::~TrackletLUT ( )
default

Member Function Documentation

◆ getphiCorrValue()

int TrackletLUT::getphiCorrValue ( unsigned int  layerdisk,
unsigned int  ibend,
unsigned int  irbin,
double  rmean,
double  dr,
double  drmax 
) const
private

Definition at line 854 of file TrackletLUT.cc.

References trklet::Settings::benddecode(), trklet::Settings::kphi(), trklet::Settings::kphi1(), trklet::N_PSLAYER, settings_, and trklet::Settings::stripPitch().

Referenced by initPhiCorrTable().

855  {
856  bool psmodule = layerdisk < N_PSLAYER;
857 
858  double bend = -settings_.benddecode(ibend, layerdisk, psmodule);
859 
860  //for the rbin - calculate the distance to the nominal layer radius
861  double Delta = (irbin + 0.5) * dr - drmax;
862 
863  //calculate the phi correction - this is a somewhat approximate formula
864  double dphi = (Delta / 0.18) * bend * settings_.stripPitch(psmodule) / rmean;
865 
866  double kphi = psmodule ? settings_.kphi() : settings_.kphi1();
867 
868  int idphi = dphi / kphi;
869 
870  return idphi;
871 }
double kphi1() const
Definition: Settings.h:311
double benddecode(int ibend, int layerdisk, bool isPSmodule) const
Definition: Settings.h:415
const Settings & settings_
Definition: TrackletLUT.h:85
double stripPitch(bool isPSmodule) const
Definition: Settings.h:270
constexpr unsigned int N_PSLAYER
Definition: Settings.h:23
double kphi() const
Definition: Settings.h:310

◆ getVMRLookup()

int TrackletLUT::getVMRLookup ( unsigned int  layerdisk,
double  z,
double  r,
double  dz,
double  dr,
int  iseed = -1 
) const
private

Definition at line 669 of file TrackletLUT.cc.

References funct::abs(), cms::cuda::assert(), PVValHelper::dz, iseed, trklet::L1D1, trklet::L2D1, trklet::L2L3, trklet::L2L3D1, SiStripPI::max, SiStripPI::min, trklet::N_LAYER, NBINS, trklet::Settings::NLONGVMBINS(), hltL1SingleMuFiltered5_cfi::overlap, diffTwoXMLs::r2, trklet::Settings::rmaxdisk(), trklet::Settings::rmaxdiskl1overlapvm(), trklet::Settings::rmaxdiskvm(), trklet::Settings::rmean(), trklet::Settings::rmindiskl2overlapvm(), trklet::Settings::rmindiskvm(), settings_, relativeConstraints::value, trklet::Settings::z0cut(), testProducerWithPsetDescEmpty_cfi::z2, trklet::Settings::zlength(), SiStripMonitorCluster_cfi::zmax, trklet::Settings::zmean(), and SiStripMonitorCluster_cfi::zmin.

Referenced by initVMRTable().

669  {
670  double z0cut = settings_.z0cut();
671 
672  if (layerdisk < N_LAYER) {
673  if (iseed == Seed::L2L3 && std::abs(z) < 52.0)
674  return -1;
675 
676  double rmean = settings_.rmean(layerdisk);
677 
678  double rratio1 = rmean / (r + 0.5 * dr);
679  double rratio2 = rmean / (r - 0.5 * dr);
680 
681  double z1 = (z - 0.5 * dz) * rratio1 + z0cut * (rratio1 - 1.0);
682  double z2 = (z + 0.5 * dz) * rratio1 + z0cut * (rratio1 - 1.0);
683  double z3 = (z - 0.5 * dz) * rratio2 + z0cut * (rratio2 - 1.0);
684  double z4 = (z + 0.5 * dz) * rratio2 + z0cut * (rratio2 - 1.0);
685  double z5 = (z - 0.5 * dz) * rratio1 - z0cut * (rratio1 - 1.0);
686  double z6 = (z + 0.5 * dz) * rratio1 - z0cut * (rratio1 - 1.0);
687  double z7 = (z - 0.5 * dz) * rratio2 - z0cut * (rratio2 - 1.0);
688  double z8 = (z + 0.5 * dz) * rratio2 - z0cut * (rratio2 - 1.0);
689 
690  double zmin = std::min({z1, z2, z3, z4, z5, z6, z7, z8});
691  double zmax = std::max({z1, z2, z3, z4, z5, z6, z7, z8});
692 
694 
695  int zbin1 = NBINS * (zmin + settings_.zlength()) / (2 * settings_.zlength());
696  int zbin2 = NBINS * (zmax + settings_.zlength()) / (2 * settings_.zlength());
697 
698  if (zbin1 >= NBINS)
699  return -1;
700  if (zbin2 < 0)
701  return -1;
702 
703  if (zbin2 >= NBINS)
704  zbin2 = NBINS - 1;
705  if (zbin1 < 0)
706  zbin1 = 0;
707 
708  // This is a 10 bit word:
709  // xxx|yyy|z|rrr
710  // xxx is the delta z window
711  // yyy is the z bin
712  // z is flag to look in next bin
713  // rrr first fine z bin
714  // NOTE : this encoding is not efficient z is one if xxx+rrr is greater than 8
715  // and xxx is only 1,2, or 3
716  // should also reject xxx=0 as this means projection is outside range
717 
718  int value = zbin1 / 8;
719  value *= 2;
720  if (zbin2 / 8 - zbin1 / 8 > 0)
721  value += 1;
722  value *= 8;
723  value += (zbin1 & 7);
724  assert(value / 8 < 15);
725  int deltaz = zbin2 - zbin1;
726  if (deltaz > 7) {
727  deltaz = 7;
728  }
729  assert(deltaz < 8);
730  value += (deltaz << 7);
731 
732  return value;
733 
734  } else {
735  if (std::abs(z) < 2.0 * z0cut)
736  return -1;
737 
738  double zmean = settings_.zmean(layerdisk - N_LAYER);
739  if (z < 0.0)
740  zmean = -zmean;
741 
742  double r1 = (r + 0.5 * dr) * (zmean + z0cut) / (z + 0.5 * dz + z0cut);
743  double r2 = (r - 0.5 * dr) * (zmean - z0cut) / (z + 0.5 * dz - z0cut);
744  double r3 = (r + 0.5 * dr) * (zmean + z0cut) / (z - 0.5 * dz + z0cut);
745  double r4 = (r - 0.5 * dr) * (zmean - z0cut) / (z - 0.5 * dz - z0cut);
746  double r5 = (r + 0.5 * dr) * (zmean - z0cut) / (z + 0.5 * dz - z0cut);
747  double r6 = (r - 0.5 * dr) * (zmean + z0cut) / (z + 0.5 * dz + z0cut);
748  double r7 = (r + 0.5 * dr) * (zmean - z0cut) / (z - 0.5 * dz - z0cut);
749  double r8 = (r - 0.5 * dr) * (zmean + z0cut) / (z - 0.5 * dz + z0cut);
750 
751  double rmin = std::min({r1, r2, r3, r4, r5, r6, r7, r8});
752  double rmax = std::max({r1, r2, r3, r4, r5, r6, r7, r8});
753 
755 
756  double rmindisk = settings_.rmindiskvm();
757  double rmaxdisk = settings_.rmaxdiskvm();
758 
759  if (iseed == Seed::L1D1)
760  rmaxdisk = settings_.rmaxdiskl1overlapvm();
761  if (iseed == Seed::L2D1)
762  rmindisk = settings_.rmindiskl2overlapvm();
763  if (iseed == Seed::L2L3D1)
764  rmaxdisk = settings_.rmaxdisk();
765 
766  if (rmin > rmaxdisk)
767  return -1;
768  if (rmax > rmaxdisk)
769  rmax = rmaxdisk;
770 
771  if (rmax < rmindisk)
772  return -1;
773  if (rmin < rmindisk)
774  rmin = rmindisk;
775 
776  int rbin1 = NBINS * (rmin - settings_.rmindiskvm()) / (settings_.rmaxdiskvm() - settings_.rmindiskvm());
777  int rbin2 = NBINS * (rmax - settings_.rmindiskvm()) / (settings_.rmaxdiskvm() - settings_.rmindiskvm());
778 
779  if (iseed == Seed::L2L3D1) {
780  constexpr double rminspec = 40.0;
781  rbin1 = NBINS * (rmin - rminspec) / (settings_.rmaxdisk() - rminspec);
782  rbin2 = NBINS * (rmax - rminspec) / (settings_.rmaxdisk() - rminspec);
783  }
784 
785  if (rbin2 >= NBINS)
786  rbin2 = NBINS - 1;
787  if (rbin1 < 0)
788  rbin1 = 0;
789 
790  // This is a 9 bit word:
791  // xxx|yy|z|rrr
792  // xxx is the delta r window
793  // yy is the r bin yy is three bits for overlaps
794  // z is flag to look in next bin
795  // rrr fine r bin
796  // NOTE : this encoding is not efficient z is one if xxx+rrr is greater than 8
797  // and xxx is only 1,2, or 3
798  // should also reject xxx=0 as this means projection is outside range
799 
800  bool overlap = iseed == Seed::L1D1 || iseed == Seed::L2D1 || iseed == Seed::L2L3D1;
801 
802  int value = rbin1 / 8;
803  if (overlap) {
804  if (z < 0.0)
805  value += 4;
806  }
807  value *= 2;
808  if (rbin2 / 8 - rbin1 / 8 > 0)
809  value += 1;
810  value *= 8;
811  value += (rbin1 & 7);
812  assert(value / 8 < 15);
813  int deltar = rbin2 - rbin1;
814  if (deltar > 7)
815  deltar = 7;
816  if (overlap) {
817  value += (deltar << 7);
818  } else {
819  value += (deltar << 6);
820  }
821 
822  return value;
823  }
824 }
const Settings & settings_
Definition: TrackletLUT.h:85
double zlength() const
Definition: Settings.h:124
double rmindiskvm() const
Definition: Settings.h:327
assert(be >=bs)
unsigned int NLONGVMBINS() const
Definition: Settings.h:341
double rmindiskl2overlapvm() const
Definition: Settings.h:331
double rmean(unsigned int iLayer) const
Definition: Settings.h:164
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: value.py:1
double zmean(unsigned int iDisk) const
Definition: Settings.h:167
double z0cut() const
Definition: Settings.h:336
int iseed
Definition: AMPTWrapper.h:134
double rmaxdisk() const
Definition: Settings.h:125
Definition: deltar.py:1
double rmaxdiskvm() const
Definition: Settings.h:328
const int NBINS
constexpr int N_LAYER
Definition: Settings.h:21
double rmaxdiskl1overlapvm() const
Definition: Settings.h:330

◆ initBendMatch()

void TrackletLUT::initBendMatch ( unsigned int  layerdisk)

Definition at line 446 of file TrackletLUT.cc.

References funct::abs(), Reference_intrackfit_cff::barrel, trklet::Settings::bendcutme(), trklet::Settings::benddecode(), trklet::bendstrip(), trklet::Settings::krinvpars(), trklet::TrackletConfigBuilder::LayerName(), trklet::N_BENDBITS_2S, trklet::N_BENDBITS_PS, trklet::N_LAYER, trklet::N_PSLAYER, name_, trklet::Settings::nbitsrinv(), trklet::NRINVBITS, positive_, trklet::rinv(), trklet::Settings::rmean(), settings_, trklet::Settings::stripPitch(), table_, and writeTable().

Referenced by trklet::MatchEngine::MatchEngine(), and trklet::MatchProcessor::MatchProcessor().

446  {
447  unsigned int nrinv = NRINVBITS;
448  double rinvhalf = 0.5 * ((1 << nrinv) - 1);
449 
450  bool barrel = layerdisk < N_LAYER;
451  bool isPSmodule = layerdisk < N_PSLAYER;
452  double stripPitch = settings_.stripPitch(isPSmodule);
453 
454  if (barrel) {
455  unsigned int nbits = isPSmodule ? N_BENDBITS_PS : N_BENDBITS_2S;
456 
457  for (unsigned int irinv = 0; irinv < (1u << nrinv); irinv++) {
458  double rinv = (irinv - rinvhalf) * (1 << (settings_.nbitsrinv() - nrinv)) * settings_.krinvpars();
459 
460  double projbend = bendstrip(settings_.rmean(layerdisk), rinv, stripPitch);
461  for (unsigned int ibend = 0; ibend < (1u << nbits); ibend++) {
462  double stubbend = settings_.benddecode(ibend, layerdisk, isPSmodule);
463  bool pass = std::abs(stubbend - projbend) < settings_.bendcutme(ibend, layerdisk, isPSmodule);
464  table_.push_back(pass);
465  }
466  }
467  } else {
468  for (unsigned int iprojbend = 0; iprojbend < (1u << nrinv); iprojbend++) {
469  double projbend = 0.5 * (iprojbend - rinvhalf);
470  for (unsigned int ibend = 0; ibend < (1 << N_BENDBITS_2S); ibend++) {
471  double stubbend = settings_.benddecode(ibend, layerdisk, false);
472  bool pass = std::abs(stubbend - projbend) < settings_.bendcutme(ibend, layerdisk, false);
473  table_.push_back(pass);
474  }
475  }
476  for (unsigned int iprojbend = 0; iprojbend < (1u << nrinv); iprojbend++) {
477  double projbend = 0.5 * (iprojbend - rinvhalf);
478  for (unsigned int ibend = 0; ibend < (1 << N_BENDBITS_PS); ibend++) {
479  double stubbend = settings_.benddecode(ibend, layerdisk, true);
480  bool pass = std::abs(stubbend - projbend) < settings_.bendcutme(ibend, layerdisk, true);
481  table_.push_back(pass);
482  }
483  }
484  }
485 
486  positive_ = false;
487 
488  name_ = "METable_" + TrackletConfigBuilder::LayerName(layerdisk) + ".tab";
489 
490  writeTable();
491 }
double benddecode(int ibend, int layerdisk, bool isPSmodule) const
Definition: Settings.h:415
constexpr unsigned int NRINVBITS
Definition: Settings.h:32
const Settings & settings_
Definition: TrackletLUT.h:85
static std::string LayerName(unsigned int ilayer)
constexpr unsigned int N_BENDBITS_2S
Definition: Settings.h:30
double krinvpars() const
Definition: Settings.h:397
constexpr unsigned int N_BENDBITS_PS
Definition: Settings.h:29
std::string name_
Definition: TrackletLUT.h:87
double rmean(unsigned int iLayer) const
Definition: Settings.h:164
int nbitsrinv() const
Definition: Settings.h:346
double stripPitch(bool isPSmodule) const
Definition: Settings.h:270
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double bendcutme(int ibend, int layerdisk, bool isPSmodule) const
Definition: Settings.h:445
constexpr unsigned int N_PSLAYER
Definition: Settings.h:23
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:49
std::vector< int > table_
Definition: TrackletLUT.h:89
double bendstrip(double r, double rinv, double stripPitch)
Definition: Util.h:42
void writeTable() const
Definition: TrackletLUT.cc:874
constexpr int N_LAYER
Definition: Settings.h:21

◆ initmatchcut()

void TrackletLUT::initmatchcut ( unsigned int  layerdisk,
MatchType  type,
unsigned int  region 
)

Definition at line 14 of file TrackletLUT.cc.

References barrelphi, barrelz, trklet::Settings::combined(), disk2Sphi, disk2Sr, diskPSphi, diskPSr, trklet::Settings::kphi(), trklet::Settings::kphi1(), trklet::Settings::kr(), trklet::Settings::krprojshiftdisk(), trklet::Settings::kz(), trklet::TrackletConfigBuilder::LayerName(), trklet::N_LAYER, name_, positive_, trklet::Settings::rcut2S(), trklet::Settings::rcutPS(), HLT_2023v12_cff::region, trklet::Settings::rmean(), trklet::Settings::rphicut2S(), trklet::Settings::rphicutPS(), trklet::Settings::rphimatchcut(), settings_, table_, writeTable(), and trklet::Settings::zmatchcut().

Referenced by trklet::MatchCalculator::MatchCalculator(), and trklet::MatchProcessor::MatchProcessor().

14  {
15  char cregion = 'A' + region;
16 
17  for (unsigned int iSeed = 0; iSeed < 12; iSeed++) {
18  if (type == barrelphi) {
19  table_.push_back(settings_.rphimatchcut(iSeed, layerdisk) / (settings_.kphi1() * settings_.rmean(layerdisk)));
20  }
21  if (type == barrelz) {
22  table_.push_back(settings_.zmatchcut(iSeed, layerdisk) / settings_.kz());
23  }
24  if (type == diskPSphi) {
25  table_.push_back(settings_.rphicutPS(iSeed, layerdisk - N_LAYER) / (settings_.kphi() * settings_.kr()));
26  }
27  if (type == disk2Sphi) {
28  table_.push_back(settings_.rphicut2S(iSeed, layerdisk - N_LAYER) / (settings_.kphi() * settings_.kr()));
29  }
30  if (type == disk2Sr) {
31  table_.push_back(settings_.rcut2S(iSeed, layerdisk - N_LAYER) / settings_.krprojshiftdisk());
32  }
33  if (type == diskPSr) {
34  table_.push_back(settings_.rcutPS(iSeed, layerdisk - N_LAYER) / settings_.krprojshiftdisk());
35  }
36  }
37 
38  name_ = settings_.combined() ? "MP_" : "MC_";
39 
40  if (type == barrelphi) {
41  name_ += TrackletConfigBuilder::LayerName(layerdisk) + "PHI" + cregion + "_phicut.tab";
42  }
43  if (type == barrelz) {
44  name_ += TrackletConfigBuilder::LayerName(layerdisk) + "PHI" + cregion + "_zcut.tab";
45  }
46  if (type == diskPSphi) {
47  name_ += TrackletConfigBuilder::LayerName(layerdisk) + "PHI" + cregion + "_PSphicut.tab";
48  }
49  if (type == disk2Sphi) {
50  name_ += TrackletConfigBuilder::LayerName(layerdisk) + "PHI" + cregion + "_2Sphicut.tab";
51  }
52  if (type == disk2Sr) {
53  name_ += TrackletConfigBuilder::LayerName(layerdisk) + "PHI" + cregion + "_2Srcut.tab";
54  }
55  if (type == diskPSr) {
56  name_ += TrackletConfigBuilder::LayerName(layerdisk) + "PHI" + cregion + "_PSrcut.tab";
57  }
58 
59  positive_ = false;
60 
61  writeTable();
62 }
double rphicutPS(unsigned int iSeed, unsigned int idisk) const
Definition: Settings.h:159
double kz() const
Definition: Settings.h:314
double zmatchcut(unsigned int iSeed, unsigned int ilayer) const
Definition: Settings.h:158
double kphi1() const
Definition: Settings.h:311
bool combined() const
Definition: Settings.h:258
const Settings & settings_
Definition: TrackletLUT.h:85
static std::string LayerName(unsigned int ilayer)
double rphimatchcut(unsigned int iSeed, unsigned int ilayer) const
Definition: Settings.h:157
std::string name_
Definition: TrackletLUT.h:87
double rmean(unsigned int iLayer) const
Definition: Settings.h:164
double rcut2S(unsigned int iSeed, unsigned int idisk) const
Definition: Settings.h:162
double kr() const
Definition: Settings.h:316
double rphicut2S(unsigned int iSeed, unsigned int idisk) const
Definition: Settings.h:161
double rcutPS(unsigned int iSeed, unsigned int idisk) const
Definition: Settings.h:160
std::vector< int > table_
Definition: TrackletLUT.h:89
double krprojshiftdisk() const
Definition: Settings.h:413
double kphi() const
Definition: Settings.h:310
void writeTable() const
Definition: TrackletLUT.cc:874
constexpr int N_LAYER
Definition: Settings.h:21

◆ initPhiCorrTable()

void TrackletLUT::initPhiCorrTable ( unsigned int  layerdisk,
unsigned int  rbits 
)

Definition at line 826 of file TrackletLUT.cc.

References trklet::Settings::drmax(), getphiCorrValue(), trklet::N_BENDBITS_2S, trklet::N_BENDBITS_PS, trklet::N_PSLAYER, name_, nbits_, positive_, trklet::Settings::rmean(), settings_, table_, cond::impl::to_string(), and writeTable().

Referenced by trklet::Sector::addStub().

826  {
827  bool psmodule = layerdisk < N_PSLAYER;
828 
829  unsigned int bendbits = psmodule ? N_BENDBITS_PS : N_BENDBITS_2S;
830 
831  unsigned int rbins = (1 << rbits);
832 
833  double rmean = settings_.rmean(layerdisk);
834  double drmax = settings_.drmax();
835 
836  double dr = 2.0 * drmax / rbins;
837 
838  unsigned int bendbins = (1 << bendbits);
839 
840  for (unsigned int ibend = 0; ibend < bendbins; ibend++) {
841  for (unsigned int irbin = 0; irbin < rbins; irbin++) {
842  int value = getphiCorrValue(layerdisk, ibend, irbin, rmean, dr, drmax);
843  table_.push_back(value);
844  }
845  }
846 
847  name_ = "VMPhiCorrL" + std::to_string(layerdisk + 1) + ".tab";
848  nbits_ = 14;
849  positive_ = false;
850 
851  writeTable();
852 }
const Settings & settings_
Definition: TrackletLUT.h:85
constexpr unsigned int N_BENDBITS_2S
Definition: Settings.h:30
std::string to_string(const V &value)
Definition: OMSAccess.h:77
constexpr unsigned int N_BENDBITS_PS
Definition: Settings.h:29
std::string name_
Definition: TrackletLUT.h:87
double rmean(unsigned int iLayer) const
Definition: Settings.h:164
Definition: value.py:1
constexpr unsigned int N_PSLAYER
Definition: Settings.h:23
double drmax() const
Definition: Settings.h:128
unsigned int nbits_
Definition: TrackletLUT.h:91
int getphiCorrValue(unsigned int layerdisk, unsigned int ibend, unsigned int irbin, double rmean, double dr, double drmax) const
Definition: TrackletLUT.cc:854
std::vector< int > table_
Definition: TrackletLUT.h:89
void writeTable() const
Definition: TrackletLUT.cc:874

◆ initProjectionBend()

void TrackletLUT::initProjectionBend ( double  k_phider,
unsigned int  idisk,
unsigned int  nrbits,
unsigned int  nphiderbits 
)

Definition at line 394 of file TrackletLUT.cc.

References trklet::bendstrip(), l1t::bitShift(), trklet::Settings::combined(), trklet::Settings::krprojshiftdisk(), trklet::TrackletConfigBuilder::LayerName(), trklet::N_LAYER, name_, trklet::Settings::nbitsphiprojderL123(), trklet::Settings::nrbitsstub(), trklet::NRINVBITS, positive_, trklet::Settings::rcrit(), trklet::rinv(), settings_, trklet::Settings::stripPitch(), submitPVValidationJobs::t, table_, writeTable(), and trklet::Settings::zmean().

Referenced by trklet::MatchProcessor::MatchProcessor(), and trklet::ProjectionRouter::ProjectionRouter().

397  {
398  unsigned int nsignbins = 2;
399  unsigned int nrbins = 1 << (nrbits);
400  unsigned int nphiderbins = 1 << (nphiderbits);
401 
402  for (unsigned int isignbin = 0; isignbin < nsignbins; isignbin++) {
403  for (unsigned int irbin = 0; irbin < nrbins; irbin++) {
404  int ir = irbin;
405  if (ir > (1 << (nrbits - 1)))
406  ir -= (1 << nrbits);
407  ir = l1t::bitShift(ir, (settings_.nrbitsstub(N_LAYER) - nrbits));
408  for (unsigned int iphiderbin = 0; iphiderbin < nphiderbins; iphiderbin++) {
409  int iphider = iphiderbin;
410  if (iphider > (1 << (nphiderbits - 1)))
411  iphider -= (1 << nphiderbits);
412  iphider = l1t::bitShift(iphider, (settings_.nbitsphiprojderL123() - nphiderbits));
413 
414  double rproj = ir * settings_.krprojshiftdisk();
415  double phider = iphider * k_phider;
416  double t = settings_.zmean(idisk) / rproj;
417 
418  if (isignbin)
419  t = -t;
420 
421  double rinv = -phider * (2.0 * t);
422 
423  double stripPitch = (rproj < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false);
424  double bendproj = bendstrip(rproj, rinv, stripPitch);
425 
426  static double maxbend = (1 << NRINVBITS) - 1;
427 
428  int ibendproj = 2.0 * bendproj + 0.5 * maxbend;
429  if (ibendproj < 0)
430  ibendproj = 0;
431  if (ibendproj > maxbend)
432  ibendproj = maxbend;
433 
434  table_.push_back(ibendproj);
435  }
436  }
437  }
438 
439  positive_ = false;
440  name_ = settings_.combined() ? "MP_" : "PR_";
441  name_ += "ProjectionBend_" + TrackletConfigBuilder::LayerName(N_LAYER + idisk) + ".tab";
442 
443  writeTable();
444 }
unsigned int nrbitsstub(unsigned int layerdisk) const
Definition: Settings.h:84
constexpr unsigned int NRINVBITS
Definition: Settings.h:32
bool combined() const
Definition: Settings.h:258
const Settings & settings_
Definition: TrackletLUT.h:85
static std::string LayerName(unsigned int ilayer)
std::string name_
Definition: TrackletLUT.h:87
double stripPitch(bool isPSmodule) const
Definition: Settings.h:270
double zmean(unsigned int iDisk) const
Definition: Settings.h:167
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:49
unsigned int nbitsphiprojderL123() const
Definition: Settings.h:87
std::vector< int > table_
Definition: TrackletLUT.h:89
double krprojshiftdisk() const
Definition: Settings.h:413
double bendstrip(double r, double rinv, double stripPitch)
Definition: Util.h:42
int bitShift(int num, int bits)
Definition: BitShift.h:6
void writeTable() const
Definition: TrackletLUT.cc:874
constexpr int N_LAYER
Definition: Settings.h:21
double rcrit() const
Definition: Settings.h:299

◆ initteptlut()

void TrackletLUT::initteptlut ( bool  fillInner,
bool  fillTEMem,
unsigned int  iSeed,
unsigned int  layerdisk1,
unsigned int  layerdisk2,
unsigned int  innerphibits,
unsigned int  outerphibits,
double  innerphimin,
double  innerphimax,
double  outerphimin,
double  outerphimax,
const std::string &  innermem,
const std::string &  outermem 
)

Definition at line 241 of file TrackletLUT.cc.

References funct::abs(), trklet::Settings::bendcutte(), trklet::Settings::benddecode(), trklet::bendstrip(), trklet::D1D2, trklet::D3D4, testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, testProducerWithPsetDescEmpty_cfi::i3, trklet::L1D1, trklet::L2D1, trklet::L3L4, trklet::L5L6, trklet::N_LAYER, name_, positive_, trklet::Settings::rcrit(), trklet::rinv(), trklet::Settings::rinvcutte(), trklet::Settings::rmaxdiskvm(), trklet::Settings::rmean(), trklet::Settings::rmindiskvm(), settings_, trklet::Settings::stripPitch(), table_, writeTable(), and trklet::Settings::zmean().

Referenced by trklet::TrackletEngine::setVMPhiBin().

253  {
254  int outerrbits = 0;
255  if (iSeed == Seed::D1D2 || iSeed == Seed::D3D4 || iSeed == Seed::L1D1 || iSeed == Seed::L2D1) {
256  outerrbits = 3;
257  }
258 
259  int outerrbins = (1 << outerrbits);
260  int innerphibins = (1 << innerphibits);
261  int outerphibins = (1 << outerphibits);
262 
263  double phiinner[2];
264  double phiouter[2];
265  double router[2];
266 
267  unsigned int nbendbitsinner = 3;
268  unsigned int nbendbitsouter = 3;
269  if (iSeed == Seed::L3L4) {
270  nbendbitsouter = 4;
271  }
272  if (iSeed == Seed::L5L6) {
273  nbendbitsinner = 4;
274  nbendbitsouter = 4;
275  }
276 
277  if (fillTEMem) {
278  if (fillInner) {
279  table_.resize((1 << nbendbitsinner), false);
280  } else {
281  table_.resize((1 << nbendbitsouter), false);
282  }
283  }
284 
285  for (int iphiinnerbin = 0; iphiinnerbin < innerphibins; iphiinnerbin++) {
286  phiinner[0] = innerphimin + iphiinnerbin * (innerphimax - innerphimin) / innerphibins;
287  phiinner[1] = innerphimin + (iphiinnerbin + 1) * (innerphimax - innerphimin) / innerphibins;
288  for (int iphiouterbin = 0; iphiouterbin < outerphibins; iphiouterbin++) {
289  phiouter[0] = outerphimin + iphiouterbin * (outerphimax - outerphimin) / outerphibins;
290  phiouter[1] = outerphimin + (iphiouterbin + 1) * (outerphimax - outerphimin) / outerphibins;
291  for (int irouterbin = 0; irouterbin < outerrbins; irouterbin++) {
292  if (iSeed == Seed::D1D2 || iSeed == Seed::D3D4 || iSeed == Seed::L1D1 || iSeed == Seed::L2D1) {
293  router[0] =
294  settings_.rmindiskvm() + irouterbin * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins;
295  router[1] = settings_.rmindiskvm() +
296  (irouterbin + 1) * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins;
297  } else {
298  router[0] = settings_.rmean(layerdisk2);
299  router[1] = settings_.rmean(layerdisk2);
300  }
301 
302  double bendinnermin = 20.0;
303  double bendinnermax = -20.0;
304  double bendoutermin = 20.0;
305  double bendoutermax = -20.0;
306  double rinvmin = 1.0;
307  for (int i1 = 0; i1 < 2; i1++) {
308  for (int i2 = 0; i2 < 2; i2++) {
309  for (int i3 = 0; i3 < 2; i3++) {
310  double rinner = 0.0;
311  if (iSeed == Seed::D1D2 || iSeed == Seed::D3D4) {
312  rinner = router[i3] * settings_.zmean(layerdisk1 - N_LAYER) / settings_.zmean(layerdisk2 - N_LAYER);
313  } else {
314  rinner = settings_.rmean(layerdisk1);
315  }
316  double rinv1 = (rinner < router[i3]) ? -rinv(phiinner[i1], phiouter[i2], rinner, router[i3]) : -20.0;
317  double pitchinner =
318  (rinner < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false);
319  double pitchouter =
320  (router[i3] < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false);
321  double abendinner = bendstrip(rinner, rinv1, pitchinner);
322  double abendouter = bendstrip(router[i3], rinv1, pitchouter);
323  if (abendinner < bendinnermin)
324  bendinnermin = abendinner;
325  if (abendinner > bendinnermax)
326  bendinnermax = abendinner;
327  if (abendouter < bendoutermin)
328  bendoutermin = abendouter;
329  if (abendouter > bendoutermax)
330  bendoutermax = abendouter;
331  if (std::abs(rinv1) < rinvmin) {
332  rinvmin = std::abs(rinv1);
333  }
334  }
335  }
336  }
337 
338  bool passptcut = rinvmin < settings_.rinvcutte();
339 
340  if (fillInner) {
341  for (int ibend = 0; ibend < (1 << nbendbitsinner); ibend++) {
342  double bend = settings_.benddecode(ibend, layerdisk1, nbendbitsinner == 3);
343 
344  bool passinner = bend > bendinnermin - settings_.bendcutte(ibend, layerdisk1, nbendbitsinner == 3) &&
345  bend < bendinnermax + settings_.bendcutte(ibend, layerdisk1, nbendbitsinner == 3);
346 
347  if (fillTEMem) {
348  if (passinner) {
349  table_[ibend] = 1;
350  }
351  } else {
352  table_.push_back(passinner && passptcut);
353  }
354  }
355  } else {
356  for (int ibend = 0; ibend < (1 << nbendbitsouter); ibend++) {
357  double bend = settings_.benddecode(ibend, layerdisk2, nbendbitsouter == 3);
358 
359  bool passouter = bend > bendoutermin - settings_.bendcutte(ibend, layerdisk2, nbendbitsouter == 3) &&
360  bend < bendoutermax + settings_.bendcutte(ibend, layerdisk2, nbendbitsouter == 3);
361  if (fillTEMem) {
362  if (passouter) {
363  table_[ibend] = 1;
364  }
365  } else {
366  table_.push_back(passouter && passptcut);
367  }
368  }
369  }
370  }
371  }
372  }
373 
374  positive_ = false;
375 
376  if (fillTEMem) {
377  if (fillInner) {
378  name_ = "VMSTE_" + innermem + "_vmbendcut.tab";
379  } else {
380  name_ = "VMSTE_" + outermem + "_vmbendcut.tab";
381  }
382  } else {
383  name_ = "TE_" + innermem.substr(0, innermem.size() - 2) + "_" + outermem.substr(0, outermem.size() - 2);
384  if (fillInner) {
385  name_ += "_stubptinnercut.tab";
386  } else {
387  name_ += "_stubptoutercut.tab";
388  }
389  }
390 
391  writeTable();
392 }
double benddecode(int ibend, int layerdisk, bool isPSmodule) const
Definition: Settings.h:415
const Settings & settings_
Definition: TrackletLUT.h:85
double rmindiskvm() const
Definition: Settings.h:327
std::string name_
Definition: TrackletLUT.h:87
double rmean(unsigned int iLayer) const
Definition: Settings.h:164
double stripPitch(bool isPSmodule) const
Definition: Settings.h:270
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double bendcutte(int ibend, int layerdisk, bool isPSmodule) const
Definition: Settings.h:443
double zmean(unsigned int iDisk) const
Definition: Settings.h:167
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:49
double rmaxdiskvm() const
Definition: Settings.h:328
double rinvcutte() const
Definition: Settings.h:325
std::vector< int > table_
Definition: TrackletLUT.h:89
double bendstrip(double r, double rinv, double stripPitch)
Definition: Util.h:42
void writeTable() const
Definition: TrackletLUT.cc:874
constexpr int N_LAYER
Definition: Settings.h:21
double rcrit() const
Definition: Settings.h:299

◆ initTPlut()

void TrackletLUT::initTPlut ( bool  fillInner,
unsigned int  iSeed,
unsigned int  layerdisk1,
unsigned int  layerdisk2,
unsigned int  nbitsfinephidiff,
unsigned int  iTP 
)

Definition at line 64 of file TrackletLUT.cc.

References funct::abs(), trklet::Settings::bendcutte(), trklet::Settings::benddecode(), trklet::bendstrip(), trklet::D1D2, trklet::D3D4, trklet::Settings::dphisectorHG(), testProducerWithPsetDescEmpty_cfi::i2, testProducerWithPsetDescEmpty_cfi::i3, trklet::L1D1, trklet::L1L2, trklet::L2D1, trklet::L2L3, trklet::L3L4, trklet::L5L6, trklet::TrackletConfigBuilder::LayerName(), trklet::N_LAYER, trklet::Settings::nallstubs(), name_, trklet::Settings::nfinephi(), trklet::Settings::nvmte(), positive_, trklet::Settings::rcrit(), trklet::rinv(), trklet::Settings::rinvcutte(), trklet::Settings::rmaxdiskvm(), trklet::Settings::rmean(), trklet::Settings::rmindiskvm(), settings_, trklet::Settings::stripPitch(), table_, writeTable(), and trklet::Settings::zmean().

Referenced by trklet::TrackletProcessor::addInput().

69  {
70  //number of fine phi bins in sector
71  int nfinephibins = settings_.nallstubs(layerdisk2) * settings_.nvmte(1, iSeed) * (1 << settings_.nfinephi(1, iSeed));
72  double dfinephi = settings_.dphisectorHG() / nfinephibins;
73 
74  int outerrbits = 3;
75 
76  if (iSeed == Seed::L1L2 || iSeed == Seed::L2L3 || iSeed == Seed::L3L4 || iSeed == Seed::L5L6) {
77  outerrbits = 0;
78  }
79 
80  int outerrbins = (1 << outerrbits);
81 
82  double dphi[2];
83  double router[2];
84 
85  unsigned int nbendbitsinner = 3;
86  unsigned int nbendbitsouter = 3;
87  if (iSeed == Seed::L3L4) {
88  nbendbitsouter = 4;
89  } else if (iSeed == Seed::L5L6) {
90  nbendbitsinner = 4;
91  nbendbitsouter = 4;
92  }
93 
94  int nbinsfinephidiff = (1 << nbitsfinephidiff);
95 
96  for (int iphibin = 0; iphibin < nbinsfinephidiff; iphibin++) {
97  int iphidiff = iphibin;
98  if (iphibin >= nbinsfinephidiff / 2) {
99  iphidiff = iphibin - nbinsfinephidiff;
100  }
101  //min and max dphi
102  dphi[0] = (iphidiff - 1.5) * dfinephi;
103  dphi[1] = (iphidiff + 1.5) * dfinephi;
104  for (int irouterbin = 0; irouterbin < outerrbins; irouterbin++) {
105  if (iSeed == Seed::D1D2 || iSeed == Seed::D3D4 || iSeed == Seed::L1D1 || iSeed == Seed::L2D1) {
106  router[0] =
107  settings_.rmindiskvm() + irouterbin * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins;
108  router[1] =
109  settings_.rmindiskvm() + (irouterbin + 1) * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins;
110  } else {
111  router[0] = settings_.rmean(layerdisk2);
112  router[1] = settings_.rmean(layerdisk2);
113  }
114 
115  double bendinnermin = 20.0;
116  double bendinnermax = -20.0;
117  double bendoutermin = 20.0;
118  double bendoutermax = -20.0;
119  double rinvmin = 1.0;
120  for (int i2 = 0; i2 < 2; i2++) {
121  for (int i3 = 0; i3 < 2; i3++) {
122  double rinner = 0.0;
123  if (iSeed == Seed::D1D2 || iSeed == Seed::D3D4) {
124  rinner = router[i3] * settings_.zmean(layerdisk1 - N_LAYER) / settings_.zmean(layerdisk2 - N_LAYER);
125  } else {
126  rinner = settings_.rmean(layerdisk1);
127  }
128  double rinv1 = (rinner < router[i3]) ? rinv(0.0, -dphi[i2], rinner, router[i3]) : 20.0;
129  double pitchinner = (rinner < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false);
130  double pitchouter =
131  (router[i3] < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false);
132  double abendinner = bendstrip(rinner, rinv1, pitchinner);
133  double abendouter = bendstrip(router[i3], rinv1, pitchouter);
134  if (abendinner < bendinnermin)
135  bendinnermin = abendinner;
136  if (abendinner > bendinnermax)
137  bendinnermax = abendinner;
138  if (abendouter < bendoutermin)
139  bendoutermin = abendouter;
140  if (abendouter > bendoutermax)
141  bendoutermax = abendouter;
142  if (std::abs(rinv1) < rinvmin) {
143  rinvmin = std::abs(rinv1);
144  }
145  }
146  }
147 
148  bool passptcut = rinvmin < settings_.rinvcutte();
149 
150  if (fillInner) {
151  for (int ibend = 0; ibend < (1 << nbendbitsinner); ibend++) {
152  double bend = settings_.benddecode(ibend, layerdisk1, nbendbitsinner == 3);
153 
154  bool passinner = bend <= bendinnermax + settings_.bendcutte(ibend, layerdisk1, nbendbitsinner == 3) &&
155  bend >= bendinnermin - settings_.bendcutte(ibend, layerdisk1, nbendbitsinner == 3);
156  table_.push_back(passinner && passptcut);
157  }
158  } else {
159  for (int ibend = 0; ibend < (1 << nbendbitsouter); ibend++) {
160  double bend = settings_.benddecode(ibend, layerdisk2, nbendbitsouter == 3);
161 
162  bool passouter = bend <= bendoutermax + settings_.bendcutte(ibend, layerdisk2, nbendbitsouter == 3) &&
163  bend >= bendoutermin - settings_.bendcutte(ibend, layerdisk2, nbendbitsouter == 3);
164  table_.push_back(passouter && passptcut);
165  }
166  }
167  }
168  }
169 
170  positive_ = false;
171  char cTP = 'A' + iTP;
172 
173  name_ = "TP_" + TrackletConfigBuilder::LayerName(layerdisk1) + TrackletConfigBuilder::LayerName(layerdisk2) + cTP;
174 
175  if (fillInner) {
176  name_ += "_stubptinnercut.tab";
177  } else {
178  name_ += "_stubptoutercut.tab";
179  }
180 
181  writeTable();
182 }
double benddecode(int ibend, int layerdisk, bool isPSmodule) const
Definition: Settings.h:415
double dphisectorHG() const
Definition: Settings.h:292
const Settings & settings_
Definition: TrackletLUT.h:85
static std::string LayerName(unsigned int ilayer)
double rmindiskvm() const
Definition: Settings.h:327
std::string name_
Definition: TrackletLUT.h:87
double rmean(unsigned int iLayer) const
Definition: Settings.h:164
double stripPitch(bool isPSmodule) const
Definition: Settings.h:270
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double bendcutte(int ibend, int layerdisk, bool isPSmodule) const
Definition: Settings.h:443
double zmean(unsigned int iDisk) const
Definition: Settings.h:167
unsigned int nvmte(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:101
unsigned int nallstubs(unsigned int layerdisk) const
Definition: Settings.h:107
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:49
int nfinephi(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:133
double rmaxdiskvm() const
Definition: Settings.h:328
double rinvcutte() const
Definition: Settings.h:325
std::vector< int > table_
Definition: TrackletLUT.h:89
double bendstrip(double r, double rinv, double stripPitch)
Definition: Util.h:42
void writeTable() const
Definition: TrackletLUT.cc:874
constexpr int N_LAYER
Definition: Settings.h:21
double rcrit() const
Definition: Settings.h:299

◆ initTPregionlut()

void TrackletLUT::initTPregionlut ( unsigned int  iSeed,
unsigned int  layerdisk1,
unsigned int  layerdisk2,
unsigned int  iAllStub,
unsigned int  nbitsfinephidiff,
unsigned int  nbitsfinephi,
const TrackletLUT tplutinner,
unsigned int  iTP 
)

Definition at line 184 of file TrackletLUT.cc.

References l1t::bitShift(), trklet::D1D2, trklet::D3D4, trklet::L1D1, trklet::L2D1, trklet::L5L6, trklet::TrackletConfigBuilder::LayerName(), lookup(), name_, trklet::Settings::nbitsallstubs(), trklet::Settings::nfinephi(), trklet::Settings::nvmte(), positive_, settings_, table_, and writeTable().

Referenced by trklet::TrackletProcessor::addInput().

191  {
192  int nirbits = 0;
193  if (iSeed == Seed::D1D2 || iSeed == Seed::D3D4 || iSeed == Seed::L1D1 || iSeed == Seed::L2D1) {
194  nirbits = 3;
195  }
196 
197  unsigned int nbendbitsinner = 3;
198 
199  if (iSeed == Seed::L5L6) {
200  nbendbitsinner = 4;
201  }
202 
203  for (int innerfinephi = 0; innerfinephi < (1 << nbitsfinephi); innerfinephi++) {
204  for (int innerbend = 0; innerbend < (1 << nbendbitsinner); innerbend++) {
205  for (int ir = 0; ir < (1 << nirbits); ir++) {
206  unsigned int usereg = 0;
207  for (unsigned int ireg = 0; ireg < settings_.nvmte(1, iSeed); ireg++) {
208  bool match = false;
209  for (int ifinephiouter = 0; ifinephiouter < (1 << settings_.nfinephi(1, iSeed)); ifinephiouter++) {
210  int outerfinephi = iAllStub * (1 << (nbitsfinephi - settings_.nbitsallstubs(layerdisk2))) +
211  ireg * (1 << settings_.nfinephi(1, iSeed)) + ifinephiouter;
212  int idphi = outerfinephi - innerfinephi;
213  bool inrange = (idphi < (1 << (nbitsfinephidiff - 1))) && (idphi >= -(1 << (nbitsfinephidiff - 1)));
214  if (idphi < 0)
215  idphi = idphi + (1 << nbitsfinephidiff);
216  int idphi1 = idphi;
217  if (iSeed >= 4)
218  idphi1 = (idphi << 3) + ir;
219  int ptinnerindexnew = l1t::bitShift(idphi1, nbendbitsinner) + innerbend;
220  match = match || (inrange && tplutinner.lookup(ptinnerindexnew));
221  }
222  if (match) {
223  usereg = usereg | (1 << ireg);
224  }
225  }
226 
227  table_.push_back(usereg);
228  }
229  }
230  }
231 
232  positive_ = false;
233  char cTP = 'A' + iTP;
234 
235  name_ = "TP_" + TrackletConfigBuilder::LayerName(layerdisk1) + TrackletConfigBuilder::LayerName(layerdisk2) + cTP +
236  "_usereg.tab";
237 
238  writeTable();
239 }
const Settings & settings_
Definition: TrackletLUT.h:85
static std::string LayerName(unsigned int ilayer)
int lookup(unsigned int index) const
Definition: TrackletLUT.cc:904
unsigned int nbitsallstubs(unsigned int layerdisk) const
Definition: Settings.h:106
std::string name_
Definition: TrackletLUT.h:87
unsigned int nvmte(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:101
int nfinephi(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:133
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
std::vector< int > table_
Definition: TrackletLUT.h:89
int bitShift(int num, int bits)
Definition: BitShift.h:6
void writeTable() const
Definition: TrackletLUT.cc:874

◆ initVMRTable()

void TrackletLUT::initVMRTable ( unsigned int  layerdisk,
VMRTableType  type,
int  region = -1 
)

Definition at line 493 of file TrackletLUT.cc.

References cms::cuda::assert(), newFWLiteAna::bin, trklet::Settings::combined(), trklet::D3, trklet::Settings::drmax(), PVValHelper::dz, trklet::Settings::dzmax(), getVMRLookup(), SurfaceOrientation::inner, PixelRegions::L1, PixelRegions::L2, trklet::L2L3, trklet::L2L3D1, PixelRegions::L3, PixelRegions::L4, trklet::L5, trklet::L6, trklet::TrackletConfigBuilder::LayerName(), hlt_dqm_clientPB-live_cfg::me, trklet::N_LAYER, name_, NBINS, nbits_, trklet::Settings::NLONGVMBINS(), positive_, trklet::Settings::rDSSinner(), trklet::Settings::rDSSouter(), HLT_2023v12_cff::region, trklet::Settings::rmaxdisk(), trklet::Settings::rmaxdiskvm(), trklet::Settings::rmean(), trklet::Settings::rmindiskvm(), settings_, table_, trklet::Settings::vmrlutrbits(), trklet::Settings::vmrlutzbits(), writeTable(), globals_cff::zbins, trklet::Settings::zlength(), SiStripMonitorCluster_cfi::zmax, trklet::Settings::zmean(), and SiStripMonitorCluster_cfi::zmin.

Referenced by trklet::TrackletProcessor::TrackletProcessor(), trklet::TrackletProcessorDisplaced::TrackletProcessorDisplaced(), trklet::VMRouter::VMRouter(), and trklet::VMRouterCM::VMRouterCM().

493  {
494  unsigned int zbits = settings_.vmrlutzbits(layerdisk);
495  unsigned int rbits = settings_.vmrlutrbits(layerdisk);
496 
497  unsigned int rbins = (1 << rbits);
498  unsigned int zbins = (1 << zbits);
499 
500  double zmin, zmax, rmin, rmax;
501 
502  if (layerdisk < N_LAYER) {
503  zmin = -settings_.zlength();
504  zmax = settings_.zlength();
505  rmin = settings_.rmean(layerdisk) - settings_.drmax();
506  rmax = settings_.rmean(layerdisk) + settings_.drmax();
507  } else {
508  rmin = 0;
509  rmax = settings_.rmaxdisk();
510  zmin = settings_.zmean(layerdisk - N_LAYER) - settings_.dzmax();
511  zmax = settings_.zmean(layerdisk - N_LAYER) + settings_.dzmax();
512  }
513 
514  double dr = (rmax - rmin) / rbins;
515  double dz = (zmax - zmin) / zbins;
516 
518 
519  for (unsigned int izbin = 0; izbin < zbins; izbin++) {
520  for (unsigned int irbin = 0; irbin < rbins; irbin++) {
521  double r = rmin + (irbin + 0.5) * dr;
522  double z = zmin + (izbin + 0.5) * dz;
523 
524  if (settings_.combined()) {
525  int iznew = izbin - (1 << (zbits - 1));
526  if (iznew < 0)
527  iznew += (1 << zbits);
528  assert(iznew >= 0);
529  assert(iznew < (1 << zbits));
530  z = zmin + (iznew + 0.5) * dz;
531  if (layerdisk < N_LAYER) {
532  int irnew = irbin - (1 << (rbits - 1));
533  if (irnew < 0)
534  irnew += (1 << rbits);
535  assert(irnew >= 0);
536  assert(irnew < (1 << rbits));
537  r = rmin + (irnew + 0.5) * dr;
538  }
539  }
540 
541  if (layerdisk >= N_LAYER && irbin < 10) //special case for the tabulated radii in 2S disks
542  r = (layerdisk < N_LAYER + 2) ? settings_.rDSSinner(irbin) : settings_.rDSSouter(irbin);
543 
544  int bin;
545  if (layerdisk < N_LAYER) {
546  double zproj = z * settings_.rmean(layerdisk) / r;
547  bin = NBINS * (zproj + settings_.zlength()) / (2 * settings_.zlength());
548  } else {
549  double rproj = r * settings_.zmean(layerdisk - N_LAYER) / z;
551  }
552  if (bin < 0)
553  bin = 0;
554  if (bin >= NBINS)
555  bin = NBINS - 1;
556 
557  if (type == VMRTableType::me) {
558  table_.push_back(bin);
559  }
560 
561  if (type == VMRTableType::disk) {
562  if (layerdisk >= N_LAYER) {
563  double rproj = r * settings_.zmean(layerdisk - N_LAYER) / z;
564  bin = 0.5 * NBINS * (rproj - settings_.rmindiskvm()) / (settings_.rmaxdiskvm() - settings_.rmindiskvm());
565  //bin value of zero indicates that stub is out of range
566  if (bin < 0)
567  bin = 0;
568  if (bin >= NBINS / 2)
569  bin = 0;
570  table_.push_back(bin);
571  }
572  }
573 
574  if (type == VMRTableType::inner) {
575  if (layerdisk == LayerDisk::L1 || layerdisk == LayerDisk::L3 || layerdisk == LayerDisk::L5 ||
576  layerdisk == LayerDisk::D1 || layerdisk == LayerDisk::D3) {
577  table_.push_back(getVMRLookup(layerdisk + 1, z, r, dz, dr));
578  }
579  if (layerdisk == LayerDisk::L2) {
580  table_.push_back(getVMRLookup(layerdisk + 1, z, r, dz, dr, Seed::L2L3));
581  }
582  }
583 
584  if (type == VMRTableType::inneroverlap) {
585  if (layerdisk == LayerDisk::L1 || layerdisk == LayerDisk::L2) {
586  table_.push_back(getVMRLookup(6, z, r, dz, dr, layerdisk + 6));
587  }
588  }
589 
590  if (type == VMRTableType::innerthird) {
591  if (layerdisk == LayerDisk::L2) { //projection from L2 to D1 for L2L3D1 seeding
593  }
594 
595  if (layerdisk == LayerDisk::L5) { //projection from L5 to L4 for L5L6L4 seeding
596  table_.push_back(getVMRLookup(LayerDisk::L4, z, r, dz, dr));
597  }
598 
599  if (layerdisk == LayerDisk::L3) { //projection from L3 to L5 for L3L4L2 seeding
600  table_.push_back(getVMRLookup(LayerDisk::L2, z, r, dz, dr));
601  }
602 
603  if (layerdisk == LayerDisk::D1) { //projection from D1 to L2 for D1D2L2 seeding
604  table_.push_back(getVMRLookup(LayerDisk::L2, z, r, dz, dr));
605  }
606  }
607  }
608  }
609 
610  if (settings_.combined()) {
611  if (type == VMRTableType::me) {
612  positive_ = false;
613  name_ = "VMRME_" + TrackletConfigBuilder::LayerName(layerdisk) + ".tab";
614  }
615  if (type == VMRTableType::disk) {
616  positive_ = false;
617  name_ = "VMRTE_" + TrackletConfigBuilder::LayerName(layerdisk) + ".tab";
618  }
619  if (type == VMRTableType::inner) {
620  positive_ = true;
621  nbits_ = 10;
622  name_ = "TP_" + TrackletConfigBuilder::LayerName(layerdisk) + TrackletConfigBuilder::LayerName(layerdisk + 1) +
623  ".tab";
624  }
625 
626  if (type == VMRTableType::inneroverlap) {
627  positive_ = true;
628  nbits_ = 10;
630  }
631 
632  } else {
633  if (type == VMRTableType::me) {
634  //This if a hack where the same memory is used in both ME and TE modules
635  if (layerdisk == LayerDisk::L2 || layerdisk == LayerDisk::L3 || layerdisk == LayerDisk::L4 ||
636  layerdisk == LayerDisk::L6) {
637  positive_ = false;
638  name_ = "VMTableOuter" + TrackletConfigBuilder::LayerName(layerdisk) + ".tab";
639  writeTable();
640  }
641 
642  assert(region >= 0);
643  char cregion = 'A' + region;
644  name_ = "VMR_" + TrackletConfigBuilder::LayerName(layerdisk) + "PHI" + cregion + "_finebin.tab";
645  positive_ = false;
646  }
647 
648  if (type == VMRTableType::inner) {
649  positive_ = false;
650  name_ = "VMTableInner" + TrackletConfigBuilder::LayerName(layerdisk) +
651  TrackletConfigBuilder::LayerName(layerdisk + 1) + ".tab";
652  }
653 
654  if (type == VMRTableType::inneroverlap) {
655  positive_ = false;
657  ".tab";
658  }
659 
660  if (type == VMRTableType::disk) {
661  positive_ = false;
662  name_ = "VMTableOuter" + TrackletConfigBuilder::LayerName(layerdisk) + ".tab";
663  }
664  }
665 
666  writeTable();
667 }
unsigned int vmrlutrbits(unsigned int layerdisk) const
Definition: Settings.h:179
double rDSSinner(unsigned int iBin) const
Definition: Settings.h:171
bool combined() const
Definition: Settings.h:258
const Settings & settings_
Definition: TrackletLUT.h:85
static std::string LayerName(unsigned int ilayer)
double zlength() const
Definition: Settings.h:124
double rmindiskvm() const
Definition: Settings.h:327
double dzmax() const
Definition: Settings.h:129
assert(be >=bs)
unsigned int NLONGVMBINS() const
Definition: Settings.h:341
std::string name_
Definition: TrackletLUT.h:87
double rmean(unsigned int iLayer) const
Definition: Settings.h:164
double rDSSouter(unsigned int iBin) const
Definition: Settings.h:174
Divides< A, C > D1
Definition: Factorize.h:136
double zmean(unsigned int iDisk) const
Definition: Settings.h:167
double drmax() const
Definition: Settings.h:128
double rmaxdisk() const
Definition: Settings.h:125
unsigned int nbits_
Definition: TrackletLUT.h:91
double rmaxdiskvm() const
Definition: Settings.h:328
int getVMRLookup(unsigned int layerdisk, double z, double r, double dz, double dr, int iseed=-1) const
Definition: TrackletLUT.cc:669
std::vector< int > table_
Definition: TrackletLUT.h:89
const int NBINS
void writeTable() const
Definition: TrackletLUT.cc:874
unsigned int vmrlutzbits(unsigned int layerdisk) const
Definition: Settings.h:178
constexpr int N_LAYER
Definition: Settings.h:21

◆ lookup()

int TrackletLUT::lookup ( unsigned int  index) const

◆ operator=()

TrackletLUT& trklet::TrackletLUT::operator= ( const TrackletLUT other)
inline

Definition at line 16 of file TrackletLUT.h.

References name_, nbits_, trackingPlots::other, positive_, and table_.

16  {
17  name_ = other.name_;
18  table_ = other.table_;
19  nbits_ = other.nbits_;
20  positive_ = other.positive_;
21 
22  return *this;
23  }
std::string name_
Definition: TrackletLUT.h:87
unsigned int nbits_
Definition: TrackletLUT.h:91
std::vector< int > table_
Definition: TrackletLUT.h:89

◆ size()

unsigned int trklet::TrackletLUT::size ( void  ) const
inline

Definition at line 77 of file TrackletLUT.h.

References table_.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), and trklet::VMStubsTEMemory::addVMStub().

77 { return table_.size(); }
std::vector< int > table_
Definition: TrackletLUT.h:89

◆ writeTable()

void TrackletLUT::writeTable ( ) const

Definition at line 874 of file TrackletLUT.cc.

References mps_fire::i, name_, nbits_, trklet::openfile(), MillePedeFileConverter_cfg::out, positive_, settings_, table_, trklet::Settings::tablePath(), and trklet::Settings::writeTable().

Referenced by initBendMatch(), initmatchcut(), initPhiCorrTable(), initProjectionBend(), initteptlut(), initTPlut(), initTPregionlut(), and initVMRTable().

874  {
875  if (!settings_.writeTable()) {
876  return;
877  }
878 
879  if (name_.empty()) {
880  return;
881  }
882 
883  ofstream out = openfile(settings_.tablePath(), name_, __FILE__, __LINE__);
884 
885  out << "{" << endl;
886  for (unsigned int i = 0; i < table_.size(); i++) {
887  if (i != 0) {
888  out << "," << endl;
889  }
890 
891  int itable = table_[i];
892  if (positive_) {
893  if (table_[i] < 0) {
894  itable = (1 << nbits_) - 1;
895  }
896  }
897 
898  out << itable;
899  }
900  out << endl << "};" << endl;
901  out.close();
902 }
bool writeTable() const
Definition: Settings.h:189
const Settings & settings_
Definition: TrackletLUT.h:85
std::string tablePath() const
Definition: Settings.h:193
std::string name_
Definition: TrackletLUT.h:87
unsigned int nbits_
Definition: TrackletLUT.h:91
std::vector< int > table_
Definition: TrackletLUT.h:89
std::ofstream openfile(const std::string &dir, const std::string &fname, const char *file, int line)
Definition: Util.h:137

Member Data Documentation

◆ name_

std::string trklet::TrackletLUT::name_
private

◆ nbits_

unsigned int trklet::TrackletLUT::nbits_
private

Definition at line 91 of file TrackletLUT.h.

Referenced by initPhiCorrTable(), initVMRTable(), operator=(), and writeTable().

◆ positive_

bool trklet::TrackletLUT::positive_
private

◆ settings_

const Settings& trklet::TrackletLUT::settings_
private

◆ table_

std::vector<int> trklet::TrackletLUT::table_
private