CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
ShiftedPFCandidateProducerByMatchedObject Class Reference
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
 
 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 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<>
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.

Author
Christian Veelken, LLR

Definition at line 28 of file ShiftedPFCandidateProducerByMatchedObject.cc.

Constructor & Destructor Documentation

◆ ShiftedPFCandidateProducerByMatchedObject()

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

Definition at line 71 of file ShiftedPFCandidateProducerByMatchedObject.cc.

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

71  {
72  srcPFCandidates_ = consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("srcPFCandidates"));
73  srcUnshiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcUnshiftedObjects"));
74  srcShiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcShiftedObjects"));
75 
76  dRmatch_PFCandidate_ = cfg.getParameter<double>("dRmatch_PFCandidate");
78  dRmatch_Object_ = cfg.exists("dRmatch_Object") ? cfg.getParameter<double>("dRmatch_Object") : 0.1;
80  produces<reco::PFCandidateCollection>();
81 }
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_

◆ ~ShiftedPFCandidateProducerByMatchedObject()

ShiftedPFCandidateProducerByMatchedObject::~ShiftedPFCandidateProducerByMatchedObject ( )
override

Definition at line 83 of file ShiftedPFCandidateProducerByMatchedObject.cc.

83  {
84  // nothing to be done yet...
85 }

Member Function Documentation

◆ produce()

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

Definition at line 87 of file ShiftedPFCandidateProducerByMatchedObject.cc.

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

87  {
88  edm::Handle<reco::PFCandidateCollection> originalPFCandidates;
89  evt.getByToken(srcPFCandidates_, originalPFCandidates);
90 
92 
93  edm::Handle<CandidateView> unshiftedObjects;
94  evt.getByToken(srcUnshiftedObjects_, unshiftedObjects);
95 
96  edm::Handle<CandidateView> shiftedObjects;
97  evt.getByToken(srcShiftedObjects_, shiftedObjects);
98 
99  objects_.clear();
100 
101  CandidateView::const_iterator shiftedObjectP4_matched;
102  bool isMatched_Object = false;
103  double dR2bestMatch_Object = dRDefault;
104  for (CandidateView::const_iterator unshiftedObject = unshiftedObjects->begin();
105  unshiftedObject != unshiftedObjects->end();
106  ++unshiftedObject) {
107  isMatched_Object = false;
108  dR2bestMatch_Object = dRDefault;
109 
110  for (CandidateView::const_iterator shiftedObject = shiftedObjects->begin(); shiftedObject != shiftedObjects->end();
111  ++shiftedObject) {
112  double dR2 = deltaR2(unshiftedObject->p4(), shiftedObject->p4());
113  if (dR2 < dR2match_Object_ && dR2 < dR2bestMatch_Object) {
114  shiftedObjectP4_matched = shiftedObject;
115  isMatched_Object = true;
116  dR2bestMatch_Object = dR2;
117  }
118  }
119  if (isMatched_Object) {
120  objects_.push_back(
121  objectEntryType(shiftedObjectP4_matched->p4(), unshiftedObject->p4(), sqrt(dR2bestMatch_Object)));
122  }
123  }
124 
125  auto shiftedPFCandidates = std::make_unique<reco::PFCandidateCollection>();
126 
127  for (reco::PFCandidateCollection::const_iterator originalPFCandidate = originalPFCandidates->begin();
128  originalPFCandidate != originalPFCandidates->end();
129  ++originalPFCandidate) {
130  double shift = 0.;
131  bool applyShift = false;
132  double dR2bestMatch_PFCandidate = dRDefault;
133  for (std::vector<objectEntryType>::const_iterator object = objects_.begin(); object != objects_.end(); ++object) {
134  if (!object->isValidMatch_)
135  continue;
136  double dR2 = deltaR2(originalPFCandidate->p4(), object->unshiftedObjectP4_);
137  if (dR2 < dR2match_PFCandidate_ && dR2 < dR2bestMatch_PFCandidate) {
138  shift = object->shift_;
139  applyShift = true;
140  dR2bestMatch_PFCandidate = dR2;
141  }
142  }
143 
144  reco::Candidate::LorentzVector shiftedPFCandidateP4 = originalPFCandidate->p4();
145  if (applyShift) {
146  double shiftedPx = (1. + shift) * originalPFCandidate->px();
147  double shiftedPy = (1. + shift) * originalPFCandidate->py();
148  double shiftedPz = (1. + shift) * originalPFCandidate->pz();
149  double mass = originalPFCandidate->mass();
150  double shiftedEn = sqrt(shiftedPx * shiftedPx + shiftedPy * shiftedPy + shiftedPz * shiftedPz + mass * mass);
151  shiftedPFCandidateP4.SetPxPyPzE(shiftedPx, shiftedPy, shiftedPz, shiftedEn);
152  }
153 
154  reco::PFCandidate shiftedPFCandidate(*originalPFCandidate);
155  shiftedPFCandidate.setP4(shiftedPFCandidateP4);
156 
157  shiftedPFCandidates->push_back(shiftedPFCandidate);
158  }
159 
160  evt.put(std::move(shiftedPFCandidates));
161 }
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:540
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:36
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
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

◆ 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 66 of file ShiftedPFCandidateProducerByMatchedObject.cc.

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