CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
HLTScoutingPFProducer Class Reference

#include <HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc>

Inheritance diagram for HLTScoutingPFProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HLTScoutingPFProducer (const edm::ParameterSet &)
 
 ~HLTScoutingPFProducer ()
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void produce (edm::StreamID sid, edm::Event &iEvent, edm::EventSetup const &setup) const overridefinal
 

Private Attributes

const bool doCandidates
 
const bool doJetTags
 
const bool doMet
 
const edm::EDGetTokenT
< reco::METCollection
metCollection_
 
const edm::EDGetTokenT
< reco::PFCandidateCollection
pfCandidateCollection_
 
const double pfCandidatePtCut
 
const edm::EDGetTokenT
< reco::PFJetCollection
pfJetCollection_
 
const double pfJetEtaCut
 
const double pfJetPtCut
 
const edm::EDGetTokenT
< reco::JetTagCollection
pfJetTagCollection_
 
const edm::EDGetTokenT< double > rho_
 
const edm::EDGetTokenT
< reco::VertexCollection
vertexCollection_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: Producer for ScoutingPFJets from reco::PFJet objects, ScoutingVertexs from reco::Vertexs and ScoutingParticles from reco::PFCandidates

Definition at line 42 of file HLTScoutingPFProducer.cc.

Constructor & Destructor Documentation

HLTScoutingPFProducer::HLTScoutingPFProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 71 of file HLTScoutingPFProducer.cc.

71  :
72  pfJetCollection_(consumes<reco::PFJetCollection>(iConfig.getParameter<edm::InputTag>("pfJetCollection"))),
73  pfJetTagCollection_(consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("pfJetTagCollection"))),
74  pfCandidateCollection_(consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfCandidateCollection"))),
75  vertexCollection_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection"))),
76  metCollection_(consumes<reco::METCollection>(iConfig.getParameter<edm::InputTag>("metCollection"))),
77  rho_(consumes<double>(iConfig.getParameter<edm::InputTag>("rho"))),
78  pfJetPtCut(iConfig.getParameter<double>("pfJetPtCut")),
79  pfJetEtaCut(iConfig.getParameter<double>("pfJetEtaCut")),
80  pfCandidatePtCut(iConfig.getParameter<double>("pfCandidatePtCut")),
81  doJetTags(iConfig.getParameter<bool>("doJetTags")),
82  doCandidates(iConfig.getParameter<bool>("doCandidates")),
83  doMet(iConfig.getParameter<bool>("doMet"))
84 {
85  //register products
86  produces<ScoutingPFJetCollection>();
87  produces<ScoutingParticleCollection>();
88  produces<ScoutingVertexCollection>();
89  produces<double>("rho");
90  produces<double>("pfMetPt");
91  produces<double>("pfMetPhi");
92 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidateCollection_
const edm::EDGetTokenT< reco::METCollection > metCollection_
const edm::EDGetTokenT< reco::VertexCollection > vertexCollection_
const edm::EDGetTokenT< reco::PFJetCollection > pfJetCollection_
const edm::EDGetTokenT< reco::JetTagCollection > pfJetTagCollection_
const edm::EDGetTokenT< double > rho_
HLTScoutingPFProducer::~HLTScoutingPFProducer ( )

Definition at line 94 of file HLTScoutingPFProducer.cc.

95 { }

Member Function Documentation

void HLTScoutingPFProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 227 of file HLTScoutingPFProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and HLT_FULL_cff::InputTag.

227  {
229  desc.add<edm::InputTag>("pfJetCollection",edm::InputTag("hltAK4PFJets"));
230  desc.add<edm::InputTag>("pfJetTagCollection",edm::InputTag("hltCombinedSecondaryVertexBJetTagsPF"));
231  desc.add<edm::InputTag>("pfCandidateCollection", edm::InputTag("hltParticleFlow"));
232  desc.add<edm::InputTag>("vertexCollection", edm::InputTag("hltPixelVertices"));
233  desc.add<edm::InputTag>("metCollection", edm::InputTag("hltPFMETProducer"));
234  desc.add<edm::InputTag>("rho", edm::InputTag("hltFixedGridRhoFastjetAll"));
235  desc.add<double>("pfJetPtCut", 20.0);
236  desc.add<double>("pfJetEtaCut", 3.0);
237  desc.add<double>("pfCandidatePtCut", 0.6);
238  desc.add<bool>("doJetTags", true);
239  desc.add<bool>("doCandidates", true);
240  desc.add<bool>("doMet", true);
241  descriptions.add("hltScoutingPFProducer", desc);
242 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void HLTScoutingPFProducer::produce ( edm::StreamID  sid,
edm::Event iEvent,
edm::EventSetup const &  setup 
) const
finaloverrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 98 of file HLTScoutingPFProducer.cc.

References reco::deltaR2(), doCandidates, doJetTags, doMet, edm::Event::getByToken(), metsig::jet, MT2Analyzer::metCollection, metCollection_, pfCandidateCollection_, pfCandidatePtCut, pfJetCollection_, pfJetEtaCut, pfJetPtCut, pfJetTagCollection_, funct::pow(), edm::Event::put(), rho, rho_, GlobalPosition_Frontier_DevDB_cff::tag, GoodVertex_cfg::vertexCollection, and vertexCollection_.

99 {
100  using namespace edm;
101 
102  //get vertices
104  std::auto_ptr<ScoutingVertexCollection> outVertices(new ScoutingVertexCollection());
106  for(auto &vtx : *vertexCollection){
107  outVertices->emplace_back(
108  vtx.x(), vtx.y(), vtx.z(), vtx.zError()
109  );
110  }
111  }
112 
113  //get rho
115  std::auto_ptr<double> outRho(new double(-999));
116  if(iEvent.getByToken(rho_, rho)){
117  outRho.reset(new double(*rho));
118  }
119 
120  //get MET
122  std::auto_ptr<double> outMetPt(new double(-999));
123  std::auto_ptr<double> outMetPhi(new double(-999));
125  outMetPt.reset(new double(metCollection->front().pt()));
126  outMetPhi.reset(new double(metCollection->front().phi()));
127  }
128 
129  //get PF candidates
130  Handle<reco::PFCandidateCollection> pfCandidateCollection;
131  std::auto_ptr<ScoutingParticleCollection> outPFCandidates(new ScoutingParticleCollection());
132  if(doCandidates && iEvent.getByToken(pfCandidateCollection_, pfCandidateCollection)){
133  for(auto &cand : *pfCandidateCollection){
134  if(cand.pt() > pfCandidatePtCut){
135  int vertex_index = -1;
136  int index_counter = 0;
137  double dr2 = 0.0001;
138  for (auto &vtx: *outVertices) {
139  double tmp_dr2 = pow(vtx.x() - cand.vx(), 2) + pow(vtx.y() - cand.vy(), 2)
140  + pow(vtx.z() - cand.vz(), 2);
141  if (tmp_dr2 < dr2) {
142  dr2 = tmp_dr2;
143  vertex_index = index_counter;
144  }
145  if (dr2 == 0.0)
146  break;
147  ++index_counter;
148  }
149  outPFCandidates->emplace_back(
150  cand.pt(), cand.eta(), cand.phi(), cand.mass(), cand.pdgId(), vertex_index
151  );
152  }
153  }
154  }
155 
156  //get PF jets
157  Handle<reco::PFJetCollection> pfJetCollection;
158  std::auto_ptr<ScoutingPFJetCollection> outPFJets(new ScoutingPFJetCollection());
159  if(iEvent.getByToken(pfJetCollection_, pfJetCollection)){
160  //get PF jet tags
161  Handle<reco::JetTagCollection> pfJetTagCollection;
162  bool haveJetTags = false;
163  if(doJetTags && iEvent.getByToken(pfJetTagCollection_, pfJetTagCollection)){
164  haveJetTags = true;
165  }
166 
167  for(auto &jet : *pfJetCollection){
168  if(jet.pt() < pfJetPtCut || fabs(jet.eta()) > pfJetEtaCut) continue;
169  //find the jet tag corresponding to the jet
170  float tagValue = -20;
171  float minDR2 = 0.01;
172  if(haveJetTags){
173  for(auto &tag : *pfJetTagCollection){
174  float dR2 = reco::deltaR2(jet, *(tag.first));
175  if(dR2 < minDR2){
176  minDR2 = dR2;
177  tagValue = tag.second;
178  }
179  }
180  }
181  //get the PF constituents of the jet
182  std::vector<int> candIndices;
183  if(doCandidates){
184  for(auto &cand : jet.getPFConstituents()){
185  if(cand->pt() > pfCandidatePtCut){
186  //search for the candidate in the collection
187  float minDR2 = 0.0001;
188  int matchIndex = -1;
189  int outIndex = 0;
190  for(auto &outCand : *outPFCandidates){
191  float dR2 = pow(cand->eta() - outCand.eta(), 2) + pow(cand->phi() - outCand.phi(), 2);
192  if(dR2 < minDR2){
193  minDR2 = dR2;
194  matchIndex = outIndex;
195  }
196  if(minDR2 == 0){
197  break;
198  }
199  outIndex++;
200  }
201  candIndices.push_back(matchIndex);
202  }
203  }
204  }
205  outPFJets->emplace_back(
206  jet.pt(), jet.eta(), jet.phi(), jet.mass(), jet.jetArea(),
207  jet.chargedHadronEnergy(), jet.neutralHadronEnergy(), jet.photonEnergy(),
208  jet.electronEnergy(), jet.muonEnergy(), jet.HFHadronEnergy(), jet.HFEMEnergy(),
209  jet.chargedHadronMultiplicity(), jet.neutralHadronMultiplicity(), jet.photonMultiplicity(),
210  jet.electronMultiplicity(), jet.muonMultiplicity(),
211  jet.HFHadronMultiplicity(), jet.HFEMMultiplicity(),
212  jet.hoEnergy(), tagValue, 0.0, candIndices
213  );
214  }
215  }
216 
217  //put output
218  iEvent.put(outVertices);
219  iEvent.put(outPFCandidates);
220  iEvent.put(outPFJets);
221  iEvent.put(outRho, "rho");
222  iEvent.put(outMetPt, "pfMetPt");
223  iEvent.put(outMetPhi, "pfMetPhi");
224 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
tuple vertexCollection
const edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidateCollection_
const edm::EDGetTokenT< reco::METCollection > metCollection_
const edm::EDGetTokenT< reco::VertexCollection > vertexCollection_
std::vector< ScoutingVertex > ScoutingVertexCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
std::vector< ScoutingParticle > ScoutingParticleCollection
const edm::EDGetTokenT< reco::PFJetCollection > pfJetCollection_
const edm::EDGetTokenT< reco::JetTagCollection > pfJetTagCollection_
const edm::EDGetTokenT< double > rho_
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
std::vector< ScoutingPFJet > ScoutingPFJetCollection
Definition: ScoutingPFJet.h:87
string metCollection
Definition: MT2Analyzer.py:460
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40

Member Data Documentation

const bool HLTScoutingPFProducer::doCandidates
private

Definition at line 64 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const bool HLTScoutingPFProducer::doJetTags
private

Definition at line 63 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const bool HLTScoutingPFProducer::doMet
private

Definition at line 65 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::METCollection> HLTScoutingPFProducer::metCollection_
private

Definition at line 56 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::PFCandidateCollection> HLTScoutingPFProducer::pfCandidateCollection_
private

Definition at line 54 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const double HLTScoutingPFProducer::pfCandidatePtCut
private

Definition at line 61 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::PFJetCollection> HLTScoutingPFProducer::pfJetCollection_
private

Definition at line 52 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const double HLTScoutingPFProducer::pfJetEtaCut
private

Definition at line 60 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const double HLTScoutingPFProducer::pfJetPtCut
private

Definition at line 59 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::JetTagCollection> HLTScoutingPFProducer::pfJetTagCollection_
private

Definition at line 53 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<double> HLTScoutingPFProducer::rho_
private

Definition at line 57 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::VertexCollection> HLTScoutingPFProducer::vertexCollection_
private

Definition at line 55 of file HLTScoutingPFProducer.cc.

Referenced by produce().