44 useUserData_(iConfig.exists(
"userData"))
49 if ( iConfig.
exists(
"embedCaloTowers") ) {
68 addBTagInfo_ = iConfig.getParameter<
bool>(
"addBTagInfo" );
69 addDiscriminators_ = iConfig.getParameter<
bool>(
"addDiscriminators" );
70 discriminatorTags_ = iConfig.getParameter<std::vector<edm::InputTag> >(
"discriminatorSources" );
72 addTagInfos_ = iConfig.getParameter<
bool>(
"addTagInfos" );
73 tagInfoTags_ = iConfig.getParameter<std::vector<edm::InputTag> >(
"tagInfoSources" );
75 addAssociatedTracks_ = iConfig.getParameter<
bool>(
"addAssociatedTracks" );
76 trackAssociationToken_ = mayConsume<reco::JetTracksAssociation::Container>(iConfig.getParameter<
edm::InputTag>(
"trackAssociationSource" ));
77 addJetCharge_ = iConfig.getParameter<
bool>(
"addJetCharge" );
78 jetChargeToken_ = mayConsume<reco::JetFloatAssociation::Container>(iConfig.getParameter<
edm::InputTag>(
"jetChargeSource" ));
79 addJetID_ = iConfig.getParameter<
bool>(
"addJetID");
80 jetIDMapToken_ = mayConsume<reco::JetIDValueMap>(iConfig.getParameter<
edm::InputTag>(
"jetIDMap"));
82 addEfficiencies_ = iConfig.getParameter<
bool>(
"addEfficiencies");
83 if (addEfficiencies_) {
87 addResolutions_ = iConfig.getParameter<
bool>(
"addResolutions");
88 if (addResolutions_) {
91 if (discriminatorTags_.empty()) {
92 addDiscriminators_ =
false;
94 for (std::vector<edm::InputTag>::const_iterator it = discriminatorTags_.begin(), ed = discriminatorTags_.end(); it != ed; ++it) {
97 if ((pos != std::string::npos) && (pos != label.length() - 7)) {
100 discriminatorLabels_.push_back(label);
103 if (tagInfoTags_.empty()) {
104 addTagInfos_ =
false;
106 for (std::vector<edm::InputTag>::const_iterator it = tagInfoTags_.begin(), ed = tagInfoTags_.end(); it != ed; ++it) {
109 if ((pos != std::string::npos) && (pos != label.length() - 8)) {
112 tagInfoLabels_.push_back(label);
115 if (!addBTagInfo_) { addDiscriminators_ =
false; addTagInfos_ =
false; }
117 if ( useUserData_ ) {
121 produces<std::vector<Jet> >();
122 produces<reco::GenJetCollection> (
"genJets");
123 produces<std::vector<CaloTower> > (
"caloTowers");
124 produces<reco::PFCandidateCollection > (
"pfCandidates");
125 produces<edm::OwnVector<reco::BaseTagInfo> > (
"tagInfos");
129 PATJetProducer::~PATJetProducer() {
172 std::vector<edm::ValueMap<JetCorrFactors> > jetCorrs;
177 jetCorrs.push_back( *jetCorr );
182 std::vector<edm::Handle<reco::JetFloatAssociation::Container> > jetDiscriminators;
189 std::vector<edm::Handle<edm::View<reco::BaseTagInfo> > > jetTagInfos;
208 std::auto_ptr< std::vector<Jet> >
patJets (
new std::vector<Jet>() );
211 std::auto_ptr<std::vector<CaloTower> > caloTowersOut(
new std::vector<CaloTower> () );
225 unsigned int idx = itJet - jets->begin();
234 if ( ajet.
isCaloJet()) cj = dynamic_cast<const reco::CaloJet *>(jetRef.
get());
241 for ( std::vector<CaloTowerPtr>::const_iterator towBegin = itowers.begin(), towEnd = itowers.end(), itow = towBegin; itow != towEnd; ++itow ) {
242 if( itow->isAvailable() && itow->isNonnull() ){
243 caloTowersOut->push_back( **itow );
246 edm::Ptr<CaloTower> caloForwardRef ( h_caloTowersOut.id(), caloTowerRef.key(), h_caloTowersOut.productGetter() );
261 for ( std::vector<reco::PFCandidatePtr>::const_iterator partBegin = iparticles.begin(),
262 partEnd = iparticles.end(), ipart = partBegin;
263 ipart != partEnd; ++ipart ) {
264 pfCandidatesOut->push_back( **ipart );
284 std::vector<std::string> levels = jetCorrs[0][jetRef].correctionLabels();
285 if(
std::find(levels.begin(), levels.end(),
"L2L3Residual")!=levels.end()){
286 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"L2L3Residual"));
288 else if(
std::find(levels.begin(), levels.end(),
"L3Absolute")!=levels.end()){
289 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"L3Absolute"));
292 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"Uncorrected"));
294 edm::LogWarning(
"L3Absolute not found") <<
"L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n"
295 <<
"of module " << jetCorrs[0][jetRef].jecSet() <<
" jets will remain"
296 <<
" uncorrected."; first=
false;
324 genJetsOut->push_back( *genjet );
351 for (
size_t k=0;
k<jetDiscriminators.size(); ++
k) {
352 float value = (*jetDiscriminators[
k])[jetRef];
357 for (
size_t k=0;
k<jetTagInfos.size(); ++
k) {
362 if ((idx < taginfos.
size()) && (taginfos[idx].
jet() == jetRef)) {
363 match = taginfos.
ptrAt(idx);
367 if (itTI->jet() == jetRef) { match = taginfos.
ptrAt( itTI - taginfos.
begin() );
break; }
371 tagInfosOut->push_back( match->clone() );
402 patJets->push_back(ajet);
411 iEvent.
put( genJetsOut,
"genJets" );
412 iEvent.
put( caloTowersOut,
"caloTowers" );
413 iEvent.
put( pfCandidatesOut,
"pfCandidates" );
414 iEvent.
put( tagInfosOut,
"tagInfos" );
429 iDesc.
addOptional<
bool>(
"embedCaloTowers",
false)->setComment(
"embed external CaloTowers (not to be used on AOD input)");
430 iDesc.
add<
bool>(
"embedPFCandidates",
true)->setComment(
"embed external PFCandidates");
433 iDesc.
add<
bool>(
"addGenPartonMatch",
true)->setComment(
"add MC matching");
434 iDesc.
add<
bool>(
"embedGenPartonMatch",
false)->setComment(
"embed MC matched MC information");
437 iDesc.
add<
bool>(
"addGenJetMatch",
true)->setComment(
"add MC matching");
438 iDesc.
add<
bool>(
"embedGenJetMatch",
false)->setComment(
"embed MC matched MC information");
441 iDesc.
add<
bool>(
"addJetCharge",
true);
445 iDesc.
add<
bool>(
"addJetID",
true)->setComment(
"Add jet ID information");
448 iDesc.
add<
bool>(
"addPartonJetMatch",
false);
452 iDesc.
add<
bool>(
"addAssociatedTracks",
true);
456 iDesc.
add<
bool>(
"addTagInfos",
true);
457 std::vector<edm::InputTag> emptyVInputTags;
458 iDesc.
add<std::vector<edm::InputTag> >(
"tagInfoSources", emptyVInputTags);
461 iDesc.
add<
bool>(
"addJetCorrFactors",
true);
462 iDesc.
add<std::vector<edm::InputTag> >(
"jetCorrFactorsSource", emptyVInputTags);
465 iDesc.
add<
bool>(
"addBTagInfo",
true);
466 iDesc.
add<
bool>(
"addDiscriminators",
true);
467 iDesc.
add<std::vector<edm::InputTag> >(
"discriminatorSources", emptyVInputTags);
470 iDesc.
add<
bool>(
"getJetMCFlavour",
true);
471 iDesc.
add<
bool>(
"useLegacyJetMCFlavour",
false);
472 iDesc.
add<
bool>(
"addJetFlavourInfo",
false);
481 iDesc.
add(
"efficiencies", efficienciesPSet);
482 iDesc.
add<
bool>(
"addEfficiencies",
false);
489 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
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 setGenJetRef(const edm::FwdRef< reco::GenJetCollection > &gj)
method to set the matched generated jet reference, embedding if requested
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
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
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
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
void setJetFlavourInfo(const reco::JetFlavourInfo &jetFlavourInfo)
method to set the JetFlavourInfo of the jet
const edm::RefToBase< reco::Jet > & getCaloJetRef() const
void setCaloTowers(const CaloTowerFwdPtrCollection &caloTowers)
method to store the CaloJet constituents internally
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 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.
GreaterByPt< Jet > pTComparator_
void addTagInfo(const std::string &label, const TagInfoFwdPtrCollection::value_type &info)
bool enabled() const
'true' if this there is at least one efficiency configured
static void fillDescription(edm::ParameterSetDescription &iDesc)
PATJetProducer(const edm::ParameterSet &iConfig)
bool isCaloJet() const
check to see if the jet is a reco::CaloJet
bool isNonnull() const
Checks for non-null.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< reco::JetFloatAssociation::Container > jetChargeToken_
void setComment(std::string const &value)
Ptr< value_type > ptrAt(size_type i) const
void setAssociatedTracks(const reco::TrackRefVector &tracks)
method to set the vector of refs to the tracks associated to this jet
bool isNonnull() const
Checks for non-null.
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 ...
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Jets made from CaloJets corrected for ZSP and tracks.
Class for the storage of jet correction factors.
edm::EDGetTokenT< reco::JetIDValueMap > jetIDMapToken_
void setPartonFlavour(int partonFl)
method to set the parton-based flavour of the jet
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Container::value_type value_type
RefProd< PROD > getRefBeforePut()
bool isPFJet() const
check to see if the jet is a reco::PFJet
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 setJetCharge(float jetCharge)
method to set the jet charge
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 addBDiscriminatorPair(const std::pair< std::string, float > &thePair)
method to add a algolabel-discriminator pair
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_
void setPFCandidates(const PFCandidateFwdPtrCollection &pfCandidates)
method to store the PFCandidate constituents internally
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > genPartonToken_
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
const_iterator begin() const
bool embedGenPartonMatch_
const_iterator end() const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
void setHadronFlavour(int hadronFl)
method to set the hadron-based flavour of the jet
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
void newEvent(const edm::Event &event, const edm::EventSetup &setup) const
To be called for each new event, reads in the EventSetup object.
value_type const * get() const
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.