CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/HLTrigger/special/interface/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 bool filter(edm::Event& iEvent, const edm::EventSetup&)
00044   {
00045     // The filtered object. which is put empty.
00046     std::auto_ptr<trigger::TriggerFilterObjectWithRefs> filterproduct (new trigger::TriggerFilterObjectWithRefs(path(),module()));
00047 
00048     edm::Handle<reco::TrackCollection> oHandle;
00049     iEvent.getByLabel(src_, oHandle);
00050     int s=oHandle->size();
00051     int count=0;
00052     for (int i=0;i!=s;++i){
00053       const reco::Track & track = (*oHandle)[i];
00054       const reco::HitPattern & hits = track.hitPattern();
00055       if ( MinBPX_>0 && hits.numberOfValidPixelBarrelHits() >= MinBPX_ ) count++; continue;
00056       if ( MinFPX_>0 && hits.numberOfValidPixelEndcapHits() >= MinFPX_ ) count++; continue;
00057       if ( MinPXL_>0 && hits.numberOfValidPixelHits() >= MinPXL_ ) count++; continue;
00058     }
00059       
00060     bool answer=(count>=minN_ && count<=maxN_);
00061     LogDebug("HLTTrackWithHits")<<module()<<" sees: "<<s<<" objects. Only: "<<count<<" satisfy the hit requirement. Filter answer is: "<<(answer?"true":"false")<<std::endl;
00062 
00063     iEvent.put(filterproduct);
00064     return answer;
00065   }
00066   virtual void endJob(){};
00067  
00068   edm::InputTag src_;
00069   int minN_,maxN_,MinBPX_,MinFPX_,MinPXL_;
00070 };
00071 
00072 
00073 #endif