File indexing completed on 2024-07-12 02:41:52
0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "FWCore/Framework/interface/Frameworkfwd.h"
0003 #include "FWCore/Framework/interface/stream/EDProducer.h"
0004 #include "FWCore/Framework/interface/MakerMacros.h"
0005 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0008 #include "FWCore/Utilities/interface/EDGetToken.h"
0009 #include "FWCore/Utilities/interface/EDPutToken.h"
0010 #include "FWCore/Utilities/interface/Exception.h"
0011 #include "FWCore/Utilities/interface/InputTag.h"
0012 #include "FWCore/Utilities/interface/StreamID.h"
0013 #include "FWCore/Utilities/interface/Span.h"
0014
0015
0016 #include "DataFormats/L1Scouting/interface/L1ScoutingMuon.h"
0017 #include "DataFormats/L1Scouting/interface/L1ScoutingCalo.h"
0018 #include "DataFormats/L1Scouting/interface/L1ScoutingBMTFStub.h"
0019 #include "DataFormats/L1Scouting/interface/OrbitCollection.h"
0020
0021 #include <vector>
0022 #include <set>
0023
0024 using namespace l1ScoutingRun3;
0025
0026 template <typename T>
0027 class MaskOrbitBx : public edm::stream::EDProducer<> {
0028 public:
0029 explicit MaskOrbitBx(const edm::ParameterSet&);
0030 ~MaskOrbitBx() {}
0031 static void fillDescriptions(edm::ConfigurationDescriptions&);
0032
0033 private:
0034 void produce(edm::Event&, const edm::EventSetup&) override;
0035
0036 std::vector<std::vector<T>> orbitBuffer_;
0037
0038
0039 edm::EDGetTokenT<OrbitCollection<T>> tokenData_;
0040
0041
0042 edm::EDGetTokenT<std::vector<unsigned>> tokenSelBxs_;
0043
0044 std::string productLabel_;
0045
0046 const int NBX = 3565;
0047 };
0048
0049 template <typename T>
0050 MaskOrbitBx<T>::MaskOrbitBx(const edm::ParameterSet& iPSet)
0051 : tokenData_(consumes<OrbitCollection<T>>(iPSet.getParameter<edm::InputTag>("dataTag"))),
0052 tokenSelBxs_(consumes<std::vector<unsigned>>(iPSet.getParameter<edm::InputTag>("selectBxs"))),
0053 productLabel_(iPSet.getParameter<std::string>("productLabel")) {
0054
0055 orbitBuffer_ = std::vector<std::vector<T>>(NBX);
0056
0057
0058 produces<OrbitCollection<T>>(productLabel_).setBranchAlias(productLabel_ + "OrbitCollection");
0059 }
0060
0061
0062 template <typename T>
0063 void MaskOrbitBx<T>::produce(edm::Event& iEvent, const edm::EventSetup&) {
0064
0065 edm::Handle<std::vector<unsigned>> selBxs;
0066 iEvent.getByToken(tokenSelBxs_, selBxs);
0067
0068
0069 edm::Handle<OrbitCollection<T>> objCollection;
0070 iEvent.getByToken(tokenData_, objCollection);
0071
0072
0073 std::unique_ptr<OrbitCollection<T>> selectedObjs(new OrbitCollection<T>);
0074
0075 int nObjOrbit_ = 0;
0076
0077
0078 for (const unsigned& bx : *selBxs) {
0079 for (const auto& obj : objCollection->bxIterator(bx)) {
0080 orbitBuffer_[bx].push_back(obj);
0081 nObjOrbit_++;
0082 }
0083 }
0084
0085
0086 selectedObjs->fillAndClear(orbitBuffer_, nObjOrbit_);
0087
0088
0089 iEvent.put(std::move(selectedObjs), productLabel_);
0090
0091 }
0092
0093 template <typename T>
0094 void MaskOrbitBx<T>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0095 edm::ParameterSetDescription desc;
0096 desc.setUnknown();
0097 descriptions.addDefault(desc);
0098 }
0099
0100 typedef MaskOrbitBx<l1ScoutingRun3::Muon> MaskOrbitBxScoutingMuon;
0101 typedef MaskOrbitBx<l1ScoutingRun3::Jet> MaskOrbitBxScoutingJet;
0102 typedef MaskOrbitBx<l1ScoutingRun3::EGamma> MaskOrbitBxScoutingEGamma;
0103 typedef MaskOrbitBx<l1ScoutingRun3::Tau> MaskOrbitBxScoutingTau;
0104 typedef MaskOrbitBx<l1ScoutingRun3::BxSums> MaskOrbitBxScoutingBxSums;
0105 typedef MaskOrbitBx<l1ScoutingRun3::BMTFStub> MaskOrbitBxScoutingBMTFStub;
0106
0107 DEFINE_FWK_MODULE(MaskOrbitBxScoutingMuon);
0108 DEFINE_FWK_MODULE(MaskOrbitBxScoutingJet);
0109 DEFINE_FWK_MODULE(MaskOrbitBxScoutingEGamma);
0110 DEFINE_FWK_MODULE(MaskOrbitBxScoutingTau);
0111 DEFINE_FWK_MODULE(MaskOrbitBxScoutingBxSums);
0112 DEFINE_FWK_MODULE(MaskOrbitBxScoutingBMTFStub);