CMS 3D CMS Logo

Public Member Functions | Private Attributes

HLTEventSelector Class Reference

#include <HLTEventSelector.h>

Inheritance diagram for HLTEventSelector:
EventSelector

List of all members.

Public Member Functions

 HLTEventSelector (const edm::ParameterSet &)
virtual bool select (const edm::Event &) const
 decision of the selector module
virtual ~HLTEventSelector ()

Private Attributes

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

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_.

                                                              {
  // input collection
  triggerResults_ = pset.getParameter<edm::InputTag>("triggerResults");
  // trigger path names
  pathNames_ = pset.getParameter< std::vector<std::string> >("pathNames");

  edm::LogInfo("HLTEventSelector") << "constructed with \n"
                                   << "  src = " << triggerResults_ << "\n"
                                   << "  #pathnames = " << pathNames_.size();
}
virtual HLTEventSelector::~HLTEventSelector ( ) [inline, virtual]

Definition at line 26 of file HLTEventSelector.h.

{}

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_.

{
  //
  // get the trigger results and check validity
  //
  edm::Handle<edm::TriggerResults> hltHandle;
  event.getByLabel(triggerResults_, hltHandle);
  if ( !hltHandle.isValid() ) {
    edm::LogWarning("HLTEventSelector") << "No trigger results for InputTag " << triggerResults_;
    return false;
  }
  //
  // get results
  //
  const edm::TriggerNames & trgNames = event.triggerNames(*hltHandle);
  unsigned int trgSize = trgNames.size();
//   static int first(true);
//   if ( first ) {
//     first = false;
//     std::cout << "Trigger menu" << std::endl;
//     for ( unsigned int i=0; i<trgSize; ++i ) {
//       std::cout << trgNames.triggerName(i) << std::endl;
//     }
//   }
//
// example for OR of all specified triggers
//
  for ( std::vector<std::string>::const_iterator i=pathNames_.begin();
        i!=pathNames_.end(); ++i ) {
    // get index
    unsigned int index = trgNames.triggerIndex(*i);
    if ( index==trgSize ) {
      edm::LogWarning("HLTEventSelector") << "Unknown trigger name " << *i;
//       return false;
      continue;
    }
//     if ( !hltHandle->accept(index) )  return false;
    if ( hltHandle->accept(index) ) {
      LogDebug("HLTEventSelector") << "Event selected by " << *i;
      return true;
    }
  }
//   return true;
  LogDebug("HLTEventSelector") << "Event rejected";
  return false;
}

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().

tag for input collection

Definition at line 28 of file HLTEventSelector.h.

Referenced by HLTEventSelector(), and select().