44 useUserData_(iConfig.exists(
"userData"))
49 if ( iConfig.
exists(
"embedCaloTowers") ) {
65 addBTagInfo_ = iConfig.getParameter<
bool>(
"addBTagInfo" );
66 addDiscriminators_ = iConfig.getParameter<
bool>(
"addDiscriminators" );
67 discriminatorTags_ = iConfig.getParameter<std::vector<edm::InputTag> >(
"discriminatorSources" );
69 addTagInfos_ = iConfig.getParameter<
bool>(
"addTagInfos" );
70 tagInfoTags_ = iConfig.getParameter<std::vector<edm::InputTag> >(
"tagInfoSources" );
72 addAssociatedTracks_ = iConfig.getParameter<
bool>(
"addAssociatedTracks" );
73 trackAssociationToken_ = mayConsume<reco::JetTracksAssociation::Container>(iConfig.getParameter<
edm::InputTag>(
"trackAssociationSource" ));
74 addJetCharge_ = iConfig.getParameter<
bool>(
"addJetCharge" );
75 jetChargeToken_ = mayConsume<reco::JetFloatAssociation::Container>(iConfig.getParameter<
edm::InputTag>(
"jetChargeSource" ));
76 addJetID_ = iConfig.getParameter<
bool>(
"addJetID");
77 jetIDMapToken_ = mayConsume<reco::JetIDValueMap>(iConfig.getParameter<
edm::InputTag>(
"jetIDMap"));
79 addEfficiencies_ = iConfig.getParameter<
bool>(
"addEfficiencies");
80 if (addEfficiencies_) {
84 addResolutions_ = iConfig.getParameter<
bool>(
"addResolutions");
85 if (addResolutions_) {
88 if (discriminatorTags_.empty()) {
89 addDiscriminators_ =
false;
91 for (std::vector<edm::InputTag>::const_iterator it = discriminatorTags_.begin(), ed = discriminatorTags_.end(); it != ed; ++it) {
94 if ((pos != std::string::npos) && (pos != label.length() - 7)) {
97 discriminatorLabels_.push_back(label);
100 if (tagInfoTags_.empty()) {
101 addTagInfos_ =
false;
103 for (std::vector<edm::InputTag>::const_iterator it = tagInfoTags_.begin(), ed = tagInfoTags_.end(); it != ed; ++it) {
106 if ((pos != std::string::npos) && (pos != label.length() - 8)) {
109 tagInfoLabels_.push_back(label);
112 if (!addBTagInfo_) { addDiscriminators_ =
false; addTagInfos_ =
false; }
114 if ( useUserData_ ) {
118 produces<std::vector<Jet> >();
119 produces<reco::GenJetCollection> (
"genJets");
120 produces<std::vector<CaloTower> > (
"caloTowers");
121 produces<reco::PFCandidateCollection > (
"pfCandidates");
122 produces<edm::OwnVector<reco::BaseTagInfo> > (
"tagInfos");
126 PATJetProducer::~PATJetProducer() {
165 std::vector<edm::ValueMap<JetCorrFactors> > jetCorrs;
170 jetCorrs.push_back( *jetCorr );
175 std::vector<edm::Handle<reco::JetFloatAssociation::Container> > jetDiscriminators;
182 std::vector<edm::Handle<edm::View<reco::BaseTagInfo> > > jetTagInfos;
201 std::auto_ptr< std::vector<Jet> >
patJets (
new std::vector<Jet>() );
204 std::auto_ptr<std::vector<CaloTower> > caloTowersOut(
new std::vector<CaloTower> () );
218 unsigned int idx = itJet - jets->begin();
227 if ( ajet.
isCaloJet()) cj = dynamic_cast<const reco::CaloJet *>(jetRef.
get());
234 for ( std::vector<CaloTowerPtr>::const_iterator towBegin = itowers.begin(), towEnd = itowers.end(), itow = towBegin; itow != towEnd; ++itow ) {
235 if( itow->isAvailable() && itow->isNonnull() ){
236 caloTowersOut->push_back( **itow );
239 edm::Ptr<CaloTower> caloForwardRef ( h_caloTowersOut.id(), caloTowerRef.key(), h_caloTowersOut.productGetter() );
254 for ( std::vector<reco::PFCandidatePtr>::const_iterator partBegin = iparticles.begin(),
255 partEnd = iparticles.end(), ipart = partBegin;
256 ipart != partEnd; ++ipart ) {
257 pfCandidatesOut->push_back( **ipart );
277 std::vector<std::string> levels = jetCorrs[0][jetRef].correctionLabels();
278 if(
std::find(levels.begin(), levels.end(),
"L2L3Residual")!=levels.end()){
279 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"L2L3Residual"));
281 else if(
std::find(levels.begin(), levels.end(),
"L3Absolute")!=levels.end()){
282 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"L3Absolute"));
285 ajet.
initializeJEC(jetCorrs[0][jetRef].jecLevel(
"Uncorrected"));
287 edm::LogWarning(
"L3Absolute not found") <<
"L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n"
288 <<
"of module " << jetCorrs[0][jetRef].jecSet() <<
" jets will remain"
289 <<
" uncorrected."; first=
false;
309 genJetsOut->push_back( *genjet );
336 for (
size_t k=0;
k<jetDiscriminators.size(); ++
k) {
337 float value = (*jetDiscriminators[
k])[jetRef];
342 for (
size_t k=0;
k<jetTagInfos.size(); ++
k) {
347 if ((idx < taginfos.
size()) && (taginfos[idx].
jet() == jetRef)) {
348 match = taginfos.
ptrAt(idx);
352 if (itTI->jet() == jetRef) { match = taginfos.
ptrAt( itTI - taginfos.
begin() );
break; }
356 tagInfosOut->push_back( match->clone() );
387 patJets->push_back(ajet);
396 iEvent.
put( genJetsOut,
"genJets" );
397 iEvent.
put( caloTowersOut,
"caloTowers" );
398 iEvent.
put( pfCandidatesOut,
"pfCandidates" );
399 iEvent.
put( tagInfosOut,
"tagInfos" );
414 iDesc.
addOptional<
bool>(
"embedCaloTowers",
false)->setComment(
"embed external CaloTowers (not to be used on AOD input)");
415 iDesc.
add<
bool>(
"embedPFCandidates",
true)->setComment(
"embed external PFCandidates");
418 iDesc.
add<
bool>(
"addGenPartonMatch",
true)->setComment(
"add MC matching");
419 iDesc.
add<
bool>(
"embedGenPartonMatch",
false)->setComment(
"embed MC matched MC information");
422 iDesc.
add<
bool>(
"addGenJetMatch",
true)->setComment(
"add MC matching");
423 iDesc.
add<
bool>(
"embedGenJetMatch",
false)->setComment(
"embed MC matched MC information");
426 iDesc.
add<
bool>(
"addJetCharge",
true);
430 iDesc.
add<
bool>(
"addJetID",
true)->setComment(
"Add jet ID information");
433 iDesc.
add<
bool>(
"addPartonJetMatch",
false);
437 iDesc.
add<
bool>(
"addAssociatedTracks",
true);
441 iDesc.
add<
bool>(
"addTagInfos",
true);
442 std::vector<edm::InputTag> emptyVInputTags;
443 iDesc.
add<std::vector<edm::InputTag> >(
"tagInfoSources", emptyVInputTags);
446 iDesc.
add<
bool>(
"addJetCorrFactors",
true);
447 iDesc.
add<std::vector<edm::InputTag> >(
"jetCorrFactorsSource", emptyVInputTags);
450 iDesc.
add<
bool>(
"addBTagInfo",
true);
451 iDesc.
add<
bool>(
"addDiscriminators",
true);
452 iDesc.
add<std::vector<edm::InputTag> >(
"discriminatorSources", emptyVInputTags);
455 iDesc.
add<
bool>(
"getJetMCFlavour",
true);
463 iDesc.
add(
"efficiencies", efficienciesPSet);
464 iDesc.
add<
bool>(
"addEfficiencies",
false);
471 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
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.
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 flavour of the parton underlying 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.
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.
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.