76 : useUserData_(iConfig.exists(
"userData")), printWarning_(iConfig.getParameter<
bool>(
"printWarning")) {
83 iConfig.
getParameter<std::vector<edm::InputTag>>(
"jetCorrFactorsSource"),
84 [
this](
edm::InputTag const&
tag) { return mayConsume<edm::ValueMap<JetCorrFactors>>(tag); });
90 return mayConsume<reco::JetFloatAssociation::Container>(
tag);
104 if ((
pos != std::string::npos) && (
pos !=
label.length() - 7)) {
107 if (!it->instance().empty()) {
120 if ((
pos != std::string::npos) && (
pos !=
label.length() - 8)) {
135 produces<std::vector<Jet>>();
136 produces<edm::OwnVector<reco::BaseTagInfo>>(
"tagInfos");
147 std::vector<edm::ValueMap<JetCorrFactors>> jetCorrs;
152 jetCorrs.push_back(*jetCorr);
157 std::vector<edm::Handle<reco::JetFloatAssociation::Container>> jetDiscriminators;
164 std::vector<edm::Handle<edm::View<reco::BaseTagInfo>>> jetTagInfos;
173 auto patJets = std::make_unique<std::vector<Jet>>();
175 auto tagInfosOut = std::make_unique<edm::OwnVector<reco::BaseTagInfo>>();
182 unsigned int idx = itJet -
jets->begin();
199 std::vector<std::string>
levels = jetCorrs[0][jetRef].correctionLabels();
201 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"L2L3Residual"));
203 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"L3Absolute"));
205 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"Uncorrected"));
208 <<
"L2L3Residual and L3Absolute are not part of the jetCorrFactors\n" 209 <<
"of module " << jetCorrs[0][jetRef].jecSet() <<
". Jets will remain" 219 for (
size_t k = 0;
k < jetDiscriminators.size(); ++
k) {
220 float value = (*jetDiscriminators[
k])[jetRef];
225 for (
size_t k = 0;
k < jetTagInfos.size(); ++
k) {
230 if ((
idx < taginfos.
size()) && (taginfos[
idx].
jet() == jetRef)) {
237 if (itTI->jet() == jetRef) {
238 match = taginfos.
ptrAt(itTI - taginfos.
begin());
243 if (match.isNonnull()) {
244 tagInfosOut->push_back(match->clone());
247 h_tagInfosOut.id(), &tagInfosOut->back(), tagInfosOut->size() - 1);
264 ajet.
refToOrig_ = patJetRef->originalObjectRef();
289 iDesc.
add<
bool>(
"sort",
true);
292 iDesc.
add<
bool>(
"addTagInfos",
true);
293 std::vector<edm::InputTag> emptyVInputTags;
294 iDesc.
add<std::vector<edm::InputTag>>(
"tagInfoSources", emptyVInputTags);
297 iDesc.
add<
bool>(
"addJetCorrFactors",
true);
298 iDesc.
add<std::vector<edm::InputTag>>(
"jetCorrFactorsSource", emptyVInputTags);
301 iDesc.
add<
bool>(
"addBTagInfo",
true);
302 iDesc.
add<
bool>(
"addDiscriminators",
true);
303 iDesc.
add<std::vector<edm::InputTag>>(
"discriminatorSources", emptyVInputTags);
306 iDesc.
add<
bool>(
"printWarning",
true);
313 descriptions.
add(
"PATJetUpdater", iDesc);
void initializeJEC(unsigned int level, const JetCorrFactors::Flavor &flavor=JetCorrFactors::NONE, unsigned int set=0)
initialize the jet to a given JEC level during creation starting from Uncorrected ...
GreaterByPt< Jet > pTComparator_
T getParameter(std::string const &) const
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void addJECFactors(const JetCorrFactors &jec)
add more sets of energy correction factors
Ptr< value_type > ptrAt(size_type i) const
~PATJetUpdater() override
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken_
std::vector< edm::InputTag > tagInfoTags_
PATJetUpdater(const edm::ParameterSet &iConfig)
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void addBDiscriminatorPair(const std::pair< std::string, float > &thePair)
method to add a algolabel-discriminator pair
static void fillDescription(edm::ParameterSetDescription &iDesc)
std::vector< edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > > tagInfoTokens_
void setComment(std::string const &value)
std::vector< edm::EDGetTokenT< reco::JetFloatAssociation::Container > > discriminatorTokens_
Container::value_type value_type
Class for the storage of jet correction factors.
std::vector< edm::InputTag > discriminatorTags_
#define DEFINE_FWK_MODULE(type)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
std::vector< pat::JetCorrFactors > jec_
std::vector< std::string > discriminatorLabels_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
pat::PATUserDataHelper< pat::Jet > userDataHelper_
const_iterator begin() const
Log< level::Warning, false > LogWarning
std::vector< std::string > tagInfoLabels_
const LorentzVector correctedP4(const std::string &level, const std::string &flavor="none", const std::string &set="") const
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
std::vector< edm::EDGetTokenT< edm::ValueMap< JetCorrFactors > > > jetCorrFactorsTokens_
const_iterator end() const
edm::Ptr< reco::Candidate > refToOrig_
void setP4(const LorentzVector &p4) final
set 4-momentum
void addTagInfo(const std::string &label, const TagInfoFwdPtrCollection::value_type &info)