53 if (unshiftedObjectP4.energy() > 0.) {
54 shift_ = (shiftedObjectP4.energy() / unshiftedObjectP4.energy()) - 1.;
80 produces<reco::PFCandidateCollection>();
101 CandidateView::const_iterator shiftedObjectP4_matched;
102 bool isMatched_Object =
false;
104 for (CandidateView::const_iterator unshiftedObject = unshiftedObjects->begin();
105 unshiftedObject != unshiftedObjects->end();
107 isMatched_Object =
false;
110 for (CandidateView::const_iterator shiftedObject = shiftedObjects->begin(); shiftedObject != shiftedObjects->end();
112 double dR2 =
deltaR2(unshiftedObject->p4(), shiftedObject->p4());
114 shiftedObjectP4_matched = shiftedObject;
115 isMatched_Object =
true;
116 dR2bestMatch_Object = dR2;
119 if (isMatched_Object) {
121 objectEntryType(shiftedObjectP4_matched->p4(), unshiftedObject->p4(),
sqrt(dR2bestMatch_Object)));
125 auto shiftedPFCandidates = std::make_unique<reco::PFCandidateCollection>();
127 for (reco::PFCandidateCollection::const_iterator originalPFCandidate = originalPFCandidates->begin();
128 originalPFCandidate != originalPFCandidates->end();
129 ++originalPFCandidate) {
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_)
136 double dR2 =
deltaR2(originalPFCandidate->p4(),
object->unshiftedObjectP4_);
138 shift =
object->shift_;
140 dR2bestMatch_PFCandidate = dR2;
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);
155 shiftedPFCandidate.
setP4(shiftedPFCandidateP4);
157 shiftedPFCandidates->push_back(shiftedPFCandidate);
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
double dR2match_PFCandidate_
objectEntryType(const reco::Candidate::LorentzVector &shiftedObjectP4, const reco::Candidate::LorentzVector &unshiftedObjectP4, double dRmatch)
~ShiftedPFCandidateProducerByMatchedObject() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
double dRmatch_PFCandidate_
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
reco::Candidate::LorentzVector unshiftedObjectP4_
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
reco::Candidate::LorentzVector shiftedObjectP4_
std::vector< objectEntryType > objects_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Particle reconstructed by the particle flow algorithm.
static unsigned int const shift
ShiftedPFCandidateProducerByMatchedObject(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
void setP4(const LorentzVector &p4) final
set 4-momentum
edm::View< Candidate > CandidateView
view of a collection containing candidates