File indexing completed on 2024-04-06 12:18:41
0001 #include <vector>
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/MakerMacros.h"
0004 #include "FWCore/Framework/interface/global/EDFilter.h"
0005 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0007 #include "FWCore/Utilities/interface/EDGetToken.h"
0008 #include "FWCore/Utilities/interface/InputTag.h"
0009 #include "FWCore/Utilities/interface/StreamID.h"
0010 #include "DataFormats/MuonReco/interface/MuonRecHitCluster.h"
0011
0012 class HLTMuonRecHitClusterFilter : public edm::global::EDFilter<> {
0013 public:
0014 explicit HLTMuonRecHitClusterFilter(const edm::ParameterSet&);
0015 ~HLTMuonRecHitClusterFilter() override = default;
0016 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0017
0018 private:
0019 bool filter(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
0020 const edm::EDGetTokenT<reco::MuonRecHitClusterCollection> cluster_token_;
0021 const int min_N_;
0022 const int min_Size_;
0023 const int min_SizeMinusMB1_;
0024 const std::vector<double> min_SizeRegionCutEtas_;
0025 const std::vector<double> max_SizeRegionCutEtas_;
0026 const std::vector<int> min_SizeRegionCutNstations_;
0027 const std::vector<int> max_SizeRegionCutNstations_;
0028 const std::vector<int> min_SizeRegionCutClusterSize_;
0029 const int max_nMB1_;
0030 const int max_nMB2_;
0031 const int max_nME11_;
0032 const int max_nME12_;
0033 const int max_nME41_;
0034 const int max_nME42_;
0035 const int min_Nstation_;
0036 const double min_AvgStation_;
0037 const double min_Time_;
0038 const double max_Time_;
0039 const double min_Eta_;
0040 const double max_Eta_;
0041 const double max_TimeSpread_;
0042 };
0043
0044
0045
0046 HLTMuonRecHitClusterFilter::HLTMuonRecHitClusterFilter(const edm::ParameterSet& iConfig)
0047 : cluster_token_(consumes<reco::MuonRecHitClusterCollection>(iConfig.getParameter<edm::InputTag>("ClusterTag"))),
0048 min_N_(iConfig.getParameter<int>("MinN")),
0049 min_Size_(iConfig.getParameter<int>("MinSize")),
0050 min_SizeMinusMB1_(iConfig.getParameter<int>("MinSizeMinusMB1")),
0051 min_SizeRegionCutEtas_(iConfig.getParameter<std::vector<double>>("MinSizeRegionCutEtas")),
0052 max_SizeRegionCutEtas_(iConfig.getParameter<std::vector<double>>("MaxSizeRegionCutEtas")),
0053 min_SizeRegionCutNstations_(iConfig.getParameter<std::vector<int>>("MinSizeRegionCutNstations")),
0054 max_SizeRegionCutNstations_(iConfig.getParameter<std::vector<int>>("MaxSizeRegionCutNstations")),
0055 min_SizeRegionCutClusterSize_(iConfig.getParameter<std::vector<int>>("MinSizeRegionCutClusterSize")),
0056 max_nMB1_(iConfig.getParameter<int>("Max_nMB1")),
0057 max_nMB2_(iConfig.getParameter<int>("Max_nMB2")),
0058 max_nME11_(iConfig.getParameter<int>("Max_nME11")),
0059 max_nME12_(iConfig.getParameter<int>("Max_nME12")),
0060 max_nME41_(iConfig.getParameter<int>("Max_nME41")),
0061 max_nME42_(iConfig.getParameter<int>("Max_nME42")),
0062 min_Nstation_(iConfig.getParameter<int>("MinNstation")),
0063 min_AvgStation_(iConfig.getParameter<double>("MinAvgStation")),
0064 min_Time_(iConfig.getParameter<double>("MinTime")),
0065 max_Time_(iConfig.getParameter<double>("MaxTime")),
0066 min_Eta_(iConfig.getParameter<double>("MinEta")),
0067 max_Eta_(iConfig.getParameter<double>("MaxEta")),
0068 max_TimeSpread_(iConfig.getParameter<double>("MaxTimeSpread")) {
0069 if (!(min_SizeRegionCutEtas_.size() == max_SizeRegionCutEtas_.size() &&
0070 min_SizeRegionCutEtas_.size() == min_SizeRegionCutNstations_.size() &&
0071 min_SizeRegionCutEtas_.size() == max_SizeRegionCutNstations_.size() &&
0072 min_SizeRegionCutEtas_.size() == min_SizeRegionCutClusterSize_.size())) {
0073 throw cms::Exception("Configuration")
0074 << "size of \"MinSizeRegionCutEtas\" (" << min_SizeRegionCutEtas_.size() << ") and \"MaxSizeRegionCutEtas\" ("
0075 << max_SizeRegionCutEtas_.size() << ") and \"MinSizeRegionCutNstations\" ("
0076 << min_SizeRegionCutNstations_.size() << ") and \"MaxSizeRegionCutNstations\" ("
0077 << max_SizeRegionCutNstations_.size() << ") and \"MinSizeRegionCutClusterSize\" ("
0078 << min_SizeRegionCutClusterSize_.size() << ") differ";
0079 }
0080 }
0081
0082 void HLTMuonRecHitClusterFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0083 edm::ParameterSetDescription desc;
0084 desc.add<edm::InputTag>("ClusterTag", edm::InputTag("hltCSCrechitClusters"));
0085 desc.add<int>("MinN", 1);
0086 desc.add<int>("MinSize", 50);
0087 desc.add<int>("MinSizeMinusMB1", -1);
0088 desc.add<std::vector<double>>("MinSizeRegionCutEtas", {-1., -1., 1.9, 1.9});
0089 desc.add<std::vector<double>>("MaxSizeRegionCutEtas", {1.9, 1.9, -1., -1.});
0090 desc.add<std::vector<int>>("MinSizeRegionCutNstations", {-1, 1, -1, 1});
0091 desc.add<std::vector<int>>("MaxSizeRegionCutNstations", {1, -1, 1, -1});
0092 desc.add<std::vector<int>>("MinSizeRegionCutClusterSize", {-1, -1, -1, -1});
0093 desc.add<int>("Max_nMB1", -1);
0094 desc.add<int>("Max_nMB2", -1);
0095 desc.add<int>("Max_nME11", -1);
0096 desc.add<int>("Max_nME12", -1);
0097 desc.add<int>("Max_nME41", -1);
0098 desc.add<int>("Max_nME42", -1);
0099 desc.add<int>("MinNstation", 0);
0100 desc.add<double>("MinAvgStation", 0.0);
0101 desc.add<double>("MinTime", -999);
0102 desc.add<double>("MaxTime", 999);
0103 desc.add<double>("MinEta", -1.0);
0104 desc.add<double>("MaxEta", -1.0);
0105 desc.add<double>("MaxTimeSpread", -1.0);
0106 descriptions.addWithDefaultLabel(desc);
0107 }
0108
0109
0110
0111
0112
0113
0114 bool HLTMuonRecHitClusterFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0115 int nClusterPassed = 0;
0116
0117 auto const& rechitClusters = iEvent.get(cluster_token_);
0118
0119 for (auto const& cluster : rechitClusters) {
0120 auto passSizeCut = (cluster.size() >= min_Size_ && min_Size_ > 0) ||
0121 ((cluster.size() - cluster.nMB1()) >= min_SizeMinusMB1_ && min_SizeMinusMB1_ > 0);
0122 if (not passSizeCut) {
0123 for (size_t i = 0; i < min_SizeRegionCutEtas_.size(); ++i) {
0124 if ((min_SizeRegionCutEtas_[i] < 0. || std::abs(cluster.eta()) > min_SizeRegionCutEtas_[i]) &&
0125 (max_SizeRegionCutEtas_[i] < 0. || std::abs(cluster.eta()) <= max_SizeRegionCutEtas_[i]) &&
0126 (min_SizeRegionCutNstations_[i] < 0 || cluster.nStation() > min_SizeRegionCutNstations_[i]) &&
0127 (max_SizeRegionCutNstations_[i] < 0 || cluster.nStation() <= max_SizeRegionCutNstations_[i]) &&
0128 (min_SizeRegionCutClusterSize_[i] > 0 && cluster.size() >= min_SizeRegionCutClusterSize_[i])) {
0129 passSizeCut = true;
0130 break;
0131 }
0132 }
0133 }
0134 if (passSizeCut && (max_nMB1_ < 0 || cluster.nMB1() <= max_nMB1_) &&
0135 (max_nMB2_ < 0 || cluster.nMB2() <= max_nMB2_) && (max_nME11_ < 0 || cluster.nME11() <= max_nME11_) &&
0136 (max_nME12_ < 0 || cluster.nME12() <= max_nME12_) && (max_nME41_ < 0 || cluster.nME41() <= max_nME41_) &&
0137 (max_nME42_ < 0 || cluster.nME42() <= max_nME42_) && cluster.nStation() >= min_Nstation_ &&
0138 cluster.avgStation() >= min_AvgStation_ && (min_Eta_ < 0.0 || std::abs(cluster.eta()) > min_Eta_) &&
0139 (max_Eta_ < 0.0 || std::abs(cluster.eta()) <= max_Eta_) && cluster.time() > min_Time_ &&
0140 cluster.time() <= max_Time_ && (max_TimeSpread_ < 0.0 || cluster.timeSpread() <= max_TimeSpread_)) {
0141 nClusterPassed++;
0142 }
0143 }
0144
0145 return (nClusterPassed >= min_N_);
0146 }
0147
0148 DEFINE_FWK_MODULE(HLTMuonRecHitClusterFilter);