CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::FPGAWord ( )

Definition at line 8 of file FPGAWord.cc.

8 {}
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 }
int nbits() const
Definition: FPGAWord.h:25
int value() const
Definition: FPGAWord.h:24
void set(int value, int nbits, bool positive=true, int line=-1, const char *file=nullptr)
Definition: FPGAWord.cc:14
trklet::FPGAWord::~FPGAWord ( )
default

Member Function Documentation

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 }
unsigned int FPGAWord::bits ( unsigned int  lsb,
unsigned int  nbit 
) const

Definition at line 74 of file FPGAWord.cc.

References cms::cuda::assert().

Referenced by trklet::ProjectionRouter::execute(), trklet::TrackletEngine::execute(), trklet::MatchProcessor::execute(), trklet::TrackletProcessor::execute(), trklet::VMRouterCM::execute(), trklet::VMRouter::execute(), and trklet::Stub::strinner().

74  {
75  assert(lsb + nbit <= (unsigned int)nbits());
76  return (value_ >> lsb) & ((1 << nbit) - 1);
77 }
int nbits() const
Definition: FPGAWord.h:25
assert(be >=bs)
int trklet::FPGAWord::nbits ( ) const
inline
bool FPGAWord::operator== ( const FPGAWord other) const

Definition at line 86 of file FPGAWord.cc.

References nbits_, positive_, and value_.

86  {
87  return (value_ == other.value_) && (nbits_ == other.nbits_) && (positive_ == other.positive_);
88 }
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(), 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(), trklet::Tracklet::trackletprojstrD(), trklet::Tracklet::vmstrdisk(), trklet::Tracklet::vmstrlayer(), and trklet::CandidateMatchMemory::writeCM().

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

Definition at line 24 of file FPGAWord.h.

References value_.

Referenced by Types.int32::__nonzero__(), Types.uint32::__nonzero__(), Types.int64::__nonzero__(), Types.uint64::__nonzero__(), Types.double::__nonzero__(), Types.bool::__nonzero__(), Types.string::__nonzero__(), trklet::TrackletCalculatorDisplaced::addDiskProj(), trklet::TrackletCalculatorBase::addDiskProj(), trklet::TrackletCalculatorDisplaced::addLayerProj(), trklet::TrackletCalculatorBase::addLayerProj(), trklet::Sector::addStub(), trklet::VMStubsTEMemory::addVMStub(), average.Average::average(), trklet::TrackletCalculatorBase::barrelSeeding(), Types.string::configValue(), Types.FileInPath::configValue(), trklet::TrackletCalculatorDisplaced::DDLSeeding(), trklet::TrackletCalculatorBase::diskSeeding(), trklet::ProjectionRouter::execute(), trklet::MatchEngine::execute(), trklet::TripletEngine::execute(), trklet::TrackletEngine::execute(), trklet::InputRouter::execute(), trklet::TrackletEngineDisplaced::execute(), trklet::MatchCalculator::execute(), trklet::MatchProcessor::execute(), trklet::TrackletProcessor::execute(), trklet::VMRouterCM::execute(), trklet::VMRouter::execute(), trklet::Tracklet::fit(), trklet::Tracklet::getStubIDs(), trklet::Tracklet::ichiSqfit(), Types.int32::insertInto(), Types.uint32::insertInto(), Types.int64::insertInto(), Types.uint64::insertInto(), Types.double::insertInto(), Types.bool::insertInto(), Types.string::insertInto(), Types.FileInPath::insertInto(), Types.vint32::insertInto(), Types.vuint32::insertInto(), Types.vint64::insertInto(), Types.vuint64::insertInto(), Types.vdouble::insertInto(), Types.vbool::insertInto(), Types.vstring::insertInto(), 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::Stub::rapprox(), trklet::Stub::setPhiCorr(), trklet::TrackletEngineUnit::step(), trklet::MatchEngineUnit::step(), trklet::Stub::str(), trklet::FitTrack::trackFitChisq(), trklet::FitTrack::trackFitFake(), trklet::Tracklet::vmstrlayer(), and trklet::Stub::zapprox().

24 { return value_; }

Member Data Documentation

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

Definition at line 33 of file FPGAWord.h.

Referenced by nbits(), and operator==().

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

Definition at line 34 of file FPGAWord.h.

Referenced by operator==().

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

Definition at line 32 of file FPGAWord.h.

Referenced by operator==(), and value().