CMS 3D CMS Logo

HLTTrackWithHits.h

Go to the documentation of this file.
00001 #ifndef HLTrigger_HLTTrackWithHits_H
00002 
00008 // system include files
00009 #include <memory>
00010 
00011 // user include files
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) :
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         produces<trigger::TriggerFilterObjectWithRefs>();
00038       };
00039   
00040   ~HLTTrackWithHits(){};
00041   
00042 private:
00043   virtual void beginJob(const edm::EventSetup&){};
00044   virtual bool filter(edm::Event& iEvent, const edm::EventSetup&)
00045   {
00046     // The filtered object. which is put empty.
00047     std::auto_ptr<trigger::TriggerFilterObjectWithRefs> filterproduct (new trigger::TriggerFilterObjectWithRefs(path(),module()));
00048 
00049     edm::Handle<reco::TrackCollection> oHandle;
00050     iEvent.getByLabel(src_, oHandle);
00051     int s=oHandle->size();
00052     int count=0;
00053     for (int i=0;i!=s;++i){
00054       const reco::Track & track = (*oHandle)[i];
00055       const reco::HitPattern & hits = track.hitPattern();
00056       if ( MinBPX_>0 && hits.numberOfValidPixelBarrelHits() >= MinBPX_ ) count++; continue;
00057       if ( MinFPX_>0 && hits.numberOfValidPixelEndcapHits() >= MinFPX_ ) count++; continue;
00058       if ( MinPXL_>0 && hits.numberOfValidPixelHits() >= MinPXL_ ) count++; continue;
00059     }
00060       
00061     bool answer=(count>=minN_ && count<=maxN_);
00062     LogDebug("HLTTrackWithHits")<<module()<<" sees: "<<s<<" objects. Only: "<<count<<" satisfy the hit requirement. Filter answer is: "<<(answer?"true":"false")<<std::endl;
00063 
00064     iEvent.put(filterproduct);
00065     return answer;
00066   }
00067   virtual void endJob(){};
00068  
00069   edm::InputTag src_;
00070   int minN_,maxN_,MinBPX_,MinFPX_,MinPXL_;
00071 };
00072 
00073 
00074 #endif

Generated on Tue Jun 9 17:37:58 2009 for CMSSW by  doxygen 1.5.4