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
edm::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 23 of file TriggerSelector.h.

Member Typedef Documentation

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

Definition at line 27 of file TriggerSelector.h.

Constructor & Destructor Documentation

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

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

Definition at line 18 of file TriggerSelector.cc.

21  :
22  useOld_(true)
23  {
24  acceptAll_=false;
25  eventSelector_.reset( new edm::EventSelector(pathspecs,names));
26  }
static const HistoName names[]
boost::shared_ptr< edm::EventSelector > eventSelector_
edm::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 29 of file TriggerSelector.cc.

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

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

Takes selection string and list of triggers

Definition at line 72 of file TriggerSelector.cc.

References init.

75  :
76  useOld_(false)
77  {
78  init (trim(expression),triggernames);
79  }
void init(std::string const &path, Strings const &triggernames)
static std::string trim(std::string input)
edm::TriggerSelector::~TriggerSelector ( )
inline

Definition at line 47 of file TriggerSelector.h.

47 {};

Member Function Documentation

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

Evaluates if trigger results pass selection

Definition at line 120 of file TriggerSelector.cc.

References acceptAll_, eventSelector_, masterElement_, and useOld_.

121  {
122  if (useOld_) {
123  return eventSelector_->acceptEvent(tr);
124  }
125 
126  if (acceptAll_) return true;
127 
128  return masterElement_->returnStatus(tr);
129  }
boost::shared_ptr< TreeElement > masterElement_
boost::shared_ptr< edm::EventSelector > eventSelector_
bool edm::TriggerSelector::acceptEvent ( unsigned char const *  array_of_trigger_results,
int  number_of_trigger_paths 
) const

Definition at line 133 of file TriggerSelector.cc.

137  {
138  if (useOld_)
139  return eventSelector_->acceptEvent(array_of_trigger_results,number_of_trigger_paths);
140 
141  if (acceptAll_) return true;
142 
143  // Form HLTGlobalStatus object to represent the array_of_trigger_results
144  edm::HLTGlobalStatus tr(number_of_trigger_paths);
145  int byteIndex = 0;
146  int subIndex = 0;
147  for (int pathIndex = 0; pathIndex < number_of_trigger_paths; ++pathIndex)
148  {
149  int state = array_of_trigger_results[byteIndex] >> (subIndex * 2);
150  state &= 0x3;
151  edm::HLTPathStatus pathStatus(static_cast<edm::hlt::HLTState>(state));
152  tr[pathIndex] = pathStatus;
153  ++subIndex;
154  if (subIndex == 4)
155  { ++byteIndex;
156  subIndex = 0;
157  }
158  }
159  // Now make the decision, based on the HLTGlobalStatus tr,
160  // which we have created from the supplied array of results
161  masterElement_->returnStatus(tr);
162  return masterElement_->returnStatus(tr);
163  }
boost::shared_ptr< TreeElement > masterElement_
boost::shared_ptr< edm::EventSelector > eventSelector_
std::vector< std::string > edm::TriggerSelector::getEventSelectionVString ( edm::ParameterSet const &  pset)
static

Definition at line 115 of file TriggerSelector.cc.

References edm::EventSelector::getEventSelectionVString().

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

Definition at line 83 of file TriggerSelector.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

87  {
88  //debug_ = true;
89  if (expression.empty())
90  {
91  acceptAll_ = true;
92  return;
93  }
94  if (expression.size()==1 && expression.at(0)=='*') acceptAll_=true;
95  else acceptAll_=false;
96 
97  //replace all possible alternate operators (.AND. and .OR.)
98  {
99  using namespace boost;
101  temp = regex_replace( expression , regex(".AND."), "&&");
102  expression_ = regex_replace( temp, regex(".and."), "&&");
103  temp = regex_replace( expression_, regex(".OR."), "||");
104  expression_ = regex_replace( temp, regex(".or."), "||");
105  }
106 
107  //build decision tree
108  masterElement_.reset( new TreeElement(expression_,triggernames));
109  }
boost::shared_ptr< TreeElement > masterElement_
std::string edm::TriggerSelector::makeXMLString ( std::string const &  input)
static

Definition at line 394 of file TriggerSelector.cc.

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

395  {
397  if (!input.empty()) {
398  for (size_t pos=0;pos<input.size();pos++) {
399  char ch = input.at(pos);
400  if (ch=='&') output.append("&amp;");
401  else output.append(1,ch);
402  }
403  }
404  return output;
405  }
static std::string const input
Definition: EdmProvDump.cc:44
bool edm::TriggerSelector::returnStatus ( edm::HLTGlobalStatus const &  trStatus) const
inline

Definition at line 71 of file TriggerSelector.h.

References masterElement_.

71  {
72  return masterElement_->returnStatus(trStatus);
73  }
boost::shared_ptr< TreeElement > masterElement_
std::string edm::TriggerSelector::trim ( std::string  input)
staticprivate

Definition at line 379 of file TriggerSelector.cc.

References input.

380  {
381  if (!input.empty())
382  {
383  std::string::size_type pos = input.find_first_not_of(" ");
384  if (pos != std::string::npos)
385  input.erase(0,pos);
386 
387  pos = input.find_last_not_of(" ");
388  if (pos != std::string::npos)
389  input.erase(pos+1);
390  }
391  return input;
392  }
uint16_t size_type
static std::string const input
Definition: EdmProvDump.cc:44
bool edm::TriggerSelector::wantAll ( ) const
inline

Returns status of always positive bit

Definition at line 52 of file TriggerSelector.h.

References acceptAll_.

52  {
53  // if (useOld_) return eventSelector_->wantAll();
54  return acceptAll_;
55  }

Member Data Documentation

bool edm::TriggerSelector::acceptAll_
private

Definition at line 88 of file TriggerSelector.h.

Referenced by acceptEvent(), and wantAll().

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

Definition at line 152 of file TriggerSelector.h.

boost::shared_ptr<edm::EventSelector> edm::TriggerSelector::eventSelector_
private

Definition at line 149 of file TriggerSelector.h.

Referenced by acceptEvent().

std::string edm::TriggerSelector::expression_
private

Definition at line 147 of file TriggerSelector.h.

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

Definition at line 144 of file TriggerSelector.h.

Referenced by acceptEvent(), and returnStatus().

bool edm::TriggerSelector::useOld_
private

Definition at line 150 of file TriggerSelector.h.

Referenced by acceptEvent().