CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/HLTrigger/special/src/HLTPixelActivityFilter.cc

Go to the documentation of this file.
00001 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
00002 
00003 //
00004 // class declaration
00005 //
00006 
00007 class HLTPixelActivityFilter : public HLTFilter {
00008 public:
00009   explicit HLTPixelActivityFilter(const edm::ParameterSet&);
00010   ~HLTPixelActivityFilter();
00011 
00012 private:
00013   virtual bool filter(edm::Event&, const edm::EventSetup&);
00014 
00015   edm::InputTag inputTag_;          // input tag identifying product containing pixel clusters
00016   bool          saveTag_;           // whether to save this tag
00017   unsigned int  min_clusters_;      // minimum number of clusters
00018   unsigned int  max_clusters_;      // maximum number of clusters
00019 
00020 };
00021 
00022 #include "FWCore/Framework/interface/Event.h"
00023 #include "FWCore/Framework/interface/EventSetup.h"
00024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00026 #include "DataFormats/Common/interface/Handle.h"
00027 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
00028 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00029 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
00030 
00031 //
00032 // constructors and destructor
00033 //
00034  
00035 HLTPixelActivityFilter::HLTPixelActivityFilter(const edm::ParameterSet& config) :
00036   inputTag_     (config.getParameter<edm::InputTag>("inputTag")),
00037   saveTag_      (config.getUntrackedParameter<bool>("saveTag", false)),
00038   min_clusters_ (config.getParameter<unsigned int>("minClusters")),
00039   max_clusters_ (config.getParameter<unsigned int>("maxClusters"))
00040 {
00041   LogDebug("") << "Using the " << inputTag_ << " input collection";
00042   LogDebug("") << "Requesting at least " << min_clusters_ << " clusters";
00043   if(max_clusters_ > 0) 
00044     LogDebug("") << "...but no more than " << max_clusters_ << " clusters";
00045 
00046   // register your products
00047   produces<trigger::TriggerFilterObjectWithRefs>();
00048 }
00049 
00050 HLTPixelActivityFilter::~HLTPixelActivityFilter()
00051 {
00052 }
00053 
00054 //
00055 // member functions
00056 //
00057 
00058 // ------------ method called to produce the data  ------------
00059 bool HLTPixelActivityFilter::filter(edm::Event& event, const edm::EventSetup& iSetup)
00060 {
00061   // All HLT filters must create and fill an HLT filter object,
00062   // recording any reconstructed physics objects satisfying (or not)
00063   // this HLT filter, and place it in the Event.
00064 
00065   // The filter object
00066   std::auto_ptr<trigger::TriggerFilterObjectWithRefs> filterobject (new trigger::TriggerFilterObjectWithRefs(path(),module()));
00067   if (saveTag_) filterobject->addCollectionTag(inputTag_);
00068 
00069   // get hold of products from Event
00070   edm::Handle<edmNew::DetSetVector<SiPixelCluster> > clusterColl;
00071   event.getByLabel(inputTag_, clusterColl);
00072 
00073   unsigned int clusterSize = clusterColl->dataSize();
00074   LogDebug("") << "Number of clusters accepted: " << clusterSize;
00075   bool accept = (clusterSize >= min_clusters_);
00076   if(max_clusters_ > 0) 
00077     accept &= (clusterSize <= max_clusters_);
00078 
00079   // put filter object into the Event
00080   event.put(filterobject);
00081 
00082   // return with final filter decision
00083   return accept;
00084 }
00085 
00086 // define as a framework module
00087 #include "FWCore/Framework/interface/MakerMacros.h"
00088 DEFINE_FWK_MODULE(HLTPixelActivityFilter);