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)
 
template<class... Args>
void add_cuts (VarBase *cut, Args... args)
 
void add_cuts (VarBase *cut)
 
void calculate_step ()
 
bool passes ()
 
void print (std::ofstream &fs, Verilog, int l1=0, int l2=0, int l3=0) override
 
void print (std::ofstream &fs, HLS, 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 (int debug_level)
 
bool calculate ()
 
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, Verilog)
 
void print_all (std::ofstream &fs, HLS)
 
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_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_step (int step, std::ofstream &fs, Verilog)
 
void print_step (int step, std::ofstream &fs, HLS)
 
void print_truncation (std::string &t, const std::string &o1, const int ps, Verilog) const
 
void print_truncation (std::string &t, const std::string &o1, const int ps, HLS) 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 (const std::vector< VarBase *> &v, std::ofstream &fs, Verilog)
 
static void design_print (const std::vector< VarBase *> &v, std::ofstream &fs, HLS)
 
static void hls_print (const 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 (const 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 1096 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 1099 of file imath.h.

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

1100  : VarBase(globals, name, nullptr, nullptr, nullptr, 0) {
1101  op_ = "flag";
1102  nbits_ = 1;
1103  add_cuts(cut, args...);
1104  }
std::string name() const
Definition: imath.h:208
void add_cuts(VarBase *cut, Args... args)
Definition: imath.h:1107
VarBase(imathGlobals *globals, std::string name, VarBase *p1, VarBase *p2, VarBase *p3, int l)
Definition: imath.h:162
std::string op_
Definition: imath.h:301

Member Function Documentation

◆ add_cut()

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

Definition at line 373 of file imath.cc.

References calculate_step(), PA_MinBiasSkim_cff::cut, trklet::VarBase::cuts_, and trklet::VarCut::set_parent_flag().

Referenced by add_cuts(), trklet::IMATH_TrackletCalculator::IMATH_TrackletCalculator(), trklet::IMATH_TrackletCalculatorDisk::IMATH_TrackletCalculatorDisk(), trklet::IMATH_TrackletCalculatorOverlap::IMATH_TrackletCalculatorOverlap(), and trklet::VarCut::set_parent_flag().

373  {
374  cuts_.push_back(cut);
375  if (cut->op() == "cut" && call_set_parent_flag) {
376  VarCut *const cast_cut = (VarCut *)cut;
377  cast_cut->set_parent_flag(this, false);
378  }
379  calculate_step();
380 }
void set_parent_flag(VarFlag *parent_flag, const bool call_add_cut)
Definition: imath.cc:382
std::vector< VarBase * > cuts_
Definition: imath.h:309

◆ add_cuts() [1/2]

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

Definition at line 1107 of file imath.h.

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

Referenced by VarFlag().

1107  {
1108  add_cut(cut);
1109  add_cuts(args...);
1110  }
void add_cuts(VarBase *cut, Args... args)
Definition: imath.h:1107
void add_cut(VarBase *cut, const bool call_set_parent_flag=true)
Definition: imath.cc:373

◆ add_cuts() [2/2]

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

Definition at line 1112 of file imath.h.

References add_cut(), and PA_MinBiasSkim_cff::cut.

1112 { add_cut(cut); }
void add_cut(VarBase *cut, const bool call_set_parent_flag=true)
Definition: imath.cc:373

◆ calculate_step()

void VarFlag::calculate_step ( )

Definition at line 81 of file imath_calculate.cc.

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

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

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 }
std::vector< VarBase * > cuts_
Definition: imath.h:309

◆ passes()

bool VarFlag::passes ( )

Definition at line 395 of file imath.cc.

References PA_MinBiasSkim_cff::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_.

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 }
Log< level::Info, true > LogVerbatim
VarBase * cut_var()
Definition: imath.cc:388
bool passes()
Definition: imath.cc:395
imathGlobals * globals_
Definition: imath.h:296
bool local_passes() const
Definition: imath.cc:315
std::vector< VarBase * > cuts_
Definition: imath.h:309
std::string name_
Definition: imath.h:297
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

◆ print() [1/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.

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

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 }
string separator
Definition: mps_merge.py:79
VarBase * cut_var()
Definition: imath.cc:388
assert(be >=bs)
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
static struct trklet::VarBase::Verilog verilog
std::vector< VarBase * > cuts_
Definition: imath.h:309
std::string name_
Definition: imath.h:297

◆ print() [2/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.

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

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 }
string separator
Definition: mps_merge.py:79
VarBase * cut_var()
Definition: imath.cc:388
assert(be >=bs)
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
static struct trklet::VarBase::HLS hls
std::vector< VarBase * > cuts_
Definition: imath.h:309
std::string name_
Definition: imath.h:297