CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
HLTEventSelector Class Reference

#include <HLTEventSelector.h>

Inheritance diagram for HLTEventSelector:
EventSelector

Public Member Functions

 HLTEventSelector (const edm::ParameterSet &)
 
virtual bool select (const edm::Event &) const
 decision of the selector module More...
 
virtual ~HLTEventSelector ()
 
- Public Member Functions inherited from EventSelector
const std::vector< std::string > & description ()
 
const std::vector< std::string > & description ()
 
 EventSelector ()
 
 EventSelector ()
 
 EventSelector (const edm::ParameterSet &iConfig)
 
 EventSelector (const edm::ParameterSet &iConfig)
 
const std::string & name () const
 name of the module (from configuration) More...
 
const std::string & name () const
 name of the module (from configuration) More...
 
virtual ~EventSelector ()
 
virtual ~EventSelector ()
 

Private Attributes

std::vector< std::string > pathNames_
 trigger path names (ORed) More...
 
edm::InputTag triggerResults_
 tag for input collection More...
 

Additional Inherited Members

- Protected Attributes inherited from EventSelector
std::vector< std::string > description_
 
std::string name_
 

Detailed Description

Trivial example for a HLT selector. To be modified for analysis!

Definition at line 22 of file HLTEventSelector.h.

Constructor & Destructor Documentation

HLTEventSelector::HLTEventSelector ( const edm::ParameterSet pset)

Definition at line 8 of file HLTEventSelector.cc.

References edm::ParameterSet::getParameter(), pathNames_, and triggerResults_.

8  {
9  // input collection
10  triggerResults_ = pset.getParameter<edm::InputTag>("triggerResults");
11  // trigger path names
12  pathNames_ = pset.getParameter< std::vector<std::string> >("pathNames");
13 
14  edm::LogInfo("HLTEventSelector") << "constructed with \n"
15  << " src = " << triggerResults_ << "\n"
16  << " #pathnames = " << pathNames_.size();
17 }
T getParameter(std::string const &) const
edm::InputTag triggerResults_
tag for input collection
std::vector< std::string > pathNames_
trigger path names (ORed)
virtual HLTEventSelector::~HLTEventSelector ( )
inlinevirtual

Definition at line 26 of file HLTEventSelector.h.

26 {}

Member Function Documentation

bool HLTEventSelector::select ( const edm::Event ) const
virtual

decision of the selector module

Implements EventSelector.

Definition at line 20 of file HLTEventSelector.cc.

References i, getHLTprescales::index, edm::HandleBase::isValid(), LogDebug, pathNames_, edm::TriggerNames::size(), edm::TriggerNames::triggerIndex(), edm::TriggerNames::triggerNames(), and triggerResults_.

21 {
22  //
23  // get the trigger results and check validity
24  //
26  event.getByLabel(triggerResults_, hltHandle);
27  if ( !hltHandle.isValid() ) {
28  edm::LogWarning("HLTEventSelector") << "No trigger results for InputTag " << triggerResults_;
29  return false;
30  }
31  //
32  // get results
33  //
34  const edm::TriggerNames & trgNames = event.triggerNames(*hltHandle);
35  unsigned int trgSize = trgNames.size();
36 // static int first(true);
37 // if ( first ) {
38 // first = false;
39 // std::cout << "Trigger menu" << std::endl;
40 // for ( unsigned int i=0; i<trgSize; ++i ) {
41 // std::cout << trgNames.triggerName(i) << std::endl;
42 // }
43 // }
44 //
45 // example for OR of all specified triggers
46 //
47  for ( std::vector<std::string>::const_iterator i=pathNames_.begin();
48  i!=pathNames_.end(); ++i ) {
49  // get index
50  unsigned int index = trgNames.triggerIndex(*i);
51  if ( index==trgSize ) {
52  edm::LogWarning("HLTEventSelector") << "Unknown trigger name " << *i;
53 // return false;
54  continue;
55  }
56 // if ( !hltHandle->accept(index) ) return false;
57  if ( hltHandle->accept(index) ) {
58  LogDebug("HLTEventSelector") << "Event selected by " << *i;
59  return true;
60  }
61  }
62 // return true;
63  LogDebug("HLTEventSelector") << "Event rejected";
64  return false;
65 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
Strings::size_type size() const
Definition: TriggerNames.cc:39
edm::InputTag triggerResults_
tag for input collection
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
bool isValid() const
Definition: HandleBase.h:76
std::vector< std::string > pathNames_
trigger path names (ORed)

Member Data Documentation

std::vector<std::string> HLTEventSelector::pathNames_
private

trigger path names (ORed)

Definition at line 29 of file HLTEventSelector.h.

Referenced by HLTEventSelector(), and select().

edm::InputTag HLTEventSelector::triggerResults_
private

tag for input collection

Definition at line 28 of file HLTEventSelector.h.

Referenced by HLTEventSelector(), and select().