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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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_.

6 {
7  srcPFCandidates_ = consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("srcPFCandidates"));
8  srcUnshiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcUnshiftedObjects"));
9  srcShiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcShiftedObjects"));
10 
11  dRmatch_PFCandidate_ = cfg.getParameter<double>("dRmatch_PFCandidate");
13  dRmatch_Object_ = cfg.exists("dRmatch_Object") ?
14  cfg.getParameter<double>("dRmatch_Object") : 0.1;
16  produces<reco::PFCandidateCollection>();
17 }
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< edm::View< reco::Candidate > > srcUnshiftedObjects_
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
ShiftedPFCandidateProducerByMatchedObject::~ShiftedPFCandidateProducerByMatchedObject ( )
override

Definition at line 19 of file ShiftedPFCandidateProducerByMatchedObject.cc.

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

Member Function Documentation

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

Definition at line 24 of file ShiftedPFCandidateProducerByMatchedObject.cc.

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

25 {
26  edm::Handle<reco::PFCandidateCollection> originalPFCandidates;
27  evt.getByToken(srcPFCandidates_, originalPFCandidates);
28 
30 
31  edm::Handle<CandidateView> unshiftedObjects;
32  evt.getByToken(srcUnshiftedObjects_, unshiftedObjects);
33 
34  edm::Handle<CandidateView> shiftedObjects;
35  evt.getByToken(srcShiftedObjects_, shiftedObjects);
36 
37  objects_.clear();
38 
39  CandidateView::const_iterator shiftedObjectP4_matched;
40  bool isMatched_Object = false;
41  double dR2bestMatch_Object = dRDefault;
42  for ( CandidateView::const_iterator unshiftedObject = unshiftedObjects->begin();
43  unshiftedObject != unshiftedObjects->end(); ++unshiftedObject ) {
44  isMatched_Object = false;
45  dR2bestMatch_Object = dRDefault;
46 
47  for ( CandidateView::const_iterator shiftedObject = shiftedObjects->begin();
48  shiftedObject != shiftedObjects->end(); ++shiftedObject ) {
49  double dR2 = deltaR2(unshiftedObject->p4(), shiftedObject->p4());
50  if ( dR2 < dR2match_Object_ && dR2 < dR2bestMatch_Object ) {
51  shiftedObjectP4_matched = shiftedObject;
52  isMatched_Object = true;
53  dR2bestMatch_Object = dR2;
54  }
55  }
56  if ( isMatched_Object ) {
57  objects_.push_back(objectEntryType(shiftedObjectP4_matched->p4(), unshiftedObject->p4(), sqrt(dR2bestMatch_Object) ));
58  }
59  }
60 
61  auto shiftedPFCandidates = std::make_unique<reco::PFCandidateCollection>();
62 
63  for ( reco::PFCandidateCollection::const_iterator originalPFCandidate = originalPFCandidates->begin();
64  originalPFCandidate != originalPFCandidates->end(); ++originalPFCandidate ) {
65 
66  double shift = 0.;
67  bool applyShift = false;
68  double dR2bestMatch_PFCandidate = dRDefault;
69  for ( std::vector<objectEntryType>::const_iterator object = objects_.begin();
70  object != objects_.end(); ++object ) {
71  if ( !object->isValidMatch_ ) continue;
72  double dR2 = deltaR2(originalPFCandidate->p4(), object->unshiftedObjectP4_);
73  if ( dR2 < dR2match_PFCandidate_ && dR2 < dR2bestMatch_PFCandidate ) {
74  shift = object->shift_;
75  applyShift = true;
76  dR2bestMatch_PFCandidate = dR2;
77  }
78  }
79 
80  reco::Candidate::LorentzVector shiftedPFCandidateP4 = originalPFCandidate->p4();
81  if ( applyShift ) {
82  double shiftedPx = (1. + shift)*originalPFCandidate->px();
83  double shiftedPy = (1. + shift)*originalPFCandidate->py();
84  double shiftedPz = (1. + shift)*originalPFCandidate->pz();
85  double mass = originalPFCandidate->mass();
86  double shiftedEn = sqrt(shiftedPx*shiftedPx + shiftedPy*shiftedPy + shiftedPz*shiftedPz + mass*mass);
87  shiftedPFCandidateP4.SetPxPyPzE(shiftedPx, shiftedPy, shiftedPz, shiftedEn);
88  }
89 
90  reco::PFCandidate shiftedPFCandidate(*originalPFCandidate);
91  shiftedPFCandidate.setP4(shiftedPFCandidateP4);
92 
93  shiftedPFCandidates->push_back(shiftedPFCandidate);
94  }
95 
96  evt.put(std::move(shiftedPFCandidates));
97 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
T sqrt(T t)
Definition: SSEVec.h:18
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
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:510
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 73 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