CMS 3D CMS Logo

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_(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<double>("rho");
83  produces<double>("caloMetPt");
84  produces<double>("caloMetPhi");
85 }
86 
88 
89 // ------------ method called to produce the data ------------
90  void
92 {
93  using namespace edm;
94 
95  //get calo jets
96  Handle<reco::CaloJetCollection> caloJetCollection;
97  std::unique_ptr<ScoutingCaloJetCollection> outCaloJets(new ScoutingCaloJetCollection());
98  if(iEvent.getByToken(caloJetCollection_, caloJetCollection)){
99  //get jet tags
100  Handle<reco::JetTagCollection> caloJetBTagCollection;
101  bool haveJetBTags = false;
102  if(doJetBTags && iEvent.getByToken(caloJetBTagCollection_, caloJetBTagCollection)){
103  haveJetBTags = true;
104  }
105  Handle<reco::JetTagCollection> caloJetIDTagCollection;
106  bool haveJetIDTags = false;
107  if(doJetIDTags && iEvent.getByToken(caloJetIDTagCollection_, caloJetIDTagCollection)){
108  haveJetIDTags = true;
109  }
110 
111  for(auto &jet : *caloJetCollection){
112  if(jet.pt() > caloJetPtCut && fabs(jet.eta()) < caloJetEtaCut){
113  //find the jet tag(s) corresponding to the jet
114  float bTagValue = -20;
115  float bTagMinDR2 = 0.01;
116  if(haveJetBTags){
117  for(auto &tag : *caloJetBTagCollection){
118  float dR2 = reco::deltaR2(jet, *(tag.first));
119  if(dR2 < bTagMinDR2){
120  bTagMinDR2 = dR2;
121  bTagValue = tag.second;
122  }
123  }
124  }
125  float idTagValue = -20;
126  float idTagMinDR2 = 0.01;
127  if(haveJetIDTags){
128  for(auto &tag : *caloJetIDTagCollection){
129  float dR2 = reco::deltaR2(jet, *(tag.first));
130  if(dR2 < idTagMinDR2){
131  idTagMinDR2 = dR2;
132  idTagValue = tag.second;
133  }
134  }
135  }
136  outCaloJets->emplace_back(
137  jet.pt(), jet.eta(), jet.phi(), jet.mass(),
138  jet.jetArea(), jet.maxEInEmTowers(), jet.maxEInHadTowers(),
139  jet.hadEnergyInHB(), jet.hadEnergyInHE(), jet.hadEnergyInHF(),
140  jet.emEnergyInEB(), jet.emEnergyInEE(), jet.emEnergyInHF(),
141  jet.towersArea(), idTagValue, bTagValue
142  );
143  }
144  }
145  }
146 
147  //get rho
149  std::unique_ptr<double> outRho(new double(-999));
150  if(iEvent.getByToken(rho_, rho)){
151  outRho.reset(new double(*rho));
152  }
153 
154  //get MET
156  std::unique_ptr<double> outMetPt(new double(-999));
157  std::unique_ptr<double> outMetPhi(new double(-999));
158  if(doMet && iEvent.getByToken(metCollection_, metCollection)){
159  outMetPt.reset(new double(metCollection->front().pt()));
160  outMetPhi.reset(new double(metCollection->front().phi()));
161  }
162 
163  //put output
164  iEvent.put(std::move(outCaloJets));
165  // iEvent.put(std::move(outVertices));
166  iEvent.put(std::move(outRho), "rho");
167  iEvent.put(std::move(outMetPt), "caloMetPt");
168  iEvent.put(std::move(outMetPhi), "caloMetPhi");
169 }
170 
171 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
172 void
175  desc.add<edm::InputTag>("caloJetCollection",edm::InputTag("hltAK4CaloJets"));
176  desc.add<edm::InputTag>("caloJetBTagCollection",edm::InputTag("hltCombinedSecondaryVertexBJetTagsCalo"));
177  desc.add<edm::InputTag>("caloJetIDTagCollection",edm::InputTag("hltCaloJetFromPV"));
178  desc.add<edm::InputTag>("vertexCollection", edm::InputTag("hltPixelVertices"));
179  desc.add<edm::InputTag>("metCollection", edm::InputTag("hltMet"));
180  desc.add<edm::InputTag>("rho", edm::InputTag("hltFixedGridRhoFastjetAllCalo"));
181  desc.add<double>("caloJetPtCut", 20.0);
182  desc.add<double>("caloJetEtaCut", 3.0);
183  desc.add<bool>("doMet", true);
184  desc.add<bool>("doJetBTags", false);
185  desc.add<bool>("doJetIDTags", false);
186  descriptions.add("hltScoutingCaloProducer", desc);
187 }
188 
189 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
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 &)
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
JetFloatAssociation::Container JetTagCollection
Definition: JetTag.h:18
std::vector< ScoutingCaloJet > ScoutingCaloJetCollection
const edm::EDGetTokenT< reco::CaloJetCollection > caloJetCollection_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Collection of Calo MET.
int iEvent
Definition: GenABIO.cc:230
ParameterDescriptionBase * add(U const &iLabel, T const &value)
~HLTScoutingCaloProducer() override
void produce(edm::StreamID sid, edm::Event &iEvent, edm::EventSetup const &setup) const final
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)
fixed size matrix
HLT enums.
const edm::EDGetTokenT< reco::JetTagCollection > caloJetIDTagCollection_
def move(src, dest)
Definition: eostools.py:510
const edm::EDGetTokenT< reco::JetTagCollection > caloJetBTagCollection_
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects