File indexing completed on 2024-04-06 12:18:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
0025
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0031 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0032
0033 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0034
0035
0036
0037
0038
0039 class HLTFEDSizeFilter : public HLTFilter {
0040 public:
0041 explicit HLTFEDSizeFilter(const edm::ParameterSet&);
0042 ~HLTFEDSizeFilter() override;
0043 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0044
0045 private:
0046 bool hltFilter(edm::Event&,
0047 const edm::EventSetup&,
0048 trigger::TriggerFilterObjectWithRefs& filterproduct) const override;
0049
0050
0051 edm::EDGetTokenT<FEDRawDataCollection> RawCollectionToken_;
0052 edm::InputTag RawCollection_;
0053 unsigned int threshold_;
0054 unsigned int fedStart_, fedStop_;
0055 bool requireAllFEDs_;
0056 };
0057
0058
0059
0060
0061 HLTFEDSizeFilter::HLTFEDSizeFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
0062 threshold_ = iConfig.getParameter<unsigned int>("threshold");
0063 RawCollection_ = iConfig.getParameter<edm::InputTag>("rawData");
0064
0065 fedStart_ = iConfig.getParameter<unsigned int>("firstFED");
0066 fedStop_ = iConfig.getParameter<unsigned int>("lastFED");
0067 requireAllFEDs_ = iConfig.getParameter<bool>("requireAllFEDs");
0068
0069 RawCollectionToken_ = consumes<FEDRawDataCollection>(RawCollection_);
0070 }
0071
0072 HLTFEDSizeFilter::~HLTFEDSizeFilter() {
0073
0074
0075 }
0076
0077 void HLTFEDSizeFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0078 edm::ParameterSetDescription desc;
0079 makeHLTFilterDescription(desc);
0080 desc.add<edm::InputTag>("rawData", edm::InputTag("source", "", ""));
0081 desc.add<unsigned int>("threshold", 0)
0082 ->setComment(" # 0 is pass-through, 1 means *FED ispresent*, higher values are just FED size");
0083 desc.add<unsigned int>("firstFED", 0)->setComment(" # first FED, inclusive");
0084 desc.add<unsigned int>("lastFED", 39)->setComment(" # last FED, inclusive");
0085 desc.add<bool>("requireAllFEDs", false)
0086 ->setComment(" # if True, *all* FEDs must be above threshold; if False, only *one* is required");
0087 descriptions.add("hltFEDSizeFilter", desc);
0088 }
0089
0090
0091
0092
0093
0094
0095 bool HLTFEDSizeFilter::hltFilter(edm::Event& iEvent,
0096 const edm::EventSetup& iSetup,
0097 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0098
0099 edm::Handle<FEDRawDataCollection> h_raw;
0100 iEvent.getByToken(RawCollectionToken_, h_raw);
0101
0102 const FEDRawDataCollection theRaw = *h_raw;
0103
0104 bool result = false;
0105
0106 if (not requireAllFEDs_) {
0107
0108 result = false;
0109 for (unsigned int i = fedStart_; i <= fedStop_; i++)
0110 if (theRaw.FEDData(i).size() >= threshold_) {
0111 result = true;
0112 break;
0113 }
0114 } else {
0115
0116 result = true;
0117 for (unsigned int i = fedStart_; i <= fedStop_; i++)
0118 if (theRaw.FEDData(i).size() < threshold_) {
0119 result = false;
0120 break;
0121 }
0122 }
0123
0124 return result;
0125 }
0126
0127
0128 DEFINE_FWK_MODULE(HLTFEDSizeFilter);