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
stor::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

Author:
mommsen
Revision:
1.7
Date:
2011/03/07 15:31:32

Definition at line 29 of file TriggerSelector.h.

Member Typedef Documentation

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

Definition at line 33 of file TriggerSelector.h.

Constructor & Destructor Documentation

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

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

Definition at line 21 of file TriggerSelector.cc.

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

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

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

Takes selection string and list of triggers

Definition at line 75 of file TriggerSelector.cc.

References init.

78  :
79  useOld_(false)
80  {
81  init (trim(expression),triggernames);
82  }
void init(std::string const &path, Strings const &triggernames)
static std::string trim(std::string input)
stor::TriggerSelector::~TriggerSelector ( )
inline

Definition at line 53 of file TriggerSelector.h.

53 {};

Member Function Documentation

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

Evaluates if trigger results pass selection

Definition at line 123 of file TriggerSelector.cc.

References acceptAll_, eventSelector_, masterElement_, and useOld_.

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

Definition at line 136 of file TriggerSelector.cc.

References evf::utils::state.

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

Definition at line 118 of file TriggerSelector.cc.

References edm::EventSelector::getEventSelectionVString().

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

Definition at line 86 of file TriggerSelector.cc.

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

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

Definition at line 397 of file TriggerSelector.cc.

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

398  {
400  if (!input.empty()) {
401  for (size_t pos=0;pos<input.size();pos++) {
402  char ch = input.at(pos);
403  if (ch=='&') output.append("&amp;");
404  else output.append(1,ch);
405  }
406  }
407  return output;
408  }
bool stor::TriggerSelector::returnStatus ( edm::HLTGlobalStatus const &  trStatus) const
inline

Definition at line 77 of file TriggerSelector.h.

References masterElement_.

77  {
78  return masterElement_->returnStatus(trStatus);
79  }
boost::shared_ptr< TreeElement > masterElement_
std::string stor::TriggerSelector::trim ( std::string  input)
staticprivate

Definition at line 382 of file TriggerSelector.cc.

References LaserDQM_cfg::input, and pos.

383  {
384  if (!input.empty())
385  {
386  std::string::size_type pos = input.find_first_not_of(" ");
387  if (pos != std::string::npos)
388  input.erase(0,pos);
389 
390  pos = input.find_last_not_of(" ");
391  if (pos != std::string::npos)
392  input.erase(pos+1);
393  }
394  return input;
395  }
uint16_t size_type
bool stor::TriggerSelector::wantAll ( ) const
inline

Returns status of always positive bit

Definition at line 58 of file TriggerSelector.h.

References acceptAll_.

58  {
59  //if (useOld_) return eventSelector_->wantAll();
60  return acceptAll_;
61  }

Member Data Documentation

bool stor::TriggerSelector::acceptAll_
private

Definition at line 94 of file TriggerSelector.h.

Referenced by acceptEvent(), and wantAll().

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

Definition at line 158 of file TriggerSelector.h.

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

Definition at line 155 of file TriggerSelector.h.

Referenced by acceptEvent().

std::string stor::TriggerSelector::expression_
private

Definition at line 153 of file TriggerSelector.h.

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

Definition at line 150 of file TriggerSelector.h.

Referenced by acceptEvent(), and returnStatus().

bool stor::TriggerSelector::useOld_
private

Definition at line 156 of file TriggerSelector.h.

Referenced by acceptEvent().