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
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_;
0025 unsigned int min_seeds_;
0026 unsigned int max_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
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
0066
0067
0068
0069 bool HLTTrackSeedMultiplicityFilter::hltFilter(edm::Event& event,
0070 const edm::EventSetup& iSetup,
0071 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0072
0073
0074
0075
0076
0077 if (saveTags())
0078 filterproduct.addCollectionTag(inputTag_);
0079
0080
0081 edm::Handle<TrajectorySeedCollection> seedColl;
0082 event.getByToken(inputToken_, seedColl);
0083
0084 const TrajectorySeedCollection* rsSeedCollection = nullptr;
0085
0086 if (seedColl.isValid()) {
0087
0088 rsSeedCollection = seedColl.product();
0089 } else {
0090 return false;
0091 }
0092
0093
0094
0095 unsigned int seedsize = rsSeedCollection->size();
0096
0097 LogDebug("") << "Number of seeds: " << seedsize;
0098
0099
0100
0101 bool accept = (seedsize >= min_seeds_);
0102
0103 if (max_seeds_ > 0)
0104 accept &= (seedsize <= max_seeds_);
0105
0106
0107 return accept;
0108 }
0109
0110
0111 #include "FWCore/Framework/interface/MakerMacros.h"
0112 DEFINE_FWK_MODULE(HLTTrackSeedMultiplicityFilter);