CMS 3D CMS Logo

L1CaloJetHTTProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1CaloTrigger
4 // Class: L1CaloJetHTTProducer
5 //
15 //
16 // Original Author: Tyler Ruggles
17 // Created: Fri Mar 22 2019
18 // $Id$
19 //
20 //
21 
29 
30 #include <iostream>
31 
32 // Run2/PhaseI output formats
35 // GenJets if needed
38 
40 public:
41  explicit L1CaloJetHTTProducer(const edm::ParameterSet&);
42 
43 private:
44  void produce(edm::Event&, const edm::EventSetup&) override;
45 
46  double EtaMax;
47  double PtMin;
48 
51 
52  // Gen jet collections are only loaded and used if requested
53  // (use_gen_jets == true)
56 
57  bool debug;
58 
60 };
61 
63  : EtaMax(iConfig.getParameter<double>("EtaMax")),
64  PtMin(iConfig.getParameter<double>("PtMin")),
65  bxvCaloJetsToken_(consumes<BXVector<l1t::Jet>>(iConfig.getParameter<edm::InputTag>("BXVCaloJetsInputTag"))),
66  genJetsToken_(consumes<std::vector<reco::GenJet>>(iConfig.getParameter<edm::InputTag>("genJets"))),
67  debug(iConfig.getParameter<bool>("debug")),
68  use_gen_jets(iConfig.getParameter<bool>("use_gen_jets"))
69 
70 {
71  produces<float>("CaloJetHTT");
72 }
73 
75  // Output collections
76  std::unique_ptr<float> CaloJetHTT(new float);
77 
78  *CaloJetHTT = 0.;
79 
80  // CaloJet HTT for L1 collections
81  if (!use_gen_jets) {
83 
84  if (bxvCaloJetsHandle.isValid()) {
85  for (const auto& caloJet : *bxvCaloJetsHandle.product()) {
86  if (caloJet.pt() < PtMin)
87  continue;
88  if (std::abs(caloJet.eta()) > EtaMax)
89  continue;
90  *CaloJetHTT += float(caloJet.pt());
91  }
92  }
93 
94  if (debug) {
95  LogDebug("L1CaloJetHTTProducer") << " BXV L1CaloJetCollection JetHTT = " << *CaloJetHTT << " for PtMin " << PtMin
96  << " and EtaMax " << EtaMax << "\n";
97  }
98  }
99 
100  // CaloJet HTT for gen jets
101  if (use_gen_jets) {
102  iEvent.getByToken(genJetsToken_, genJetsHandle);
103 
104  if (genJetsHandle.isValid()) {
105  for (const auto& genJet : *genJetsHandle.product()) {
106  if (genJet.pt() < PtMin)
107  continue;
108  if (std::abs(genJet.eta()) > EtaMax)
109  continue;
110  *CaloJetHTT += float(genJet.pt());
111  }
112  }
113 
114  if (debug) {
115  LogDebug("L1CaloJetHTTProducer") << " Gen Jets HTT = " << *CaloJetHTT << " for PtMin " << PtMin << " and EtaMax "
116  << EtaMax << "\n";
117  }
118  }
119 
120  iEvent.put(std::move(CaloJetHTT), "CaloJetHTT");
121 }
122 
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
T const * product() const
Definition: Handle.h:70
delete x;
Definition: CaloConfig.h:22
edm::Handle< BXVector< l1t::Jet > > bxvCaloJetsHandle
L1CaloJetHTTProducer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
Definition: Jet.py:1
edm::EDGetTokenT< std::vector< reco::GenJet > > genJetsToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::Handle< std::vector< reco::GenJet > > genJetsHandle
edm::EDGetTokenT< BXVector< l1t::Jet > > bxvCaloJetsToken_
#define debug
Definition: HDRShower.cc:19
void produce(edm::Event &, const edm::EventSetup &) override
bool isValid() const
Definition: HandleBase.h:70
fixed size matrix
HLT enums.
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)