57 if (unshiftedObjectP4.energy() > 0.) {
58 shift_ = (shiftedObjectP4.energy() / unshiftedObjectP4.energy()) - 1.;
75 : moduleLabel_(
cfg.getParameter<
std::
string>(
"@module_label")) {
86 produces<JetCollection>();
100 evt.
getByToken(srcUnshiftedObjects_, unshiftedObjects);
103 evt.
getByToken(srcShiftedObjects_, shiftedObjects);
107 std::vector<bool>
match(shiftedObjects->
size(),
false);
112 unshiftedObject != unshiftedObjects->
end();
114 bool isMatched_Object =
false;
121 shiftedObject != shiftedObjects->
end();
126 double dR2 =
deltaR2(unshiftedObject->p4(), shiftedObject->p4());
127 if (dR2 < dR2match_Object_ && dR2 < dR2bestMatch_Object) {
128 shiftedObjectP4_matched = shiftedObject->p4();
129 isMatched_Object =
true;
130 dR2bestMatch_Object = dR2;
136 if (isMatched_Object) {
138 match[prevMatch] =
true;
139 objects_.push_back(
objectEntryType(shiftedObjectP4_matched, unshiftedObject->p4(),
sqrt(dR2bestMatch_Object)));
143 match.assign(objects_.size(),
false);
145 auto shiftedJets = std::make_unique<JetCollection>();
147 for (
typename JetCollection::const_iterator originalJet = originalJets->begin(); originalJet != originalJets->end();
150 bool applyShift =
false;
155 for (
typename std::vector<objectEntryType>::const_iterator
object = objects_.begin();
object != objects_.end();
157 if (!
object->isValidMatch_)
162 double dR2 =
deltaR2(originalJet->p4(),
object->unshiftedObjectP4_);
163 if (dR2 < dR2match_Jet_ && dR2 < dR2bestMatch_Jet) {
164 shift =
object->shift_;
166 dR2bestMatch_Jet = dR2;
176 match[prevMatch] =
true;
178 shiftedJetP4 *= (1. +
shift);
181 T shiftedJet(*originalJet);
182 shiftedJet.setP4(shiftedJetP4);
184 shiftedJets->push_back(shiftedJet);
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ShiftedJetProducerByMatchedObjectT< reco::CaloJet > ShiftedCaloJetProducerByMatchedObject
#define DEFINE_FWK_MODULE(type)
void produce(edm::Event &, const edm::EventSetup &) override
reco::Candidate::LorentzVector shiftedObjectP4_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< T > JetCollection
std::vector< objectEntryType > objects_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
reco::Candidate::LorentzVector unshiftedObjectP4_
ShiftedJetProducerByMatchedObjectT< reco::PFJet > ShiftedPFJetProducerByMatchedObject
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
~ShiftedJetProducerByMatchedObjectT() override
static unsigned int const shift
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
const_iterator begin() const
edm::EDGetTokenT< JetCollection > srcJets_
const_iterator end() const
ShiftedJetProducerByMatchedObjectT(const edm::ParameterSet &)
objectEntryType(const reco::Candidate::LorentzVector &shiftedObjectP4, const reco::Candidate::LorentzVector &unshiftedObjectP4, double dRmatch)