CMS 3D CMS Logo

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 (std::string const &expression, Strings const &triggernames)
 
bool wantAll () const
 
 ~TriggerSelector ()=default
 

Static Public Member Functions

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::EventSelectoreventSelector_
 
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 20 of file TriggerSelector.h.

Member Typedef Documentation

◆ Strings

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

Definition at line 22 of file TriggerSelector.h.

Constructor & Destructor Documentation

◆ TriggerSelector() [1/2]

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

Initializes TriggerSelector to use edm::EventSelector for selection.

Definition at line 19 of file TriggerSelector.cc.

References acceptAll_, and eventSelector_.

19  : useOld_(true) {
20  acceptAll_ = false;
21  eventSelector_.reset(new edm::EventSelector(pathspecs, triggernames));
22  }
std::shared_ptr< edm::EventSelector > eventSelector_

◆ TriggerSelector() [2/2]

dqmservices::TriggerSelector::TriggerSelector ( std::string const &  expression,
Strings const &  triggernames 
)

Takes selection string and list of triggers

Definition at line 24 of file TriggerSelector.cc.

References l1tGTMenu_hadr_metSeeds_cff::expression, init(), and trim().

24  : useOld_(false) {
25  init(trim(expression), triggernames);
26  }
static std::string trim(std::string input)
void init(std::string const &path, Strings const &triggernames)

◆ ~TriggerSelector()

dqmservices::TriggerSelector::~TriggerSelector ( )
default

Member Function Documentation

◆ acceptEvent() [1/2]

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

Evaluates if trigger results pass selection

Definition at line 53 of file TriggerSelector.cc.

References acceptAll_, eventSelector_, masterElement_, and useOld_.

53  {
54  if (useOld_) {
55  return eventSelector_->acceptEvent(tr);
56  }
57 
58  if (acceptAll_)
59  return true;
60 
61  return masterElement_->returnStatus(tr);
62  }
std::shared_ptr< TreeElement > masterElement_
std::shared_ptr< edm::EventSelector > eventSelector_

◆ acceptEvent() [2/2]

bool dqmservices::TriggerSelector::acceptEvent ( unsigned char const *  array_of_trigger_results,
int  number_of_trigger_paths 
) const

Definition at line 64 of file TriggerSelector.cc.

References acceptAll_, eventSelector_, masterElement_, and useOld_.

64  {
65  if (useOld_)
66  return eventSelector_->acceptEvent(array_of_trigger_results, number_of_trigger_paths);
67 
68  if (acceptAll_)
69  return true;
70 
71  // Form HLTGlobalStatus object to represent the array_of_trigger_results
72  edm::HLTGlobalStatus tr(number_of_trigger_paths);
73  int byteIndex = 0;
74  int subIndex = 0;
75  for (int pathIndex = 0; pathIndex < number_of_trigger_paths; ++pathIndex) {
76  int state = array_of_trigger_results[byteIndex] >> (subIndex * 2);
77  state &= 0x3;
78  edm::HLTPathStatus pathStatus(static_cast<edm::hlt::HLTState>(state));
79  tr[pathIndex] = pathStatus;
80  ++subIndex;
81  if (subIndex == 4) {
82  ++byteIndex;
83  subIndex = 0;
84  }
85  }
86  // Now make the decision, based on the HLTGlobalStatus tr,
87  // which we have created from the supplied array of results
88  masterElement_->returnStatus(tr);
89  return masterElement_->returnStatus(tr);
90  }
std::shared_ptr< TreeElement > masterElement_
std::shared_ptr< edm::EventSelector > eventSelector_

◆ init()

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

Definition at line 28 of file TriggerSelector.cc.

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

Referenced by TriggerSelector().

28  {
29  // debug_ = true;
30  if (expression.empty()) {
31  acceptAll_ = true;
32  return;
33  }
34  if (expression.size() == 1 && expression.at(0) == '*')
35  acceptAll_ = true;
36  else
37  acceptAll_ = false;
38 
39  // replace all possible alternate operators (.AND. and .OR.)
40  {
41  using namespace boost;
43  temp = regex_replace(expression, regex(".AND."), "&&");
44  expression_ = regex_replace(temp, regex(".and."), "&&");
45  temp = regex_replace(expression_, regex(".OR."), "||");
46  expression_ = regex_replace(temp, regex(".or."), "||");
47  }
48 
49  // build decision tree
50  masterElement_.reset(new TreeElement(expression_, triggernames));
51  }
Definition: CLHEP.h:16
std::shared_ptr< TreeElement > masterElement_

◆ makeXMLString()

std::string dqmservices::TriggerSelector::makeXMLString ( std::string const &  input)
static

Definition at line 294 of file TriggerSelector.cc.

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

294  {
296  if (!input.empty()) {
297  for (size_t pos = 0; pos < input.size(); pos++) {
298  char ch = input.at(pos);
299  if (ch == '&')
300  output.append("&amp;");
301  else
302  output.append(1, ch);
303  }
304  }
305  return output;
306  }
static std::string const input
Definition: EdmProvDump.cc:50
Definition: output.py:1

◆ returnStatus()

bool dqmservices::TriggerSelector::returnStatus ( edm::HLTGlobalStatus const &  trStatus) const
inline

Definition at line 56 of file TriggerSelector.h.

References masterElement_.

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

56 { return masterElement_->returnStatus(trStatus); }
std::shared_ptr< TreeElement > masterElement_

◆ trim()

std::string dqmservices::TriggerSelector::trim ( std::string  input)
staticprivate

Definition at line 281 of file TriggerSelector.cc.

References input.

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

281  {
282  if (!input.empty()) {
283  std::string::size_type pos = input.find_first_not_of(' ');
284  if (pos != std::string::npos)
285  input.erase(0, pos);
286 
287  pos = input.find_last_not_of(' ');
288  if (pos != std::string::npos)
289  input.erase(pos + 1);
290  }
291  return input;
292  }
uint16_t size_type
static std::string const input
Definition: EdmProvDump.cc:50

◆ wantAll()

bool dqmservices::TriggerSelector::wantAll ( ) const
inline

Returns status of always positive bit

Definition at line 39 of file TriggerSelector.h.

References acceptAll_.

Member Data Documentation

◆ acceptAll_

bool dqmservices::TriggerSelector::acceptAll_
private

Definition at line 64 of file TriggerSelector.h.

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

◆ debug_

const bool dqmservices::TriggerSelector::debug_ = false
staticprivate

◆ eventSelector_

std::shared_ptr<edm::EventSelector> dqmservices::TriggerSelector::eventSelector_
private

Definition at line 118 of file TriggerSelector.h.

Referenced by acceptEvent(), and TriggerSelector().

◆ expression_

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

Definition at line 116 of file TriggerSelector.h.

Referenced by init().

◆ masterElement_

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

Definition at line 113 of file TriggerSelector.h.

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

◆ useOld_

bool dqmservices::TriggerSelector::useOld_
private

Definition at line 119 of file TriggerSelector.h.

Referenced by acceptEvent().