File indexing completed on 2024-04-06 12:18:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <string>
0021 #include <iostream>
0022 #include <memory>
0023
0024
0025 #include "HLTL1NumberFilter.h"
0026 #include "DataFormats/Common/interface/Handle.h"
0027 #include "DataFormats/FEDRawData/interface/FEDHeader.h"
0028 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0029 #include "DataFormats/TCDS/interface/TCDSRecord.h"
0030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0031
0032
0033
0034
0035 HLTL1NumberFilter::HLTL1NumberFilter(const edm::ParameterSet& config)
0036 :
0037 inputToken_(consumes<FEDRawDataCollection>(config.getParameter<edm::InputTag>("rawInput"))),
0038 period_(config.getParameter<unsigned int>("period")),
0039 fedId_(config.getParameter<int>("fedId")),
0040 invert_(config.getParameter<bool>("invert")),
0041
0042 useTCDS_(config.getParameter<bool>("useTCDSEventNumber") and fedId_ == 1024) {}
0043
0044 HLTL1NumberFilter::~HLTL1NumberFilter() {
0045
0046
0047 }
0048
0049 void HLTL1NumberFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0050 edm::ParameterSetDescription desc;
0051 desc.add<edm::InputTag>("rawInput", edm::InputTag("source"));
0052 desc.add<unsigned int>("period", 4096);
0053 desc.add<bool>("invert", true);
0054 desc.add<int>("fedId", 812);
0055 desc.add<bool>("useTCDSEventNumber", false);
0056 descriptions.add("hltL1NumberFilter", desc);
0057 }
0058
0059
0060
0061
0062
0063 bool HLTL1NumberFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0064 using namespace edm;
0065
0066 if (iEvent.isRealData()) {
0067 bool accept(false);
0068 edm::Handle<FEDRawDataCollection> theRaw;
0069 iEvent.getByToken(inputToken_, theRaw);
0070 const FEDRawData& data = theRaw->FEDData(fedId_);
0071 if (data.data() and data.size() > 0) {
0072 unsigned long counter;
0073 if (useTCDS_) {
0074 TCDSRecord record(data.data());
0075 counter = record.getTriggerCount();
0076 } else {
0077 FEDHeader header(data.data());
0078 counter = header.lvl1ID();
0079 }
0080 if (period_ != 0)
0081 accept = (counter % period_ == 0);
0082 if (invert_)
0083 accept = not accept;
0084 return accept;
0085 } else {
0086 LogWarning("HLTL1NumberFilter") << "No valid data for FED " << fedId_ << " used by HLTL1NumberFilter";
0087 return false;
0088 }
0089 } else {
0090 return true;
0091 }
0092 }
0093
0094
0095 #include "FWCore/Framework/interface/MakerMacros.h"
0096 DEFINE_FWK_MODULE(HLTL1NumberFilter);