CMS 3D CMS Logo

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

#include <ShiftedPFCandidateProducerByMatchedObject.h>

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

Classes

struct  objectEntryType
 

Public Member Functions

 ShiftedPFCandidateProducerByMatchedObject (const edm::ParameterSet &)
 
 ~ShiftedPFCandidateProducerByMatchedObject () 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 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::vector< objectEntryTypeobjects_
 
edm::EDGetTokenT< reco::PFCandidateCollectionsrcPFCandidates_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
 

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.

Author
Christian Veelken, LLR

Definition at line 31 of file ShiftedPFCandidateProducerByMatchedObject.h.

Constructor & Destructor Documentation

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

Definition at line 5 of file ShiftedPFCandidateProducerByMatchedObject.cc.

References dR2match_Object_, dR2match_PFCandidate_, dRmatch_Object_, dRmatch_PFCandidate_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), srcPFCandidates_, srcShiftedObjects_, and srcUnshiftedObjects_.

5  {
6  srcPFCandidates_ = consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("srcPFCandidates"));
7  srcUnshiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcUnshiftedObjects"));
8  srcShiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcShiftedObjects"));
9 
10  dRmatch_PFCandidate_ = cfg.getParameter<double>("dRmatch_PFCandidate");
12  dRmatch_Object_ = cfg.exists("dRmatch_Object") ? cfg.getParameter<double>("dRmatch_Object") : 0.1;
14  produces<reco::PFCandidateCollection>();
15 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
ShiftedPFCandidateProducerByMatchedObject::~ShiftedPFCandidateProducerByMatchedObject ( )
override

Definition at line 17 of file ShiftedPFCandidateProducerByMatchedObject.cc.

17  {
18  // nothing to be done yet...
19 }

Member Function Documentation

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

Definition at line 21 of file ShiftedPFCandidateProducerByMatchedObject.cc.

References DEFINE_FWK_MODULE, HLTMuonOfflineAnalyzer_cfi::deltaR2, dR2match_Object_, dR2match_PFCandidate_, dRDefault, edm::Event::getByToken(), EgHLTOffHistBins_cfi::mass, eostools::move(), resolutioncreator_cfi::object, objects_, edm::Event::put(), reco::LeafCandidate::setP4(), edm::shift, mathSSE::sqrt(), srcPFCandidates_, srcShiftedObjects_, and srcUnshiftedObjects_.

21  {
22  edm::Handle<reco::PFCandidateCollection> originalPFCandidates;
23  evt.getByToken(srcPFCandidates_, originalPFCandidates);
24 
26 
27  edm::Handle<CandidateView> unshiftedObjects;
28  evt.getByToken(srcUnshiftedObjects_, unshiftedObjects);
29 
30  edm::Handle<CandidateView> shiftedObjects;
31  evt.getByToken(srcShiftedObjects_, shiftedObjects);
32 
33  objects_.clear();
34 
35  CandidateView::const_iterator shiftedObjectP4_matched;
36  bool isMatched_Object = false;
37  double dR2bestMatch_Object = dRDefault;
38  for (CandidateView::const_iterator unshiftedObject = unshiftedObjects->begin();
39  unshiftedObject != unshiftedObjects->end();
40  ++unshiftedObject) {
41  isMatched_Object = false;
42  dR2bestMatch_Object = dRDefault;
43 
44  for (CandidateView::const_iterator shiftedObject = shiftedObjects->begin(); shiftedObject != shiftedObjects->end();
45  ++shiftedObject) {
46  double dR2 = deltaR2(unshiftedObject->p4(), shiftedObject->p4());
47  if (dR2 < dR2match_Object_ && dR2 < dR2bestMatch_Object) {
48  shiftedObjectP4_matched = shiftedObject;
49  isMatched_Object = true;
50  dR2bestMatch_Object = dR2;
51  }
52  }
53  if (isMatched_Object) {
54  objects_.push_back(
55  objectEntryType(shiftedObjectP4_matched->p4(), unshiftedObject->p4(), sqrt(dR2bestMatch_Object)));
56  }
57  }
58 
59  auto shiftedPFCandidates = std::make_unique<reco::PFCandidateCollection>();
60 
61  for (reco::PFCandidateCollection::const_iterator originalPFCandidate = originalPFCandidates->begin();
62  originalPFCandidate != originalPFCandidates->end();
63  ++originalPFCandidate) {
64  double shift = 0.;
65  bool applyShift = false;
66  double dR2bestMatch_PFCandidate = dRDefault;
67  for (std::vector<objectEntryType>::const_iterator object = objects_.begin(); object != objects_.end(); ++object) {
68  if (!object->isValidMatch_)
69  continue;
70  double dR2 = deltaR2(originalPFCandidate->p4(), object->unshiftedObjectP4_);
71  if (dR2 < dR2match_PFCandidate_ && dR2 < dR2bestMatch_PFCandidate) {
72  shift = object->shift_;
73  applyShift = true;
74  dR2bestMatch_PFCandidate = dR2;
75  }
76  }
77 
78  reco::Candidate::LorentzVector shiftedPFCandidateP4 = originalPFCandidate->p4();
79  if (applyShift) {
80  double shiftedPx = (1. + shift) * originalPFCandidate->px();
81  double shiftedPy = (1. + shift) * originalPFCandidate->py();
82  double shiftedPz = (1. + shift) * originalPFCandidate->pz();
83  double mass = originalPFCandidate->mass();
84  double shiftedEn = sqrt(shiftedPx * shiftedPx + shiftedPy * shiftedPy + shiftedPz * shiftedPz + mass * mass);
85  shiftedPFCandidateP4.SetPxPyPzE(shiftedPx, shiftedPy, shiftedPz, shiftedEn);
86  }
87 
88  reco::PFCandidate shiftedPFCandidate(*originalPFCandidate);
89  shiftedPFCandidate.setP4(shiftedPFCandidateP4);
90 
91  shiftedPFCandidates->push_back(shiftedPFCandidate);
92  }
93 
94  evt.put(std::move(shiftedPFCandidates));
95 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
T sqrt(T t)
Definition: SSEVec.h:19
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
static unsigned int const shift
def move(src, dest)
Definition: eostools.py:511
edm::View< Candidate > CandidateView
view of a collection containing candidates
Definition: CandidateFwd.h:23

Member Data Documentation

double ShiftedPFCandidateProducerByMatchedObject::dR2match_Object_
private
double ShiftedPFCandidateProducerByMatchedObject::dR2match_PFCandidate_
private
double ShiftedPFCandidateProducerByMatchedObject::dRmatch_Object_
private
double ShiftedPFCandidateProducerByMatchedObject::dRmatch_PFCandidate_
private
std::vector<objectEntryType> ShiftedPFCandidateProducerByMatchedObject::objects_
private

Definition at line 69 of file ShiftedPFCandidateProducerByMatchedObject.h.

Referenced by produce().

edm::EDGetTokenT<reco::PFCandidateCollection> ShiftedPFCandidateProducerByMatchedObject::srcPFCandidates_
private
edm::EDGetTokenT<edm::View<reco::Candidate> > ShiftedPFCandidateProducerByMatchedObject::srcShiftedObjects_
private
edm::EDGetTokenT<edm::View<reco::Candidate> > ShiftedPFCandidateProducerByMatchedObject::srcUnshiftedObjects_
private