CMS 3D CMS Logo

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

#include <Stub.h>

Public Member Functions

FPGAWord allStubIndex () const
 
const FPGAWordalpha () const
 
const FPGAWordbend () const
 
const FPGAWorddisk () const
 
FPGAWord iphivmFineBins (int VMbits, int finebits) const
 
bool isBarrel () const
 
bool isPSmodule () const
 
L1TStubl1tstub ()
 
const L1TStubl1tstub () const
 
const FPGAWordlayer () const
 
unsigned int layerdisk () const
 
const FPGAWordphi () const
 
double phiapprox (double phimin, double) const
 
const FPGAWordphicorr () const
 
unsigned int phiregionaddress () const
 
std::string phiregionaddressstr () const
 
const FPGAWordr () const
 
double rapprox () const
 
void setAllStubIndex (int nstub)
 
void setl1tstub (L1TStub *l1tstub)
 
void setPhiCorr (int phiCorr)
 
std::string str () const
 
std::string strbare () const
 
std::string strinner () const
 
 Stub (L1TStub &stub, Settings const &settings, Globals &globals)
 
 Stub (Settings const &settings)
 
const FPGAWordstubindex () const
 
const FPGAWordz () const
 
double zapprox () const
 
 ~Stub ()=default
 

Private Attributes

FPGAWord alpha_
 
FPGAWord bend_
 
FPGAWord disk_
 
L1TStubl1tstub_
 
FPGAWord layer_
 
unsigned int layerdisk_
 
FPGAWord phi_
 
FPGAWord phicorr_
 
FPGAWord r_
 
Settings const & settings_
 
FPGAWord stubindex_
 
FPGAWord z_
 

Detailed Description

Definition at line 18 of file Stub.h.

Constructor & Destructor Documentation

◆ Stub() [1/2]

Stub::Stub ( Settings const &  settings)

Definition at line 15 of file Stub.cc.

15 : settings_(settings) {}

◆ Stub() [2/2]

Stub::Stub ( L1TStub stub,
Settings const &  settings,
Globals globals 
)

Definition at line 17 of file Stub.cc.

17  : settings_(settings) {
18  const string& stubwordhex = stub.stubword();
19 
20  const string stubwordbin = convertHexToBin(stubwordhex);
21 
22  layerdisk_ = stub.layerdisk();
23 
24  int nbendbits = stub.isPSmodule() ? N_BENDBITS_PS : N_BENDBITS_2S;
25 
26  int nalphabits = 0;
27 
28  int nrbits = settings_.nrbitsstub(layerdisk_);
29  int nzbits = settings_.nzbitsstub(layerdisk_);
30  int nphibits = settings_.nphibitsstub(layerdisk_);
31 
32  if (layerdisk_ >= N_LAYER && !stub.isPSmodule()) {
33  nalphabits = settings.nbitsalpha();
34  nrbits = 7;
35  }
36 
37  assert(nbendbits + nalphabits + nrbits + nzbits + nphibits == 36);
38 
39  bitset<32> rbits(stubwordbin.substr(0, nrbits));
40  bitset<32> zbits(stubwordbin.substr(nrbits, nzbits));
41  bitset<32> phibits(stubwordbin.substr(nrbits + nzbits, nphibits));
42  bitset<32> alphabits(stubwordbin.substr(nphibits + nzbits + nrbits, nalphabits));
43  bitset<32> bendbits(stubwordbin.substr(nphibits + nzbits + nrbits + nalphabits, nbendbits));
44 
45  int newbend = bendbits.to_ulong();
46 
47  int newr = rbits.to_ulong();
48  if (layerdisk_ < N_LAYER) {
49  if (newr >= (1 << (nrbits - 1)))
50  newr = newr - (1 << nrbits);
51  }
52 
53  int newz = zbits.to_ulong();
54  if (newz >= (1 << (nzbits - 1)))
55  newz = newz - (1 << nzbits);
56 
57  int newphi = phibits.to_ulong();
58 
59  int newalpha = alphabits.to_ulong();
60  if (newalpha >= (1 << (nalphabits - 1)))
61  newalpha = newalpha - (1 << nalphabits);
62 
63  l1tstub_ = &stub;
64 
65  bend_.set(newbend, nbendbits, true, __LINE__, __FILE__);
66 
67  phi_.set(newphi, nphibits, true, __LINE__, __FILE__);
68  phicorr_.set(newphi, nphibits, true, __LINE__, __FILE__);
69  bool pos = false;
70  if (layerdisk_ >= N_LAYER) {
71  pos = true;
72  int disk = layerdisk_ - N_LAYER + 1;
73  if (stub.z() < 0.0)
74  disk = -disk;
75  disk_.set(disk, 4, false, __LINE__, __FILE__);
76  if (!stub.isPSmodule()) {
77  alpha_.set(newalpha, nalphabits, false, __LINE__, __FILE__);
78  nrbits = 4;
79  }
80  } else {
81  disk_.set(0, 4, false, __LINE__, __FILE__);
82  layer_.set(layerdisk_, 3, true, __LINE__, __FILE__);
83  }
84  r_.set(newr, nrbits, pos, __LINE__, __FILE__);
85  z_.set(newz, nzbits, false, __LINE__, __FILE__);
86 
87  if (settings.writeMonitorData("StubBend")) {
88  unsigned int nsimtrks = globals.event()->nsimtracks();
89 
90  for (unsigned int isimtrk = 0; isimtrk < nsimtrks; isimtrk++) {
91  const L1SimTrack& simtrk = globals.event()->simtrack(isimtrk);
92  if (stub.tpmatch2(simtrk.trackid())) {
93  double dr = 0.18;
94  double rinv = simtrk.charge() * 0.01 * settings_.c() * settings_.bfield() / simtrk.pt();
95  double pitch = settings_.stripPitch(stub.isPSmodule());
96  double bend = stub.r() * dr * 0.5 * rinv / pitch;
97 
98  globals.ofstream("stubbend.dat") << layerdisk_ << " " << stub.isPSmodule() << " "
99  << simtrk.pt() * simtrk.charge() << " " << bend << " " << newbend << " "
100  << settings.benddecode(newbend, layerdisk_, stub.isPSmodule()) << " "
101  << settings.bendcut(newbend, layerdisk_, stub.isPSmodule()) << endl;
102  }
103  }
104  }
105 }

References alpha_, cms::cuda::assert(), bend(), bend_, trklet::Settings::bendcut(), trklet::Settings::benddecode(), trklet::Settings::bfield(), trklet::Settings::c(), trklet::L1SimTrack::charge(), trklet::convertHexToBin(), disk(), disk_, flavorHistoryFilter_cfi::dr, trklet::Globals::event(), trklet::L1TStub::isPSmodule(), l1tstub_, layer_, trklet::L1TStub::layerdisk(), layerdisk_, trklet::N_BENDBITS_2S, trklet::N_BENDBITS_PS, trklet::N_LAYER, trklet::Settings::nbitsalpha(), trklet::Settings::nphibitsstub(), trklet::Settings::nrbitsstub(), trklet::SLHCEvent::nsimtracks(), trklet::Settings::nzbitsstub(), trklet::Globals::ofstream(), phi_, phicorr_, trklet::L1SimTrack::pt(), trklet::L1TStub::r(), r_, trklet::rinv(), trklet::FPGAWord::set(), settings_, trklet::SLHCEvent::simtrack(), trklet::Settings::stripPitch(), trklet::L1TStub::stubword(), trklet::L1TStub::tpmatch2(), trklet::L1SimTrack::trackid(), trklet::Settings::writeMonitorData(), trklet::L1TStub::z(), and z_.

◆ ~Stub()

trklet::Stub::~Stub ( )
default

Member Function Documentation

◆ allStubIndex()

FPGAWord trklet::Stub::allStubIndex ( ) const
inline

Definition at line 49 of file Stub.h.

49 { return stubindex_; }

References stubindex_.

◆ alpha()

const FPGAWord& trklet::Stub::alpha ( void  ) const
inline

◆ bend()

const FPGAWord& trklet::Stub::bend ( ) const
inline

◆ disk()

const FPGAWord& trklet::Stub::disk ( ) const
inline

◆ iphivmFineBins()

FPGAWord Stub::iphivmFineBins ( int  VMbits,
int  finebits 
) const

Definition at line 107 of file Stub.cc.

107  {
108  unsigned int finephi = (phicorr_.value() >> (phicorr_.nbits() - VMbits - finebits)) & ((1 << finebits) - 1);
109  return FPGAWord(finephi, finebits, true, __LINE__, __FILE__);
110 }

References trklet::FPGAWord::nbits(), phicorr_, and trklet::FPGAWord::value().

Referenced by trklet::VMRouterCM::execute(), and trklet::VMRouter::execute().

◆ isBarrel()

bool trklet::Stub::isBarrel ( ) const
inline

◆ isPSmodule()

bool trklet::Stub::isPSmodule ( ) const
inline

◆ l1tstub() [1/2]

L1TStub* trklet::Stub::l1tstub ( )
inline

◆ l1tstub() [2/2]

const L1TStub* trklet::Stub::l1tstub ( ) const
inline

Definition at line 78 of file Stub.h.

78 { return l1tstub_; }

References l1tstub_.

◆ layer()

const FPGAWord& trklet::Stub::layer ( ) const
inline

◆ layerdisk()

unsigned int Stub::layerdisk ( ) const

◆ phi()

const FPGAWord& trklet::Stub::phi ( void  ) const
inline

◆ phiapprox()

double Stub::phiapprox ( double  phimin,
double   
) const

◆ phicorr()

const FPGAWord& trklet::Stub::phicorr ( ) const
inline

◆ phiregionaddress()

unsigned int Stub::phiregionaddress ( ) const

◆ phiregionaddressstr()

std::string Stub::phiregionaddressstr ( ) const

Definition at line 117 of file Stub.cc.

117  {
119  FPGAWord phiregion(iphi, 3, true, __LINE__, __FILE__);
120  return phiregion.str() + stubindex_.str();
121 }

References LEDCalibrationChannels::iphi, layerdisk(), trklet::FPGAWord::nbits(), trklet::Settings::nbitsallstubs(), phicorr_, settings_, trklet::FPGAWord::str(), stubindex_, and trklet::FPGAWord::value().

Referenced by trklet::Tracklet::addressstr().

◆ r()

const FPGAWord& trklet::Stub::r ( ) const
inline

◆ rapprox()

double Stub::rapprox ( ) const

◆ setAllStubIndex()

void Stub::setAllStubIndex ( int  nstub)

Definition at line 123 of file Stub.cc.

123  {
124  if (nstub >= (1 << N_BITSMEMADDRESS)) {
125  if (settings_.debugTracklet())
126  edm::LogPrint("Tracklet") << "Warning too large stubindex!";
127  nstub = (1 << N_BITSMEMADDRESS) - 1;
128  }
129 
131 }

References trklet::Settings::debugTracklet(), trklet::N_BITSMEMADDRESS, trklet::FPGAWord::set(), settings_, and stubindex_.

Referenced by trklet::VMRouterCM::execute(), and trklet::VMRouter::execute().

◆ setl1tstub()

void trklet::Stub::setl1tstub ( L1TStub l1tstub)
inline

Definition at line 79 of file Stub.h.

79 { l1tstub_ = l1tstub; }

References l1tstub(), and l1tstub_.

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

◆ setPhiCorr()

void Stub::setPhiCorr ( int  phiCorr)

Definition at line 133 of file Stub.cc.

133  {
134  int iphicorr = phi_.value() - phiCorr;
135 
136  if (iphicorr < 0)
137  iphicorr = 0;
138  if (iphicorr >= (1 << phi_.nbits()))
139  iphicorr = (1 << phi_.nbits()) - 1;
140 
141  phicorr_.set(iphicorr, phi_.nbits(), true, __LINE__, __FILE__);
142 }

References trklet::FPGAWord::nbits(), phi_, phicorr_, trklet::FPGAWord::set(), and trklet::FPGAWord::value().

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

◆ str()

std::string trklet::Stub::str ( ) const
inline

Definition at line 28 of file Stub.h.

28  {
29  if (layer_.value() != -1) {
30  return r_.str() + "|" + z_.str() + "|" + phi_.str() + "|" + bend_.str();
31  } else {
32  if (isPSmodule()) {
33  return r_.str() + "|" + z_.str() + "|" + phi_.str() + "|" + bend_.str();
34  } else {
35  return "000" + r_.str() + "|" + z_.str() + "|" + phi_.str() + "|" + alpha_.str() + "|" + bend_.str();
36  }
37  }
38  }

References alpha_, bend_, isPSmodule(), layer_, phi_, r_, trklet::FPGAWord::str(), trklet::FPGAWord::value(), and z_.

Referenced by strinner().

◆ strbare()

std::string trklet::Stub::strbare ( ) const
inline

Definition at line 40 of file Stub.h.

40 { return bend_.str() + r_.str() + z_.str() + phi_.str(); }

References bend_, phi_, r_, trklet::FPGAWord::str(), and z_.

◆ strinner()

std::string trklet::Stub::strinner ( ) const
inline

Definition at line 42 of file Stub.h.

42  {
43  unsigned int nbitsfinephi = 8;
44  FPGAWord finephi(
45  phicorr_.bits(phicorr_.nbits() - nbitsfinephi, nbitsfinephi), nbitsfinephi, true, __LINE__, __FILE__);
46  return str() + "|" + stubindex_.str() + "|" + finephi.str();
47  }

References trklet::FPGAWord::bits(), trklet::FPGAWord::nbits(), phicorr_, trklet::FPGAWord::str(), str(), and stubindex_.

◆ stubindex()

const FPGAWord& trklet::Stub::stubindex ( ) const
inline

◆ z()

const FPGAWord& trklet::Stub::z ( ) const
inline

◆ zapprox()

double Stub::zapprox ( ) const

Definition at line 158 of file Stub.cc.

158  {
159  if (disk_.value() == 0) {
160  int lz = 1;
161  if (layer_.value() >= 3) {
162  lz = 16;
163  }
164  return z_.value() * settings_.kz() * lz;
165  }
166  int sign = 1;
167  if (disk_.value() < 0)
168  sign = -1;
169  if (sign < 0) {
170  //Should understand why this is needed to get agreement with integer calculations
171  return (z_.value() + 1) * settings_.kz() + sign * settings_.zmean(abs(disk_.value()) - 1);
172  } else {
173  return z_.value() * settings_.kz() + sign * settings_.zmean(abs(disk_.value()) - 1);
174  }
175 }

References funct::abs(), disk_, trklet::Settings::kz(), layer_, settings_, Validation_hcalonly_cfi::sign, trklet::FPGAWord::value(), z_, and trklet::Settings::zmean().

Referenced by trklet::TrackletCalculatorBase::barrelSeeding(), trklet::TrackletCalculatorDisplaced::DDLSeeding(), trklet::TrackletCalculatorBase::diskSeeding(), trklet::MatchCalculator::execute(), trklet::TrackletCalculatorDisplaced::LLDSeeding(), trklet::TrackletCalculatorDisplaced::LLLSeeding(), trklet::MatchProcessor::matchCalculator(), and trklet::TrackletCalculatorBase::overlapSeeding().

Member Data Documentation

◆ alpha_

FPGAWord trklet::Stub::alpha_
private

Definition at line 91 of file Stub.h.

Referenced by alpha(), str(), and Stub().

◆ bend_

FPGAWord trklet::Stub::bend_
private

Definition at line 93 of file Stub.h.

Referenced by bend(), str(), strbare(), and Stub().

◆ disk_

FPGAWord trklet::Stub::disk_
private

Definition at line 87 of file Stub.h.

Referenced by disk(), layerdisk(), rapprox(), Stub(), and zapprox().

◆ l1tstub_

L1TStub* trklet::Stub::l1tstub_
private

Definition at line 99 of file Stub.h.

Referenced by l1tstub(), rapprox(), setl1tstub(), and Stub().

◆ layer_

FPGAWord trklet::Stub::layer_
private

Definition at line 86 of file Stub.h.

Referenced by layer(), layerdisk(), phiapprox(), rapprox(), str(), Stub(), and zapprox().

◆ layerdisk_

unsigned int trklet::Stub::layerdisk_
private

Definition at line 84 of file Stub.h.

Referenced by isBarrel(), isPSmodule(), and Stub().

◆ phi_

FPGAWord trklet::Stub::phi_
private

Definition at line 90 of file Stub.h.

Referenced by phi(), phiapprox(), setPhiCorr(), str(), strbare(), and Stub().

◆ phicorr_

FPGAWord trklet::Stub::phicorr_
private

◆ r_

FPGAWord trklet::Stub::r_
private

Definition at line 88 of file Stub.h.

Referenced by isPSmodule(), r(), rapprox(), str(), strbare(), and Stub().

◆ settings_

Settings const& trklet::Stub::settings_
private

◆ stubindex_

FPGAWord trklet::Stub::stubindex_
private

◆ z_

FPGAWord trklet::Stub::z_
private

Definition at line 89 of file Stub.h.

Referenced by str(), strbare(), Stub(), z(), and zapprox().

trklet::Stub::phi_
FPGAWord phi_
Definition: Stub.h:90
trklet::N_PSLAYER
constexpr unsigned int N_PSLAYER
Definition: Settings.h:23
trklet::FPGAWord::str
std::string str() const
Definition: FPGAWord.cc:54
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
trklet::Stub::bend
const FPGAWord & bend() const
Definition: Stub.h:58
trklet::Stub::r_
FPGAWord r_
Definition: Stub.h:88
trklet::Stub::layer_
FPGAWord layer_
Definition: Stub.h:86
pos
Definition: PixelAliasList.h:18
trklet::L1TStub::z
double z() const
Definition: L1TStub.h:57
trklet::convertHexToBin
std::string convertHexToBin(const std::string &stubwordhex)
Definition: Util.h:60
trklet::Settings::nbitsallstubs
unsigned int nbitsallstubs(unsigned int layerdisk) const
Definition: Settings.h:106
cms::cuda::assert
assert(be >=bs)
trklet::FPGAWord::set
void set(int value, int nbits, bool positive=true, int line=-1, const char *file=nullptr)
Definition: FPGAWord.cc:14
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
trklet::L1SimTrack
Definition: L1SimTrack.h:14
trklet::Settings::rmean
double rmean(unsigned int iLayer) const
Definition: Settings.h:164
trklet::FPGAWord::nbits
int nbits() const
Definition: FPGAWord.h:25
trklet::Stub::bend_
FPGAWord bend_
Definition: Stub.h:93
trklet::Settings::rDSSinner
double rDSSinner(unsigned int iBin) const
Definition: Settings.h:171
trklet::Stub::phicorr_
FPGAWord phicorr_
Definition: Stub.h:95
trklet::Settings::bfield
double bfield() const
Definition: Settings.h:253
trklet::Settings::nrbitsstub
unsigned int nrbitsstub(unsigned int layerdisk) const
Definition: Settings.h:84
trklet::Stub::disk_
FPGAWord disk_
Definition: Stub.h:87
trklet::Settings::rDSSouter
double rDSSouter(unsigned int iBin) const
Definition: Settings.h:174
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
trklet::Stub::z_
FPGAWord z_
Definition: Stub.h:89
trklet::L1SimTrack::trackid
int trackid() const
Definition: L1SimTrack.h:24
trklet::Stub::disk
const FPGAWord & disk() const
Definition: Stub.h:68
trklet::N_BENDBITS_2S
constexpr unsigned int N_BENDBITS_2S
Definition: Settings.h:30
trklet::FPGAWord::bits
unsigned int bits(unsigned int lsb, unsigned int nbit) const
Definition: FPGAWord.cc:74
trklet::L1TStub::isPSmodule
unsigned int isPSmodule() const
Definition: L1TStub.h:94
trklet::N_LAYER
constexpr int N_LAYER
Definition: Settings.h:21
trklet::Settings::zmean
double zmean(unsigned int iDisk) const
Definition: Settings.h:167
trklet::Stub::layerdisk
unsigned int layerdisk() const
Definition: Stub.cc:185
trklet::L1TStub::layerdisk
int layerdisk() const
Definition: L1TStub.h:104
trklet::FPGAWord
Definition: FPGAWord.h:9
trklet::Settings::kr
double kr() const
Definition: Settings.h:304
trklet::L1TStub::tpmatch2
bool tpmatch2(int tp) const
Definition: L1TStub.cc:111
trklet::rinv
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:49
trklet::L1SimTrack::pt
double pt() const
Definition: L1SimTrack.h:26
trklet::Settings::nzbitsstub
unsigned int nzbitsstub(unsigned int layerdisk) const
Definition: Settings.h:82
trklet::SLHCEvent::nsimtracks
unsigned int nsimtracks() const
Definition: SLHCEvent.h:59
trklet::Settings::nphibitsstub
unsigned int nphibitsstub(unsigned int layerdisk) const
Definition: Settings.h:83
trklet::FPGAWord::value
int value() const
Definition: FPGAWord.h:24
trklet::Settings::stripPitch
double stripPitch(bool isPSmodule) const
Definition: Settings.h:260
trklet::Settings::kphi
double kphi() const
Definition: Settings.h:298
trklet::L1SimTrack::charge
int charge() const
Definition: L1SimTrack.h:34
trklet::N_BITSMEMADDRESS
constexpr unsigned int N_BITSMEMADDRESS
Definition: Settings.h:39
trklet::Stub::str
std::string str() const
Definition: Stub.h:28
trklet::L1TStub::stubword
const std::string & stubword() const
Definition: L1TStub.h:108
trklet::Globals::ofstream
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
trklet::Stub::l1tstub
L1TStub * l1tstub()
Definition: Stub.h:77
trklet::Globals::event
SLHCEvent *& event()
Definition: Globals.h:36
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
trklet::Settings::kz
double kz() const
Definition: Settings.h:302
trklet::Settings::debugTracklet
bool debugTracklet() const
Definition: Settings.h:182
trklet::Stub::isPSmodule
bool isPSmodule() const
Definition: Stub.h:71
trklet::L1TStub::r
double r() const
Definition: L1TStub.h:58
trklet::N_BENDBITS_PS
constexpr unsigned int N_BENDBITS_PS
Definition: Settings.h:29
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
trklet::Stub::layerdisk_
unsigned int layerdisk_
Definition: Stub.h:84
trklet::SLHCEvent::simtrack
const L1SimTrack & simtrack(int i) const
Definition: SLHCEvent.h:61
trklet::Stub::settings_
Settings const & settings_
Definition: Stub.h:100
trklet::Settings::c
double c() const
Definition: Settings.h:212
edm::Log
Definition: MessageLogger.h:70
trklet::Stub::stubindex_
FPGAWord stubindex_
Definition: Stub.h:97
trklet::Stub::l1tstub_
L1TStub * l1tstub_
Definition: Stub.h:99
trklet::Stub::alpha_
FPGAWord alpha_
Definition: Stub.h:91
reco::reduceRange
constexpr T reduceRange(T x)
Definition: deltaPhi.h:18