CMS 3D CMS Logo

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 () override
 
- 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)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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

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

Private Attributes

const bool doCandidates
 
const bool doJetTags
 
const bool doMet
 
const edm::EDGetTokenT< reco::PFMETCollectionmetCollection_
 
const edm::EDGetTokenT< reco::PFCandidateCollectionpfCandidateCollection_
 
const double pfCandidatePtCut
 
const edm::EDGetTokenT< reco::PFJetCollectionpfJetCollection_
 
const double pfJetEtaCut
 
const double pfJetPtCut
 
const edm::EDGetTokenT< reco::JetTagCollectionpfJetTagCollection_
 
const edm::EDGetTokenT< double > rho_
 
const edm::EDGetTokenT< reco::VertexCollectionvertexCollection_
 

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.

References ~HLTScoutingPFProducer().

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::PFMETCollection>(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<double>("rho");
89  produces<double>("pfMetPt");
90  produces<double>("pfMetPhi");
91 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< reco::PFMETCollection > metCollection_
const edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidateCollection_
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 ( )
overridedefault

Referenced by HLTScoutingPFProducer().

Member Function Documentation

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

Definition at line 224 of file HLTScoutingPFProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and DEFINE_FWK_MODULE.

224  {
226  desc.add<edm::InputTag>("pfJetCollection",edm::InputTag("hltAK4PFJets"));
227  desc.add<edm::InputTag>("pfJetTagCollection",edm::InputTag("hltCombinedSecondaryVertexBJetTagsPF"));
228  desc.add<edm::InputTag>("pfCandidateCollection", edm::InputTag("hltParticleFlow"));
229  desc.add<edm::InputTag>("vertexCollection", edm::InputTag("hltPixelVertices"));
230  desc.add<edm::InputTag>("metCollection", edm::InputTag("hltPFMETProducer"));
231  desc.add<edm::InputTag>("rho", edm::InputTag("hltFixedGridRhoFastjetAll"));
232  desc.add<double>("pfJetPtCut", 20.0);
233  desc.add<double>("pfJetEtaCut", 3.0);
234  desc.add<double>("pfCandidatePtCut", 0.6);
235  desc.add<bool>("doJetTags", true);
236  desc.add<bool>("doCandidates", true);
237  desc.add<bool>("doMet", true);
238  descriptions.add("hltScoutingPFProducer", desc);
239 }
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
finalprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 96 of file HLTScoutingPFProducer.cc.

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

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

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::PFMETCollection> 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().