43 useUserData_(iConfig.exists(
"userData")),
49 if ( iConfig.
exists(
"embedCaloTowers") ) {
67 if( addJetCorrFactors_ ) {
70 addBTagInfo_ = iConfig.getParameter<
bool>(
"addBTagInfo" );
71 addDiscriminators_ = iConfig.getParameter<
bool>(
"addDiscriminators" );
72 discriminatorTags_ = iConfig.getParameter<std::vector<edm::InputTag> >(
"discriminatorSources" );
74 addTagInfos_ = iConfig.getParameter<
bool>(
"addTagInfos" );
75 tagInfoTags_ = iConfig.getParameter<std::vector<edm::InputTag> >(
"tagInfoSources" );
77 addAssociatedTracks_ = iConfig.getParameter<
bool>(
"addAssociatedTracks" );
78 trackAssociationToken_ = mayConsume<reco::JetTracksAssociation::Container>(iConfig.getParameter<
edm::InputTag>(
"trackAssociationSource" ));
79 addJetCharge_ = iConfig.getParameter<
bool>(
"addJetCharge" );
80 jetChargeToken_ = mayConsume<reco::JetFloatAssociation::Container>(iConfig.getParameter<
edm::InputTag>(
"jetChargeSource" ));
81 addJetID_ = iConfig.getParameter<
bool>(
"addJetID");
82 jetIDMapToken_ = mayConsume<reco::JetIDValueMap>(iConfig.getParameter<
edm::InputTag>(
"jetIDMap"));
84 addEfficiencies_ = iConfig.getParameter<
bool>(
"addEfficiencies");
85 if (addEfficiencies_) {
89 addResolutions_ = iConfig.getParameter<
bool>(
"addResolutions");
90 if (addResolutions_) {
93 if (discriminatorTags_.empty()) {
94 addDiscriminators_ =
false;
96 for (std::vector<edm::InputTag>::const_iterator it = discriminatorTags_.begin(), ed = discriminatorTags_.end(); it != ed; ++it) {
99 if ((pos != std::string::npos) && (pos != label.length() - 7)) {
102 if(it->instance().size()) {
105 discriminatorLabels_.push_back(label);
108 if (tagInfoTags_.empty()) {
109 addTagInfos_ =
false;
111 for (std::vector<edm::InputTag>::const_iterator it = tagInfoTags_.begin(), ed = tagInfoTags_.end(); it != ed; ++it) {
114 if ((pos != std::string::npos) && (pos != label.length() - 8)) {
117 tagInfoLabels_.push_back(label);
120 if (!addBTagInfo_) { addDiscriminators_ =
false; addTagInfos_ =
false; }
122 if ( useUserData_ ) {
126 produces<std::vector<Jet> >();
127 produces<reco::GenJetCollection> (
"genJets");
128 produces<std::vector<CaloTower> > (
"caloTowers");
129 produces<reco::PFCandidateCollection > (
"pfCandidates");
130 produces<edm::OwnVector<reco::BaseTagInfo> > (
"tagInfos");
134 PATJetProducer::~PATJetProducer() {
177 std::vector<edm::ValueMap<JetCorrFactors> > jetCorrs;
182 jetCorrs.push_back( *jetCorr );
187 std::vector<edm::Handle<reco::JetFloatAssociation::Container> > jetDiscriminators;
194 std::vector<edm::Handle<edm::View<reco::BaseTagInfo> > > jetTagInfos;
213 std::auto_ptr< std::vector<Jet> >
patJets (
new std::vector<Jet>() );
216 std::auto_ptr<std::vector<CaloTower> > caloTowersOut(
new std::vector<CaloTower> () );
229 unsigned int idx = itJet - jets->begin();
238 if ( ajet.
isCaloJet()) cj = dynamic_cast<const reco::CaloJet *>(jetRef.
get());
245 for ( std::vector<CaloTowerPtr>::const_iterator towBegin = itowers.begin(), towEnd = itowers.end(), itow = towBegin; itow != towEnd; ++itow ) {
246 if( itow->isAvailable() && itow->isNonnull() ){
247 caloTowersOut->push_back( **itow );
250 edm::Ptr<CaloTower> caloForwardRef ( h_caloTowersOut.id(), caloTowerRef.key(), h_caloTowersOut.productGetter() );
265 for ( std::vector<reco::PFCandidatePtr>::const_iterator partBegin = iparticles.begin(),
266 partEnd = iparticles.end(), ipart = partBegin;
267 ipart != partEnd; ++ipart ) {
268 pfCandidatesOut->push_back( **ipart );
288 std::vector<std::string> levels = jetCorrs[0][jetRef].correctionLabels();
289 if(
std::find(levels.begin(), levels.end(),
"L2L3Residual")!=levels.end()){
290 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"L2L3Residual"));
292 else if(
std::find(levels.begin(), levels.end(),
"L3Absolute")!=levels.end()){
293 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"L3Absolute"));
296 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"Uncorrected"));
298 edm::LogWarning(
"L3Absolute not found") <<
"L2L3Residual and L3Absolute are not part of the jetCorrFactors\n"
299 <<
"of module " << jetCorrs[0][jetRef].jecSet() <<
". Jets will remain"
328 genJetsOut->push_back( *genjet );
355 for (
size_t k=0;
k<jetDiscriminators.size(); ++
k) {
356 float value = (*jetDiscriminators[
k])[jetRef];
361 for (
size_t k=0;
k<jetTagInfos.size(); ++
k) {
366 if ((idx < taginfos.
size()) && (taginfos[idx].
jet() == jetRef)) {
367 match = taginfos.
ptrAt(idx);
371 if (itTI->jet() == jetRef) { match = taginfos.
ptrAt( itTI - taginfos.
begin() );
break; }
375 tagInfosOut->push_back( match->clone() );
406 patJets->push_back(ajet);
415 iEvent.
put( genJetsOut,
"genJets" );
416 iEvent.
put( caloTowersOut,
"caloTowers" );
417 iEvent.
put( pfCandidatesOut,
"pfCandidates" );
418 iEvent.
put( tagInfosOut,
"tagInfos" );
433 iDesc.
addOptional<
bool>(
"embedCaloTowers",
false)->setComment(
"embed external CaloTowers (not to be used on AOD input)");
434 iDesc.
add<
bool>(
"embedPFCandidates",
true)->setComment(
"embed external PFCandidates");
437 iDesc.
add<
bool>(
"addGenPartonMatch",
true)->setComment(
"add MC matching");
438 iDesc.
add<
bool>(
"embedGenPartonMatch",
false)->setComment(
"embed MC matched MC information");
441 iDesc.
add<
bool>(
"addGenJetMatch",
true)->setComment(
"add MC matching");
442 iDesc.
add<
bool>(
"embedGenJetMatch",
false)->setComment(
"embed MC matched MC information");
445 iDesc.
add<
bool>(
"addJetCharge",
true);
449 iDesc.
add<
bool>(
"addJetID",
true)->setComment(
"Add jet ID information");
452 iDesc.
add<
bool>(
"addPartonJetMatch",
false);
456 iDesc.
add<
bool>(
"addAssociatedTracks",
true);
460 iDesc.
add<
bool>(
"addTagInfos",
true);
461 std::vector<edm::InputTag> emptyVInputTags;
462 iDesc.
add<std::vector<edm::InputTag> >(
"tagInfoSources", emptyVInputTags);
465 iDesc.
add<
bool>(
"addJetCorrFactors",
true);
466 iDesc.
add<std::vector<edm::InputTag> >(
"jetCorrFactorsSource", emptyVInputTags);
469 iDesc.
add<
bool>(
"addBTagInfo",
true);
470 iDesc.
add<
bool>(
"addDiscriminators",
true);
471 iDesc.
add<std::vector<edm::InputTag> >(
"discriminatorSources", emptyVInputTags);
474 iDesc.
add<
bool>(
"getJetMCFlavour",
true);
475 iDesc.
add<
bool>(
"useLegacyJetMCFlavour",
false);
476 iDesc.
add<
bool>(
"addJetFlavourInfo",
false);
485 iDesc.
add(
"efficiencies", efficienciesPSet);
486 iDesc.
add<
bool>(
"addEfficiencies",
false);
493 descriptions.
add(
"PATJetProducer", iDesc);
bool enabled() const
'true' if this there is at least one efficiency configured
void setJetID(reco::JetID const &id)
methods for jet ID
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 ...
value_type const * get() const
T getParameter(std::string const &) const
pat::helper::EfficiencyLoader efficiencyLoader_
Assists in assimilating all pat::UserData into pat objects.
void setGenParton(const reco::GenParticleRef &gp, bool embed=false)
method to set the matched parton
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken_
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void addJECFactors(const JetCorrFactors &jec)
add more sets of energy correction factors
bool isNonnull() const
Checks for non-null.
std::vector< edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > > tagInfoTokens_
edm::EDGetTokenT< reco::JetTracksAssociation::Container > trackAssociationToken_
Jets made from CaloTowers.
std::vector< std::string > tagInfoLabels_
std::vector< edm::EDGetTokenT< edm::ValueMap< JetCorrFactors > > > jetCorrFactorsTokens_
bool addAssociatedTracks_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setAllowAnything()
allow any parameter label/value pairs
Ptr< value_type > ptrAt(size_type i) const
pat::helper::KinResolutionsLoader resolutionLoader_
#define DEFINE_FWK_MODULE(type)
std::vector< GenJet > GenJetCollection
collection of GenJet objects
std::vector< std::string > discriminatorLabels_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
const edm::RefToBase< reco::Jet > & getCaloJetRef() const
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)
virtual std::vector< CaloTowerPtr > getCaloConstituents() const
get all constituents
void addBDiscriminatorPair(const std::pair< std::string, float > &thePair)
method to add a algolabel-discriminator pair
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > jetFlavourInfoToken_
Jets made from PFObjects.
void setCaloTowers(const CaloTowerFwdPtrCollection &caloTowers)
method to store the CaloJet constituents internally
GreaterByPt< Jet > pTComparator_
bool enabled() const
'true' if this there is at least one efficiency configured
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
static void fillDescription(edm::ParameterSetDescription &iDesc)
PATJetProducer(const edm::ParameterSet &iConfig)
bool isCaloJet() const
check to see if the jet is a reco::CaloJet
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< reco::JetFloatAssociation::Container > jetChargeToken_
void setHadronFlavour(int hadronFl)
method to set the hadron-based flavour of the jet
void setComment(std::string const &value)
Container::value_type value_type
const_iterator begin() const
void setPartonFlavour(int partonFl)
method to set the parton-based flavour of the jet
void setPFCandidates(const PFCandidateFwdPtrCollection &pfCandidates)
method to store the PFCandidate constituents internally
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
Jets made from CaloJets corrected for ZSP and tracks.
Class for the storage of jet correction factors.
void setJetCharge(float jetCharge)
method to set the jet charge
edm::EDGetTokenT< reco::JetIDValueMap > jetIDMapToken_
void setJetFlavourInfo(const reco::JetFlavourInfo &jetFlavourInfo)
method to set the JetFlavourInfo of the jet
ParameterDescriptionBase * add(U const &iLabel, T const &value)
RefProd< PROD > getRefBeforePut()
bool isPFJet() const
check to see if the jet is a reco::PFJet
bool isNonnull() const
Checks for non-null.
bool isJPTJet() const
check to see if the jet is a reco::JPTJet
pat::PATUserDataHelper< pat::Jet > userDataHelper_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
void setAssociatedTracks(const reco::TrackRefVector &tracks)
method to set the vector of refs to the tracks associated to this jet
edm::EDGetTokenT< reco::JetFlavourMatchingCollection > jetPartonMapToken_
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
bool useLegacyJetMCFlavour_
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
std::vector< edm::FwdPtr< CaloTower > > CaloTowerFwdPtrCollection
std::vector< edm::FwdPtr< reco::PFCandidate > > PFCandidateFwdPtrCollection
void setGenJetRef(const edm::FwdRef< reco::GenJetCollection > &gj)
method to set the matched generated jet reference, embedding if requested
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
Analysis-level calorimeter jet class.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
edm::EDGetTokenT< edm::Association< reco::GenJetCollection > > genJetToken_
std::vector< edm::EDGetTokenT< reco::JetFloatAssociation::Container > > discriminatorTokens_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > genPartonToken_
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
const_iterator end() const
bool embedGenPartonMatch_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
void addTagInfo(const std::string &label, const TagInfoFwdPtrCollection::value_type &info)