File indexing completed on 2024-09-12 04:16:40
0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "FWCore/Framework/interface/global/EDFilter.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "DataFormats/L1Trigger/interface/P2GTCandidate.h"
0005 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0006
0007 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "DataFormats/Common/interface/Handle.h"
0010 #include "FWCore/Utilities/interface/EDGetToken.h"
0011 #include "DataFormats/Common/interface/Ref.h"
0012
0013 #include "L1Trigger/Phase2L1GT/interface/L1GTScales.h"
0014 #include "L1GTSingleCollectionCut.h"
0015
0016 #include <cmath>
0017 #include <cinttypes>
0018
0019 #include <ap_int.h>
0020
0021 using namespace l1t;
0022
0023 class L1GTSingleObjectCond : public edm::global::EDFilter<> {
0024 public:
0025 explicit L1GTSingleObjectCond(const edm::ParameterSet&);
0026 ~L1GTSingleObjectCond() override = default;
0027
0028 static void fillDescriptions(edm::ConfigurationDescriptions&);
0029
0030 private:
0031 bool filter(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
0032
0033 const L1GTScales scales_;
0034 const L1GTSingleCollectionCut collection;
0035
0036 const edm::EDGetTokenT<P2GTCandidateCollection> token_;
0037 const edm::EDGetTokenT<P2GTCandidateCollection> primVertToken_;
0038 };
0039
0040 L1GTSingleObjectCond::L1GTSingleObjectCond(const edm::ParameterSet& config)
0041 : scales_(config.getParameter<edm::ParameterSet>("scales")),
0042 collection(config, config, scales_),
0043 token_(consumes<P2GTCandidateCollection>(collection.tag())),
0044 primVertToken_(consumes<P2GTCandidateCollection>(config.getParameter<edm::InputTag>("primVertTag"))) {
0045 produces<P2GTCandidateVectorRef>(collection.tag().instance());
0046 }
0047
0048 void L1GTSingleObjectCond::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0049 edm::ParameterSetDescription desc;
0050 L1GTSingleCollectionCut::fillPSetDescription(desc);
0051
0052 desc.add<edm::InputTag>("primVertTag");
0053
0054 edm::ParameterSetDescription scalesDesc;
0055 L1GTScales::fillPSetDescription(scalesDesc);
0056 desc.add<edm::ParameterSetDescription>("scales", scalesDesc);
0057
0058 descriptions.addWithDefaultLabel(desc);
0059 }
0060
0061 bool L1GTSingleObjectCond::filter(edm::StreamID, edm::Event& event, const edm::EventSetup& setup) const {
0062 edm::Handle<P2GTCandidateCollection> col = event.getHandle(token_);
0063 edm::Handle<P2GTCandidateCollection> primVertCol = event.getHandle(primVertToken_);
0064
0065 bool condition_result = false;
0066
0067 std::unique_ptr<P2GTCandidateVectorRef> triggerCol = std::make_unique<P2GTCandidateVectorRef>();
0068
0069 for (std::size_t idx = 0; idx < col->size(); ++idx) {
0070 bool pass{collection.checkObject(col->at(idx))};
0071 pass &= collection.checkPrimaryVertices(col->at(idx), *primVertCol);
0072
0073 condition_result |= pass;
0074
0075 if (pass) {
0076 triggerCol->push_back(P2GTCandidateRef(col, idx));
0077 }
0078 }
0079
0080 condition_result &= collection.checkCollection(*col);
0081
0082 if (condition_result) {
0083 event.put(std::move(triggerCol), collection.tag().instance());
0084 }
0085
0086 return condition_result;
0087 }
0088
0089 DEFINE_FWK_MODULE(L1GTSingleObjectCond);