Public Member Functions | Private Member Functions | Private Attributes | List of all members
Expression Class Reference

a class for expression parsing. More...

Public Member Functions

 Expression (const std::string &expr)
novaddt::HitSet Eval (const art::Event &e)
const std::map< std::string, uint64_t > & GetStatistics ()

Private Member Functions

void Parse (const std::string &s)
novaddt::HitSet fetchOne (const std::string &tag, const art::Event &e)
novaddt::HitSet fetchAll (const std::string &tag, const art::Event &e)
novaddt::HitSet fetch (const std::string &tag, const art::Event &e)

Private Attributes

std::vector< std::stringfTokens
std::map< std::string, uint64_t > fSeenHits

Detailed Description

a class for expression parsing.

Definition at line 31 of file

Constructor & Destructor Documentation

Expression::Expression ( const std::string expr)

Definition at line 33 of file

References e, Eval(), and Parse().

33 {Parse(expr);}
void Parse(const std::string &s)

Member Function Documentation

novaddt::HitSet Expression::Eval ( const art::Event e)

Definition at line 72 of file

References novaddt::HitSet::add(), fetch(), fSeenHits, fTokens, hits(), fillBadChanDBTables::result, runNovaSAM::stream, novaddt::HitSet::subtract(), confusionMatrixTree::t, and art::to_string().

Referenced by Expression(), and novaddt::HitSubtract::produce().

72  {
74  char next_op='+';
75  auto stream=mf::LogDebug("HitSub eval");
76  for(const auto& t: fTokens){
77  if(t[0]=='-'||t[0]=='+'){next_op=t[0]; continue;}
79  fSeenHits[t]+=hits.size();
80  stream<<next_op<<" Hits["<<t<<"]= "<<hits.size()<<"\n";
81  switch(next_op){
82  case '-': result.subtract(hits); break;
83  case '+': result.add(hits); break;
84  default: throw std::logic_error("Wrong operation:"+std::to_string(next_op));
85  }
86  }
87  stream<<"Result="<<result.size();
88  fSeenHits["result"]+=result.size();
89  return result;
90 }
void add(const AnyCollection &v)
Definition: HitSet.h:24
novaddt::HitSet fetch(const std::string &tag, const art::Event &e)
void hits()
Definition: readHits.C:15
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
std::map< std::string, uint64_t > fSeenHits
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
void subtract(const AnyCollection &v)
Definition: HitSet.h:30
std::vector< std::string > fTokens
novaddt::HitSet Expression::fetch ( const std::string tag,
const art::Event e 

Definition at line 49 of file

References stan::lang::ends_with(), fetchAll(), and fetchOne().

Referenced by Eval().

49  {
50  if(boost::ends_with(tag,"[]")){
51  return fetchAll(boost::erase_tail_copy(tag,2),e);
52  }
53  else
54  return fetchOne(tag,e);
55  }
novaddt::HitSet fetchAll(const std::string &tag, const art::Event &e)
novaddt::HitSet fetchOne(const std::string &tag, const art::Event &e)
bool ends_with(const std::string &suffix, const std::string &s)
novaddt::HitSet Expression::fetchAll ( const std::string tag,
const art::Event e 

Definition at line 42 of file

References novaddt::HitSet::add(), art::DataViewImpl::getValidHandle(), hits(), and getGoodRuns4SAM::tag.

Referenced by fetch().

42  {
44  auto handle=e.getValidHandle<std::vector<novaddt::HitList>>(tag);
45  for(const auto& hitlist: *handle)
46  hits.add(hitlist);
47  return hits;
48  };
void add(const AnyCollection &v)
Definition: HitSet.h:24
void hits()
Definition: readHits.C:15
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
novaddt::HitSet Expression::fetchOne ( const std::string tag,
const art::Event e 

Definition at line 38 of file

References art::DataViewImpl::getValidHandle(), and getGoodRuns4SAM::tag.

Referenced by fetch().

38  {
39  auto handle=e.getValidHandle<novaddt::HitList>(tag);
40  return novaddt::HitSet(*handle);
41  };
std::vector< DAQHit > HitList
Definition: HitList.h:15
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
const std::map<std::string,uint64_t>& Expression::GetStatistics ( )

Definition at line 35 of file

References fSeenHits, Parse(), and string.

Referenced by novaddt::HitSubtract::endJob().

35 {return fSeenHits;}
std::map< std::string, uint64_t > fSeenHits
void Expression::Parse ( const std::string s)

Definition at line 61 of file

References fTokens, sep, submit_syst::str, string, confusionMatrixTree::t, and trim().

Referenced by Expression(), and GetStatistics().

61  {
62  mf::LogInfo("HitSub expression")<<"parse string:\'"<<str<<"\'";
64  boost::char_separator<char> sep{"", "-+"};
65  boost::tokenizer<boost::char_separator<char>> tok{str, sep};
66  for (std::string t : tok){
67  boost::trim(t);
68  fTokens.push_back(t);
69  }
70 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
string trim(string in)
Definition: rootgINukeVal.C:65
const char sep
std::vector< std::string > fTokens
enum BeamMode string

Member Data Documentation

std::map<std::string,uint64_t> Expression::fSeenHits

Definition at line 58 of file

Referenced by Eval(), and GetStatistics().

std::vector<std::string> Expression::fTokens

Definition at line 57 of file

Referenced by Eval(), and Parse().

The documentation for this class was generated from the following file: