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
89  edm::LogError ("HLTScoutingCaloProducer") << "invalid collection: caloJetCollection" << "\n";
90  return;
91  }
92 
93  //get vertices
95  std::auto_ptr<ScoutingVertexCollection> outVertices(new ScoutingVertexCollection());
97  //produce vertices (only if present; otherwise return an empty collection)
98  for(auto &vtx : *vertexCollection){
99  outVertices->emplace_back(
100  vtx.x(), vtx.y(), vtx.z(), vtx.zError()
101  );
102  }
103  }
104 
105  //get rho
107  if(!iEvent.getByToken(rho_, rho)){
108  edm::LogError ("HLTScoutingCaloProducer") << "invalid collection: rho" << "\n";
109  return;
110  }
111  std::auto_ptr<double> outRho(new double(*rho));
112 
113  //get MET
115  if(doMet && !iEvent.getByToken(metCollection_, metCollection)){
116  edm::LogError ("HLTScoutingCaloProducer") << "invalid collection: metCollection" << "\n";
117  return;
118  }
119 
120  //produce calo jets
121  std::auto_ptr<ScoutingCaloJetCollection> outCaloJets(new ScoutingCaloJetCollection());
122  for(auto &jet : *caloJetCollection){
123  if(jet.pt() > caloJetPtCut && fabs(jet.eta()) < caloJetEtaCut){
124  outCaloJets->emplace_back(
125  jet.pt(), jet.eta(), jet.phi(), jet.mass(),
126  jet.jetArea(), jet.maxEInEmTowers(), jet.maxEInHadTowers(),
127  jet.hadEnergyInHB(), jet.hadEnergyInHE(), jet.hadEnergyInHF(),
128  jet.emEnergyInEB(), jet.emEnergyInEE(), jet.emEnergyInHF(),
129  jet.towersArea(), 0.0
130  );
131  }
132  }
133 
134  //produce MET
135  double metPt = -999;
136  double metPhi = -999;
137  if(doMet){
138  metPt = metCollection->front().pt();
139  metPhi = metCollection->front().phi();
140  }
141  std::auto_ptr<double> outMetPt(new double(metPt));
142  std::auto_ptr<double> outMetPhi(new double(metPhi));
143 
144  //put output
145  iEvent.put(outCaloJets);
146  iEvent.put(outVertices);
147  iEvent.put(outRho, "rho");
148  iEvent.put(outMetPt, "caloMetPt");
149  iEvent.put(outMetPhi, "caloMetPhi");
150 }
151 
152 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
153 void
156  desc.add<edm::InputTag>("caloJetCollection",edm::InputTag("hltAK4CaloJets"));
157  desc.add<edm::InputTag>("vertexCollection", edm::InputTag("hltPixelVertices"));
158  desc.add<edm::InputTag>("metCollection", edm::InputTag("hltMetCleanUsingJetID"));
159  desc.add<edm::InputTag>("rho", edm::InputTag("hltFixedGridRhoFastjetAllCalo"));
160  desc.add<double>("caloJetPtCut", 20.0);
161  desc.add<double>("caloJetEtaCut", 3.0);
162  desc.add<bool>("doMet", true);
163  descriptions.add("hltScoutingCaloProducer", desc);
164 }
165 
166 //define this as a plug-in
tuple caloJetCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
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:115
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