CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HLTScoutingCaloProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTrigger/JetMET
4 // Class: HLTScoutingCaloProducer
5 //
11 //
12 // Original Author: Dustin James Anderson
13 // Created: Fri, 12 Jun 2015 15:49:20 GMT
14 //
15 //
16 
17 // system include files
18 #include <memory>
19 
20 // user include files
26 
33 
36 
38 
40 public:
42  ~HLTScoutingCaloProducer() override;
43 
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46 private:
47  void produce(edm::StreamID sid, edm::Event& iEvent, edm::EventSetup const& setup) const final;
48 
55 
56  const double caloJetPtCut;
57  const double caloJetEtaCut;
58 
59  const bool doMet;
60  const bool doJetBTags;
61  const bool doJetIDTags;
62 };
63 
64 //
65 // constructors and destructor
66 //
68  : caloJetCollection_(consumes<reco::CaloJetCollection>(iConfig.getParameter<edm::InputTag>("caloJetCollection"))),
69  caloJetBTagCollection_(
70  consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("caloJetBTagCollection"))),
71  caloJetIDTagCollection_(
72  consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("caloJetIDTagCollection"))),
73  vertexCollection_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection"))),
74  metCollection_(consumes<reco::CaloMETCollection>(iConfig.getParameter<edm::InputTag>("metCollection"))),
75  rho_(consumes<double>(iConfig.getParameter<edm::InputTag>("rho"))),
76  caloJetPtCut(iConfig.getParameter<double>("caloJetPtCut")),
77  caloJetEtaCut(iConfig.getParameter<double>("caloJetEtaCut")),
78  doMet(iConfig.getParameter<bool>("doMet")),
79  doJetBTags(iConfig.getParameter<bool>("doJetBTags")),
80  doJetIDTags(iConfig.getParameter<bool>("doJetIDTags")) {
81  //register products
82  produces<Run3ScoutingCaloJetCollection>();
83  produces<double>("rho");
84  produces<double>("caloMetPt");
85  produces<double>("caloMetPhi");
86 }
87 
89 
90 // ------------ method called to produce the data ------------
92  using namespace edm;
93 
94  //get calo jets
96  std::unique_ptr<Run3ScoutingCaloJetCollection> outCaloJets(new Run3ScoutingCaloJetCollection());
98  //get jet tags
100  bool haveJetBTags = false;
101  if (doJetBTags && iEvent.getByToken(caloJetBTagCollection_, caloJetBTagCollection)) {
102  haveJetBTags = true;
103  }
105  bool haveJetIDTags = false;
106  if (doJetIDTags && iEvent.getByToken(caloJetIDTagCollection_, caloJetIDTagCollection)) {
107  haveJetIDTags = true;
108  }
109 
110  for (auto& jet : *caloJetCollection) {
111  if (jet.pt() > caloJetPtCut && fabs(jet.eta()) < caloJetEtaCut) {
112  //find the jet tag(s) corresponding to the jet
113  float bTagValue = -20;
114  float bTagMinDR2 = 0.01;
115  if (haveJetBTags) {
116  for (auto& tag : *caloJetBTagCollection) {
117  float dR2 = reco::deltaR2(jet, *(tag.first));
118  if (dR2 < bTagMinDR2) {
119  bTagMinDR2 = dR2;
120  bTagValue = tag.second;
121  }
122  }
123  }
124  float idTagValue = -20;
125  float idTagMinDR2 = 0.01;
126  if (haveJetIDTags) {
127  for (auto& tag : *caloJetIDTagCollection) {
128  float dR2 = reco::deltaR2(jet, *(tag.first));
129  if (dR2 < idTagMinDR2) {
130  idTagMinDR2 = dR2;
131  idTagValue = tag.second;
132  }
133  }
134  }
135  outCaloJets->emplace_back(jet.pt(),
136  jet.eta(),
137  jet.phi(),
138  jet.mass(),
139  jet.jetArea(),
140  jet.maxEInEmTowers(),
141  jet.maxEInHadTowers(),
142  jet.hadEnergyInHB(),
143  jet.hadEnergyInHE(),
144  jet.hadEnergyInHF(),
145  jet.emEnergyInEB(),
146  jet.emEnergyInEE(),
147  jet.emEnergyInHF(),
148  jet.towersArea(),
149  idTagValue,
150  bTagValue);
151  }
152  }
153  }
154 
155  //get rho
157  std::unique_ptr<double> outRho(new double(-999));
158  if (iEvent.getByToken(rho_, rho)) {
159  outRho = std::make_unique<double>(*rho);
160  }
161 
162  //get MET
164  std::unique_ptr<double> outMetPt(new double(-999));
165  std::unique_ptr<double> outMetPhi(new double(-999));
166  if (doMet && iEvent.getByToken(metCollection_, metCollection)) {
167  outMetPt = std::make_unique<double>(metCollection->front().pt());
168  outMetPhi = std::make_unique<double>(metCollection->front().phi());
169  }
170 
171  //put output
172  iEvent.put(std::move(outCaloJets));
173  // iEvent.put(std::move(outVertices));
174  iEvent.put(std::move(outRho), "rho");
175  iEvent.put(std::move(outMetPt), "caloMetPt");
176  iEvent.put(std::move(outMetPhi), "caloMetPhi");
177 }
178 
179 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
182  desc.add<edm::InputTag>("caloJetCollection", edm::InputTag("hltAK4CaloJets"));
183  desc.add<edm::InputTag>("caloJetBTagCollection", edm::InputTag("hltCombinedSecondaryVertexBJetTagsCalo"));
184  desc.add<edm::InputTag>("caloJetIDTagCollection", edm::InputTag("hltCaloJetFromPV"));
185  desc.add<edm::InputTag>("vertexCollection", edm::InputTag("hltPixelVertices"));
186  desc.add<edm::InputTag>("metCollection", edm::InputTag("hltMet"));
187  desc.add<edm::InputTag>("rho", edm::InputTag("hltFixedGridRhoFastjetAllCalo"));
188  desc.add<double>("caloJetPtCut", 20.0);
189  desc.add<double>("caloJetEtaCut", 3.0);
190  desc.add<bool>("doMet", true);
191  desc.add<bool>("doJetBTags", false);
192  desc.add<bool>("doJetIDTags", false);
193  descriptions.add("hltScoutingCaloProducer", desc);
194 }
195 
196 // declare this class as a framework plugin
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
tuple caloJetCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
const edm::EDGetTokenT< reco::VertexCollection > vertexCollection_
const edm::EDGetTokenT< reco::CaloMETCollection > metCollection_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HLTScoutingCaloProducer(const edm::ParameterSet &)
JetFloatAssociation::Container JetTagCollection
Definition: JetTag.h:17
std::vector< Vertex > VertexCollection
Definition: Vertex.h:12
const edm::EDGetTokenT< reco::CaloJetCollection > caloJetCollection_
void produce(edm::StreamID sid, edm::Event &iEvent, edm::EventSetup const &setup) const final
std::vector< Run3ScoutingCaloJet > Run3ScoutingCaloJetCollection
Collection of Calo MET.
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
ParameterDescriptionBase * add(U const &iLabel, T const &value)
~HLTScoutingCaloProducer() override
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
const edm::EDGetTokenT< double > rho_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
tuple caloJetBTagCollection
const edm::EDGetTokenT< reco::JetTagCollection > caloJetIDTagCollection_
tuple caloJetIDTagCollection
const edm::EDGetTokenT< reco::JetTagCollection > caloJetBTagCollection_
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects