CMS 3D CMS Logo

List of all members | Public Member Functions
trklet::VarFlag Class Reference

#include <imath.h>

Inheritance diagram for trklet::VarFlag:
trklet::VarBase

Public Member Functions

void add_cut (VarBase *cut, const bool call_set_parent_flag=true)
 
void add_cuts (VarBase *cut)
 
template<class... Args>
void add_cuts (VarBase *cut, Args... args)
 
void calculate_step ()
 
bool passes ()
 
void print (std::ofstream &fs, HLS, int l1=0, int l2=0, int l3=0) override
 
void print (std::ofstream &fs, Verilog, int l1=0, int l2=0, int l3=0) override
 
template<class... Args>
 VarFlag (imathGlobals *globals, std::string name, VarBase *cut, Args... args)
 
- Public Member Functions inherited from trklet::VarBase
void add_cut (VarCut *cut, const bool call_set_cut_var=true)
 
void add_delay (int i)
 
void add_latency (unsigned int l)
 
void analyze ()
 
bool calculate ()
 
bool calculate (int debug_level)
 
VarBasecut_var ()
 
std::string dump ()
 
void dump_msg ()
 
double fval () const
 
bool has_delay (int i)
 
void inputs (std::vector< VarBase * > *vd)
 
long int ival () const
 
double K () const
 
std::map< std::string, int > Kmap () const
 
std::string kstring () const
 
int latency () const
 
virtual void local_calculate ()
 
bool local_passes () const
 
void makeready ()
 
double maxval () const
 
double minval () const
 
std::string name () const
 
int nbits () const
 
std::string op () const
 
VarBasep1 () const
 
VarBasep2 () const
 
VarBasep3 () const
 
void passes (std::map< const VarBase *, std::vector< bool > > &passes, const std::map< const VarBase *, std::vector< bool > > *const previous_passes=nullptr) const
 
int pipe_counter ()
 
std::string pipe_delays (const int step)
 
void pipe_increment ()
 
void print_all (std::ofstream &fs, HLS)
 
void print_all (std::ofstream &fs, Verilog)
 
void print_cuts (std::map< const VarBase *, std::set< std::string > > &cut_strings, const int step, HLS, const std::map< const VarBase *, std::set< std::string > > *const previous_cut_strings=nullptr) const
 
void print_cuts (std::map< const VarBase *, std::set< std::string > > &cut_strings, const int step, Verilog, const std::map< const VarBase *, std::set< std::string > > *const previous_cut_strings=nullptr) const
 
void print_step (int step, std::ofstream &fs, HLS)
 
void print_step (int step, std::ofstream &fs, Verilog)
 
void print_truncation (std::string &t, const std::string &o1, const int ps, HLS) const
 
void print_truncation (std::string &t, const std::string &o1, const int ps, Verilog) const
 
double range () const
 
void reset ()
 
int shift () const
 
int step () const
 
 VarBase (imathGlobals *globals, std::string name, VarBase *p1, VarBase *p2, VarBase *p3, int l)
 
virtual ~VarBase ()
 

Additional Inherited Members

- Static Public Member Functions inherited from trklet::VarBase
static void design_print (std::vector< VarBase * > v, std::ofstream &fs, HLS)
 
static void design_print (std::vector< VarBase * > v, std::ofstream &fs, Verilog)
 
static void hls_print (std::vector< VarBase * > v, std::ofstream &fs)
 
static std::string itos (int i)
 
static std::string pipe_delay (VarBase *v, int nbits, int delay)
 
static std::string pipe_delay_wire (VarBase *v, std::string name_delayed, int nbits, int delay)
 
static void verilog_print (std::vector< VarBase * > v, std::ofstream &fs)
 
- Static Public Attributes inherited from trklet::VarBase
static struct trklet::VarBase::HLS hls
 
static struct trklet::VarBase::Verilog verilog
 
- Protected Attributes inherited from trklet::VarBase
VarBasecut_var_
 
std::vector< VarBase * > cuts_
 
double fval_
 
imathGlobalsglobals_
 
long int ival_
 
double K_
 
std::map< std::string, int > Kmap_
 
int latency_
 
double maxval_
 
double minval_
 
std::string name_
 
int nbits_
 
std::string op_
 
VarBasep1_
 
VarBasep2_
 
VarBasep3_
 
int pipe_counter_
 
std::vector< int > pipe_delays_
 
bool readytoanalyze_
 
bool readytoprint_
 
int step_
 
bool usedasinput_
 
double val_
 

Detailed Description

Definition at line 1095 of file imath.h.

Constructor & Destructor Documentation

◆ VarFlag()

template<class... Args>
trklet::VarFlag::VarFlag ( imathGlobals globals,
std::string  name,
VarBase cut,
Args...  args 
)
inline

Definition at line 1098 of file imath.h.

1099  : VarBase(globals, name, nullptr, nullptr, nullptr, 0) {
1100  op_ = "flag";
1101  nbits_ = 1;
1102  add_cuts(cut, args...);
1103  }

References add_cuts(), writedatasetfile::args, TkAlMuonSelectors_cfi::cut, trklet::VarBase::nbits_, and trklet::VarBase::op_.

Member Function Documentation

◆ add_cut()

void VarFlag::add_cut ( VarBase cut,
const bool  call_set_parent_flag = true 
)

◆ add_cuts() [1/2]

void trklet::VarFlag::add_cuts ( VarBase cut)
inline

Definition at line 1111 of file imath.h.

1111 { add_cut(cut); }

References add_cut(), and TkAlMuonSelectors_cfi::cut.

◆ add_cuts() [2/2]

template<class... Args>
void trklet::VarFlag::add_cuts ( VarBase cut,
Args...  args 
)
inline

Definition at line 1106 of file imath.h.

1106  {
1107  add_cut(cut);
1108  add_cuts(args...);
1109  }

References add_cut(), writedatasetfile::args, and TkAlMuonSelectors_cfi::cut.

Referenced by VarFlag().

◆ calculate_step()

void VarFlag::calculate_step ( )

Definition at line 81 of file imath_calculate.cc.

81  {
82  int max_step = 0;
83  for (const auto &cut : cuts_) {
84  if (!cut->cut_var())
85  continue;
86  if (cut->cut_var()->latency() + cut->cut_var()->step() > max_step)
87  max_step = cut->cut_var()->latency() + cut->cut_var()->step();
88  }
89  step_ = max_step;
90 }

References TkAlMuonSelectors_cfi::cut, trklet::VarBase::cuts_, and trklet::VarBase::step_.

Referenced by add_cut(), and trklet::VarCut::set_cut_var().

◆ passes()

bool VarFlag::passes ( )

Definition at line 395 of file imath.cc.

395  {
396  if (globals_->printCutInfo_) {
397  edm::LogVerbatim("Tracklet") << "Checking if " << name_ << " passes...";
398  }
399 
400  std::map<const VarBase *, std::vector<bool> > passes0, passes1;
401  for (const auto &cut : cuts_) {
402  if (cut->op() != "cut")
403  continue;
404  const VarCut *const cast_cut = (VarCut *)cut;
405  cast_cut->local_passes(passes0);
406  }
407  for (const auto &cut : cuts_) {
408  if (cut->op() != "cut")
409  cut->passes(passes1, &passes0);
410  else {
411  if (cut->cut_var()->p1())
412  cut->cut_var()->p1()->passes(passes1, &passes0);
413  if (cut->cut_var()->p2())
414  cut->cut_var()->p2()->passes(passes1, &passes0);
415  if (cut->cut_var()->p3())
416  cut->cut_var()->p3()->passes(passes1, &passes0);
417  }
418  }
419 
420  bool passes = true;
421  for (const auto &cut_var : passes0) {
422  bool local_passes = false;
423  for (const auto &pass : cut_var.second)
424  local_passes = local_passes || pass;
426  }
427  for (const auto &cut_var : passes1) {
428  bool local_passes = false;
429  for (const auto &pass : cut_var.second)
430  local_passes = local_passes || pass;
432  }
433 
434  if (globals_->printCutInfo_) {
435  edm::LogVerbatim("Tracklet") << name_ << " " << (passes ? "PASSES" : "FAILS");
436  }
437 
438  return passes;
439 }

References TkAlMuonSelectors_cfi::cut, trklet::VarBase::cut_var(), trklet::VarBase::cuts_, trklet::VarBase::globals_, trklet::VarBase::local_passes(), trklet::VarCut::local_passes(), trklet::VarBase::name_, and trklet::imathGlobals::printCutInfo_.

◆ print() [1/2]

void VarFlag::print ( std::ofstream &  fs,
HLS  ,
int  l1 = 0,
int  l2 = 0,
int  l3 = 0 
)
overridevirtual

Reimplemented from trklet::VarBase.

Definition at line 284 of file imath_HLS.cc.

284  {
285  assert(l1 == 0);
286  assert(l2 == 0);
287  assert(l3 == 0);
288 
289  fs << "const ap_int<1> " << name_ << " = (";
290  std::map<const VarBase*, std::set<std::string> > cut_strings0, cut_strings1;
291  for (const auto& cut : cuts_) {
292  if (cut->op() != "cut")
293  continue;
294  const VarCut* const cast_cut = (VarCut*)cut;
295  cast_cut->print(cut_strings0, step_, hls);
296  }
297  for (const auto& cut : cuts_) {
298  if (cut->op() != "cut")
299  cut->print_cuts(cut_strings1, step_, hls, &cut_strings0);
300  else {
301  if (cut->cut_var()->p1())
302  cut->cut_var()->p1()->print_cuts(cut_strings1, step_, hls, &cut_strings1);
303  if (cut->cut_var()->p2())
304  cut->cut_var()->p2()->print_cuts(cut_strings1, step_, hls, &cut_strings1);
305  if (cut->cut_var()->p3())
306  cut->cut_var()->p3()->print_cuts(cut_strings1, step_, hls, &cut_strings1);
307  }
308  }
309 
310  std::string separator = "";
311  for (const auto& cut_var : cut_strings0) {
312  separator += "((";
313  for (const auto& cut_string : cut_var.second) {
314  fs << separator << cut_string;
315  separator = ") || (";
316  }
317  separator = ")) && ";
318  }
319  for (const auto& cut_var : cut_strings1) {
320  separator += "((";
321  for (const auto& cut_string : cut_var.second) {
322  fs << separator << cut_string;
323  separator = ") || (";
324  }
325  separator = ")) && ";
326  }
327 
328  fs << ")));";
329 }

References cms::cuda::assert(), TkAlMuonSelectors_cfi::cut, trklet::VarBase::cut_var(), trklet::VarBase::cuts_, trklet::VarBase::hls, trklet::VarBase::name_, trklet::VarCut::print(), mps_merge::separator, trklet::VarBase::step_, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ print() [2/2]

void VarFlag::print ( std::ofstream &  fs,
Verilog  ,
int  l1 = 0,
int  l2 = 0,
int  l3 = 0 
)
overridevirtual

Reimplemented from trklet::VarBase.

Definition at line 354 of file imath_Verilog.cc.

354  {
355  assert(l1 == 0);
356  assert(l2 == 0);
357  assert(l3 == 0);
358 
359  fs << "wire " << name_ << ";" << std::endl;
360  fs << "assign " << name_ << " = (";
361  std::map<const VarBase*, std::set<std::string> > cut_strings0, cut_strings1;
362  for (const auto& cut : cuts_) {
363  if (cut->op() != "cut")
364  continue;
365  const VarCut* const cast_cut = (VarCut*)cut;
366  cast_cut->print(cut_strings0, step_, verilog);
367  }
368  for (const auto& cut : cuts_) {
369  if (cut->op() != "cut")
370  cut->print_cuts(cut_strings1, step_, verilog, &cut_strings0);
371  else {
372  if (cut->cut_var()->p1())
373  cut->cut_var()->p1()->print_cuts(cut_strings1, step_, verilog, &cut_strings1);
374  if (cut->cut_var()->p2())
375  cut->cut_var()->p2()->print_cuts(cut_strings1, step_, verilog, &cut_strings1);
376  if (cut->cut_var()->p3())
377  cut->cut_var()->p3()->print_cuts(cut_strings1, step_, verilog, &cut_strings1);
378  }
379  }
380 
381  std::string separator = "";
382  for (const auto& cut_var : cut_strings0) {
383  separator += "((";
384  for (const auto& cut_string : cut_var.second) {
385  fs << separator << cut_string;
386  separator = ") || (";
387  }
388  separator = ")) && ";
389  }
390  for (const auto& cut_var : cut_strings1) {
391  separator += "((";
392  for (const auto& cut_string : cut_var.second) {
393  fs << separator << cut_string;
394  separator = ") || (";
395  }
396  separator = ")) && ";
397  }
398 
399  fs << ")));";
400 }

References cms::cuda::assert(), TkAlMuonSelectors_cfi::cut, trklet::VarBase::cut_var(), trklet::VarBase::cuts_, trklet::VarBase::name_, trklet::VarCut::print(), mps_merge::separator, trklet::VarBase::step_, AlCaHLTBitMon_QueryRunRegistry::string, and trklet::VarBase::verilog.

writedatasetfile.args
args
Definition: writedatasetfile.py:18
trklet::VarFlag::calculate_step
void calculate_step()
Definition: imath_calculate.cc:81
trklet::VarBase::name
std::string name() const
Definition: imath.h:207
trklet::VarBase::step_
int step_
Definition: imath.h:302
TkAlMuonSelectors_cfi.cut
cut
Definition: TkAlMuonSelectors_cfi.py:5
trklet::VarBase::cut_var
VarBase * cut_var()
Definition: imath.cc:388
trklet::VarCut::set_parent_flag
void set_parent_flag(VarFlag *parent_flag, const bool call_add_cut)
Definition: imath.cc:382
trklet::VarFlag::passes
bool passes()
Definition: imath.cc:395
cms::cuda::assert
assert(be >=bs)
trklet::VarBase::globals_
imathGlobals * globals_
Definition: imath.h:295
trklet::VarFlag::add_cuts
void add_cuts(VarBase *cut, Args... args)
Definition: imath.h:1106
trklet::imathGlobals::printCutInfo_
bool printCutInfo_
Definition: imath.h:149
trklet::VarBase::verilog
static struct trklet::VarBase::Verilog verilog
trklet::VarBase::VarBase
VarBase(imathGlobals *globals, std::string name, VarBase *p1, VarBase *p2, VarBase *p3, int l)
Definition: imath.h:161
trklet::VarCut::local_passes
void local_passes(std::map< const VarBase *, std::vector< bool > > &passes, const std::map< const VarBase *, std::vector< bool > > *const previous_passes=nullptr) const
Definition: imath.cc:304
mps_merge.separator
string separator
Definition: mps_merge.py:79
trklet::VarBase::op_
std::string op_
Definition: imath.h:300
trklet::VarBase::local_passes
bool local_passes() const
Definition: imath.cc:315
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
trklet::VarFlag::add_cut
void add_cut(VarBase *cut, const bool call_set_parent_flag=true)
Definition: imath.cc:373
edm::LogVerbatim
Definition: MessageLogger.h:297
trklet::VarBase::hls
static struct trklet::VarBase::HLS hls
trklet::VarBase::cuts_
std::vector< VarBase * > cuts_
Definition: imath.h:308
trklet::VarBase::name_
std::string name_
Definition: imath.h:296
trklet::VarCut::print
void print(std::map< const VarBase *, std::set< std::string > > &cut_strings, const int step, Verilog, const std::map< const VarBase *, std::set< std::string > > *const previous_cut_strings=nullptr) const
Definition: imath_Verilog.cc:26
trklet::VarBase::nbits_
int nbits_
Definition: imath.h:311
trklet::VarCut
Definition: imath.h:1054