28 useUserData_(iConfig.exists(
"userData")),
37 addBTagInfo_ = iConfig.getParameter<
bool>(
"addBTagInfo" );
38 addDiscriminators_ = iConfig.getParameter<
bool>(
"addDiscriminators" );
39 discriminatorTags_ = iConfig.getParameter<std::vector<edm::InputTag> >(
"discriminatorSources" );
41 addTagInfos_ = iConfig.getParameter<
bool>(
"addTagInfos" );
42 tagInfoTags_ = iConfig.getParameter<std::vector<edm::InputTag> >(
"tagInfoSources" );
44 if (discriminatorTags_.empty()) {
45 addDiscriminators_ =
false;
47 for (std::vector<edm::InputTag>::const_iterator it = discriminatorTags_.begin(), ed = discriminatorTags_.end(); it != ed; ++it) {
50 if ((pos != std::string::npos) && (pos != label.length() - 7)) {
53 if(it->instance().size()) {
56 discriminatorLabels_.push_back(label);
59 if (tagInfoTags_.empty()) {
62 for (std::vector<edm::InputTag>::const_iterator it = tagInfoTags_.begin(), ed = tagInfoTags_.end(); it != ed; ++it) {
65 if ((pos != std::string::npos) && (pos != label.length() - 8)) {
68 tagInfoLabels_.push_back(label);
71 if (!addBTagInfo_) { addDiscriminators_ =
false; addTagInfos_ =
false; }
77 produces<std::vector<Jet> >();
78 produces<edm::OwnVector<reco::BaseTagInfo> > (
"tagInfos");
82 PATJetUpdater::~PATJetUpdater() {
94 std::vector<edm::ValueMap<JetCorrFactors> > jetCorrs;
99 jetCorrs.push_back( *jetCorr );
104 std::vector<edm::Handle<reco::JetFloatAssociation::Container> > jetDiscriminators;
111 std::vector<edm::Handle<edm::View<reco::BaseTagInfo> > > jetTagInfos;
120 std::auto_ptr< std::vector<Jet> >
patJets (
new std::vector<Jet>() );
129 unsigned int idx = itJet - jets->begin();
132 Jet ajet( patJetRef );
146 std::vector<std::string> levels = jetCorrs[0][jetRef].correctionLabels();
147 if(
std::find(levels.begin(), levels.end(),
"L2L3Residual")!=levels.end()){
148 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"L2L3Residual"));
150 else if(
std::find(levels.begin(), levels.end(),
"L3Absolute")!=levels.end()){
151 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"L3Absolute"));
154 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"Uncorrected"));
156 edm::LogWarning(
"L3Absolute not found") <<
"L2L3Residual and L3Absolute are not part of the jetCorrFactors\n"
157 <<
"of module " << jetCorrs[0][jetRef].jecSet() <<
". Jets will remain"
166 for (
size_t k=0;
k<jetDiscriminators.size(); ++
k) {
167 float value = (*jetDiscriminators[
k])[jetRef];
172 for (
size_t k=0;
k<jetTagInfos.size(); ++
k) {
177 if ((idx < taginfos.
size()) && (taginfos[idx].
jet() == jetRef)) {
178 match = taginfos.
ptrAt(idx);
182 if (itTI->jet() == jetRef) { match = taginfos.
ptrAt( itTI - taginfos.
begin() );
break; }
186 tagInfosOut->push_back( match->clone() );
205 ajet.
refToOrig_ = patJetRef->originalObjectRef();
207 patJets->push_back(ajet);
216 iEvent.
put( tagInfosOut,
"tagInfos" );
230 iDesc.
add<
bool>(
"addTagInfos",
true);
231 std::vector<edm::InputTag> emptyVInputTags;
232 iDesc.
add<std::vector<edm::InputTag> >(
"tagInfoSources", emptyVInputTags);
235 iDesc.
add<
bool>(
"addJetCorrFactors",
true);
236 iDesc.
add<std::vector<edm::InputTag> >(
"jetCorrFactorsSource", emptyVInputTags);
239 iDesc.
add<
bool>(
"addBTagInfo",
true);
240 iDesc.
add<
bool>(
"addDiscriminators",
true);
241 iDesc.
add<std::vector<edm::InputTag> >(
"discriminatorSources", emptyVInputTags);
248 descriptions.
add(
"PATJetUpdater", iDesc);
const LorentzVector correctedP4(const std::string &level, const std::string &flavor="none", const std::string &set="") const
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 ...
T getParameter(std::string const &) const
Assists in assimilating all pat::UserData into pat objects.
GreaterByPt< Jet > pTComparator_
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void addJECFactors(const JetCorrFactors &jec)
add more sets of energy correction factors
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Ptr< value_type > ptrAt(size_type i) const
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken_
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
const_iterator begin() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Class for the storage of jet correction factors.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
RefProd< PROD > getRefBeforePut()
bool isNonnull() const
Checks for non-null.
std::vector< pat::JetCorrFactors > jec_
std::vector< std::string > discriminatorLabels_
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
Analysis-level calorimeter jet class.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
ProductID id() const
Accessor for product ID.
const_iterator end() const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
pat::PATUserDataHelper< pat::Jet > userDataHelper_
std::vector< std::string > tagInfoLabels_
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
std::vector< edm::EDGetTokenT< edm::ValueMap< JetCorrFactors > > > jetCorrFactorsTokens_
edm::Ptr< reco::Candidate > refToOrig_
void addTagInfo(const std::string &label, const TagInfoFwdPtrCollection::value_type &info)