CMS 3D CMS Logo

L1GTProducer.cc
Go to the documentation of this file.
4 
7 
10 
16 
19 
22 
30 
32 
33 #include <vector>
34 #include <array>
35 #include <string>
36 #include <type_traits>
37 
38 namespace l1t {
39 
41  public:
42  explicit L1GTProducer(const edm::ParameterSet &);
43  ~L1GTProducer() override = default;
44 
46 
47  private:
51 
54  void produceGMTTkMuons(edm::Event &event) const;
55 
56  void produceCL2Jets(edm::Event &event) const;
57  void produceCL2Photons(edm::Event &event) const;
59  void produceCL2Taus(edm::Event &event) const;
60  void produceCL2EtSum(edm::Event &event) const;
61  void produceCl2HtSum(edm::Event &event) const;
62 
63  void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
64 
66 
70 
74 
81  };
82 
84  : scales_(config.getParameter<edm::ParameterSet>("scales")),
85  gttPromptJetToken_(consumes<TkJetWordCollection>(config.getParameter<edm::InputTag>("GTTPromptJets"))),
86  gttDisplacedJetToken_(consumes<TkJetWordCollection>(config.getParameter<edm::InputTag>("GTTDisplacedJets"))),
87  gttPrimaryVertexToken_(consumes<VertexWordCollection>(config.getParameter<edm::InputTag>("GTTPrimaryVert"))),
88  gmtSaPromptMuonToken_(consumes<SAMuonCollection>(config.getParameter<edm::InputTag>("GMTSaPromptMuons"))),
89  gmtSaDisplacedMuonToken_(consumes<SAMuonCollection>(config.getParameter<edm::InputTag>("GMTSaDisplacedMuons"))),
90  gmtTkMuonToken_(consumes<TrackerMuonCollection>(config.getParameter<edm::InputTag>("GMTTkMuons"))),
91  cl2JetToken_(consumes<PFJetCollection>(config.getParameter<edm::InputTag>("CL2Jets"))),
92  cl2PhotonToken_(consumes<TkEmCollection>(config.getParameter<edm::InputTag>("CL2Photons"))),
93  cl2ElectronToken_(consumes<TkElectronCollection>(config.getParameter<edm::InputTag>("CL2Electrons"))),
94  cl2TauToken_(consumes<PFTauCollection>(config.getParameter<edm::InputTag>("CL2Taus"))),
95  cl2EtSumToken_(consumes<std::vector<l1t::EtSum>>(config.getParameter<edm::InputTag>("CL2EtSum"))),
96  cl2HtSumToken_(consumes<std::vector<l1t::EtSum>>(config.getParameter<edm::InputTag>("CL2HtSum"))) {
97  produces<P2GTCandidateCollection>("GTTPromptJets");
98  produces<P2GTCandidateCollection>("GTTDisplacedJets");
99  produces<P2GTCandidateCollection>("GTTPrimaryVert");
100 
101  produces<P2GTCandidateCollection>("GMTSaPromptMuons");
102  produces<P2GTCandidateCollection>("GMTSaDisplacedMuons");
103  produces<P2GTCandidateCollection>("GMTTkMuons");
104 
105  produces<P2GTCandidateCollection>("CL2Jets");
106  produces<P2GTCandidateCollection>("CL2Photons");
107  produces<P2GTCandidateCollection>("CL2Electrons");
108  produces<P2GTCandidateCollection>("CL2Taus");
109  produces<P2GTCandidateCollection>("CL2EtSum");
110  produces<P2GTCandidateCollection>("CL2HtSum");
111  }
112 
115 
116  edm::ParameterSetDescription scalesDesc;
118  desc.add<edm::ParameterSetDescription>("scales", scalesDesc);
119 
120  desc.add<edm::InputTag>("GTTPromptJets");
121  desc.add<edm::InputTag>("GTTDisplacedJets");
122  desc.add<edm::InputTag>("GTTPrimaryVert");
123 
124  desc.add<edm::InputTag>("GMTSaPromptMuons");
125  desc.add<edm::InputTag>("GMTSaDisplacedMuons");
126  desc.add<edm::InputTag>("GMTTkMuons");
127 
128  desc.add<edm::InputTag>("CL2Jets");
129  desc.add<edm::InputTag>("CL2Photons");
130  desc.add<edm::InputTag>("CL2Electrons");
131  desc.add<edm::InputTag>("CL2Taus");
132  desc.add<edm::InputTag>("CL2EtSum");
133  desc.add<edm::InputTag>("CL2HtSum");
134 
135  description.addWithDefaultLabel(desc);
136  }
137 
139  std::unique_ptr<P2GTCandidateCollection> outputCollection = std::make_unique<P2GTCandidateCollection>();
141  for (std::size_t i = 0; i < collection.size() && i < 10; i++) {
142  const VertexWord &obj = collection[i];
143  int hwZ0 = obj.z0Word().V.to_int() * 5;
144  P2GTCandidate gtObj(
146  gtObj.hwZ0_ = hwZ0;
147  gtObj.hwQual_ = obj.qualityWord().V.to_int();
148  gtObj.hwSum_pT_pv_ = obj.multiplicityWord().V.to_int();
149  gtObj.hwNumber_of_tracks_in_pv_ = obj.multiplicityWord().V.to_int();
150  gtObj.hwNumber_of_tracks_not_in_pv_ = obj.inverseMultiplicityWord().V.to_int();
152 
153  outputCollection->push_back(gtObj);
154  }
155  event.put(std::move(outputCollection), "GTTPrimaryVert");
156  }
157 
159  std::unique_ptr<P2GTCandidateCollection> outputCollection = std::make_unique<P2GTCandidateCollection>();
161  for (std::size_t i = 0; i < collection.size() && i < 12; i++) {
162  const TkJetWord &obj = collection[i];
163  int hwZ0 = obj.z0Word().V.to_int() << 7;
164  P2GTCandidate gtObj(0,
166  scales_.to_eta(obj.glbEtaWord().V.to_int()),
167  scales_.to_phi(obj.glbPhiWord().V.to_int()),
168  0),
170  gtObj.hwPT_ = obj.ptWord().V.to_int();
171  gtObj.hwPhi_ = obj.glbPhiWord().V.to_int();
172  gtObj.hwEta_ = obj.glbEtaWord().V.to_int();
173  gtObj.hwZ0_ = hwZ0;
174  gtObj.hwNumber_of_tracks_ = obj.ntWord().V.to_int();
176 
177  outputCollection->push_back(gtObj);
178  }
179  event.put(std::move(outputCollection), "GTTPromptJets");
180  }
181 
183  std::unique_ptr<P2GTCandidateCollection> outputCollection = std::make_unique<P2GTCandidateCollection>();
185  for (std::size_t i = 0; i < collection.size() && i < 12; i++) {
186  const TkJetWord &obj = collection[i];
187  int hwZ0 = obj.z0Word().V.to_int() << 7;
188  P2GTCandidate gtObj(0,
190  scales_.to_eta(obj.glbEtaWord().V.to_int()),
191  scales_.to_phi(obj.glbPhiWord().V.to_int()),
192  0),
194  gtObj.hwPT_ = obj.ptWord().V.to_int();
195  gtObj.hwPhi_ = obj.glbPhiWord().V.to_int();
196  gtObj.hwEta_ = obj.glbEtaWord().V.to_int();
197  gtObj.hwZ0_ = hwZ0;
198  gtObj.hwNumber_of_tracks_ = obj.ntWord().V.to_int();
200 
201  outputCollection->push_back(gtObj);
202  }
203  event.put(std::move(outputCollection), "GTTDisplacedJets");
204  }
205 
207  std::unique_ptr<P2GTCandidateCollection> outputCollection = std::make_unique<P2GTCandidateCollection>();
209  for (size_t i = 0; i < collection.size() && i < 12; i++) {
210  const SAMuon &obj = collection[i];
211  int hwZ0 = obj.apZ0().to_int() << 12;
212  P2GTCandidate gtObj(scales_.to_chg(obj.apCharge().to_int()),
214  scales_.to_eta(obj.apEta().to_int()),
215  scales_.to_phi(obj.apPhi().to_int()),
216  0),
218  gtObj.hwPT_ = obj.apPt().to_int();
219  gtObj.hwPhi_ = obj.apPhi().to_int();
220  gtObj.hwEta_ = obj.apEta().to_int();
221  gtObj.hwZ0_ = hwZ0;
222  gtObj.hwQual_ = obj.apQual().to_int();
223  gtObj.hwCharge_ = obj.apCharge().to_int();
224  gtObj.hwD0_ = obj.apD0().to_int();
226 
227  outputCollection->push_back(gtObj);
228  }
229  event.put(std::move(outputCollection), "GMTSaPromptMuons");
230  }
231 
233  std::unique_ptr<P2GTCandidateCollection> outputCollection = std::make_unique<P2GTCandidateCollection>();
235  for (size_t i = 0; i < collection.size() && i < 12; i++) {
236  const SAMuon &obj = collection[i];
237  int hwZ0 = obj.apZ0().to_int() << 12;
238  P2GTCandidate gtObj(scales_.to_chg(obj.apCharge().to_int()),
240  scales_.to_eta(obj.apEta().to_int()),
241  scales_.to_phi(obj.apPhi().to_int()),
242  0),
244  gtObj.hwPT_ = obj.apPt().to_int();
245  gtObj.hwPhi_ = obj.apPhi().to_int();
246  gtObj.hwEta_ = obj.apEta().to_int();
247  gtObj.hwZ0_ = hwZ0;
248  gtObj.hwQual_ = obj.apQual().to_int();
249  gtObj.hwCharge_ = obj.apCharge().to_int();
250  gtObj.hwD0_ = obj.apD0().to_int();
252 
253  outputCollection->push_back(gtObj);
254  }
255  event.put(std::move(outputCollection), "GMTSaDisplacedMuons");
256  }
257 
259  std::unique_ptr<P2GTCandidateCollection> outputCollection = std::make_unique<P2GTCandidateCollection>();
261  for (size_t i = 0; i < collection.size() && i < 12; i++) {
262  const TrackerMuon &obj = collection[i];
263  int hwZ0 = obj.apZ0().to_int() << 7;
264  P2GTCandidate gtObj(scales_.to_chg(obj.apCharge().to_int()),
266  scales_.to_eta(obj.apEta().to_int()),
267  scales_.to_phi(obj.apPhi().to_int()),
268  0),
270  gtObj.hwPT_ = obj.apPt().to_int();
271  gtObj.hwPhi_ = obj.apPhi().to_int();
272  gtObj.hwEta_ = obj.apEta().to_int();
273  gtObj.hwZ0_ = hwZ0;
274  gtObj.hwIso_ = obj.apIso().to_int();
275  gtObj.hwQual_ = obj.apQual().to_int();
276  gtObj.hwCharge_ = obj.apCharge().to_int();
277  gtObj.hwD0_ = obj.apD0().to_int();
278  gtObj.hwBeta_ = obj.apBeta().to_int();
280 
281  outputCollection->push_back(gtObj);
282  }
283  event.put(std::move(outputCollection), "GMTTkMuons");
284  }
285 
287  std::unique_ptr<P2GTCandidateCollection> outputCollection = std::make_unique<P2GTCandidateCollection>();
288  const PFJetCollection &collection = event.get(cl2JetToken_);
289  for (size_t i = 0; i < collection.size() && i < 12; i++) {
290  l1gt::Jet gtJet = l1gt::Jet::unpack(collection[i].getHWJetGT());
291  int hwZ0 = gtJet.z0.V.to_int() << 7;
292  P2GTCandidate gtObj(0,
294  scales_.to_eta(gtJet.v3.eta.V.to_int()),
295  scales_.to_phi(gtJet.v3.phi.V.to_int()),
296  0),
298  gtObj.hwPT_ = gtJet.v3.pt.V.to_int();
299  gtObj.hwPhi_ = gtJet.v3.phi.V.to_int();
300  gtObj.hwEta_ = gtJet.v3.eta.V.to_int();
301  gtObj.hwZ0_ = hwZ0;
303 
304  outputCollection->push_back(gtObj);
305  }
306  event.put(std::move(outputCollection), "CL2Jets");
307  }
308 
310  std::unique_ptr<P2GTCandidateCollection> outputCollection = std::make_unique<P2GTCandidateCollection>();
311  const TkEmCollection &collection = event.get(cl2PhotonToken_);
312  for (size_t i = 0; i < collection.size() && i < 12; i++) {
313  l1gt::Photon gtPhoton = l1gt::Photon::unpack_ap(const_cast<TkEm &>(collection[i]).egBinaryWord<96>());
314  P2GTCandidate gtObj(0,
316  scales_.to_eta(gtPhoton.v3.eta.V.to_int()),
317  scales_.to_phi(gtPhoton.v3.phi.V.to_int()),
318  0));
319  gtObj.hwPT_ = gtPhoton.v3.pt.V.to_int();
320  gtObj.hwPhi_ = gtPhoton.v3.phi.V.to_int();
321  gtObj.hwEta_ = gtPhoton.v3.eta.V.to_int();
322  gtObj.hwIso_ = gtPhoton.isolation.V.to_int();
323  gtObj.hwQual_ = gtPhoton.quality.V.to_int();
324  gtObj.objectType_ = P2GTCandidate::CL2Photons;
325 
326  outputCollection->push_back(gtObj);
327  }
328  event.put(std::move(outputCollection), "CL2Photons");
329  }
330 
332  std::unique_ptr<P2GTCandidateCollection> outputCollection = std::make_unique<P2GTCandidateCollection>();
334  for (size_t i = 0; i < collection.size() && i < 12; i++) {
335  l1gt::Electron gtElectron = l1gt::Electron::unpack_ap(const_cast<TkElectron &>(collection[i]).egBinaryWord<96>());
336  int hwZ0 = gtElectron.z0.V.to_int() << 7;
337  P2GTCandidate gtObj(scales_.to_chg(gtElectron.charge.V.to_int()),
339  scales_.to_eta(gtElectron.v3.eta.V.to_int()),
340  scales_.to_phi(gtElectron.v3.phi.V.to_int()),
341  0),
343  gtObj.hwPT_ = gtElectron.v3.pt.V.to_int();
344  gtObj.hwPhi_ = gtElectron.v3.phi.V.to_int();
345  gtObj.hwEta_ = gtElectron.v3.eta.V.to_int();
346  gtObj.hwZ0_ = hwZ0;
347  gtObj.hwIso_ = gtElectron.isolation.V.to_int();
348  gtObj.hwQual_ = gtElectron.quality.V.to_int();
349  gtObj.hwCharge_ = gtElectron.charge.V.to_int();
351 
352  outputCollection->push_back(gtObj);
353  }
354  event.put(std::move(outputCollection), "CL2Electrons");
355  }
356 
358  std::unique_ptr<P2GTCandidateCollection> outputCollection = std::make_unique<P2GTCandidateCollection>();
359  const PFTauCollection &collection = event.get(cl2TauToken_);
360  for (size_t i = 0; i < collection.size() && i < 12; i++) {
361  l1gt::Tau gtTau = collection[i].getHWTauGT();
362  P2GTCandidate gtObj(scales_.to_chg(gtTau.charge.V.to_int()),
364  scales_.to_eta(gtTau.v3.eta.V.to_int()),
365  scales_.to_phi(gtTau.v3.phi.V.to_int()),
366  0));
367  gtObj.hwPT_ = gtTau.v3.pt.V.to_int();
368  gtObj.hwPhi_ = gtTau.v3.phi.V.to_int();
369  gtObj.hwEta_ = gtTau.v3.eta.V.to_int();
370  gtObj.hwSeed_pT_ = gtTau.seed_pt.V.to_int();
371  gtObj.hwSeed_z0_ = gtTau.seed_z0.V.to_int();
372  gtObj.hwCharge_ = gtTau.charge.V.to_int();
373  gtObj.hwType_ = gtTau.type.V.to_int();
374  gtObj.hwIso_ = gtTau.isolation.V.to_int();
375  gtObj.objectType_ = P2GTCandidate::CL2Taus;
376 
377  outputCollection->push_back(gtObj);
378  }
379  event.put(std::move(outputCollection), "CL2Taus");
380  }
381 
383  std::unique_ptr<P2GTCandidateCollection> outputCollection = std::make_unique<P2GTCandidateCollection>();
384  const std::vector<EtSum> &collection = event.get(cl2EtSumToken_);
385  const EtSum &met = collection[0];
386 
387  l1gt::Sum sum{true /* valid */, met.pt(), met.phi() / l1gt::Scales::ETAPHI_LSB, 0 /* scalar sum */};
388 
389  P2GTCandidate gtObj(0,
391  scales_.to_pT(sum.vector_pt.V.to_int()), 0, scales_.to_phi(sum.vector_phi.V.to_int()), 0));
392  gtObj.hwPT_ = sum.vector_pt.V.to_int();
393  gtObj.hwPhi_ = sum.vector_phi.V.to_int();
394  gtObj.hwSca_sum_ = sum.scalar_pt.V.to_int();
395  gtObj.objectType_ = P2GTCandidate::CL2EtSum;
396 
397  outputCollection->push_back(gtObj);
398  event.put(std::move(outputCollection), "CL2EtSum");
399  }
400 
402  std::unique_ptr<P2GTCandidateCollection> outputCollection = std::make_unique<P2GTCandidateCollection>();
403  const std::vector<EtSum> &collection = event.get(cl2HtSumToken_);
404  const EtSum &ht = collection[0];
405  const EtSum &mht = collection[1];
406 
407  P2GTCandidate gtObj(
408  0, reco::ParticleState::PolarLorentzVector(scales_.to_pT(mht.hwPt()), 0, scales_.to_phi(mht.hwPhi()), 0));
409  gtObj.hwPT_ = mht.hwPt();
410  gtObj.hwPhi_ = mht.hwPhi();
411  gtObj.hwSca_sum_ = ht.hwPt();
412  gtObj.objectType_ = P2GTCandidate::CL2HtSum;
413 
414  outputCollection->push_back(gtObj);
415  event.put(std::move(outputCollection), "CL2HtSum");
416  }
417 
422 
426 
433  }
434 } // namespace l1t
435 
436 using namespace l1t;
437 
~L1GTProducer() override=default
Optional< int > hwIso_
egquality_t quality
Definition: gt_datatypes.h:260
const edm::EDGetTokenT< VertexWordCollection > gttPrimaryVertexToken_
Definition: L1GTProducer.cc:69
std::vector< l1t::TkJetWord > TkJetWordCollection
Definition: TkJetWord.h:191
std::vector< TkElectron > TkElectronCollection
Definition: TkElectronFwd.h:16
std::vector< l1t::PFTau > PFTauCollection
Definition: PFTau.h:93
const edm::EDGetTokenT< TkElectronCollection > cl2ElectronToken_
Definition: L1GTProducer.cc:77
L1GTProducer(const edm::ParameterSet &)
Definition: L1GTProducer.cc:83
Optional< int > hwNumber_of_tracks_in_pv_
const L1GTScales scales_
Definition: L1GTProducer.cc:65
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: ParticleState.h:29
const edm::EDGetTokenT< TkJetWordCollection > gttPromptJetToken_
Definition: L1GTProducer.cc:67
double to_phi(int value) const
Definition: L1GTScales.h:56
ObjectType objectType_
int to_chg(int value) const
Definition: L1GTScales.h:60
static void fillPSetDescription(edm::ParameterSetDescription &)
Definition: L1GTScales.cc:55
delete x;
Definition: CaloConfig.h:22
Definition: config.py:1
math::XYZPoint Point
point in the space
Definition: ParticleState.h:31
Optional< int > hwD0_
void produceGMTSaPromptMuons(edm::Event &event) const
const edm::EDGetTokenT< std::vector< l1t::EtSum > > cl2HtSumToken_
Definition: L1GTProducer.cc:80
const edm::EDGetTokenT< PFTauCollection > cl2TauToken_
Definition: L1GTProducer.cc:78
double to_z0(int value) const
Definition: L1GTScales.h:58
void produceCL2Taus(edm::Event &event) const
void produceCL2Photons(edm::Event &event) const
Optional< int > hwCharge_
static Jet unpack(const std::array< uint64_t, 2 > &src)
Definition: gt_datatypes.h:125
std::vector< l1t::PFJet > PFJetCollection
Definition: PFJet.h:61
std::vector< TkEm > TkEmCollection
Definition: TkEmFwd.h:17
const edm::EDGetTokenT< PFJetCollection > cl2JetToken_
Definition: L1GTProducer.cc:75
double to_eta(int value) const
Definition: L1GTScales.h:57
void produceCL2Electrons(edm::Event &event) const
void produceGMTTkMuons(edm::Event &event) const
Optional< int > hwPT_
void produceGTTPromptJets(edm::Event &event) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDGetTokenT< TrackerMuonCollection > gmtTkMuonToken_
Definition: L1GTProducer.cc:73
std::vector< VertexWord > VertexWordCollection
Definition: VertexWord.h:197
const edm::EDGetTokenT< std::vector< l1t::EtSum > > cl2EtSumToken_
Definition: L1GTProducer.cc:79
ThreeVector v3
Definition: gt_datatypes.h:259
void produceCL2EtSum(edm::Event &event) const
static void fillDescriptions(edm::ConfigurationDescriptions &)
const edm::EDGetTokenT< SAMuonCollection > gmtSaDisplacedMuonToken_
Definition: L1GTProducer.cc:72
static Photon unpack_ap(const ap_uint< BITWIDTH > &src)
Definition: gt_datatypes.h:336
void produceGTTDisplacedJets(edm::Event &event) const
std::vector< TrackerMuon > TrackerMuonCollection
Definition: TrackerMuon.h:16
std::vector< SAMuon > SAMuonCollection
Definition: SAMuon.h:14
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Optional< int > hwNumber_of_tracks_
const edm::EDGetTokenT< SAMuonCollection > gmtSaPromptMuonToken_
Definition: L1GTProducer.cc:71
double to_pT(int value) const
Definition: L1GTScales.h:55
constexpr float ETAPHI_LSB
Definition: gt_datatypes.h:44
ThreeVector v3
Definition: gt_datatypes.h:311
HLT enums.
void produceCl2HtSum(edm::Event &event) const
egquality_t quality
Definition: gt_datatypes.h:312
Optional< int > hwSum_pT_pv_
ap_uint< 1 > charge
Definition: gt_datatypes.h:261
Optional< int > hwNumber_of_tracks_not_in_pv_
void produceGTTPrimaryVert(edm::Event &event) const
Optional< int > hwQual_
Optional< int > hwPhi_
void produceCL2Jets(edm::Event &event) const
const edm::EDGetTokenT< TkEmCollection > cl2PhotonToken_
Definition: L1GTProducer.cc:76
static Electron unpack_ap(const ap_uint< BITWIDTH > &src)
Definition: gt_datatypes.h:290
Optional< int > hwEta_
def move(src, dest)
Definition: eostools.py:511
Optional< int > hwBeta_
void produceGMTSaDisplacedMuons(edm::Event &event) const
Definition: event.py:1
const edm::EDGetTokenT< TkJetWordCollection > gttDisplacedJetToken_
Definition: L1GTProducer.cc:68
Optional< int > hwZ0_