CMS 3D CMS Logo

L1MHtPFProducer.cc
Go to the documentation of this file.
1 #include <vector>
2 #include <numeric>
3 
10 
13 
16 
17 // bitwise emulation headers
19 
21 public:
22  explicit L1MhtPfProducer(const edm::ParameterSet&);
23  ~L1MhtPfProducer() override;
24 
25 private:
26  void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
28  float minJetPt;
29  float maxJetEta;
30 
31  std::vector<l1ct::Jet> convertEDMToHW(std::vector<l1t::PFJet> edmJets) const;
32  std::vector<l1t::EtSum> convertHWToEDM(l1ct::Sum hwSums) const;
33 };
34 
36  : jetsToken(consumes<std::vector<l1t::PFJet>>(cfg.getParameter<edm::InputTag>("jets"))),
37  minJetPt(cfg.getParameter<double>("minJetPt")),
38  maxJetEta(cfg.getParameter<double>("maxJetEta")) {
39  produces<std::vector<l1t::EtSum>>();
40 }
41 
43  // Get the jets from the event
44  l1t::PFJetCollection edmJets = iEvent.get(jetsToken);
45 
46  std::vector<l1ct::Jet> hwJets = convertEDMToHW(edmJets); // convert to the emulator format
47  // Apply pT and eta selections
48  std::vector<l1ct::Jet> hwJetsFiltered;
49  std::copy_if(hwJets.begin(), hwJets.end(), std::back_inserter(hwJetsFiltered), [&](auto jet) {
52  });
53 
54  l1ct::Sum hwSums = htmht(hwJetsFiltered); // call the emulator
55  std::vector<l1t::EtSum> edmSums = convertHWToEDM(hwSums); // convert back to edm format
56 
57  // Put the sums in the event
58  std::unique_ptr<std::vector<l1t::EtSum>> mhtCollection(new std::vector<l1t::EtSum>(0));
59  mhtCollection->push_back(edmSums.at(0)); // HT
60  mhtCollection->push_back(edmSums.at(1)); // MHT
61 
62  iEvent.put(std::move(mhtCollection));
63 }
64 
65 std::vector<l1ct::Jet> L1MhtPfProducer::convertEDMToHW(std::vector<l1t::PFJet> edmJets) const {
66  std::vector<l1ct::Jet> hwJets;
67  std::for_each(edmJets.begin(), edmJets.end(), [&](l1t::PFJet jet) {
68  l1ct::Jet hwJet = l1ct::Jet::unpack(jet.getHWJetCT());
69  hwJets.push_back(hwJet);
70  });
71  return hwJets;
72 }
73 
74 std::vector<l1t::EtSum> L1MhtPfProducer::convertHWToEDM(l1ct::Sum hwSums) const {
75  std::vector<l1t::EtSum> edmSums;
76 
78  l1gt::Sum gtSum = hwSums.toGT();
79  htVector.SetPt(l1gt::Scales::floatPt(gtSum.scalar_pt));
80  htVector.SetPhi(0);
81  htVector.SetEta(0);
82 
84  mhtVector.SetPt(l1gt::Scales::floatPt(gtSum.vector_pt));
85  mhtVector.SetPhi(l1gt::Scales::floatPhi(gtSum.vector_phi));
86  mhtVector.SetEta(0);
87 
88  l1t::EtSum ht(htVector, l1t::EtSum::EtSumType::kTotalHt, gtSum.scalar_pt.bits_to_uint64());
89  l1t::EtSum mht(mhtVector, l1t::EtSum::EtSumType::kMissingHt, gtSum.vector_pt.bits_to_uint64(), 0, gtSum.vector_phi);
90 
91  edmSums.push_back(ht);
92  edmSums.push_back(mht);
93  return edmSums;
94 }
95 
97 
Definition: jets.h:12
glbeta_t makeGlbEta(float eta)
Definition: datatypes.h:203
float floatPhi(phi_t phi)
Definition: gt_datatypes.h:49
l1ct::Sum htmht(std::vector< l1ct::Jet > jets)
delete x;
Definition: CaloConfig.h:22
std::vector< l1t::EtSum > convertHWToEDM(l1ct::Sum hwSums) const
pt_t makePtFromFloat(float pt)
Definition: datatypes.h:183
l1gt::Sum toGT() const
Definition: sums.h:50
std::vector< l1t::PFJet > PFJetCollection
Definition: PFJet.h:61
L1MhtPfProducer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
~L1MhtPfProducer() override
edm::EDGetTokenT< std::vector< l1t::PFJet > > jetsToken
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float floatPt(pt_t pt)
Definition: gt_datatypes.h:47
static Jet unpack(const std::array< uint64_t, 2 > &src)
Definition: jets.h:78
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
pt_t vector_pt
Definition: gt_datatypes.h:146
phi_t vector_phi
Definition: gt_datatypes.h:147
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
HLT enums.
Definition: sums.h:10
pt_t scalar_pt
Definition: gt_datatypes.h:148
std::vector< l1ct::Jet > convertEDMToHW(std::vector< l1t::PFJet > edmJets) const
def move(src, dest)
Definition: eostools.py:511
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38