CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
ShiftedPFCandidateProducerForPFMVAMEt Class Reference

#include <ShiftedPFCandidateProducerForPFMVAMEt.h>

Inheritance diagram for ShiftedPFCandidateProducerForPFMVAMEt:
edm::stream::EDProducer<>

Classes

struct  objectEntryType
 

Public Member Functions

 ShiftedPFCandidateProducerForPFMVAMEt (const edm::ParameterSet &)
 
 ~ShiftedPFCandidateProducerForPFMVAMEt () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Types

typedef edm::View< reco::CandidateCandidateView
 

Private Member Functions

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

Private Attributes

double dR2match_Object_
 
double dR2match_PFCandidate_
 
double dRmatch_Object_
 
double dRmatch_PFCandidate_
 
std::string moduleLabel_
 
std::vector< objectEntryTypeobjects_
 
edm::EDGetTokenT< reco::PFCandidateCollectionsrcPFCandidatesToken_
 
edm::EDGetTokenT< CandidateViewsrcShiftedObjectsToken_
 
edm::EDGetTokenT< CandidateViewsrcUnshiftedObjectsToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Vary energy of PFCandidates coinciding in eta-phi with selected electrons/muons/tau-jets/jets by electron/muon/tau-jet/jet energy uncertainty.

NOTE: Auxiliary class specific to estimating systematic uncertainty on PFMET reconstructed by MVA-based algorithm (implemented in RecoMET/METPUSubtraction/src/PFMETProducerMVA.cc)

Author
Christian Veelken, LLR

Definition at line 33 of file ShiftedPFCandidateProducerForPFMVAMEt.h.

Member Typedef Documentation

◆ CandidateView

Definition at line 39 of file ShiftedPFCandidateProducerForPFMVAMEt.h.

Constructor & Destructor Documentation

◆ ShiftedPFCandidateProducerForPFMVAMEt()

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

Definition at line 7 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

8  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
9  srcPFCandidatesToken_(consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("srcPFCandidates"))),
10  srcUnshiftedObjectsToken_(consumes<CandidateView>(cfg.getParameter<edm::InputTag>("srcUnshiftedObjects"))),
11  srcShiftedObjectsToken_(consumes<CandidateView>(cfg.getParameter<edm::InputTag>("srcShiftedObjects"))) {
12  dRmatch_PFCandidate_ = cfg.getParameter<double>("dRmatch_PFCandidate");
13  dRmatch_Object_ = cfg.exists("dRmatch_Object") ? cfg.getParameter<double>("dRmatch_Object") : 0.1;
14 
17 
18  produces<reco::PFCandidateCollection>();
19 }

References looper::cfg, dR2match_Object_, dR2match_PFCandidate_, dRmatch_Object_, and dRmatch_PFCandidate_.

◆ ~ShiftedPFCandidateProducerForPFMVAMEt()

ShiftedPFCandidateProducerForPFMVAMEt::~ShiftedPFCandidateProducerForPFMVAMEt ( )
override

Definition at line 21 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

21  {
22  // nothing to be done yet...
23 }

Member Function Documentation

◆ produce()

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

Definition at line 25 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

25  {
26  edm::Handle<reco::PFCandidateCollection> originalPFCandidates;
27  evt.getByToken(srcPFCandidatesToken_, originalPFCandidates);
28 
29  edm::Handle<CandidateView> unshiftedObjects;
30  evt.getByToken(srcUnshiftedObjectsToken_, unshiftedObjects);
31 
32  edm::Handle<CandidateView> shiftedObjects;
33  evt.getByToken(srcShiftedObjectsToken_, shiftedObjects);
34 
35  objects_.clear();
36 
37  std::vector<bool> match(shiftedObjects->size(), false);
38  int prevMatch = -1;
39  int cnt = 0;
40 
41  for (CandidateView::const_iterator unshiftedObject = unshiftedObjects->begin();
42  unshiftedObject != unshiftedObjects->end();
43  ++unshiftedObject) {
44  bool isMatched_Object = false;
45  double dR2bestMatch_Object = dRDefault;
46  reco::Candidate::LorentzVector shiftedObjectP4_matched;
47  prevMatch = -1;
48 
49  for (CandidateView::const_iterator shiftedObject = shiftedObjects->begin(); shiftedObject != shiftedObjects->end();
50  ++shiftedObject) {
51  if (match[cnt])
52  continue;
53 
54  double dR2 = deltaR2(unshiftedObject->p4(), shiftedObject->p4());
55  if (dR2 < dR2match_Object_ && dR2 < dR2bestMatch_Object) {
56  shiftedObjectP4_matched = shiftedObject->p4();
57  isMatched_Object = true;
58  dR2bestMatch_Object = dR2;
59 
60  prevMatch = cnt;
61  }
62  cnt++;
63  }
64  if (isMatched_Object) {
65  //Ambiguity removal
66  match[prevMatch] = true;
67  objects_.push_back(objectEntryType(shiftedObjectP4_matched, unshiftedObject->p4(), sqrt(dR2bestMatch_Object)));
68  }
69  }
70 
71  match.assign(objects_.size(), false);
72 
73  auto shiftedPFCandidates = std::make_unique<reco::PFCandidateCollection>();
74 
75  for (reco::PFCandidateCollection::const_iterator originalPFCandidate = originalPFCandidates->begin();
76  originalPFCandidate != originalPFCandidates->end();
77  ++originalPFCandidate) {
78  double shift = 0.;
79  bool applyShift = false;
80  double dR2bestMatch_PFCandidate = dRDefault;
81  prevMatch = -1;
82  cnt = 0;
83 
84  for (std::vector<objectEntryType>::const_iterator object = objects_.begin(); object != objects_.end(); ++object) {
85  if (!object->isValidMatch_)
86  continue;
87  if (match[cnt])
88  continue;
89 
90  double dR2 = deltaR2(originalPFCandidate->p4(), object->unshiftedObjectP4_);
91  if (dR2 < dR2match_PFCandidate_ && dR2 < dR2bestMatch_PFCandidate) {
92  shift = object->shift_;
93  applyShift = true;
94  dR2bestMatch_PFCandidate = dR2;
95 
96  prevMatch = cnt;
97  }
98  cnt++;
99  }
100 
101  reco::Candidate::LorentzVector shiftedPFCandidateP4 = originalPFCandidate->p4();
102  if (applyShift) {
103  //Ambiguity removal
104  match[prevMatch] = true;
105 
106  shiftedPFCandidateP4 *= (1. + shift);
107  }
108 
109  reco::PFCandidate shiftedPFCandidate(*originalPFCandidate);
110  shiftedPFCandidate.setP4(shiftedPFCandidateP4);
111 
112  shiftedPFCandidates->push_back(shiftedPFCandidate);
113  }
114 
115  evt.put(std::move(shiftedPFCandidates));
116 }

References edm::View< T >::begin(), HLTMuonOfflineAnalyzer_cfi::deltaR2, dR2match_Object_, dR2match_PFCandidate_, dRDefault, edm::View< T >::end(), edm::Event::getByToken(), match(), eostools::move(), resolutioncreator_cfi::object, objects_, edm::Event::put(), reco::LeafCandidate::setP4(), edm::shift, edm::View< T >::size(), mathSSE::sqrt(), srcPFCandidatesToken_, srcShiftedObjectsToken_, and srcUnshiftedObjectsToken_.

Member Data Documentation

◆ dR2match_Object_

double ShiftedPFCandidateProducerForPFMVAMEt::dR2match_Object_
private

◆ dR2match_PFCandidate_

double ShiftedPFCandidateProducerForPFMVAMEt::dR2match_PFCandidate_
private

◆ dRmatch_Object_

double ShiftedPFCandidateProducerForPFMVAMEt::dRmatch_Object_
private

◆ dRmatch_PFCandidate_

double ShiftedPFCandidateProducerForPFMVAMEt::dRmatch_PFCandidate_
private

◆ moduleLabel_

std::string ShiftedPFCandidateProducerForPFMVAMEt::moduleLabel_
private

◆ objects_

std::vector<objectEntryType> ShiftedPFCandidateProducerForPFMVAMEt::objects_
private

Definition at line 76 of file ShiftedPFCandidateProducerForPFMVAMEt.h.

Referenced by produce().

◆ srcPFCandidatesToken_

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

Definition at line 45 of file ShiftedPFCandidateProducerForPFMVAMEt.h.

Referenced by produce().

◆ srcShiftedObjectsToken_

edm::EDGetTokenT<CandidateView> ShiftedPFCandidateProducerForPFMVAMEt::srcShiftedObjectsToken_
private

Definition at line 47 of file ShiftedPFCandidateProducerForPFMVAMEt.h.

Referenced by produce().

◆ srcUnshiftedObjectsToken_

edm::EDGetTokenT<CandidateView> ShiftedPFCandidateProducerForPFMVAMEt::srcUnshiftedObjectsToken_
private

Definition at line 46 of file ShiftedPFCandidateProducerForPFMVAMEt.h.

Referenced by produce().

edm::View::begin
const_iterator begin() const
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
ShiftedPFCandidateProducerForPFMVAMEt::dRmatch_PFCandidate_
double dRmatch_PFCandidate_
Definition: ShiftedPFCandidateProducerForPFMVAMEt.h:49
dRDefault
const double dRDefault
Definition: ShiftedPFCandidateProducerForPFMVAMEt.cc:5
ShiftedPFCandidateProducerForPFMVAMEt::dRmatch_Object_
double dRmatch_Object_
Definition: ShiftedPFCandidateProducerForPFMVAMEt.h:50
edm::Handle
Definition: AssociativeIterator.h:50
ShiftedPFCandidateProducerForPFMVAMEt::dR2match_PFCandidate_
double dR2match_PFCandidate_
Definition: ShiftedPFCandidateProducerForPFMVAMEt.h:52
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
ShiftedPFCandidateProducerForPFMVAMEt::moduleLabel_
std::string moduleLabel_
Definition: ShiftedPFCandidateProducerForPFMVAMEt.h:43
ShiftedPFCandidateProducerForPFMVAMEt::dR2match_Object_
double dR2match_Object_
Definition: ShiftedPFCandidateProducerForPFMVAMEt.h:53
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
ShiftedPFCandidateProducerForPFMVAMEt::srcShiftedObjectsToken_
edm::EDGetTokenT< CandidateView > srcShiftedObjectsToken_
Definition: ShiftedPFCandidateProducerForPFMVAMEt.h:47
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View::size
size_type size() const
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
looper.cfg
cfg
Definition: looper.py:297
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
ShiftedPFCandidateProducerForPFMVAMEt::srcPFCandidatesToken_
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidatesToken_
Definition: ShiftedPFCandidateProducerForPFMVAMEt.h:45
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
edm::View::end
const_iterator end() const
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
ShiftedPFCandidateProducerForPFMVAMEt::srcUnshiftedObjectsToken_
edm::EDGetTokenT< CandidateView > srcUnshiftedObjectsToken_
Definition: ShiftedPFCandidateProducerForPFMVAMEt.h:46
ShiftedPFCandidateProducerForPFMVAMEt::objects_
std::vector< objectEntryType > objects_
Definition: ShiftedPFCandidateProducerForPFMVAMEt.h:76
edm::InputTag
Definition: InputTag.h:15