File indexing completed on 2024-04-06 12:11:06
0001 #include <memory>
0002 #include <algorithm>
0003
0004 #include "EvFFEDExcluder.h"
0005
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0010 #include "FWCore/Utilities/interface/InputTag.h"
0011 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0012 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0013
0014 evf::EvFFEDExcluder::EvFFEDExcluder(edm::ParameterSet const& config)
0015 : rawDataToken_(consumes(config.getParameter<edm::InputTag>("src"))),
0016 fedIds_([](std::vector<unsigned int> const& fedsToExclude) {
0017
0018 std::vector<unsigned int> ret;
0019 auto const maxSize = FEDNumbering::lastFEDId() + 1;
0020 ret.reserve(maxSize);
0021
0022 for (auto fedId = 0u; fedId < maxSize; ++fedId) {
0023
0024 if (std::find(fedsToExclude.begin(), fedsToExclude.end(), fedId) == fedsToExclude.end())
0025 ret.emplace_back(fedId);
0026 }
0027 ret.shrink_to_fit();
0028 return ret;
0029 }(config.getParameter<std::vector<unsigned int>>("fedsToExclude"))) {
0030 produces<FEDRawDataCollection>();
0031 }
0032
0033 void evf::EvFFEDExcluder::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0034 edm::ParameterSetDescription desc;
0035 desc.add<edm::InputTag>("src", edm::InputTag("source"));
0036 desc.add<std::vector<unsigned int>>("fedsToExclude", {});
0037 descriptions.add("EvFFEDExcluder", desc);
0038 }
0039
0040 void evf::EvFFEDExcluder::produce(edm::StreamID, edm::Event& event, edm::EventSetup const&) const {
0041 auto out = std::make_unique<FEDRawDataCollection>();
0042 auto const rawDataHandle = event.getHandle(rawDataToken_);
0043
0044 for (auto const fedId : fedIds_)
0045 if (rawDataHandle->FEDData(fedId).size() > 0)
0046 out->FEDData(fedId) = rawDataHandle->FEDData(fedId);
0047
0048 event.put(std::move(out));
0049 }