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 | 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
< JetCorrectionUncertainty
jecUncertainty_
 
bool jecValidFileName_
 
edm::FileInPath jetCorrInputFileName_
 
std::unique_ptr
< JetCorrectorParameters
jetCorrParameters_
 
std::string jetCorrPayloadName_
 
edm::ESGetToken
< JetCorrectorParametersCollection,
JetCorrectionsRecord
jetCorrPayloadToken_
 
std::string jetCorrUncertaintyTag_
 
double minJetPt_
 
std::string moduleLabel_
 
double shiftBy_
 
edm::EDGetTokenT
< reco::PFJetCollection
srcJetsToken_
 
edm::EDGetTokenT
< reco::PFCandidateCollection
srcPFCandidatesToken_
 
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 ( const edm::ParameterSet cfg)
explicit

Definition at line 72 of file ShiftedPFCandidateProducerForPFNoPUMEt.cc.

References DeDxTools::esConsumes(), edm::ParameterSet::exists(), edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), 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 }
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidatesToken_
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< reco::PFJetCollection > srcJetsToken_
edm::ESGetToken< JetCorrectorParametersCollection, JetCorrectionsRecord > jetCorrPayloadToken_
LocationCode location() const
Where was the file found?
Definition: FileInPath.cc:159
std::unique_ptr< JetCorrectorParameters > jetCorrParameters_
Log< level::Info, false > LogInfo
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< JetCorrectionUncertainty > jecUncertainty_
std::string fullPath() const
Definition: FileInPath.cc:161
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283

Member Function Documentation

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

Definition at line 105 of file ShiftedPFCandidateProducerForPFNoPUMEt.cc.

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

105  {
106  edm::Handle<reco::PFCandidateCollection> originalPFCandidates;
107  evt.getByToken(srcPFCandidatesToken_, originalPFCandidates);
108 
110  evt.getByToken(srcJetsToken_, jets);
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 {
148  shift = unclEnUncertainty_;
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
double pt() const final
transverse momentum
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidatesToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::EDGetTokenT< reco::PFJetCollection > srcJetsToken_
Jets made from PFObjects.
Definition: PFJet.h:20
bool getData(T &iHolder) const
Definition: EventSetup.h:122
vector< PseudoJet > jets
edm::ESGetToken< JetCorrectorParametersCollection, JetCorrectionsRecord > jetCorrPayloadToken_
def move
Definition: eostools.py:511
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
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
double eta() const final
momentum pseudorapidity

Member Data Documentation

std::unique_ptr<JetCorrectionUncertainty> ShiftedPFCandidateProducerForPFNoPUMEt::jecUncertainty_
private
bool ShiftedPFCandidateProducerForPFNoPUMEt::jecValidFileName_
private
edm::FileInPath ShiftedPFCandidateProducerForPFNoPUMEt::jetCorrInputFileName_
private
std::unique_ptr<JetCorrectorParameters> ShiftedPFCandidateProducerForPFNoPUMEt::jetCorrParameters_
private
std::string ShiftedPFCandidateProducerForPFNoPUMEt::jetCorrPayloadName_
private
edm::ESGetToken<JetCorrectorParametersCollection, JetCorrectionsRecord> ShiftedPFCandidateProducerForPFNoPUMEt::jetCorrPayloadToken_
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 50 of file ShiftedPFCandidateProducerForPFNoPUMEt.cc.

Referenced by produce().

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

Definition at line 49 of file ShiftedPFCandidateProducerForPFNoPUMEt.cc.

Referenced by produce().

double ShiftedPFCandidateProducerForPFNoPUMEt::unclEnUncertainty_
private