CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ShiftedPFCandidateProducerForPFNoPUMEt Class Reference

#include <ShiftedPFCandidateProducerForPFNoPUMEt.h>

Inheritance diagram for ShiftedPFCandidateProducerForPFNoPUMEt:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ShiftedPFCandidateProducerForPFNoPUMEt (const edm::ParameterSet &)
 
 ~ShiftedPFCandidateProducerForPFNoPUMEt () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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
 
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)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

JetCorrectionUncertaintyjecUncertainty_
 
bool jecValidFileName_
 
edm::FileInPath jetCorrInputFileName_
 
JetCorrectorParametersjetCorrParameters_
 
std::string jetCorrPayloadName_
 
std::string jetCorrUncertaintyTag_
 
double minJetPt_
 
std::string moduleLabel_
 
double shiftBy_
 
edm::EDGetTokenT< reco::PFJetCollectionsrcJetsToken_
 
edm::EDGetTokenT< reco::PFCandidateCollectionsrcPFCandidatesToken_
 
double unclEnUncertainty_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer 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
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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

Vary energy of PFCandidates which are (are not) within jets of Pt > 10 GeV by jet energy uncertainty (by 10% "unclustered" energy uncertainty)

NOTE: Auxiliary class specific to estimating systematic uncertainty on PFMET reconstructed by no-PU MET reconstruction algorithm (implemented in JetMETCorrections/Type1MET/src/PFNoPUMETProducer.cc)

In case all PFCandidates not within jets of Pt > 30 GeV would be varied by the 10% "unclustered" energy uncertainty, the systematic uncertainty on the reconstructed no-PU MET would be overestimated significantly !!

Author
Christian Veelken, LLR

Definition at line 42 of file ShiftedPFCandidateProducerForPFNoPUMEt.h.

Constructor & Destructor Documentation

ShiftedPFCandidateProducerForPFNoPUMEt::ShiftedPFCandidateProducerForPFNoPUMEt ( const edm::ParameterSet cfg)
explicit

Definition at line 10 of file ShiftedPFCandidateProducerForPFNoPUMEt.cc.

References edm::ParameterSet::exists(), edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), jecUncertainty_, jecValidFileName_, jetCorrInputFileName_, jetCorrParameters_, jetCorrPayloadName_, jetCorrUncertaintyTag_, edm::FileInPath::location(), minJetPt_, shiftBy_, AlCaHLTBitMon_QueryRunRegistry::string, unclEnUncertainty_, and edm::FileInPath::Unknown.

11  : srcPFCandidatesToken_(consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("srcPFCandidates")))
12  , srcJetsToken_(consumes<reco::PFJetCollection>(cfg.getParameter<edm::InputTag>("srcJets")))
13 {
14 
15  jetCorrUncertaintyTag_ = cfg.getParameter<std::string>("jetCorrUncertaintyTag");
16 
17  jecValidFileName_ = cfg.exists("jetCorrInputFileName");
18  if ( jecValidFileName_ ) {
19  jetCorrInputFileName_ = cfg.getParameter<edm::FileInPath>("jetCorrInputFileName");
20  if ( jetCorrInputFileName_.location() == edm::FileInPath::Unknown) throw cms::Exception("ShiftedJetProducerT")
21  << " Failed to find JEC parameter file = " << jetCorrInputFileName_ << " !!\n";
22  edm::LogInfo("ShiftedPFCandidateProducerForPFNoPUMEt")
23  << "Reading JEC parameters = " << jetCorrUncertaintyTag_
24  << " from file = " << jetCorrInputFileName_.fullPath() << "." << std::endl;
27  } else {
28  edm::LogInfo("ShiftedPFCandidateProducerForPFNoPUMEt")
29  << "Reading JEC parameters = " << jetCorrUncertaintyTag_
30  << " from DB/SQLlite file." << std::endl;
31  jetCorrPayloadName_ = cfg.getParameter<std::string>("jetCorrPayloadName");
32  }
33 
34  minJetPt_ = cfg.getParameter<double>("minJetPt");
35 
36  shiftBy_ = cfg.getParameter<double>("shiftBy");
37 
38  unclEnUncertainty_ = cfg.getParameter<double>("unclEnUncertainty");
39 
40 
41  produces<reco::PFCandidateCollection>();
42 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidatesToken_
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< reco::PFJetCollection > srcJetsToken_
LocationCode location() const
Where was the file found?
Definition: FileInPath.cc:191
std::string fullPath() const
Definition: FileInPath.cc:197
ShiftedPFCandidateProducerForPFNoPUMEt::~ShiftedPFCandidateProducerForPFNoPUMEt ( )
override

Member Function Documentation

void ShiftedPFCandidateProducerForPFNoPUMEt::produce ( edm::Event evt,
const edm::EventSetup es 
)
overrideprivate

Definition at line 52 of file ShiftedPFCandidateProducerForPFNoPUMEt.cc.

References DEFINE_FWK_MODULE, reco::deltaR2(), dR2Match, reco::LeafCandidate::eta(), edm::EventSetup::get(), edm::Event::getByToken(), JetCorrectionUncertainty::getUncertainty(), jecUncertainty_, metsig::jet, jetCorrPayloadName_, jetCorrUncertaintyTag_, fwrapper::jets, minJetPt_, eostools::move(), reco::LeafCandidate::pt(), edm::Event::put(), objectSelection_cff::selectedJets, JetCorrectionUncertainty::setJetEta(), JetCorrectionUncertainty::setJetPt(), reco::LeafCandidate::setP4(), edm::shift, shiftBy_, srcJetsToken_, srcPFCandidatesToken_, and unclEnUncertainty_.

53 {
54  edm::Handle<reco::PFCandidateCollection> originalPFCandidates;
55  evt.getByToken(srcPFCandidatesToken_, originalPFCandidates);
56 
58  evt.getByToken(srcJetsToken_, jets);
59 
60  std::vector<const reco::PFJet*> selectedJets;
61  for ( reco::PFJetCollection::const_iterator jet = jets->begin();
62  jet != jets->end(); ++jet ) {
63  if ( jet->pt() > minJetPt_ ) selectedJets.push_back(&(*jet));
64  }
65 
66  if ( jetCorrPayloadName_ != "" ) {
68  es.get<JetCorrectionsRecord>().get(jetCorrPayloadName_, jetCorrParameterSet);
69  const JetCorrectorParameters& jetCorrParameters = (*jetCorrParameterSet)[jetCorrUncertaintyTag_];
70  delete jecUncertainty_;
71  jecUncertainty_ = new JetCorrectionUncertainty(jetCorrParameters);
72  }
73 
74  auto shiftedPFCandidates = std::make_unique<reco::PFCandidateCollection>();
75 
76  for ( reco::PFCandidateCollection::const_iterator originalPFCandidate = originalPFCandidates->begin();
77  originalPFCandidate != originalPFCandidates->end(); ++originalPFCandidate ) {
78 
79  const reco::PFJet* jet_matched = nullptr;
80  for ( std::vector<const reco::PFJet*>::iterator jet = selectedJets.begin();
81  jet != selectedJets.end(); ++jet ) {
82  for ( std::vector<reco::PFCandidatePtr>::const_iterator jetConstituent = (*jet)->getPFConstituents().begin();
83  jetConstituent != (*jet)->getPFConstituents().end() && jet_matched==nullptr; ++jetConstituent ) {
84  if ( deltaR2(originalPFCandidate->p4(), (*jetConstituent)->p4()) < dR2Match ) jet_matched = (*jet);
85  }
86  }
87 
88  double shift = 0.;
89  if ( jet_matched!=nullptr ) {
90  jecUncertainty_->setJetEta(jet_matched->eta());
91  jecUncertainty_->setJetPt(jet_matched->pt());
92 
93  shift = jecUncertainty_->getUncertainty(true);
94  } else {
95  shift = unclEnUncertainty_;
96  }
97 
98  shift *= shiftBy_;
99 
100  reco::Candidate::LorentzVector shiftedPFCandidateP4 = originalPFCandidate->p4();
101  shiftedPFCandidateP4 *= (1. + shift);
102 
103  reco::PFCandidate shiftedPFCandidate(*originalPFCandidate);
104  shiftedPFCandidate.setP4(shiftedPFCandidateP4);
105 
106  shiftedPFCandidates->push_back(shiftedPFCandidate);
107  }
108 
109  evt.put(std::move(shiftedPFCandidates));
110 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
double eta() const final
momentum pseudorapidity
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidatesToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
double pt() const final
transverse momentum
edm::EDGetTokenT< reco::PFJetCollection > srcJetsToken_
Jets made from PFObjects.
Definition: PFJet.h:21
vector< PseudoJet > jets
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
T get() const
Definition: EventSetup.h:63
static unsigned int const shift
float getUncertainty(bool fDirection)
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

JetCorrectionUncertainty* ShiftedPFCandidateProducerForPFNoPUMEt::jecUncertainty_
private
bool ShiftedPFCandidateProducerForPFNoPUMEt::jecValidFileName_
private
edm::FileInPath ShiftedPFCandidateProducerForPFNoPUMEt::jetCorrInputFileName_
private
JetCorrectorParameters* ShiftedPFCandidateProducerForPFNoPUMEt::jetCorrParameters_
private
std::string ShiftedPFCandidateProducerForPFNoPUMEt::jetCorrPayloadName_
private
std::string ShiftedPFCandidateProducerForPFNoPUMEt::jetCorrUncertaintyTag_
private
double ShiftedPFCandidateProducerForPFNoPUMEt::minJetPt_
private
std::string ShiftedPFCandidateProducerForPFNoPUMEt::moduleLabel_
private
double ShiftedPFCandidateProducerForPFNoPUMEt::shiftBy_
private
edm::EDGetTokenT<reco::PFJetCollection> ShiftedPFCandidateProducerForPFNoPUMEt::srcJetsToken_
private

Definition at line 56 of file ShiftedPFCandidateProducerForPFNoPUMEt.h.

Referenced by produce().

edm::EDGetTokenT<reco::PFCandidateCollection> ShiftedPFCandidateProducerForPFNoPUMEt::srcPFCandidatesToken_
private

Definition at line 55 of file ShiftedPFCandidateProducerForPFNoPUMEt.h.

Referenced by produce().

double ShiftedPFCandidateProducerForPFNoPUMEt::unclEnUncertainty_
private