test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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:
43 
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46  private:
47  virtual void produce(edm::StreamID sid, edm::Event & iEvent, edm::EventSetup const & setup) const override 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_(consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("caloJetBTagCollection"))),
70  caloJetIDTagCollection_(consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("caloJetIDTagCollection"))),
71  vertexCollection_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection"))),
72  metCollection_(consumes<reco::CaloMETCollection>(iConfig.getParameter<edm::InputTag>("metCollection"))),
73  rho_(consumes<double>(iConfig.getParameter<edm::InputTag>("rho"))),
74  caloJetPtCut(iConfig.getParameter<double>("caloJetPtCut")),
75  caloJetEtaCut(iConfig.getParameter<double>("caloJetEtaCut")),
76  doMet(iConfig.getParameter<bool>("doMet")),
77  doJetBTags(iConfig.getParameter<bool>("doJetBTags")),
78  doJetIDTags(iConfig.getParameter<bool>("doJetIDTags"))
79 {
80  //register products
81  produces<ScoutingCaloJetCollection>();
82  produces<ScoutingVertexCollection>();
83  produces<double>("rho");
84  produces<double>("caloMetPt");
85  produces<double>("caloMetPhi");
86 }
87 
89 { }
90 
91 // ------------ method called to produce the data ------------
92  void
94 {
95  using namespace edm;
96 
97  //get calo jets
98  Handle<reco::CaloJetCollection> caloJetCollection;
99  std::auto_ptr<ScoutingCaloJetCollection> outCaloJets(new ScoutingCaloJetCollection());
100  if(iEvent.getByToken(caloJetCollection_, caloJetCollection)){
101  //get jet tags
102  Handle<reco::JetTagCollection> caloJetBTagCollection;
103  bool haveJetBTags = false;
104  if(doJetBTags && iEvent.getByToken(caloJetBTagCollection_, caloJetBTagCollection)){
105  haveJetBTags = true;
106  }
107  Handle<reco::JetTagCollection> caloJetIDTagCollection;
108  bool haveJetIDTags = false;
109  if(doJetIDTags && iEvent.getByToken(caloJetIDTagCollection_, caloJetIDTagCollection)){
110  haveJetIDTags = true;
111  }
112 
113  for(auto &jet : *caloJetCollection){
114  if(jet.pt() > caloJetPtCut && fabs(jet.eta()) < caloJetEtaCut){
115  //find the jet tag(s) corresponding to the jet
116  float bTagValue = -20;
117  float bTagMinDR2 = 0.01;
118  if(haveJetBTags){
119  for(auto &tag : *caloJetBTagCollection){
120  float dR2 = reco::deltaR2(jet, *(tag.first));
121  if(dR2 < bTagMinDR2){
122  bTagMinDR2 = dR2;
123  bTagValue = tag.second;
124  }
125  }
126  }
127  float idTagValue = -20;
128  float idTagMinDR2 = 0.01;
129  if(haveJetIDTags){
130  for(auto &tag : *caloJetIDTagCollection){
131  float dR2 = reco::deltaR2(jet, *(tag.first));
132  if(dR2 < idTagMinDR2){
133  idTagMinDR2 = dR2;
134  idTagValue = tag.second;
135  }
136  }
137  }
138  outCaloJets->emplace_back(
139  jet.pt(), jet.eta(), jet.phi(), jet.mass(),
140  jet.jetArea(), jet.maxEInEmTowers(), jet.maxEInHadTowers(),
141  jet.hadEnergyInHB(), jet.hadEnergyInHE(), jet.hadEnergyInHF(),
142  jet.emEnergyInEB(), jet.emEnergyInEE(), jet.emEnergyInHF(),
143  jet.towersArea(), idTagValue, bTagValue
144  );
145  }
146  }
147  }
148 
149  //get vertices
151  std::auto_ptr<ScoutingVertexCollection> outVertices(new ScoutingVertexCollection());
153  //produce vertices (only if present; otherwise return an empty collection)
154  for(auto &vtx : *vertexCollection){
155  outVertices->emplace_back(
156  vtx.x(), vtx.y(), vtx.z(), vtx.zError()
157  );
158  }
159  }
160 
161  //get rho
163  std::auto_ptr<double> outRho(new double(-999));
164  if(iEvent.getByToken(rho_, rho)){
165  outRho.reset(new double(*rho));
166  }
167 
168  //get MET
170  std::auto_ptr<double> outMetPt(new double(-999));
171  std::auto_ptr<double> outMetPhi(new double(-999));
173  outMetPt.reset(new double(metCollection->front().pt()));
174  outMetPhi.reset(new double(metCollection->front().phi()));
175  }
176 
177  //put output
178  iEvent.put(outCaloJets);
179  iEvent.put(outVertices);
180  iEvent.put(outRho, "rho");
181  iEvent.put(outMetPt, "caloMetPt");
182  iEvent.put(outMetPhi, "caloMetPhi");
183 }
184 
185 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
186 void
189  desc.add<edm::InputTag>("caloJetCollection",edm::InputTag("hltAK4CaloJets"));
190  desc.add<edm::InputTag>("caloJetBTagCollection",edm::InputTag("hltCombinedSecondaryVertexBJetTagsCalo"));
191  desc.add<edm::InputTag>("caloJetIDTagCollection",edm::InputTag("hltCaloJetFromPV"));
192  desc.add<edm::InputTag>("vertexCollection", edm::InputTag("hltPixelVertices"));
193  desc.add<edm::InputTag>("metCollection", edm::InputTag("hltMet"));
194  desc.add<edm::InputTag>("rho", edm::InputTag("hltFixedGridRhoFastjetAllCalo"));
195  desc.add<double>("caloJetPtCut", 20.0);
196  desc.add<double>("caloJetEtaCut", 3.0);
197  desc.add<bool>("doMet", true);
198  desc.add<bool>("doJetBTags", false);
199  desc.add<bool>("doJetIDTags", false);
200  descriptions.add("hltScoutingCaloProducer", desc);
201 }
202 
203 //define this as a plug-in
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
const edm::EDGetTokenT< reco::VertexCollection > vertexCollection_
const edm::EDGetTokenT< reco::CaloMETCollection > metCollection_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
HLTScoutingCaloProducer(const edm::ParameterSet &)
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
JetFloatAssociation::Container JetTagCollection
Definition: JetTag.h:18
tuple vertexCollection
std::vector< ScoutingCaloJet > ScoutingCaloJetCollection
const edm::EDGetTokenT< reco::CaloJetCollection > caloJetCollection_
Collection of Calo MET.
int iEvent
Definition: GenABIO.cc:230
std::vector< ScoutingVertex > ScoutingVertexCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
ParameterDescriptionBase * add(U const &iLabel, T const &value)
virtual void produce(edm::StreamID sid, edm::Event &iEvent, edm::EventSetup const &setup) const overridefinal
const edm::EDGetTokenT< double > rho_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
string metCollection
Definition: MT2Analyzer.py:466
const edm::EDGetTokenT< reco::JetTagCollection > caloJetIDTagCollection_
const edm::EDGetTokenT< reco::JetTagCollection > caloJetBTagCollection_
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects