Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
/** \file
 *
 * $Date: 2012/01/21 14:56:53 $
 * $Revision: 1.3 $
 * \author Silvia Goy Lopez - CERN <silvia.goy.lopez@cern.ch>
 */

/* This Class Header */
#include "DPGAnalysis/Skims/interface/MuonPtFilter.h"

/* Collaborating Class Header */
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"

/* C++ Headers */
using namespace std;
using namespace edm;

/* ====================================================================== */

/// Constructor
MuonPtFilter::MuonPtFilter(const edm::ParameterSet& pset) {
  // the name of the STA rec hits collection
  theSTAMuonLabel = pset.getParameter<std::string>("SALabel");

  theMinPt = pset.getParameter<double>("minPt");  // pt min (GeV)

  LogDebug("MuonPt") << " SALabel : " << theSTAMuonLabel << " Min Pt : " << theMinPt;
}

/// Destructor
MuonPtFilter::~MuonPtFilter() {}

/* Operations */
bool MuonPtFilter::filter(edm::Event& event, const edm::EventSetup& eventSetup) {
  // Get the RecTrack collection from the event
  Handle<reco::TrackCollection> staTracks;
  event.getByLabel(theSTAMuonLabel, staTracks);

  reco::TrackCollection::const_iterator staTrack;

  for (staTrack = staTracks->begin(); staTrack != staTracks->end(); ++staTrack) {
    if (staTrack->pt() > theMinPt)
      return true;
  }

  return false;
}

// define this as a plug-in
DEFINE_FWK_MODULE(MuonPtFilter);