CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
dqmservices::TriggerSelector Class Reference

#include <TriggerSelector.h>

Classes

class  TreeElement
 

Public Types

typedef std::vector< std::string > Strings
 

Public Member Functions

bool acceptEvent (edm::TriggerResults const &) const
 
bool acceptEvent (unsigned char const *, int) const
 
bool returnStatus (edm::HLTGlobalStatus const &trStatus) const
 
 TriggerSelector (Strings const &pathspecs, Strings const &names)
 
 TriggerSelector (edm::ParameterSet const &pset, Strings const &triggernames, bool old_=false)
 
 TriggerSelector (std::string const &expression, Strings const &triggernames)
 
bool wantAll () const
 
 ~TriggerSelector ()
 

Static Public Member Functions

static std::vector< std::string > getEventSelectionVString (edm::ParameterSet const &pset)
 
static std::string makeXMLString (std::string const &input)
 

Private Member Functions

void init (std::string const &path, Strings const &triggernames)
 

Static Private Member Functions

static std::string trim (std::string input)
 

Private Attributes

bool acceptAll_
 
boost::shared_ptr
< edm::EventSelector
eventSelector_
 
std::string expression_
 
boost::shared_ptr< TreeElementmasterElement_
 
bool useOld_
 

Static Private Attributes

static const bool debug_ = false
 

Detailed Description

Event selector allowing for and/not combination of triggers/paths

Definition at line 21 of file TriggerSelector.h.

Member Typedef Documentation

typedef std::vector<std::string> dqmservices::TriggerSelector::Strings

Definition at line 23 of file TriggerSelector.h.

Constructor & Destructor Documentation

dqmservices::TriggerSelector::TriggerSelector ( Strings const &  pathspecs,
Strings const &  names 
)

Obsolete: Initializes TriggerSelector to use edm::EventSelector for selection.

Definition at line 16 of file TriggerSelector.cc.

References acceptAll_, and eventSelector_.

17  : useOld_(true) {
18  acceptAll_ = false;
19  eventSelector_.reset(new edm::EventSelector(pathspecs, names));
20 }
static const HistoName names[]
boost::shared_ptr< edm::EventSelector > eventSelector_
dqmservices::TriggerSelector::TriggerSelector ( edm::ParameterSet const &  pset,
Strings const &  triggernames,
bool  old_ = false 
)

Takes ParameterSet wth TriggerSelector string or EventSelection list, and a list of triggers. if old_ is true, it is forced to use EventSelection.

Definition at line 22 of file TriggerSelector.cc.

References acceptAll_, edm::ParameterSet::empty(), eventSelector_, edm::ParameterSet::getParameter(), init(), mergeAndRegister::paths, AlCaHLTBitMon_QueryRunRegistry::string, trim(), and useOld_.

24  : useOld_(old_) {
25  acceptAll_ = false;
26  if (old_) {
27  // old mode forced
28  acceptAll_ = false;
29  eventSelector_.reset(new edm::EventSelector(config, triggernames));
30  return;
31  }
32  if (!config.empty()) {
33  // let's see if non empty TriggerSelector is present
34  try {
35  std::string myPath =
36  trim(config.getParameter<std::string>("TriggerSelector"));
37  if (!myPath.empty()) {
38  init(myPath, triggernames);
39  return;
40  }
41  } catch (...) {
42  }
43 
44  // now try with the SelectEvents
45  try {
46  Strings paths;
47  paths = config.getParameter<Strings>("SelectEvents");
48  if (!paths.empty()) {
49  useOld_ = true;
50  eventSelector_.reset(new edm::EventSelector(config, triggernames));
51  return;
52  }
53  } catch (...) {
54  }
55  }
56  // if selection parameters aren't present, don't do selection
57  // log
58  acceptAll_ = true;
59 }
std::vector< std::string > Strings
Definition: MsgTools.h:18
static std::string trim(std::string input)
boost::shared_ptr< edm::EventSelector > eventSelector_
void init(std::string const &path, Strings const &triggernames)
dqmservices::TriggerSelector::TriggerSelector ( std::string const &  expression,
Strings const &  triggernames 
)

Takes selection string and list of triggers

Definition at line 61 of file TriggerSelector.cc.

References init(), and trim().

63  : useOld_(false) {
64  init(trim(expression), triggernames);
65 }
static std::string trim(std::string input)
void init(std::string const &path, Strings const &triggernames)
dqmservices::TriggerSelector::~TriggerSelector ( )
inline

Definition at line 44 of file TriggerSelector.h.

44 {};

Member Function Documentation

bool dqmservices::TriggerSelector::acceptEvent ( edm::TriggerResults const &  tr) const

Evaluates if trigger results pass selection

Definition at line 101 of file TriggerSelector.cc.

References acceptAll_, eventSelector_, masterElement_, and useOld_.

101  {
102  if (useOld_) {
103  return eventSelector_->acceptEvent(tr);
104  }
105 
106  if (acceptAll_) return true;
107 
108  return masterElement_->returnStatus(tr);
109 }
boost::shared_ptr< TreeElement > masterElement_
boost::shared_ptr< edm::EventSelector > eventSelector_
bool dqmservices::TriggerSelector::acceptEvent ( unsigned char const *  array_of_trigger_results,
int  number_of_trigger_paths 
) const

Definition at line 111 of file TriggerSelector.cc.

References acceptAll_, eventSelector_, masterElement_, and useOld_.

112  {
113  if (useOld_)
114  return eventSelector_->acceptEvent(array_of_trigger_results,
115  number_of_trigger_paths);
116 
117  if (acceptAll_) return true;
118 
119  // Form HLTGlobalStatus object to represent the array_of_trigger_results
120  edm::HLTGlobalStatus tr(number_of_trigger_paths);
121  int byteIndex = 0;
122  int subIndex = 0;
123  for (int pathIndex = 0; pathIndex < number_of_trigger_paths; ++pathIndex) {
124  int state = array_of_trigger_results[byteIndex] >> (subIndex * 2);
125  state &= 0x3;
126  edm::HLTPathStatus pathStatus(static_cast<edm::hlt::HLTState>(state));
127  tr[pathIndex] = pathStatus;
128  ++subIndex;
129  if (subIndex == 4) {
130  ++byteIndex;
131  subIndex = 0;
132  }
133  }
134  // Now make the decision, based on the HLTGlobalStatus tr,
135  // which we have created from the supplied array of results
136  masterElement_->returnStatus(tr);
137  return masterElement_->returnStatus(tr);
138 }
boost::shared_ptr< TreeElement > masterElement_
boost::shared_ptr< edm::EventSelector > eventSelector_
std::vector< std::string > dqmservices::TriggerSelector::getEventSelectionVString ( edm::ParameterSet const &  pset)
static

Definition at line 96 of file TriggerSelector.cc.

References edm::EventSelector::getEventSelectionVString().

97  {
99 }
static std::vector< std::string > getEventSelectionVString(edm::ParameterSet const &pset)
void dqmservices::TriggerSelector::init ( std::string const &  path,
Strings const &  triggernames 
)
private

Definition at line 67 of file TriggerSelector.cc.

References acceptAll_, expression_, masterElement_, AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by TriggerSelector().

68  {
69  // debug_ = true;
70  if (expression.empty()) {
71  acceptAll_ = true;
72  return;
73  }
74  if (expression.size() == 1 && expression.at(0) == '*')
75  acceptAll_ = true;
76  else
77  acceptAll_ = false;
78 
79  // replace all possible alternate operators (.AND. and .OR.)
80  {
81  using namespace boost;
83  temp = regex_replace(expression, regex(".AND."), "&&");
84  expression_ = regex_replace(temp, regex(".and."), "&&");
85  temp = regex_replace(expression_, regex(".OR."), "||");
86  expression_ = regex_replace(temp, regex(".or."), "||");
87  }
88 
89  // build decision tree
90  masterElement_.reset(new TreeElement(expression_, triggernames));
91 }
boost::shared_ptr< TreeElement > masterElement_
std::string dqmservices::TriggerSelector::makeXMLString ( std::string const &  input)
static

Definition at line 355 of file TriggerSelector.cc.

References convertSQLitetoXML_cfg::output, and AlCaHLTBitMon_QueryRunRegistry::string.

355  {
357  if (!input.empty()) {
358  for (size_t pos = 0; pos < input.size(); pos++) {
359  char ch = input.at(pos);
360  if (ch == '&')
361  output.append("&amp;");
362  else
363  output.append(1, ch);
364  }
365  }
366  return output;
367 }
static std::string const input
Definition: EdmProvDump.cc:43
bool dqmservices::TriggerSelector::returnStatus ( edm::HLTGlobalStatus const &  trStatus) const
inline

Definition at line 69 of file TriggerSelector.h.

References masterElement_.

Referenced by dqmservices::TriggerSelector::TreeElement::returnStatus().

69  {
70  return masterElement_->returnStatus(trStatus);
71  }
boost::shared_ptr< TreeElement > masterElement_
std::string dqmservices::TriggerSelector::trim ( std::string  input)
staticprivate

Definition at line 344 of file TriggerSelector.cc.

References input.

Referenced by dqmservices::TriggerSelector::TreeElement::TreeElement(), and TriggerSelector().

344  {
345  if (!input.empty()) {
346  std::string::size_type pos = input.find_first_not_of(" ");
347  if (pos != std::string::npos) input.erase(0, pos);
348 
349  pos = input.find_last_not_of(" ");
350  if (pos != std::string::npos) input.erase(pos + 1);
351  }
352  return input;
353 }
uint16_t size_type
static std::string const input
Definition: EdmProvDump.cc:43
bool dqmservices::TriggerSelector::wantAll ( ) const
inline

Returns status of always positive bit

Definition at line 49 of file TriggerSelector.h.

References acceptAll_.

49  {
50  // if (useOld_) return eventSelector_->wantAll();
51  return acceptAll_;
52  }

Member Data Documentation

bool dqmservices::TriggerSelector::acceptAll_
private

Definition at line 85 of file TriggerSelector.h.

Referenced by acceptEvent(), init(), TriggerSelector(), and wantAll().

const bool dqmservices::TriggerSelector::debug_ = false
staticprivate
boost::shared_ptr<edm::EventSelector> dqmservices::TriggerSelector::eventSelector_
private

Definition at line 140 of file TriggerSelector.h.

Referenced by acceptEvent(), and TriggerSelector().

std::string dqmservices::TriggerSelector::expression_
private

Definition at line 138 of file TriggerSelector.h.

Referenced by init().

boost::shared_ptr<TreeElement> dqmservices::TriggerSelector::masterElement_
private

Definition at line 135 of file TriggerSelector.h.

Referenced by acceptEvent(), init(), and returnStatus().

bool dqmservices::TriggerSelector::useOld_
private

Definition at line 141 of file TriggerSelector.h.

Referenced by acceptEvent(), and TriggerSelector().