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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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().

72  : pfJetCollection_(consumes<reco::PFJetCollection>(iConfig.getParameter<edm::InputTag>("pfJetCollection"))),
73  pfJetTagCollection_(consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("pfJetTagCollection"))),
75  consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfCandidateCollection"))),
76  vertexCollection_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection"))),
77  metCollection_(consumes<reco::PFMETCollection>(iConfig.getParameter<edm::InputTag>("metCollection"))),
78  rho_(consumes<double>(iConfig.getParameter<edm::InputTag>("rho"))),
79  pfJetPtCut(iConfig.getParameter<double>("pfJetPtCut")),
80  pfJetEtaCut(iConfig.getParameter<double>("pfJetEtaCut")),
81  pfCandidatePtCut(iConfig.getParameter<double>("pfCandidatePtCut")),
82  doJetTags(iConfig.getParameter<bool>("doJetTags")),
83  doCandidates(iConfig.getParameter<bool>("doCandidates")),
84  doMet(iConfig.getParameter<bool>("doMet")) {
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 242 of file HLTScoutingPFProducer.cc.

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

242  {
244  desc.add<edm::InputTag>("pfJetCollection", edm::InputTag("hltAK4PFJets"));
245  desc.add<edm::InputTag>("pfJetTagCollection", edm::InputTag("hltDeepCombinedSecondaryVertexBJetTagsPF"));
246  desc.add<edm::InputTag>("pfCandidateCollection", edm::InputTag("hltParticleFlow"));
247  desc.add<edm::InputTag>("vertexCollection", edm::InputTag("hltPixelVertices"));
248  desc.add<edm::InputTag>("metCollection", edm::InputTag("hltPFMETProducer"));
249  desc.add<edm::InputTag>("rho", edm::InputTag("hltFixedGridRhoFastjetAll"));
250  desc.add<double>("pfJetPtCut", 20.0);
251  desc.add<double>("pfJetEtaCut", 3.0);
252  desc.add<double>("pfCandidatePtCut", 0.6);
253  desc.add<bool>("doJetTags", true);
254  desc.add<bool>("doCandidates", true);
255  desc.add<bool>("doMet", true);
256  descriptions.add("hltScoutingPFProducer", desc);
257 }
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, susyDQM_cfi::metCollection, metCollection_, eostools::move(), HLT_2018_cff::pfCandidateCollection, pfCandidateCollection_, pfCandidatePtCut, ExoticaDQM_cfi::pfJetCollection, pfJetCollection_, pfJetEtaCut, pfJetPtCut, HLT_2018_cff::pfJetTagCollection, pfJetTagCollection_, funct::pow(), edm::Event::put(), rho, rho_, GlobalPosition_Frontier_DevDB_cff::tag, spclusmultinvestigator_cfi::vertexCollection, vertexCollection_, and badGlobalMuonTaggersAOD_cff::vtx.

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

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