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 
32 
35 
37  public:
40 
41  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
42 
43  private:
44  virtual void produce(edm::StreamID sid, edm::Event & iEvent, edm::EventSetup const & setup) const override final;
45 
50 
51  const double caloJetPtCut;
52  const double caloJetEtaCut;
53 
54  const bool doMet;
55 };
56 
57 //
58 // constructors and destructor
59 //
61  caloJetCollection_(consumes<reco::CaloJetCollection>(iConfig.getParameter<edm::InputTag>("caloJetCollection"))),
62  vertexCollection_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection"))),
63  metCollection_(consumes<reco::CaloMETCollection>(iConfig.getParameter<edm::InputTag>("metCollection"))),
64  rho_(consumes<double>(iConfig.getParameter<edm::InputTag>("rho"))),
65  caloJetPtCut(iConfig.getParameter<double>("caloJetPtCut")),
66  caloJetEtaCut(iConfig.getParameter<double>("caloJetEtaCut")),
67  doMet(iConfig.getParameter<bool>("doMet"))
68 {
69  //register products
70  produces<ScoutingCaloJetCollection>();
71  produces<ScoutingVertexCollection>();
72  produces<double>("rho");
73  produces<double>("caloMetPt");
74  produces<double>("caloMetPhi");
75 }
76 
78 { }
79 
80 // ------------ method called to produce the data ------------
81  void
83 {
84  using namespace edm;
85 
86  //get calo jets
87  Handle<reco::CaloJetCollection> caloJetCollection;
88  std::auto_ptr<ScoutingCaloJetCollection> outCaloJets(new ScoutingCaloJetCollection());
89  if(iEvent.getByToken(caloJetCollection_, caloJetCollection)){
90  for(auto &jet : *caloJetCollection){
91  if(jet.pt() > caloJetPtCut && fabs(jet.eta()) < caloJetEtaCut){
92  outCaloJets->emplace_back(
93  jet.pt(), jet.eta(), jet.phi(), jet.mass(),
94  jet.jetArea(), jet.maxEInEmTowers(), jet.maxEInHadTowers(),
95  jet.hadEnergyInHB(), jet.hadEnergyInHE(), jet.hadEnergyInHF(),
96  jet.emEnergyInEB(), jet.emEnergyInEE(), jet.emEnergyInHF(),
97  jet.towersArea(), 0.0
98  );
99  }
100  }
101  }
102 
103  //get vertices
105  std::auto_ptr<ScoutingVertexCollection> outVertices(new ScoutingVertexCollection());
107  //produce vertices (only if present; otherwise return an empty collection)
108  for(auto &vtx : *vertexCollection){
109  outVertices->emplace_back(
110  vtx.x(), vtx.y(), vtx.z(), vtx.zError()
111  );
112  }
113  }
114 
115  //get rho
117  std::auto_ptr<double> outRho(new double(-999));
118  if(iEvent.getByToken(rho_, rho)){
119  outRho.reset(new double(*rho));
120  }
121 
122  //get MET
124  std::auto_ptr<double> outMetPt(new double(-999));
125  std::auto_ptr<double> outMetPhi(new double(-999));
127  outMetPt.reset(new double(metCollection->front().pt()));
128  outMetPhi.reset(new double(metCollection->front().phi()));
129  }
130 
131  //put output
132  iEvent.put(outCaloJets);
133  iEvent.put(outVertices);
134  iEvent.put(outRho, "rho");
135  iEvent.put(outMetPt, "caloMetPt");
136  iEvent.put(outMetPhi, "caloMetPhi");
137 }
138 
139 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
140 void
143  desc.add<edm::InputTag>("caloJetCollection",edm::InputTag("hltAK4CaloJets"));
144  desc.add<edm::InputTag>("vertexCollection", edm::InputTag("hltPixelVertices"));
145  desc.add<edm::InputTag>("metCollection", edm::InputTag("hltMet"));
146  desc.add<edm::InputTag>("rho", edm::InputTag("hltFixedGridRhoFastjetAllCalo"));
147  desc.add<double>("caloJetPtCut", 20.0);
148  desc.add<double>("caloJetEtaCut", 3.0);
149  desc.add<bool>("doMet", true);
150  descriptions.add("hltScoutingCaloProducer", desc);
151 }
152 
153 //define this as a plug-in
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
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
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:120
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)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects