Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:43

0001 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
0002 
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0006 
0007 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
0008 
0009 //
0010 // class declaration
0011 //
0012 
0013 class HLTTrackSeedMultiplicityFilter : public HLTFilter {
0014 public:
0015   explicit HLTTrackSeedMultiplicityFilter(const edm::ParameterSet&);
0016   ~HLTTrackSeedMultiplicityFilter() override;
0017   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0018 
0019 private:
0020   bool hltFilter(edm::Event&,
0021                  const edm::EventSetup&,
0022                  trigger::TriggerFilterObjectWithRefs& filterproduct) const override;
0023 
0024   edm::InputTag inputTag_;  // input tag identifying product containing track seeds
0025   unsigned int min_seeds_;  // minimum number of track seeds
0026   unsigned int max_seeds_;  // maximum number of track seeds
0027   edm::EDGetTokenT<TrajectorySeedCollection> inputToken_;
0028 };
0029 
0030 #include "FWCore/Framework/interface/Event.h"
0031 #include "FWCore/Framework/interface/EventSetup.h"
0032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0033 #include "DataFormats/Common/interface/Handle.h"
0034 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0035 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0036 
0037 //
0038 // constructors and destructor
0039 //
0040 
0041 HLTTrackSeedMultiplicityFilter::HLTTrackSeedMultiplicityFilter(const edm::ParameterSet& config)
0042     : HLTFilter(config),
0043       inputTag_(config.getParameter<edm::InputTag>("inputTag")),
0044       min_seeds_(config.getParameter<unsigned int>("minSeeds")),
0045       max_seeds_(config.getParameter<unsigned int>("maxSeeds")) {
0046   inputToken_ = consumes<TrajectorySeedCollection>(inputTag_);
0047   LogDebug("") << "Using the " << inputTag_ << " input collection";
0048   LogDebug("") << "Requesting at least " << min_seeds_ << " seeds";
0049   if (max_seeds_ > 0)
0050     LogDebug("") << "...but no more than " << max_seeds_ << " seeds";
0051 }
0052 
0053 HLTTrackSeedMultiplicityFilter::~HLTTrackSeedMultiplicityFilter() = default;
0054 
0055 void HLTTrackSeedMultiplicityFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0056   edm::ParameterSetDescription desc;
0057   makeHLTFilterDescription(desc);
0058   desc.add<edm::InputTag>("inputTag", edm::InputTag("hltRegionalCosmicTrackerSeeds"));
0059   desc.add<unsigned int>("minSeeds", 0);
0060   desc.add<unsigned int>("maxSeeds", 10000);
0061   descriptions.add("hltTrackSeedMultiplicityFilter", desc);
0062 }
0063 
0064 //
0065 // member functions
0066 //
0067 
0068 // ------------ method called to produce the data  ------------
0069 bool HLTTrackSeedMultiplicityFilter::hltFilter(edm::Event& event,
0070                                                const edm::EventSetup& iSetup,
0071                                                trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0072   // All HLT filters must create and fill an HLT filter object,
0073   // recording any reconstructed physics objects satisfying (or not)
0074   // this HLT filter, and place it in the Event.
0075 
0076   // The filter object
0077   if (saveTags())
0078     filterproduct.addCollectionTag(inputTag_);
0079 
0080   // get hold of products from Event
0081   edm::Handle<TrajectorySeedCollection> seedColl;
0082   event.getByToken(inputToken_, seedColl);
0083 
0084   const TrajectorySeedCollection* rsSeedCollection = nullptr;
0085 
0086   if (seedColl.isValid()) {
0087     //std::cout << "Problem!!" << std::endl;
0088     rsSeedCollection = seedColl.product();
0089   } else {
0090     return false;
0091   }
0092 
0093   // Number of trakc seeds in the collection
0094 
0095   unsigned int seedsize = rsSeedCollection->size();
0096 
0097   LogDebug("") << "Number of seeds: " << seedsize;
0098 
0099   // Apply the filter cuts
0100 
0101   bool accept = (seedsize >= min_seeds_);
0102 
0103   if (max_seeds_ > 0)
0104     accept &= (seedsize <= max_seeds_);
0105 
0106   // return with final filter decision
0107   return accept;
0108 }
0109 
0110 // define as a framework module
0111 #include "FWCore/Framework/interface/MakerMacros.h"
0112 DEFINE_FWK_MODULE(HLTTrackSeedMultiplicityFilter);