Go to the documentation of this file.00001 #ifndef HLTrigger_HLTTrackWithHits_H
00002
00008
00009 #include <memory>
00010
00011
00012 #include "FWCore/Framework/interface/Frameworkfwd.h"
00013 #include "FWCore/Framework/interface/EDFilter.h"
00014
00015 #include "FWCore/Framework/interface/Event.h"
00016 #include "FWCore/Framework/interface/MakerMacros.h"
00017
00018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00019
00020 #include "FWCore/MessageService/interface/MessageLogger.h"
00021
00022 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
00023 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00024 #include "DataFormats/TrackReco/interface/Track.h"
00025 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00026
00027 class HLTTrackWithHits : public HLTFilter {
00028 public:
00029 explicit HLTTrackWithHits(const edm::ParameterSet& iConfig) : HLTFilter(iConfig),
00030 src_(iConfig.getParameter<edm::InputTag>("src")),
00031 minN_(iConfig.getParameter<int>("MinN")),
00032 maxN_(iConfig.getParameter<int>("MaxN")),
00033 MinBPX_(iConfig.getParameter<int>("MinBPX")),
00034 MinFPX_(iConfig.getParameter<int>("MinFPX")),
00035 MinPXL_(iConfig.getParameter<int>("MinPXL"))
00036 {
00037 }
00038
00039 ~HLTTrackWithHits() { }
00040
00041 private:
00042 virtual bool hltFilter(edm::Event& iEvent, const edm::EventSetup&, trigger::TriggerFilterObjectWithRefs & filterproduct)
00043 {
00044 edm::Handle<reco::TrackCollection> oHandle;
00045 iEvent.getByLabel(src_, oHandle);
00046 int s=oHandle->size();
00047 int count=0;
00048 for (int i=0;i!=s;++i){
00049 const reco::Track & track = (*oHandle)[i];
00050 const reco::HitPattern & hits = track.hitPattern();
00051 if ( MinBPX_>0 && hits.numberOfValidPixelBarrelHits() >= MinBPX_ ) { ++count; continue; }
00052 if ( MinFPX_>0 && hits.numberOfValidPixelEndcapHits() >= MinFPX_ ) { ++count; continue; }
00053 if ( MinPXL_>0 && hits.numberOfValidPixelHits() >= MinPXL_ ) { ++count; continue; }
00054 }
00055
00056 bool answer=(count>=minN_ && count<=maxN_);
00057 LogDebug("HLTTrackWithHits")<<module()<<" sees: "<<s<<" objects. Only: "<<count<<" satisfy the hit requirement. Filter answer is: "<<(answer?"true":"false")<<std::endl;
00058 return answer;
00059 }
00060
00061 edm::InputTag src_;
00062 int minN_,maxN_,MinBPX_,MinFPX_,MinPXL_;
00063 };
00064
00065
00066 #endif