CMS 3D CMS Logo

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

#include <FPGAWord.h>

Public Member Functions

bool atExtreme () const
 
unsigned int bits (unsigned int lsb, unsigned int nbit) const
 
 FPGAWord ()
 
 FPGAWord (int value, int nbits, bool positive=true, int line=-1, const char *file=nullptr)
 
int nbits () const
 
bool operator== (const FPGAWord &other) const
 
void set (int value, int nbits, bool positive=true, int line=-1, const char *file=nullptr)
 
std::string str () const
 
int value () const
 
 ~FPGAWord ()=default
 

Private Attributes

int nbits_ {-1}
 
bool positive_ {true}
 
int value_ {-1}
 

Detailed Description

Definition at line 9 of file FPGAWord.h.

Constructor & Destructor Documentation

◆ FPGAWord() [1/2]

FPGAWord::FPGAWord ( )

Definition at line 8 of file FPGAWord.cc.

8 {}

◆ FPGAWord() [2/2]

FPGAWord::FPGAWord ( int  value,
int  nbits,
bool  positive = true,
int  line = -1,
const char *  file = nullptr 
)

Definition at line 10 of file FPGAWord.cc.

10  {
11  set(value, nbits, positive, line, file);
12 }

References FrontierConditions_GlobalTag_cff::file, and mps_splice::line.

◆ ~FPGAWord()

trklet::FPGAWord::~FPGAWord ( )
default

Member Function Documentation

◆ atExtreme()

bool FPGAWord::atExtreme ( ) const

Definition at line 79 of file FPGAWord.cc.

79  {
80  if (positive_) {
81  return (value_ == 0) || (value_ == (1 << nbits_) - 1);
82  }
83  return ((value_ == (-(1 << (nbits_ - 1)))) || (value_ == ((1 << (nbits_ - 1)) - 1)));
84 }

Referenced by trklet::TrackletCalculatorDisplaced::addLayerProj(), and trklet::TrackletCalculatorBase::addLayerProj().

◆ bits()

unsigned int FPGAWord::bits ( unsigned int  lsb,
unsigned int  nbit 
) const

Definition at line 74 of file FPGAWord.cc.

74  {
75  assert(lsb + nbit <= (unsigned int)nbits());
76  return (value_ >> lsb) & ((1 << nbit) - 1);
77 }

References cms::cuda::assert().

Referenced by trklet::ProjectionRouter::execute(), trklet::TrackletEngine::execute(), and trklet::TrackletProcessor::execute().

◆ nbits()

int trklet::FPGAWord::nbits ( ) const
inline

◆ operator==()

bool FPGAWord::operator== ( const FPGAWord other) const

Definition at line 86 of file FPGAWord.cc.

86  {
87  return (value_ == other.value_) && (nbits_ == other.nbits_) && (positive_ == other.positive_);
88 }

References trackingPlots::other.

◆ set()

void FPGAWord::set ( int  value,
int  nbits,
bool  positive = true,
int  line = -1,
const char *  file = nullptr 
)

Definition at line 14 of file FPGAWord.cc.

14  {
15  value_ = value;
16  nbits_ = nbits;
17  positive_ = positive;
18  if (positive) {
19  if (value < 0) {
20  edm::LogProblem("Tracklet") << "FPGAWord got negative value:" << value << " (" << file << ":" << line << ")";
21  }
22  assert(value >= 0);
23  }
24  if (nbits >= 22) {
25  edm::LogPrint("Tracklet") << "FPGAWord got too many bits:" << nbits << " (" << file << ":" << line << ")";
26  }
27  assert(nbits < 22);
28  if (nbits <= 0) {
29  edm::LogPrint("Tracklet") << "FPGAWord got too few bits:" << nbits << " (" << file << ":" << line << ")";
30  }
31  assert(nbits > 0);
32  if (positive) {
33  if (value >= (1 << nbits)) {
34  if (file != nullptr) {
35  edm::LogProblem("Tracklet") << "value too large:" << value << " " << (1 << nbits) << " (" << file << ":" << line
36  << ")";
37  }
38  }
39  assert(value < (1 << nbits));
40  } else {
41  if (value > (1 << (nbits - 1))) {
42  edm::LogProblem("Tracklet") << "value too large:" << value << " " << (1 << (nbits - 1)) << " (" << file << ":"
43  << line << ")";
44  }
45  assert(value <= (1 << (nbits - 1)));
46  if (value < -(1 << (nbits - 1))) {
47  edm::LogProblem("Tracklet") << "value too negative:" << value << " " << -(1 << (nbits - 1)) << " (" << file << ":"
48  << line << ")";
49  }
50  assert(value >= -(1 << (nbits - 1)));
51  }
52 }

References cms::cuda::assert(), FrontierConditions_GlobalTag_cff::file, mps_splice::line, and relativeConstraints::value.

Referenced by trklet::TrackletEventProcessor::event(), trklet::VMRouter::execute(), trklet::TrackDerTable::fillTable(), trklet::Tracklet::fullmatchdiskstr(), trklet::Tracklet::fullmatchstr(), trklet::Stub::setAllStubIndex(), trklet::DiskProjection::setBendIndex(), trklet::Tracklet::setFitPars(), trklet::Stub::setPhiCorr(), trklet::Stub::Stub(), trklet::FitTrack::trackFitChisq(), trklet::Tracklet::Tracklet(), trklet::Tracklet::trackletprojstr(), and trklet::Tracklet::trackletprojstrD().

◆ str()

std::string FPGAWord::str ( ) const

Definition at line 54 of file FPGAWord.cc.

54  {
55  const int nbit = nbits_;
56 
57  if (!(nbit > 0 && nbit < 22))
58  edm::LogVerbatim("Tracklet") << "nbit: " << nbit;
59  if (nbit == -1)
60  return "?";
61  if (nbit == 0)
62  return "~";
63 
64  int valtmp = value_;
65  string str = "";
66  for (int i = 0; i < nbit; i++) {
67  str = ((valtmp & 1) ? "1" : "0") + str;
68  valtmp >>= 1;
69  }
70 
71  return str;
72 }

References mps_fire::i, and str.

Referenced by trklet::TrackletEventProcessor::event(), trklet::TrackDerTable::fillTable(), trklet::Tracklet::fullmatchdiskstr(), trklet::Tracklet::fullmatchstr(), trklet::Stub::phiregionaddressstr(), trklet::Stub::str(), trklet::Stub::strbare(), trklet::FitTrack::trackFitChisq(), trklet::Tracklet::trackfitstr(), trklet::Tracklet::trackletparstr(), trklet::Tracklet::trackletprojstr(), trklet::Tracklet::trackletprojstrD(), trklet::Tracklet::vmstrdisk(), trklet::Tracklet::vmstrlayer(), and trklet::VMStubsMEMemory::writeStubs().

◆ value()

int trklet::FPGAWord::value ( void  ) const
inline

Definition at line 24 of file FPGAWord.h.

24 { return value_; }

References value_.

Referenced by trklet::TrackletCalculatorDisplaced::addDiskProj(), trklet::TrackletCalculatorBase::addDiskProj(), trklet::TrackletCalculatorDisplaced::addLayerProj(), trklet::TrackletCalculatorBase::addLayerProj(), trklet::InputLinkMemory::addStub(), trklet::VMStubsTEMemory::addVMStub(), average.Average::average(), trklet::TrackletCalculatorBase::barrelSeeding(), trklet::TrackletCalculatorDisplaced::DDLSeeding(), trklet::TrackletCalculatorBase::diskSeeding(), trklet::MatchEngine::execute(), trklet::ProjectionRouter::execute(), trklet::TrackletEngine::execute(), trklet::TripletEngine::execute(), trklet::TrackletEngineDisplaced::execute(), trklet::MatchCalculator::execute(), trklet::TrackletProcessor::execute(), trklet::MatchProcessor::execute(), trklet::VMRouter::execute(), trklet::Tracklet::finervm(), trklet::Tracklet::finezvm(), trklet::Tracklet::fit(), trklet::PurgeDuplicate::getPhiRes(), trklet::Tracklet::getStubIDs(), trklet::Tracklet::ichiSqfit(), trklet::Stub::iphivmFineBins(), trklet::Stub::isBarrel(), trklet::Stub::isDisk(), trklet::Stub::isPSmodule(), trklet::Stub::layerdisk(), trklet::TrackletCalculatorDisplaced::LLDSeeding(), trklet::TrackletCalculatorDisplaced::LLLSeeding(), trklet::Tracklet::makeTrack(), trklet::MatchProcessor::matchCalculator(), trklet::TrackletCalculatorBase::overlapSeeding(), trklet::Stub::phiapprox(), trklet::Tracklet::phiprojvm(), trklet::Stub::phiregionaddress(), trklet::Stub::phiregionaddressstr(), trklet::Stub::rapprox(), trklet::Tracklet::rbin1projvm(), trklet::Tracklet::rbin2projvm(), trklet::Stub::setPhiCorr(), trklet::MatchEngineUnit::step(), trklet::Stub::str(), trklet::FitTrack::trackFitChisq(), trklet::FitTrack::trackFitFake(), trklet::Tracklet::vmstrlayer(), trklet::Stub::zapprox(), trklet::Tracklet::zbin1projvm(), trklet::Tracklet::zbin2projvm(), and trklet::Tracklet::zprojvm().

Member Data Documentation

◆ nbits_

int trklet::FPGAWord::nbits_ {-1}
private

Definition at line 33 of file FPGAWord.h.

Referenced by nbits().

◆ positive_

bool trklet::FPGAWord::positive_ {true}
private

Definition at line 34 of file FPGAWord.h.

◆ value_

int trklet::FPGAWord::value_ {-1}
private

Definition at line 32 of file FPGAWord.h.

Referenced by value().

mps_fire.i
i
Definition: mps_fire.py:355
trklet::FPGAWord::str
std::string str() const
Definition: FPGAWord.cc:54
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
trklet::FPGAWord::nbits_
int nbits_
Definition: FPGAWord.h:33
trklet::FPGAWord::nbits
int nbits() const
Definition: FPGAWord.h:25
trackingPlots.other
other
Definition: trackingPlots.py:1465
edm::LogProblem
Definition: MessageLogger.h:387
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
value
Definition: value.py:1
edm::LogVerbatim
Definition: MessageLogger.h:297
edm::LogPrint
Definition: MessageLogger.h:342
trklet::FPGAWord::value_
int value_
Definition: FPGAWord.h:32
trklet::FPGAWord::value
int value() const
Definition: FPGAWord.h:24
mps_splice.line
line
Definition: mps_splice.py:76
trklet::FPGAWord::positive_
bool positive_
Definition: FPGAWord.h:34