CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 (fabs(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) {
103 
104  if (genJetsHandle.isValid()) {
105  for (const auto& genJet : *genJetsHandle.product()) {
106  if (genJet.pt() < PtMin)
107  continue;
108  if (fabs(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 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::Handle< BXVector< l1t::Jet > > bxvCaloJetsHandle
L1CaloJetHTTProducer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< std::vector< reco::GenJet > > genJetsToken_
def move
Definition: eostools.py:511
edm::Handle< std::vector< reco::GenJet > > genJetsHandle
edm::EDGetTokenT< BXVector< l1t::Jet > > bxvCaloJetsToken_
bool isValid() const
Definition: HandleBase.h:70
#define debug
Definition: HDRShower.cc:19
T const * product() const
Definition: Handle.h:70
void produce(edm::Event &, const edm::EventSetup &) override
constexpr char Jet[]
Definition: modules.cc:9
#define LogDebug(id)