CMS 3D CMS Logo

ShiftedPFCandidateProducerForNoPileUpPFMEt.cc
Go to the documentation of this file.
2 
5 
7 
9  : srcPFCandidatesToken_(consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("srcPFCandidates"))),
10  srcJetsToken_(consumes<reco::PFJetCollection>(cfg.getParameter<edm::InputTag>("srcJets"))) {
11  jetCorrUncertaintyTag_ = cfg.getParameter<std::string>("jetCorrUncertaintyTag");
12  if (cfg.exists("jetCorrInputFileName")) {
13  jetCorrInputFileName_ = cfg.getParameter<edm::FileInPath>("jetCorrInputFileName");
15  throw cms::Exception("ShiftedJetProducerT")
16  << " Failed to find JEC parameter file = " << jetCorrInputFileName_ << " !!\n";
19  } else {
20  jetCorrPayloadName_ = cfg.getParameter<std::string>("jetCorrPayloadName");
21  }
22 
23  minJetPt_ = cfg.getParameter<double>("minJetPt");
24 
25  shiftBy_ = cfg.getParameter<double>("shiftBy");
26 
27  unclEnUncertainty_ = cfg.getParameter<double>("unclEnUncertainty");
28 
29  produces<reco::PFCandidateCollection>();
30 }
31 
33  // nothing to be done yet...
34 }
35 
37  edm::Handle<reco::PFCandidateCollection> originalPFCandidates;
38  evt.getByToken(srcPFCandidatesToken_, originalPFCandidates);
39 
42 
43  std::vector<const reco::PFJet*> selectedJets;
44  for (reco::PFJetCollection::const_iterator jet = jets->begin(); jet != jets->end(); ++jet) {
45  if (jet->pt() > minJetPt_)
46  selectedJets.push_back(&(*jet));
47  }
48 
49  if (!jetCorrPayloadName_.empty()) {
51  es.get<JetCorrectionsRecord>().get(jetCorrPayloadName_, jetCorrParameterSet);
52  const JetCorrectorParameters& jetCorrParameters = (*jetCorrParameterSet)[jetCorrUncertaintyTag_];
53  delete jecUncertainty_;
54  jecUncertainty_ = new JetCorrectionUncertainty(jetCorrParameters);
55  }
56 
57  auto shiftedPFCandidates = std::make_unique<reco::PFCandidateCollection>();
58  for (reco::PFCandidateCollection::const_iterator originalPFCandidate = originalPFCandidates->begin();
59  originalPFCandidate != originalPFCandidates->end();
60  ++originalPFCandidate) {
61  const reco::PFJet* jet_matched = nullptr;
62  for (std::vector<const reco::PFJet*>::iterator jet = selectedJets.begin(); jet != selectedJets.end(); ++jet) {
63  std::vector<reco::PFCandidatePtr> jetConstituents = (*jet)->getPFConstituents();
64  for (std::vector<reco::PFCandidatePtr>::const_iterator jetConstituent = jetConstituents.begin();
65  jetConstituent != jetConstituents.end() && !jet_matched;
66  ++jetConstituent) {
67  if (deltaR(originalPFCandidate->p4(), (*jetConstituent)->p4()) < 1.e-2)
68  jet_matched = (*jet);
69  }
70  }
71 
72  double shift = 0.;
73  if (jet_matched) {
74  jecUncertainty_->setJetEta(jet_matched->eta());
75  jecUncertainty_->setJetPt(jet_matched->pt());
76 
78  } else {
80  }
81 
82  shift *= shiftBy_;
83 
84  reco::Candidate::LorentzVector shiftedPFCandidateP4 = originalPFCandidate->p4();
85  shiftedPFCandidateP4 *= (1. + shift);
86 
87  reco::PFCandidate shiftedPFCandidate(*originalPFCandidate);
88  shiftedPFCandidate.setP4(shiftedPFCandidateP4);
89 
90  shiftedPFCandidates->push_back(shiftedPFCandidate);
91  }
92 
93  evt.put(std::move(shiftedPFCandidates));
94 }
95 
97 
ShiftedPFCandidateProducerForNoPileUpPFMEt::ShiftedPFCandidateProducerForNoPileUpPFMEt
ShiftedPFCandidateProducerForNoPileUpPFMEt(const edm::ParameterSet &)
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.cc:8
reco::PFJet::getPFConstituents
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
Definition: PFJet.cc:41
ESHandle.h
edm
HLT enums.
Definition: AlignableModifier.h:19
ShiftedPFCandidateProducerForNoPileUpPFMEt::minJetPt_
double minJetPt_
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.h:59
ShiftedPFCandidateProducerForNoPileUpPFMEt
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.h:42
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
JetCorrectionUncertainty::setJetEta
void setJetEta(float fEta)
Definition: JetCorrectionUncertainty.cc:204
deltaR.h
JetCorrectionsRecord.h
edm::FileInPath
Definition: FileInPath.h:64
MakerMacros.h
ShiftedPFCandidateProducerForNoPileUpPFMEt::jecUncertainty_
JetCorrectionUncertainty * jecUncertainty_
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.h:57
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ShiftedPFCandidateProducerForNoPileUpPFMEt::shiftBy_
double shiftBy_
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.h:61
edm::ESHandle
Definition: DTSurvey.h:22
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
JetCorrectionsRecord
Definition: JetCorrectionsRecord.h:11
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
JetCorrectionUncertainty::setJetPt
void setJetPt(float fPt)
Definition: JetCorrectionUncertainty.cc:209
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::FileInPath::location
LocationCode location() const
Where was the file found?
Definition: FileInPath.cc:161
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
ShiftedPFCandidateProducerForNoPileUpPFMEt::jetCorrPayloadName_
std::string jetCorrPayloadName_
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.h:54
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
ShiftedPFCandidateProducerForNoPileUpPFMEt::jetCorrInputFileName_
edm::FileInPath jetCorrInputFileName_
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.h:53
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
edm::EventSetup
Definition: EventSetup.h:57
ShiftedPFCandidateProducerForNoPileUpPFMEt::srcPFCandidatesToken_
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidatesToken_
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.h:50
get
#define get
JetCorrectionUncertainty
Definition: JetCorrectionUncertainty.h:11
l1t::PFCandidateCollection
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition: PFCandidate.h:57
looper.cfg
cfg
Definition: looper.py:297
ShiftedPFCandidateProducerForNoPileUpPFMEt::jetCorrUncertaintyTag_
std::string jetCorrUncertaintyTag_
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.h:55
JetCorrectionUncertainty::getUncertainty
float getUncertainty(bool fDirection)
Definition: JetCorrectionUncertainty.cc:83
reco::LeafCandidate::setP4
void setP4(const LorentzVector &p4) final
set 4-momentum
Definition: LeafCandidate.h:158
eostools.move
def move(src, dest)
Definition: eostools.py:511
ShiftedPFCandidateProducerForNoPileUpPFMEt::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.cc:36
ShiftedPFCandidateProducerForNoPileUpPFMEt::~ShiftedPFCandidateProducerForNoPileUpPFMEt
~ShiftedPFCandidateProducerForNoPileUpPFMEt() override
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.cc:32
edm::FileInPath::Unknown
Definition: FileInPath.h:66
reco::PFJetCollection
std::vector< PFJet > PFJetCollection
collection of PFJet objects
Definition: PFJetCollection.h:14
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
metsig::jet
Definition: SignAlgoResolutions.h:47
reco::PFJet
Jets made from PFObjects.
Definition: PFJet.h:20
JetCorrectorParameters
Definition: JetCorrectorParameters.h:25
ShiftedPFCandidateProducerForNoPileUpPFMEt::jetCorrParameters_
JetCorrectorParameters * jetCorrParameters_
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.h:56
ShiftedPFCandidateProducerForNoPileUpPFMEt::unclEnUncertainty_
double unclEnUncertainty_
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.h:63
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
objectSelection_cff.selectedJets
selectedJets
Definition: objectSelection_cff.py:99
cms::Exception
Definition: Exception.h:70
ShiftedPFCandidateProducerForNoPileUpPFMEt::srcJetsToken_
edm::EDGetTokenT< reco::PFJetCollection > srcJetsToken_
Definition: ShiftedPFCandidateProducerForNoPileUpPFMEt.h:51
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
edm::Event
Definition: Event.h:73
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163
ShiftedPFCandidateProducerForNoPileUpPFMEt.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37