CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
00002 
00003 //
00004 // class declaration
00005 //
00006 
00007 class HLTTrackSeedMultiplicityFilter : public HLTFilter {
00008 public:
00009   explicit HLTTrackSeedMultiplicityFilter(const edm::ParameterSet&);
00010   ~HLTTrackSeedMultiplicityFilter();
00011 
00012 private:
00013   virtual bool filter(edm::Event&, const edm::EventSetup&);
00014 
00015   edm::InputTag inputTag_;       // input tag identifying product containing track seeds
00016   bool          saveTag_;        // whether to save this tag
00017   unsigned int  min_seeds_;      // minimum number of track seeds
00018   unsigned int  max_seeds_;      // maximum number of track seeds
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/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00028 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
00029 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00030 
00031 //
00032 // constructors and destructor
00033 //
00034  
00035 HLTTrackSeedMultiplicityFilter::HLTTrackSeedMultiplicityFilter(const edm::ParameterSet& config) :
00036   inputTag_     (config.getParameter<edm::InputTag>("inputTag")),
00037   saveTag_      (config.getUntrackedParameter<bool>("saveTag", false)),
00038   min_seeds_ (config.getParameter<unsigned int>("minSeeds")),
00039   max_seeds_ (config.getParameter<unsigned int>("maxSeeds"))
00040 {
00041   LogDebug("") << "Using the " << inputTag_ << " input collection";
00042   LogDebug("") << "Requesting at least " << min_seeds_ << " seeds";
00043   if(max_seeds_ > 0) 
00044     LogDebug("") << "...but no more than " << max_seeds_ << " seeds";
00045 
00046   // register your products
00047   produces<trigger::TriggerFilterObjectWithRefs>();
00048 }
00049 
00050 HLTTrackSeedMultiplicityFilter::~HLTTrackSeedMultiplicityFilter()
00051 {
00052 }
00053 
00054 //
00055 // member functions
00056 //
00057 
00058 // ------------ method called to produce the data  ------------
00059 bool HLTTrackSeedMultiplicityFilter::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<TrajectorySeedCollection> seedColl;
00071   event.getByLabel(inputTag_, seedColl);
00072 
00073   const TrajectorySeedCollection *rsSeedCollection = 0;
00074 
00075 
00076   if( seedColl.isValid() )
00077   {
00078     //std::cout << "Problem!!" << std::endl;
00079     rsSeedCollection = seedColl.product();
00080   } 
00081   else
00082   {
00083     return false;
00084   }
00085 
00086 
00087   // Number of trakc seeds in the collection
00088 
00089   unsigned int seedsize = rsSeedCollection->size();
00090 
00091 
00092   LogDebug("") << "Number of seeds: " << seedsize;
00093 
00094   // Apply the filter cuts
00095 
00096   bool accept = (seedsize >= min_seeds_);
00097 
00098   if(max_seeds_ > 0) 
00099     accept &= (seedsize <= max_seeds_);
00100   
00101   // put filter object into the Event
00102   event.put(filterobject);
00103 
00104   // return with final filter decision
00105   return accept;
00106 }
00107 
00108 // define as a framework module
00109 #include "FWCore/Framework/interface/MakerMacros.h"
00110 DEFINE_FWK_MODULE(HLTTrackSeedMultiplicityFilter);