CMS 3D CMS Logo

L1GTDoubleObjectCond.cc
Go to the documentation of this file.
6 
12 
14 
16 
17 #include "L1GTOptionalParam.h"
19 #include "L1GTDeltaCut.h"
20 #include "L1GTSingleInOutLUT.h"
21 
22 #include <cinttypes>
23 #include <memory>
24 #include <vector>
25 #include <set>
26 
27 #include <ap_int.h>
28 
29 using namespace l1t;
30 
32 public:
33  explicit L1GTDoubleObjectCond(const edm::ParameterSet&);
34  ~L1GTDoubleObjectCond() override = default;
35 
37 
38 private:
39  bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
40 
42 
45 
47  const bool inv_mass_checks_;
48 
50 
53 };
54 
56  : scales_(config.getParameter<edm::ParameterSet>("scales")),
57  collection1Cuts_(config.getParameterSet("collection1"), config, scales_),
58  collection2Cuts_(config.getParameterSet("collection2"), config, scales_),
59  enable_sanity_checks_(config.getUntrackedParameter<bool>("sanity_checks")),
60  inv_mass_checks_(config.getUntrackedParameter<bool>("inv_mass_checks")),
61  deltaCuts_(config, config, scales_, enable_sanity_checks_, inv_mass_checks_),
62  token1_(consumes<P2GTCandidateCollection>(collection1Cuts_.tag())),
63  token2_(collection1Cuts_.tag() == collection2Cuts_.tag()
64  ? token1_
65  : consumes<P2GTCandidateCollection>(collection2Cuts_.tag())) {
66  produces<P2GTCandidateVectorRef>(collection1Cuts_.tag().instance());
67 
68  if (!(collection1Cuts_.tag() == collection2Cuts_.tag())) {
69  produces<P2GTCandidateVectorRef>(collection2Cuts_.tag().instance());
70  }
71 
72  if (inv_mass_checks_) {
73  produces<InvariantMassErrorCollection>();
74  }
75 }
76 
79 
80  edm::ParameterSetDescription collection1Desc;
82  desc.add<edm::ParameterSetDescription>("collection1", collection1Desc);
83 
84  edm::ParameterSetDescription collection2Desc;
86  desc.add<edm::ParameterSetDescription>("collection2", collection2Desc);
87 
88  desc.addUntracked<bool>("sanity_checks", false);
89  desc.addUntracked<bool>("inv_mass_checks", false);
90 
92  L1GTDeltaCut::fillLUTDescriptions(desc);
93 
96  desc.add<edm::ParameterSetDescription>("scales", scalesDesc);
97 
98  descriptions.addWithDefaultLabel(desc);
99 }
100 
102  edm::Handle<P2GTCandidateCollection> col1 = event.getHandle(token1_);
103  edm::Handle<P2GTCandidateCollection> col2 = event.getHandle(token2_);
104 
105  bool condition_result = false;
106 
107  std::set<std::size_t> triggeredIdcs1;
108  std::set<std::size_t> triggeredIdcs2;
109 
110  InvariantMassErrorCollection massErrors;
111 
112  for (std::size_t idx1 = 0; idx1 < col1->size(); ++idx1) {
113  for (std::size_t idx2 = 0; idx2 < col2->size(); ++idx2) {
114  // If we're looking at the same collection then we shouldn't use the same object in one comparison.
115  if (col1.product() == col2.product() && idx1 == idx2) {
116  continue;
117  }
118 
119  bool pass = true;
120  pass &= collection1Cuts_.checkObject(col1->at(idx1));
121  pass &= collection2Cuts_.checkObject(col2->at(idx2));
122  pass &= deltaCuts_.checkObjects(col1->at(idx1), col2->at(idx2), massErrors);
123 
124  condition_result |= pass;
125 
126  if (pass) {
127  triggeredIdcs1.emplace(idx1);
128  if (col1.product() != col2.product()) {
129  triggeredIdcs2.emplace(idx2);
130  } else {
131  triggeredIdcs1.emplace(idx2);
132  }
133  }
134  }
135  }
136 
137  if (condition_result) {
138  std::unique_ptr<P2GTCandidateVectorRef> triggerCol1 = std::make_unique<P2GTCandidateVectorRef>();
139 
140  for (std::size_t idx : triggeredIdcs1) {
141  triggerCol1->push_back(P2GTCandidateRef(col1, idx));
142  }
143  event.put(std::move(triggerCol1), collection1Cuts_.tag().instance());
144 
145  if (col1.product() != col2.product()) {
146  std::unique_ptr<P2GTCandidateVectorRef> triggerCol2 = std::make_unique<P2GTCandidateVectorRef>();
147 
148  for (std::size_t idx : triggeredIdcs2) {
149  triggerCol2->push_back(P2GTCandidateRef(col2, idx));
150  }
151  event.put(std::move(triggerCol2), collection2Cuts_.tag().instance());
152  }
153  }
154 
155  if (inv_mass_checks_) {
156  event.put(std::make_unique<InvariantMassErrorCollection>(std::move(massErrors)), "");
157  }
158 
159  return condition_result;
160 }
161 
const edm::EDGetTokenT< P2GTCandidateCollection > token1_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
bool checkObject(const P2GTCandidate &obj) const
std::vector< P2GTCandidate > P2GTCandidateCollection
Definition: P2GTCandidate.h:16
std::string const & instance() const
Definition: InputTag.h:37
T const * product() const
Definition: Handle.h:70
const edm::InputTag & tag() const
edm::Ref< P2GTCandidateCollection > P2GTCandidateRef
Definition: P2GTCandidate.h:18
delete x;
Definition: CaloConfig.h:22
Definition: config.py:1
std::vector< InvariantMassError > InvariantMassErrorCollection
const edm::EDGetTokenT< P2GTCandidateCollection > token2_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool checkObjects(const P2GTCandidate &obj1, const P2GTCandidate &obj2, InvariantMassErrorCollection &massErrors) const
Definition: L1GTDeltaCut.h:67
static void fillDescriptions(edm::ConfigurationDescriptions &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void fillPSetDescription(edm::ParameterSetDescription &desc)
const L1GTSingleCollectionCut collection2Cuts_
L1GTDoubleObjectCond(const edm::ParameterSet &)
ParameterSet const & getParameterSet(ParameterSetID const &id)
HLT enums.
bool filter(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const L1GTDeltaCut deltaCuts_
const L1GTSingleCollectionCut collection1Cuts_
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1