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 (edm::ParameterSet const &pset, Strings const &triggernames, bool old_=false)
 
 TriggerSelector (std::string const &expression, Strings const &triggernames)
 
 TriggerSelector (Strings const &pathspecs, Strings const &names)
 
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::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 19 of file TriggerSelector.h.

Member Typedef Documentation

◆ Strings

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

Definition at line 21 of file TriggerSelector.h.

Constructor & Destructor Documentation

◆ TriggerSelector() [1/3]

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.

16  : useOld_(true) {
17  acceptAll_ = false;
18  eventSelector_.reset(new edm::EventSelector(pathspecs, names));
19  }

References acceptAll_, eventSelector_, and names.

◆ TriggerSelector() [2/3]

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.

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  }

References acceptAll_, eventSelector_, init(), Skims_PA_cff::paths, AlCaHLTBitMon_QueryRunRegistry::string, trim(), and useOld_.

◆ TriggerSelector() [3/3]

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.

58  : useOld_(false) {
59  init(trim(expression), triggernames);
60  }

References init(), and trim().

◆ ~TriggerSelector()

dqmservices::TriggerSelector::~TriggerSelector ( )
inline

Definition at line 41 of file TriggerSelector.h.

41 {};

Member Function Documentation

◆ acceptEvent() [1/2]

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

Evaluates if trigger results pass selection

Definition at line 94 of file TriggerSelector.cc.

94  {
95  if (useOld_) {
96  return eventSelector_->acceptEvent(tr);
97  }
98 
99  if (acceptAll_)
100  return true;
101 
102  return masterElement_->returnStatus(tr);
103  }

References acceptAll_, eventSelector_, masterElement_, and useOld_.

◆ acceptEvent() [2/2]

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.

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  }

References acceptAll_, eventSelector_, masterElement_, and useOld_.

◆ getEventSelectionVString()

std::vector< std::string > dqmservices::TriggerSelector::getEventSelectionVString ( edm::ParameterSet const &  pset)
static

◆ init()

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

Definition at line 62 of file TriggerSelector.cc.

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  }

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

Referenced by TriggerSelector().

◆ makeXMLString()

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

Definition at line 335 of file TriggerSelector.cc.

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  }

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

◆ returnStatus()

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

Definition at line 66 of file TriggerSelector.h.

66 { return masterElement_->returnStatus(trStatus); }

References masterElement_.

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

◆ trim()

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

Definition at line 322 of file TriggerSelector.cc.

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  }

References input.

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

◆ wantAll()

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

Returns status of always positive bit

Definition at line 46 of file TriggerSelector.h.

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

References acceptAll_.

Member Data Documentation

◆ acceptAll_

bool dqmservices::TriggerSelector::acceptAll_
private

Definition at line 79 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 133 of file TriggerSelector.h.

Referenced by acceptEvent(), and TriggerSelector().

◆ expression_

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

Definition at line 131 of file TriggerSelector.h.

Referenced by init().

◆ masterElement_

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

Definition at line 128 of file TriggerSelector.h.

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

◆ useOld_

bool dqmservices::TriggerSelector::useOld_
private

Definition at line 134 of file TriggerSelector.h.

Referenced by acceptEvent(), and TriggerSelector().

input
static const std::string input
Definition: EdmProvDump.cc:48
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
pos
Definition: PixelAliasList.h:18
edm::HLTGlobalStatus
Definition: HLTGlobalStatus.h:25
boost
Definition: CLHEP.h:16
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::EventSelector
Definition: EventSelector.h:35
Strings
std::vector< std::string > Strings
Definition: MsgTools.h:18
config
Definition: config.py:1
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
dqmservices::TriggerSelector::trim
static std::string trim(std::string input)
Definition: TriggerSelector.cc:322
dqmservices::TriggerSelector::masterElement_
std::shared_ptr< TreeElement > masterElement_
Definition: TriggerSelector.h:128
dqmservices::TriggerSelector::expression_
std::string expression_
Definition: TriggerSelector.h:131
dqmservices::TriggerSelector::useOld_
bool useOld_
Definition: TriggerSelector.h:134
edm::HLTPathStatus
Definition: HLTPathStatus.h:33
dqmservices::TriggerSelector::acceptAll_
bool acceptAll_
Definition: TriggerSelector.h:79
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
dqmservices::TriggerSelector::eventSelector_
std::shared_ptr< edm::EventSelector > eventSelector_
Definition: TriggerSelector.h:133
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
Skims_PA_cff.paths
paths
Definition: Skims_PA_cff.py:18
edm::EventSelector::getEventSelectionVString
static std::vector< std::string > getEventSelectionVString(edm::ParameterSet const &pset)
Definition: EventSelector.cc:812
dqmservices::TriggerSelector::init
void init(std::string const &path, Strings const &triggernames)
Definition: TriggerSelector.cc:62
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27