CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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 int mantissaPrecision
 
const edm::EDGetTokenT
< reco::PFMETCollection
metCollection_
 
const edm::EDGetTokenT
< reco::PFCandidateCollection
pfCandidateCollection_
 
const double pfCandidateEtaCut
 
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
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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

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

Definition at line 44 of file HLTScoutingPFProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 75 of file HLTScoutingPFProducer.cc.

76  : pfJetCollection_(consumes<reco::PFJetCollection>(iConfig.getParameter<edm::InputTag>("pfJetCollection"))),
77  pfJetTagCollection_(consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("pfJetTagCollection"))),
79  consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfCandidateCollection"))),
80  vertexCollection_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection"))),
81  metCollection_(consumes<reco::PFMETCollection>(iConfig.getParameter<edm::InputTag>("metCollection"))),
82  rho_(consumes<double>(iConfig.getParameter<edm::InputTag>("rho"))),
83  pfJetPtCut(iConfig.getParameter<double>("pfJetPtCut")),
84  pfJetEtaCut(iConfig.getParameter<double>("pfJetEtaCut")),
85  pfCandidatePtCut(iConfig.getParameter<double>("pfCandidatePtCut")),
86  pfCandidateEtaCut(iConfig.getParameter<double>("pfCandidateEtaCut")),
87  mantissaPrecision(iConfig.getParameter<int>("mantissaPrecision")),
88  doJetTags(iConfig.getParameter<bool>("doJetTags")),
89  doCandidates(iConfig.getParameter<bool>("doCandidates")),
90  doMet(iConfig.getParameter<bool>("doMet")) {
91  //register products
92  produces<Run3ScoutingPFJetCollection>();
93  produces<Run3ScoutingParticleCollection>();
94  produces<double>("rho");
95  produces<double>("pfMetPt");
96  produces<double>("pfMetPhi");
97 }
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_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HLTScoutingPFProducer::~HLTScoutingPFProducer ( )
overridedefault

Member Function Documentation

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

Definition at line 258 of file HLTScoutingPFProducer.cc.

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

258  {
260  desc.add<edm::InputTag>("pfJetCollection", edm::InputTag("hltAK4PFJets"));
261  desc.add<edm::InputTag>("pfJetTagCollection", edm::InputTag("hltDeepCombinedSecondaryVertexBJetTagsPF"));
262  desc.add<edm::InputTag>("pfCandidateCollection", edm::InputTag("hltParticleFlow"));
263  desc.add<edm::InputTag>("vertexCollection", edm::InputTag("hltPixelVertices"));
264  desc.add<edm::InputTag>("metCollection", edm::InputTag("hltPFMETProducer"));
265  desc.add<edm::InputTag>("rho", edm::InputTag("hltFixedGridRhoFastjetAll"));
266  desc.add<double>("pfJetPtCut", 20.0);
267  desc.add<double>("pfJetEtaCut", 3.0);
268  desc.add<double>("pfCandidatePtCut", 0.6);
269  desc.add<double>("pfCandidateEtaCut", 5.0);
270  desc.add<int>("mantissaPrecision", 10)->setComment("default float16, change to 23 for float32");
271  desc.add<bool>("doJetTags", true);
272  desc.add<bool>("doCandidates", true);
273  desc.add<bool>("doMet", true);
274  descriptions.add("hltScoutingPFProducer", desc);
275 }
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 102 of file HLTScoutingPFProducer.cc.

References funct::abs(), reco::deltaR2(), doCandidates, doJetTags, doMet, Exception, edm::Event::getByToken(), metsig::jet, mantissaPrecision, HLT_FULL_cff::metCollection, metCollection_, eostools::move(), HLT_FULL_cff::pfCandidateCollection, pfCandidateCollection_, pfCandidateEtaCut, pfCandidatePtCut, HLT_FULL_cff::pfJetCollection, pfJetCollection_, pfJetEtaCut, pfJetPtCut, HLT_FULL_cff::pfJetTagCollection, pfJetTagCollection_, funct::pow(), edm::Event::put(), MiniFloatConverter::reduceMantissaToNbitsRounding(), rho, rho_, GlobalPosition_Frontier_DevDB_cff::tag, GoodVertex_cfg::vertexCollection, and vertexCollection_.

102  {
103  using namespace edm;
104 
105  //get vertices
107  std::unique_ptr<Run3ScoutingVertexCollection> outVertices(new Run3ScoutingVertexCollection());
109  for (auto &vtx : *vertexCollection) {
110  outVertices->emplace_back(vtx.x(),
111  vtx.y(),
112  vtx.z(),
113  vtx.zError(),
114  vtx.xError(),
115  vtx.yError(),
116  vtx.tracksSize(),
117  vtx.chi2(),
118  vtx.ndof(),
119  vtx.isValid());
120  }
121  }
122 
123  //get rho
125  std::unique_ptr<double> outRho(new double(-999));
126  if (iEvent.getByToken(rho_, rho)) {
127  outRho = std::make_unique<double>(*rho);
128  }
129 
130  //get MET
132  std::unique_ptr<double> outMetPt(new double(-999));
133  std::unique_ptr<double> outMetPhi(new double(-999));
134  if (doMet && iEvent.getByToken(metCollection_, metCollection)) {
135  outMetPt = std::make_unique<double>(metCollection->front().pt());
136  outMetPhi = std::make_unique<double>(metCollection->front().phi());
137  }
138 
139  //get PF candidates
141  std::unique_ptr<Run3ScoutingParticleCollection> outPFCandidates(new Run3ScoutingParticleCollection());
143  for (auto &cand : *pfCandidateCollection) {
144  if (cand.pt() > pfCandidatePtCut && std::abs(cand.eta()) < pfCandidateEtaCut) {
145  int vertex_index = -1;
146  int index_counter = 0;
147  double dr2 = 0.0001;
148  for (auto &vtx : *outVertices) {
149  double tmp_dr2 = pow(vtx.x() - cand.vx(), 2) + pow(vtx.y() - cand.vy(), 2) + pow(vtx.z() - cand.vz(), 2);
150  if (tmp_dr2 < dr2) {
151  dr2 = tmp_dr2;
152  vertex_index = index_counter;
153  }
154  if (dr2 == 0.0)
155  break;
156  ++index_counter;
157  }
158 
159  outPFCandidates->emplace_back(MiniFloatConverter::reduceMantissaToNbitsRounding(cand.pt(), mantissaPrecision),
163  cand.pdgId(),
164  vertex_index);
165  }
166  }
167  }
168 
169  //get PF jets
171  std::unique_ptr<Run3ScoutingPFJetCollection> outPFJets(new Run3ScoutingPFJetCollection());
173  //get PF jet tags
175  bool haveJetTags = false;
176  if (doJetTags && iEvent.getByToken(pfJetTagCollection_, pfJetTagCollection)) {
177  haveJetTags = true;
178  }
179 
180  for (auto &jet : *pfJetCollection) {
181  if (jet.pt() < pfJetPtCut || std::abs(jet.eta()) > pfJetEtaCut)
182  continue;
183  //find the jet tag corresponding to the jet
184  float tagValue = -20;
185  float minDR2 = 0.01;
186  if (haveJetTags) {
187  for (auto &tag : *pfJetTagCollection) {
188  float dR2 = reco::deltaR2(jet, *(tag.first));
189  if (dR2 < minDR2) {
190  minDR2 = dR2;
191  tagValue = tag.second;
192  }
193  }
194  }
195  //get the PF constituents of the jet
196  std::vector<int> candIndices;
197  if (doCandidates) {
198  for (auto &cand : jet.getPFConstituents()) {
199  if (not(cand.isNonnull() and cand.isAvailable())) {
200  throw cms::Exception("HLTScoutingPFProducer")
201  << "invalid reference to reco::PFCandidate from reco::PFJet::getPFConstituents()";
202  }
203  if (cand->pt() > pfCandidatePtCut && std::abs(cand->eta()) < pfCandidateEtaCut) {
204  //search for the candidate in the collection
205  float minDR2 = 0.0001;
206  int matchIndex = -1;
207  int outIndex = 0;
208  for (auto &outCand : *outPFCandidates) {
209  float dR2 = pow(cand->eta() - outCand.eta(), 2) + pow(cand->phi() - outCand.phi(), 2);
210  if (dR2 < minDR2) {
211  minDR2 = dR2;
212  matchIndex = outIndex;
213  }
214  if (minDR2 == 0) {
215  break;
216  }
217  outIndex++;
218  }
219  candIndices.push_back(matchIndex);
220  }
221  }
222  }
223  outPFJets->emplace_back(jet.pt(),
224  jet.eta(),
225  jet.phi(),
226  jet.mass(),
227  jet.jetArea(),
228  jet.chargedHadronEnergy(),
229  jet.neutralHadronEnergy(),
230  jet.photonEnergy(),
231  jet.electronEnergy(),
232  jet.muonEnergy(),
233  jet.HFHadronEnergy(),
234  jet.HFEMEnergy(),
235  jet.chargedHadronMultiplicity(),
236  jet.neutralHadronMultiplicity(),
237  jet.photonMultiplicity(),
238  jet.electronMultiplicity(),
239  jet.muonMultiplicity(),
240  jet.HFHadronMultiplicity(),
241  jet.HFEMMultiplicity(),
242  jet.hoEnergy(),
243  tagValue,
244  0.0,
245  candIndices);
246  }
247  }
248 
249  //put output
250  iEvent.put(std::move(outPFCandidates));
251  iEvent.put(std::move(outPFJets));
252  iEvent.put(std::move(outRho), "rho");
253  iEvent.put(std::move(outMetPt), "pfMetPt");
254  iEvent.put(std::move(outMetPhi), "pfMetPhi");
255 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
std::vector< Run3ScoutingVertex > Run3ScoutingVertexCollection
const edm::EDGetTokenT< reco::PFMETCollection > metCollection_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< Run3ScoutingPFJet > Run3ScoutingPFJetCollection
tuple pfJetTagCollection
tuple vertexCollection
const edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidateCollection_
tuple pfCandidateCollection
const edm::EDGetTokenT< reco::VertexCollection > vertexCollection_
std::vector< Run3ScoutingParticle > Run3ScoutingParticleCollection
def move
Definition: eostools.py:511
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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_
static float reduceMantissaToNbitsRounding(const float &f)
Definition: libminifloat.h:79
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

Member Data Documentation

const bool HLTScoutingPFProducer::doCandidates
private

Definition at line 68 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const bool HLTScoutingPFProducer::doJetTags
private

Definition at line 67 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const bool HLTScoutingPFProducer::doMet
private

Definition at line 69 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const int HLTScoutingPFProducer::mantissaPrecision
private

Definition at line 65 of file HLTScoutingPFProducer.cc.

Referenced by produce().

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

Definition at line 58 of file HLTScoutingPFProducer.cc.

Referenced by produce().

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

Definition at line 56 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const double HLTScoutingPFProducer::pfCandidateEtaCut
private

Definition at line 64 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const double HLTScoutingPFProducer::pfCandidatePtCut
private

Definition at line 63 of file HLTScoutingPFProducer.cc.

Referenced by produce().

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

Definition at line 54 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const double HLTScoutingPFProducer::pfJetEtaCut
private

Definition at line 62 of file HLTScoutingPFProducer.cc.

Referenced by produce().

const double HLTScoutingPFProducer::pfJetPtCut
private

Definition at line 61 of file HLTScoutingPFProducer.cc.

Referenced by produce().

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

Definition at line 55 of file HLTScoutingPFProducer.cc.

Referenced by produce().

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

Definition at line 59 of file HLTScoutingPFProducer.cc.

Referenced by produce().

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

Definition at line 57 of file HLTScoutingPFProducer.cc.

Referenced by produce().