CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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_
 
std::shared_ptr
< edm::EventSelector
eventSelector_
 
std::string expression_
 
std::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 19 of file TriggerSelector.h.

Member Typedef Documentation

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

Definition at line 21 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_.

16  : useOld_(true) {
17  acceptAll_ = false;
18  eventSelector_.reset(new edm::EventSelector(pathspecs, names));
19  }
const std::string names[nVars_]
std::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 21 of file TriggerSelector.cc.

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

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

Takes selection string and list of triggers

Definition at line 58 of file TriggerSelector.cc.

References init(), and trim().

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

Definition at line 41 of file TriggerSelector.h.

41 {};

Member Function Documentation

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

Evaluates if trigger results pass selection

Definition at line 94 of file TriggerSelector.cc.

References acceptAll_, eventSelector_, masterElement_, and useOld_.

94  {
95  if (useOld_) {
96  return eventSelector_->acceptEvent(tr);
97  }
98 
99  if (acceptAll_)
100  return true;
101 
102  return masterElement_->returnStatus(tr);
103  }
std::shared_ptr< TreeElement > masterElement_
std::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 105 of file TriggerSelector.cc.

References acceptAll_, eventSelector_, masterElement_, and useOld_.

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

Definition at line 90 of file TriggerSelector.cc.

References edm::EventSelector::getEventSelectionVString().

90  {
92  }
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 62 of file TriggerSelector.cc.

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

Referenced by TriggerSelector().

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

Definition at line 335 of file TriggerSelector.cc.

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

335  {
337  if (!input.empty()) {
338  for (size_t pos = 0; pos < input.size(); pos++) {
339  char ch = input.at(pos);
340  if (ch == '&')
341  output.append("&amp;");
342  else
343  output.append(1, ch);
344  }
345  }
346  return output;
347  }
static std::string const input
Definition: EdmProvDump.cc:47
bool dqmservices::TriggerSelector::returnStatus ( edm::HLTGlobalStatus const &  trStatus) const
inline

Definition at line 66 of file TriggerSelector.h.

References masterElement_.

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

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

Definition at line 322 of file TriggerSelector.cc.

References input.

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

322  {
323  if (!input.empty()) {
324  std::string::size_type pos = input.find_first_not_of(' ');
325  if (pos != std::string::npos)
326  input.erase(0, pos);
327 
328  pos = input.find_last_not_of(' ');
329  if (pos != std::string::npos)
330  input.erase(pos + 1);
331  }
332  return input;
333  }
uint16_t size_type
static std::string const input
Definition: EdmProvDump.cc:47
bool dqmservices::TriggerSelector::wantAll ( ) const
inline

Returns status of always positive bit

Definition at line 46 of file TriggerSelector.h.

References acceptAll_.

46  {
47  // if (useOld_) return eventSelector_->wantAll();
48  return acceptAll_;
49  }

Member Data Documentation

bool dqmservices::TriggerSelector::acceptAll_
private

Definition at line 79 of file TriggerSelector.h.

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

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

Definition at line 133 of file TriggerSelector.h.

Referenced by acceptEvent(), and TriggerSelector().

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

Definition at line 131 of file TriggerSelector.h.

Referenced by init().

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

Definition at line 128 of file TriggerSelector.h.

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

bool dqmservices::TriggerSelector::useOld_
private

Definition at line 134 of file TriggerSelector.h.

Referenced by acceptEvent(), and TriggerSelector().