CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
ShiftedPFCandidateProducerForPFMVAMEt Class Reference
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
 
 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 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<>
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 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 30 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

Member Typedef Documentation

◆ CandidateView

Definition at line 36 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

Constructor & Destructor Documentation

◆ ShiftedPFCandidateProducerForPFMVAMEt()

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

Definition at line 78 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

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

79  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
80  srcPFCandidatesToken_(consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("srcPFCandidates"))),
81  srcUnshiftedObjectsToken_(consumes<CandidateView>(cfg.getParameter<edm::InputTag>("srcUnshiftedObjects"))),
82  srcShiftedObjectsToken_(consumes<CandidateView>(cfg.getParameter<edm::InputTag>("srcShiftedObjects"))) {
83  dRmatch_PFCandidate_ = cfg.getParameter<double>("dRmatch_PFCandidate");
84  dRmatch_Object_ = cfg.exists("dRmatch_Object") ? cfg.getParameter<double>("dRmatch_Object") : 0.1;
85 
88 
89  produces<reco::PFCandidateCollection>();
90 }
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidatesToken_

◆ ~ShiftedPFCandidateProducerForPFMVAMEt()

ShiftedPFCandidateProducerForPFMVAMEt::~ShiftedPFCandidateProducerForPFMVAMEt ( )
override

Definition at line 92 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

92  {
93  // nothing to be done yet...
94 }

Member Function Documentation

◆ produce()

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

Definition at line 96 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

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_.

96  {
97  edm::Handle<reco::PFCandidateCollection> originalPFCandidates;
98  evt.getByToken(srcPFCandidatesToken_, originalPFCandidates);
99 
100  edm::Handle<CandidateView> unshiftedObjects;
101  evt.getByToken(srcUnshiftedObjectsToken_, unshiftedObjects);
102 
103  edm::Handle<CandidateView> shiftedObjects;
104  evt.getByToken(srcShiftedObjectsToken_, shiftedObjects);
105 
106  objects_.clear();
107 
108  std::vector<bool> match(shiftedObjects->size(), false);
109  int prevMatch = -1;
110  int cnt = 0;
111 
112  for (CandidateView::const_iterator unshiftedObject = unshiftedObjects->begin();
113  unshiftedObject != unshiftedObjects->end();
114  ++unshiftedObject) {
115  bool isMatched_Object = false;
116  double dR2bestMatch_Object = dRDefault;
117  reco::Candidate::LorentzVector shiftedObjectP4_matched;
118  prevMatch = -1;
119 
120  for (CandidateView::const_iterator shiftedObject = shiftedObjects->begin(); shiftedObject != shiftedObjects->end();
121  ++shiftedObject) {
122  if (match[cnt])
123  continue;
124 
125  double dR2 = deltaR2(unshiftedObject->p4(), shiftedObject->p4());
126  if (dR2 < dR2match_Object_ && dR2 < dR2bestMatch_Object) {
127  shiftedObjectP4_matched = shiftedObject->p4();
128  isMatched_Object = true;
129  dR2bestMatch_Object = dR2;
130 
131  prevMatch = cnt;
132  }
133  cnt++;
134  }
135  if (isMatched_Object) {
136  //Ambiguity removal
137  match[prevMatch] = true;
138  objects_.push_back(objectEntryType(shiftedObjectP4_matched, unshiftedObject->p4(), sqrt(dR2bestMatch_Object)));
139  }
140  }
141 
142  match.assign(objects_.size(), false);
143 
144  auto shiftedPFCandidates = std::make_unique<reco::PFCandidateCollection>();
145 
146  for (reco::PFCandidateCollection::const_iterator originalPFCandidate = originalPFCandidates->begin();
147  originalPFCandidate != originalPFCandidates->end();
148  ++originalPFCandidate) {
149  double shift = 0.;
150  bool applyShift = false;
151  double dR2bestMatch_PFCandidate = dRDefault;
152  prevMatch = -1;
153  cnt = 0;
154 
155  for (std::vector<objectEntryType>::const_iterator object = objects_.begin(); object != objects_.end(); ++object) {
156  if (!object->isValidMatch_)
157  continue;
158  if (match[cnt])
159  continue;
160 
161  double dR2 = deltaR2(originalPFCandidate->p4(), object->unshiftedObjectP4_);
162  if (dR2 < dR2match_PFCandidate_ && dR2 < dR2bestMatch_PFCandidate) {
163  shift = object->shift_;
164  applyShift = true;
165  dR2bestMatch_PFCandidate = dR2;
166 
167  prevMatch = cnt;
168  }
169  cnt++;
170  }
171 
172  reco::Candidate::LorentzVector shiftedPFCandidateP4 = originalPFCandidate->p4();
173  if (applyShift) {
174  //Ambiguity removal
175  match[prevMatch] = true;
176 
177  shiftedPFCandidateP4 *= (1. + shift);
178  }
179 
180  reco::PFCandidate shiftedPFCandidate(*originalPFCandidate);
181  shiftedPFCandidate.setP4(shiftedPFCandidateP4);
182 
183  shiftedPFCandidates->push_back(shiftedPFCandidate);
184  }
185 
186  evt.put(std::move(shiftedPFCandidates));
187 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
size_type size() const
T sqrt(T t)
Definition: SSEVec.h:19
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
static unsigned int const shift
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
const_iterator begin() const
const_iterator end() const
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidatesToken_

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 73 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

Referenced by produce().

◆ srcPFCandidatesToken_

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

Definition at line 42 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

Referenced by produce().

◆ srcShiftedObjectsToken_

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

Definition at line 44 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

Referenced by produce().

◆ srcUnshiftedObjectsToken_

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

Definition at line 43 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

Referenced by produce().