CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ShiftedPFCandidateProducerForPFNoPUMEt Class Reference
Inheritance diagram for ShiftedPFCandidateProducerForPFNoPUMEt:
edm::stream::EDProducer<>

Public Member Functions

 ShiftedPFCandidateProducerForPFNoPUMEt (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::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
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

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

Private Attributes

std::unique_ptr< JetCorrectionUncertaintyjecUncertainty_
 
bool jecValidFileName_
 
edm::FileInPath jetCorrInputFileName_
 
std::unique_ptr< JetCorrectorParametersjetCorrParameters_
 
std::string jetCorrPayloadName_
 
edm::ESGetToken< JetCorrectorParametersCollection, JetCorrectionsRecordjetCorrPayloadToken_
 
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::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

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 40 of file ShiftedPFCandidateProducerForPFNoPUMEt.cc.

Constructor & Destructor Documentation

◆ ShiftedPFCandidateProducerForPFNoPUMEt()

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

Definition at line 72 of file ShiftedPFCandidateProducerForPFNoPUMEt.cc.

References looper::cfg, deDxTools::esConsumes(), edm::FileInPath::fullPath(), jecUncertainty_, jecValidFileName_, jetCorrInputFileName_, jetCorrParameters_, jetCorrPayloadName_, jetCorrPayloadToken_, jetCorrUncertaintyTag_, edm::FileInPath::location(), minJetPt_, shiftBy_, AlCaHLTBitMon_QueryRunRegistry::string, unclEnUncertainty_, and edm::FileInPath::Unknown.

73  : srcPFCandidatesToken_(consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("srcPFCandidates"))),
74  srcJetsToken_(consumes<reco::PFJetCollection>(cfg.getParameter<edm::InputTag>("srcJets"))) {
75  jetCorrUncertaintyTag_ = cfg.getParameter<std::string>("jetCorrUncertaintyTag");
76 
77  jecValidFileName_ = cfg.exists("jetCorrInputFileName");
78  if (jecValidFileName_) {
79  jetCorrInputFileName_ = cfg.getParameter<edm::FileInPath>("jetCorrInputFileName");
81  throw cms::Exception("ShiftedJetProducerT")
82  << " Failed to find JEC parameter file = " << jetCorrInputFileName_ << " !!\n";
83  edm::LogInfo("ShiftedPFCandidateProducerForPFNoPUMEt")
84  << "Reading JEC parameters = " << jetCorrUncertaintyTag_ << " from file = " << jetCorrInputFileName_.fullPath()
85  << "." << std::endl;
87  std::make_unique<JetCorrectorParameters>(jetCorrInputFileName_.fullPath(), jetCorrUncertaintyTag_);
88  jecUncertainty_ = std::make_unique<JetCorrectionUncertainty>(*jetCorrParameters_);
89  } else {
90  edm::LogInfo("ShiftedPFCandidateProducerForPFNoPUMEt")
91  << "Reading JEC parameters = " << jetCorrUncertaintyTag_ << " from DB/SQLlite file." << std::endl;
92  jetCorrPayloadName_ = cfg.getParameter<std::string>("jetCorrPayloadName");
94  }
95 
96  minJetPt_ = cfg.getParameter<double>("minJetPt");
97 
98  shiftBy_ = cfg.getParameter<double>("shiftBy");
99 
100  unclEnUncertainty_ = cfg.getParameter<double>("unclEnUncertainty");
101 
102  produces<reco::PFCandidateCollection>();
103 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidatesToken_
edm::EDGetTokenT< reco::PFJetCollection > srcJetsToken_
LocationCode location() const
Where was the file found?
Definition: FileInPath.cc:142
edm::ESGetToken< JetCorrectorParametersCollection, JetCorrectionsRecord > jetCorrPayloadToken_
std::unique_ptr< JetCorrectorParameters > jetCorrParameters_
Log< level::Info, false > LogInfo
std::unique_ptr< JetCorrectionUncertainty > jecUncertainty_
const std::string & fullPath() const
Definition: FileInPath.cc:144

Member Function Documentation

◆ produce()

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

Definition at line 105 of file ShiftedPFCandidateProducerForPFNoPUMEt.cc.

References HLTMuonOfflineAnalyzer_cfi::deltaR2, reco::LeafCandidate::eta(), edm::Event::getByToken(), edm::EventSetup::getData(), jecUncertainty_, metsig::jet, jetCorrPayloadName_, jetCorrPayloadToken_, jetCorrUncertaintyTag_, PDWG_EXODelayedJetMET_cff::jets, minJetPt_, eostools::move(), reco::LeafCandidate::pt(), edm::Event::put(), objectSelection_cff::selectedJets, reco::LeafCandidate::setP4(), edm::shift, shiftBy_, srcJetsToken_, srcPFCandidatesToken_, and unclEnUncertainty_.

105  {
106  edm::Handle<reco::PFCandidateCollection> originalPFCandidates;
107  evt.getByToken(srcPFCandidatesToken_, originalPFCandidates);
108 
111 
112  std::vector<const reco::PFJet*> selectedJets;
113  for (reco::PFJetCollection::const_iterator jet = jets->begin(); jet != jets->end(); ++jet) {
114  if (jet->pt() > minJetPt_)
115  selectedJets.push_back(&(*jet));
116  }
117 
118  if (!jetCorrPayloadName_.empty()) {
119  JetCorrectorParametersCollection const& jetCorrParameterSet = es.getData(jetCorrPayloadToken_);
120  const JetCorrectorParameters& jetCorrParameters = (jetCorrParameterSet)[jetCorrUncertaintyTag_];
121  jecUncertainty_ = std::make_unique<JetCorrectionUncertainty>(jetCorrParameters);
122  }
123 
124  auto shiftedPFCandidates = std::make_unique<reco::PFCandidateCollection>();
125 
126  for (reco::PFCandidateCollection::const_iterator originalPFCandidate = originalPFCandidates->begin();
127  originalPFCandidate != originalPFCandidates->end();
128  ++originalPFCandidate) {
129  const reco::PFJet* jet_matched = nullptr;
130  for (auto jet : selectedJets) {
131  for (const auto& jetc : jet->getPFConstituents()) {
132  if (deltaR2(originalPFCandidate->p4(), jetc->p4()) < dR2Match) {
133  jet_matched = jet;
134  break;
135  }
136  }
137  if (jet_matched)
138  break;
139  }
140 
141  double shift = 0.;
142  if (jet_matched != nullptr) {
143  jecUncertainty_->setJetEta(jet_matched->eta());
144  jecUncertainty_->setJetPt(jet_matched->pt());
145 
146  shift = jecUncertainty_->getUncertainty(true);
147  } else {
149  }
150 
151  shift *= shiftBy_;
152 
153  reco::Candidate::LorentzVector shiftedPFCandidateP4 = originalPFCandidate->p4();
154  shiftedPFCandidateP4 *= (1. + shift);
155 
156  reco::PFCandidate shiftedPFCandidate(*originalPFCandidate);
157  shiftedPFCandidate.setP4(shiftedPFCandidateP4);
158 
159  shiftedPFCandidates->push_back(shiftedPFCandidate);
160  }
161 
162  evt.put(std::move(shiftedPFCandidates));
163 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
double pt() const final
transverse momentum
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidatesToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:526
edm::EDGetTokenT< reco::PFJetCollection > srcJetsToken_
Jets made from PFObjects.
Definition: PFJet.h:20
edm::ESGetToken< JetCorrectorParametersCollection, JetCorrectionsRecord > jetCorrPayloadToken_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
std::unique_ptr< JetCorrectionUncertainty > jecUncertainty_
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
static unsigned int const shift
def move(src, dest)
Definition: eostools.py:511
double eta() const final
momentum pseudorapidity

Member Data Documentation

◆ jecUncertainty_

std::unique_ptr<JetCorrectionUncertainty> ShiftedPFCandidateProducerForPFNoPUMEt::jecUncertainty_
private

◆ jecValidFileName_

bool ShiftedPFCandidateProducerForPFNoPUMEt::jecValidFileName_
private

◆ jetCorrInputFileName_

edm::FileInPath ShiftedPFCandidateProducerForPFNoPUMEt::jetCorrInputFileName_
private

◆ jetCorrParameters_

std::unique_ptr<JetCorrectorParameters> ShiftedPFCandidateProducerForPFNoPUMEt::jetCorrParameters_
private

◆ jetCorrPayloadName_

std::string ShiftedPFCandidateProducerForPFNoPUMEt::jetCorrPayloadName_
private

◆ jetCorrPayloadToken_

edm::ESGetToken<JetCorrectorParametersCollection, JetCorrectionsRecord> ShiftedPFCandidateProducerForPFNoPUMEt::jetCorrPayloadToken_
private

◆ jetCorrUncertaintyTag_

std::string ShiftedPFCandidateProducerForPFNoPUMEt::jetCorrUncertaintyTag_
private

◆ minJetPt_

double ShiftedPFCandidateProducerForPFNoPUMEt::minJetPt_
private

◆ moduleLabel_

std::string ShiftedPFCandidateProducerForPFNoPUMEt::moduleLabel_
private

◆ shiftBy_

double ShiftedPFCandidateProducerForPFNoPUMEt::shiftBy_
private

◆ srcJetsToken_

edm::EDGetTokenT<reco::PFJetCollection> ShiftedPFCandidateProducerForPFNoPUMEt::srcJetsToken_
private

Definition at line 50 of file ShiftedPFCandidateProducerForPFNoPUMEt.cc.

Referenced by produce().

◆ srcPFCandidatesToken_

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

Definition at line 49 of file ShiftedPFCandidateProducerForPFNoPUMEt.cc.

Referenced by produce().

◆ unclEnUncertainty_

double ShiftedPFCandidateProducerForPFNoPUMEt::unclEnUncertainty_
private