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 hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () 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::ShiftedPFCandidateProducerByMatchedObject ( const edm::ParameterSet cfg)
explicit

Definition at line 5 of file ShiftedPFCandidateProducerByMatchedObject.cc.

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 }

References looper::cfg, dR2match_Object_, dR2match_PFCandidate_, dRmatch_Object_, dRmatch_PFCandidate_, srcPFCandidates_, srcShiftedObjects_, and srcUnshiftedObjects_.

◆ ~ShiftedPFCandidateProducerByMatchedObject()

ShiftedPFCandidateProducerByMatchedObject::~ShiftedPFCandidateProducerByMatchedObject ( )
override

Definition at line 17 of file ShiftedPFCandidateProducerByMatchedObject.cc.

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

Member Function Documentation

◆ produce()

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

Definition at line 21 of file ShiftedPFCandidateProducerByMatchedObject.cc.

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 }

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

Member Data Documentation

◆ dR2match_Object_

double ShiftedPFCandidateProducerByMatchedObject::dR2match_Object_
private

◆ dR2match_PFCandidate_

double ShiftedPFCandidateProducerByMatchedObject::dR2match_PFCandidate_
private

◆ dRmatch_Object_

double ShiftedPFCandidateProducerByMatchedObject::dRmatch_Object_
private

◆ dRmatch_PFCandidate_

double ShiftedPFCandidateProducerByMatchedObject::dRmatch_PFCandidate_
private

◆ objects_

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

Definition at line 69 of file ShiftedPFCandidateProducerByMatchedObject.h.

Referenced by produce().

◆ srcPFCandidates_

edm::EDGetTokenT<reco::PFCandidateCollection> ShiftedPFCandidateProducerByMatchedObject::srcPFCandidates_
private

◆ srcShiftedObjects_

edm::EDGetTokenT<edm::View<reco::Candidate> > ShiftedPFCandidateProducerByMatchedObject::srcShiftedObjects_
private

◆ srcUnshiftedObjects_

edm::EDGetTokenT<edm::View<reco::Candidate> > ShiftedPFCandidateProducerByMatchedObject::srcUnshiftedObjects_
private
reco::CandidateView
edm::View< Candidate > CandidateView
view of a collection containing candidates
Definition: CandidateFwd.h:23
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
ShiftedPFCandidateProducerByMatchedObject::dR2match_PFCandidate_
double dR2match_PFCandidate_
Definition: ShiftedPFCandidateProducerByMatchedObject.h:44
edm::Handle
Definition: AssociativeIterator.h:50
ShiftedPFCandidateProducerByMatchedObject::srcShiftedObjects_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
Definition: ShiftedPFCandidateProducerByMatchedObject.h:41
ShiftedPFCandidateProducerByMatchedObject::dRmatch_PFCandidate_
double dRmatch_PFCandidate_
Definition: ShiftedPFCandidateProducerByMatchedObject.h:43
ShiftedPFCandidateProducerByMatchedObject::dRmatch_Object_
double dRmatch_Object_
Definition: ShiftedPFCandidateProducerByMatchedObject.h:45
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:535
edm::View
Definition: CaloClusterFwd.h:14
ShiftedPFCandidateProducerByMatchedObject::srcPFCandidates_
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
Definition: ShiftedPFCandidateProducerByMatchedObject.h:39
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
looper.cfg
cfg
Definition: looper.py:297
ShiftedPFCandidateProducerByMatchedObject::objects_
std::vector< objectEntryType > objects_
Definition: ShiftedPFCandidateProducerByMatchedObject.h:69
ShiftedPFCandidateProducerByMatchedObject::srcUnshiftedObjects_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
Definition: ShiftedPFCandidateProducerByMatchedObject.h:40
ShiftedPFCandidateProducerByMatchedObject::dR2match_Object_
double dR2match_Object_
Definition: ShiftedPFCandidateProducerByMatchedObject.h:46
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
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
dRDefault
const double dRDefault
Definition: ShiftedPFCandidateProducerByMatchedObject.cc:3
edm::InputTag
Definition: InputTag.h:15