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.

References geometryDiff::file, mps_splice::line, and relativeConstraints::value.

10  {
11  set(value, nbits, positive, line, file);
12 }
int value() const
Definition: FPGAWord.h:24
int nbits() const
Definition: FPGAWord.h:25

◆ ~FPGAWord()

trklet::FPGAWord::~FPGAWord ( )
default

Member Function Documentation

◆ atExtreme()

bool FPGAWord::atExtreme ( ) const

Definition at line 79 of file FPGAWord.cc.

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

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 }

◆ bits()

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

◆ nbits()

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

◆ operator==()

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

Definition at line 86 of file FPGAWord.cc.

References trackingPlots::other.

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

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

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

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

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)) - 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 }
assert(be >=bs)
int value() const
Definition: FPGAWord.h:24
Definition: value.py:1
Log< level::Warning, true > LogPrint
int nbits() const
Definition: FPGAWord.h:25
Log< level::Error, true > LogProblem

◆ str()

std::string FPGAWord::str ( ) const

Definition at line 54 of file FPGAWord.cc.

References mps_fire::i, and str.

Referenced by trklet::Tracklet::diskstubstr(), trklet::FitTrack::execute(), trklet::TrackDerTable::fillTable(), trklet::Tracklet::fullmatchdiskstr(), trklet::Tracklet::fullmatchstr(), trklet::Tracklet::layerstubstr(), trklet::Stub::phiregionaddressstr(), trklet::Stub::str(), trklet::Stub::strbare(), trklet::Stub::strinner(), trklet::FitTrack::trackFitChisq(), trklet::Tracklet::trackletparstr(), trklet::Tracklet::trackletprojstr(), trklet::Tracklet::trackletprojstrD(), trklet::Tracklet::vmstrdisk(), trklet::Tracklet::vmstrlayer(), trklet::DTCLinkMemory::writeStubs(), and trklet::VMStubsMEMemory::writeStubs().

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 }
Log< level::Info, true > LogVerbatim
std::string str() const
Definition: FPGAWord.cc:54

◆ value()

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

Definition at line 24 of file FPGAWord.h.

References value_.

Referenced by trklet::TrackletCalculatorDisplaced::addDiskProj(), trklet::TrackletCalculatorBase::addDiskProj(), trklet::TrackletCalculatorDisplaced::addLayerProj(), trklet::TrackletCalculatorBase::addLayerProj(), trklet::Sector::addStub(), trklet::VMStubsTEMemory::addVMStub(), average.Average::average(), trklet::TrackletCalculatorBase::barrelSeeding(), trklet::TrackletCalculatorDisplaced::DDLSeeding(), trklet::TrackletCalculatorBase::diskSeeding(), trklet::MatchEngine::execute(), trklet::TrackletEngine::execute(), trklet::TripletEngine::execute(), trklet::TrackletEngineDisplaced::execute(), trklet::MatchCalculator::execute(), trklet::MatchProcessor::execute(), trklet::TrackletProcessor::execute(), trklet::TrackletProcessorDisplaced::execute(), trklet::VMRouterCM::execute(), trklet::VMRouter::execute(), trklet::Tracklet::fit(), trklet::Tracklet::getStubIDs(), trklet::Tracklet::ichiSqfit(), trklet::Stub::iphivmFineBins(), 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::Stub::phiregionaddress(), trklet::Stub::phiregionaddressstr(), trklet::MatchEngineUnit::processPipeline(), trklet::Stub::rapprox(), trklet::Stub::setPhiCorr(), trklet::TrackletEngineUnit::step(), trklet::Stub::str(), trklet::FitTrack::trackFitChisq(), trklet::FitTrack::trackFitFake(), trklet::Tracklet::vmstrlayer(), and trklet::Stub::zapprox().

24 { return value_; }

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().