CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
pat::PATJetProducer Class Reference

Produces pat::Jet's. More...

#include "PhysicsTools/PatAlgos/interface/PATJetProducer.h"

Inheritance diagram for pat::PATJetProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATJetProducer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PATJetProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

bool addAssociatedTracks_
 
bool addBTagInfo_
 
bool addDiscriminators_
 
bool addEfficiencies_
 
bool addGenJetMatch_
 
bool addGenPartonMatch_
 
bool addJetCharge_
 
bool addJetCorrFactors_
 
bool addJetFlavourInfo_
 
bool addJetID_
 
bool addPartonJetMatch_
 
bool addResolutions_
 
bool addTagInfos_
 
GreaterByPt< CaloTowercaloPTComparator_
 
std::vector< std::string > discriminatorLabels_
 
std::vector< edm::InputTagdiscriminatorTags_
 
std::vector< edm::EDGetTokenT
< reco::JetFloatAssociation::Container > > 
discriminatorTokens_
 
pat::helper::EfficiencyLoader efficiencyLoader_
 
bool embedCaloTowers_
 
bool embedGenJetMatch_
 
bool embedGenPartonMatch_
 
bool embedPFCandidates_
 
edm::EDGetTokenT
< edm::Association
< reco::GenJetCollection > > 
genJetToken_
 
edm::EDGetTokenT
< edm::Association
< reco::GenParticleCollection > > 
genPartonToken_
 
bool getJetMCFlavour_
 
edm::EDGetTokenT
< reco::JetFloatAssociation::Container
jetChargeToken_
 
std::vector< edm::EDGetTokenT
< edm::ValueMap
< JetCorrFactors > > > 
jetCorrFactorsTokens_
 
edm::EDGetTokenT
< reco::JetFlavourInfoMatchingCollection
jetFlavourInfoToken_
 
edm::EDGetTokenT
< reco::JetIDValueMap
jetIDMapToken_
 
edm::EDGetTokenT
< reco::JetFlavourMatchingCollection
jetPartonMapToken_
 
edm::EDGetTokenT< edm::View
< reco::Jet > > 
jetsToken_
 
GreaterByPt< JetpTComparator_
 
pat::helper::KinResolutionsLoader resolutionLoader_
 
std::vector< std::string > tagInfoLabels_
 
std::vector< edm::InputTagtagInfoTags_
 
std::vector< edm::EDGetTokenT
< edm::View< reco::BaseTagInfo > > > 
tagInfoTokens_
 
edm::EDGetTokenT
< reco::JetTracksAssociation::Container
trackAssociationToken_
 
bool useLegacyJetMCFlavour_
 
pat::PATUserDataHelper< pat::JetuserDataHelper_
 
bool useUserData_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Produces pat::Jet's.

The PATJetProducer produces analysis-level pat::Jet's starting from a collection of objects of JetType.

Author
Steven Lowette, Jeremy Andrea
Version
Id:
PATJetProducer.h,v 1.26 2010/08/09 18:13:54 srappocc Exp

Definition at line 47 of file PATJetProducer.h.

Constructor & Destructor Documentation

PATJetProducer::PATJetProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 43 of file PATJetProducer.cc.

References addGenJetMatch_, addGenPartonMatch_, addJetCorrFactors_, addJetFlavourInfo_, addPartonJetMatch_, embedCaloTowers_, embedGenJetMatch_, embedGenPartonMatch_, embedPFCandidates_, edm::ParameterSet::exists(), genJetToken_, genPartonToken_, getJetMCFlavour_, edm::ParameterSet::getParameter(), jetCorrFactorsTokens_, jetFlavourInfoToken_, jetPartonMapToken_, jetsToken_, edm::EDConsumerBase::mayConsume(), GlobalPosition_Frontier_DevDB_cff::tag, useLegacyJetMCFlavour_, and edm::vector_transform().

43  :
44  useUserData_(iConfig.exists("userData"))
45 {
46  // initialize configurables
47  jetsToken_ = consumes<edm::View<reco::Jet> >(iConfig.getParameter<edm::InputTag>( "jetSource" ));
48  embedCaloTowers_ = false; // parameter is optional
49  if ( iConfig.exists("embedCaloTowers") ) {
50  embedCaloTowers_ = iConfig.getParameter<bool>( "embedCaloTowers" );
51  }
52  embedPFCandidates_ = iConfig.getParameter<bool>( "embedPFCandidates" );
53  getJetMCFlavour_ = iConfig.getParameter<bool>( "getJetMCFlavour" );
54  useLegacyJetMCFlavour_ = iConfig.getParameter<bool>( "useLegacyJetMCFlavour" );
55  addJetFlavourInfo_ = ( useLegacyJetMCFlavour_ ? false : iConfig.getParameter<bool>( "addJetFlavourInfo" ) );
56  jetPartonMapToken_ = mayConsume<reco::JetFlavourMatchingCollection>(iConfig.getParameter<edm::InputTag>( "JetPartonMapSource" ));
57  jetFlavourInfoToken_ = mayConsume<reco::JetFlavourInfoMatchingCollection>(iConfig.getParameter<edm::InputTag>( "JetFlavourInfoSource" ));
58  addGenPartonMatch_ = iConfig.getParameter<bool>( "addGenPartonMatch" );
59  embedGenPartonMatch_ = iConfig.getParameter<bool>( "embedGenPartonMatch" );
60  genPartonToken_ = mayConsume<edm::Association<reco::GenParticleCollection> >(iConfig.getParameter<edm::InputTag>( "genPartonMatch" ));
61  addGenJetMatch_ = iConfig.getParameter<bool>( "addGenJetMatch" );
62  embedGenJetMatch_ = iConfig.getParameter<bool>( "embedGenJetMatch" );
63  genJetToken_ = mayConsume<edm::Association<reco::GenJetCollection> >(iConfig.getParameter<edm::InputTag>( "genJetMatch" ));
64  addPartonJetMatch_ = iConfig.getParameter<bool>( "addPartonJetMatch" );
65 // partonJetToken_ = mayConsume<reco::SomePartonJetType>(iConfig.getParameter<edm::InputTag>( "partonJetSource" ));
66  addJetCorrFactors_ = iConfig.getParameter<bool>( "addJetCorrFactors" );
67  jetCorrFactorsTokens_ = edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >( "jetCorrFactorsSource" ), [this](edm::InputTag const & tag){return mayConsume<edm::ValueMap<JetCorrFactors> >(tag);});
68  addBTagInfo_ = iConfig.getParameter<bool>( "addBTagInfo" );
69  addDiscriminators_ = iConfig.getParameter<bool>( "addDiscriminators" );
70  discriminatorTags_ = iConfig.getParameter<std::vector<edm::InputTag> >( "discriminatorSources" );
71  discriminatorTokens_ = edm::vector_transform(discriminatorTags_, [this](edm::InputTag const & tag){return mayConsume<reco::JetFloatAssociation::Container>(tag);});
72  addTagInfos_ = iConfig.getParameter<bool>( "addTagInfos" );
73  tagInfoTags_ = iConfig.getParameter<std::vector<edm::InputTag> >( "tagInfoSources" );
74  tagInfoTokens_ =edm::vector_transform(tagInfoTags_, [this](edm::InputTag const & tag){return mayConsume<edm::View<reco::BaseTagInfo> >(tag);});
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"));
81  // Efficiency configurables
82  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
83  if (addEfficiencies_) {
85  }
86  // Resolution configurables
87  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
88  if (addResolutions_) {
90  }
91  if (discriminatorTags_.empty()) {
92  addDiscriminators_ = false;
93  } else {
94  for (std::vector<edm::InputTag>::const_iterator it = discriminatorTags_.begin(), ed = discriminatorTags_.end(); it != ed; ++it) {
95  std::string label = it->label();
96  std::string::size_type pos = label.find("JetTags");
97  if ((pos != std::string::npos) && (pos != label.length() - 7)) {
98  label.erase(pos+7); // trim a tail after "JetTags"
99  }
100  discriminatorLabels_.push_back(label);
101  }
102  }
103  if (tagInfoTags_.empty()) {
104  addTagInfos_ = false;
105  } else {
106  for (std::vector<edm::InputTag>::const_iterator it = tagInfoTags_.begin(), ed = tagInfoTags_.end(); it != ed; ++it) {
107  std::string label = it->label();
108  std::string::size_type pos = label.find("TagInfos");
109  if ((pos != std::string::npos) && (pos != label.length() - 8)) {
110  label.erase(pos+8); // trim a tail after "TagInfos"
111  }
112  tagInfoLabels_.push_back(label);
113  }
114  }
115  if (!addBTagInfo_) { addDiscriminators_ = false; addTagInfos_ = false; }
116  // Check to see if the user wants to add user data
117  if ( useUserData_ ) {
119  }
120  // produces vector of jets
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");
126 }
T getParameter(std::string const &) const
pat::helper::EfficiencyLoader efficiencyLoader_
Assists in assimilating all pat::UserData into pat objects.
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken_
std::vector< edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > > tagInfoTokens_
edm::EDGetTokenT< reco::JetTracksAssociation::Container > trackAssociationToken_
std::vector< std::string > tagInfoLabels_
std::vector< edm::EDGetTokenT< edm::ValueMap< JetCorrFactors > > > jetCorrFactorsTokens_
std::vector< edm::InputTag > tagInfoTags_
pat::helper::KinResolutionsLoader resolutionLoader_
std::vector< std::string > discriminatorLabels_
bool exists(std::string const &parameterName) const
checks if a parameter exists
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 >
Definition: transform.h:11
edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > jetFlavourInfoToken_
uint16_t size_type
edm::EDGetTokenT< reco::JetFloatAssociation::Container > jetChargeToken_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< reco::JetIDValueMap > jetIDMapToken_
std::vector< edm::InputTag > discriminatorTags_
pat::PATUserDataHelper< pat::Jet > userDataHelper_
edm::EDGetTokenT< reco::JetFlavourMatchingCollection > jetPartonMapToken_
edm::EDGetTokenT< edm::Association< reco::GenJetCollection > > genJetToken_
std::vector< edm::EDGetTokenT< reco::JetFloatAssociation::Container > > discriminatorTokens_
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > genPartonToken_
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
PATJetProducer::~PATJetProducer ( )

Definition at line 129 of file PATJetProducer.cc.

129  {
130 
131 }

Member Function Documentation

void PATJetProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 420 of file PATJetProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), pat::helper::KinResolutionsLoader::fillDescription(), pat::PATUserDataHelper< ObjectType >::fillDescription(), edm::ParameterSetDescription::setAllowAnything(), and edm::ParameterSetDescription::setComment().

421 {
423  iDesc.setComment("PAT jet producer module");
424 
425  // input source
426  iDesc.add<edm::InputTag>("jetSource", edm::InputTag("no default"))->setComment("input collection");
427 
428  // embedding
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");
431 
432  // MC matching configurables
433  iDesc.add<bool>("addGenPartonMatch", true)->setComment("add MC matching");
434  iDesc.add<bool>("embedGenPartonMatch", false)->setComment("embed MC matched MC information");
435  iDesc.add<edm::InputTag>("genPartonMatch", edm::InputTag())->setComment("input with MC match information");
436 
437  iDesc.add<bool>("addGenJetMatch", true)->setComment("add MC matching");
438  iDesc.add<bool>("embedGenJetMatch", false)->setComment("embed MC matched MC information");
439  iDesc.add<edm::InputTag>("genJetMatch", edm::InputTag())->setComment("input with MC match information");
440 
441  iDesc.add<bool>("addJetCharge", true);
442  iDesc.add<edm::InputTag>("jetChargeSource", edm::InputTag("patJetCharge"));
443 
444  // jet id
445  iDesc.add<bool>("addJetID", true)->setComment("Add jet ID information");
446  iDesc.add<edm::InputTag>("jetIDMap", edm::InputTag())->setComment("jet id map");
447 
448  iDesc.add<bool>("addPartonJetMatch", false);
449  iDesc.add<edm::InputTag>("partonJetSource", edm::InputTag("NOT IMPLEMENTED"));
450 
451  // track association
452  iDesc.add<bool>("addAssociatedTracks", true);
453  iDesc.add<edm::InputTag>("trackAssociationSource", edm::InputTag("ic5JetTracksAssociatorAtVertex"));
454 
455  // tag info
456  iDesc.add<bool>("addTagInfos", true);
457  std::vector<edm::InputTag> emptyVInputTags;
458  iDesc.add<std::vector<edm::InputTag> >("tagInfoSources", emptyVInputTags);
459 
460  // jet energy corrections
461  iDesc.add<bool>("addJetCorrFactors", true);
462  iDesc.add<std::vector<edm::InputTag> >("jetCorrFactorsSource", emptyVInputTags);
463 
464  // btag discriminator tags
465  iDesc.add<bool>("addBTagInfo",true);
466  iDesc.add<bool>("addDiscriminators", true);
467  iDesc.add<std::vector<edm::InputTag> >("discriminatorSources", emptyVInputTags);
468 
469  // jet flavour idetification configurables
470  iDesc.add<bool>("getJetMCFlavour", true);
471  iDesc.add<bool>("useLegacyJetMCFlavour", false);
472  iDesc.add<bool>("addJetFlavourInfo", false);
473  iDesc.add<edm::InputTag>("JetPartonMapSource", edm::InputTag("jetFlavourAssociationLegacy"));
474  iDesc.add<edm::InputTag>("JetFlavourInfoSource", edm::InputTag("jetFlavourAssociation"));
475 
477 
478  // Efficiency configurables
479  edm::ParameterSetDescription efficienciesPSet;
480  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
481  iDesc.add("efficiencies", efficienciesPSet);
482  iDesc.add<bool>("addEfficiencies", false);
483 
484  // Check to see if the user wants to add user data
485  edm::ParameterSetDescription userDataPSet;
487  iDesc.addOptional("userData", userDataPSet);
488 
489  descriptions.add("PATJetProducer", iDesc);
490 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void setAllowAnything()
allow any parameter label/value pairs
static void fillDescription(edm::ParameterSetDescription &iDesc)
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void PATJetProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 134 of file PATJetProducer.cc.

References addAssociatedTracks_, pat::Jet::addBDiscriminatorPair(), addBTagInfo_, addDiscriminators_, addGenJetMatch_, addGenPartonMatch_, pat::Jet::addJECFactors(), addJetCharge_, addJetCorrFactors_, addJetFlavourInfo_, addJetID_, addPartonJetMatch_, pat::Jet::addTagInfo(), addTagInfos_, edm::View< T >::begin(), discriminatorLabels_, discriminatorTokens_, efficiencyLoader_, embedCaloTowers_, embedGenPartonMatch_, embedPFCandidates_, pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), edm::View< T >::end(), spr::find(), first, genJetToken_, genPartonToken_, edm::RefToBase< T >::get(), edm::Event::getByToken(), reco::CaloJet::getCaloConstituents(), reco::JPTJet::getCaloJetRef(), getJetMCFlavour_, reco::PFJet::getPFConstituents(), edm::Event::getRefBeforePut(), i, customizeTrackingMonitorSeedNumber::idx, pat::Jet::initializeJEC(), edm::Ref< C, T, F >::isAvailable(), pat::Jet::isCaloJet(), pat::Jet::isJPTJet(), edm::Ptr< T >::isNonnull(), edm::Ref< C, T, F >::isNonnull(), pat::Jet::isPFJet(), edm::EventBase::isRealData(), metsig::jet, jetChargeToken_, jetCorrFactorsTokens_, jetFlavourInfoToken_, jetIDMapToken_, jetPartonMapToken_, fwrapper::jets, jetsToken_, gen::k, match(), pat::helper::EfficiencyLoader::newEvent(), pat::helper::KinResolutionsLoader::newEvent(), jetProducer_cfi::patJets, pTComparator_, edm::View< T >::ptrAt(), edm::Event::put(), resolutionLoader_, pat::Jet::setAssociatedTracks(), pat::Jet::setCaloTowers(), pat::helper::EfficiencyLoader::setEfficiencies(), pat::Jet::setGenJetRef(), pat::Jet::setGenParton(), pat::Jet::setHadronFlavour(), pat::Jet::setJetCharge(), pat::Jet::setJetFlavourInfo(), pat::Jet::setJetID(), pat::Jet::setPartonFlavour(), pat::Jet::setPFCandidates(), pat::helper::KinResolutionsLoader::setResolutions(), edm::View< T >::size(), python.multivaluedict::sort(), tagInfoLabels_, tagInfoTokens_, trackAssociationToken_, useLegacyJetMCFlavour_, userDataHelper_, useUserData_, and relativeConstraints::value.

135 {
136  // check whether dealing with MC or real data
137  if (iEvent.isRealData()){
138  getJetMCFlavour_ = false;
139  useLegacyJetMCFlavour_ = false;
140  addJetFlavourInfo_ = false;
141  addGenPartonMatch_ = false;
142  addGenJetMatch_ = false;
143  addPartonJetMatch_ = false;
144  }
145 
146  // Get the vector of jets
148  iEvent.getByToken(jetsToken_, jets);
149 
151  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
152 
153  // for jet flavour
157  else if (getJetMCFlavour_ && !useLegacyJetMCFlavour_) iEvent.getByToken (jetFlavourInfoToken_, jetFlavInfoMatch);
158 
159  // Get the vector of generated particles from the event if needed
161  if (addGenPartonMatch_) iEvent.getByToken(genPartonToken_, partonMatch);
162  // Get the vector of GenJets from the event if needed
164  if (addGenJetMatch_) iEvent.getByToken(genJetToken_, genJetMatch);
165 /* TO BE IMPLEMENTED FOR >= 1_5_X
166  // Get the vector of PartonJets from the event if needed
167  edm::Handle<edm::View<reco::SomePartonJetType> > partonJets;
168  if (addPartonJetMatch_) iEvent.getByToken(partonJetToken_, partonJets);
169 */
170 
171  // read in the jet correction factors ValueMap
172  std::vector<edm::ValueMap<JetCorrFactors> > jetCorrs;
173  if (addJetCorrFactors_) {
174  for ( size_t i = 0; i < jetCorrFactorsTokens_.size(); ++i ) {
176  iEvent.getByToken(jetCorrFactorsTokens_[i], jetCorr);
177  jetCorrs.push_back( *jetCorr );
178  }
179  }
180 
181  // Get the vector of jet tags with b-tagging info
182  std::vector<edm::Handle<reco::JetFloatAssociation::Container> > jetDiscriminators;
184  jetDiscriminators.resize(discriminatorTokens_.size());
185  for (size_t i = 0; i < discriminatorTokens_.size(); ++i) {
186  iEvent.getByToken(discriminatorTokens_[i], jetDiscriminators[i]);
187  }
188  }
189  std::vector<edm::Handle<edm::View<reco::BaseTagInfo> > > jetTagInfos;
190  if (addBTagInfo_ && addTagInfos_) {
191  jetTagInfos.resize(tagInfoTokens_.size());
192  for (size_t i = 0; i < tagInfoTokens_.size(); ++i) {
193  iEvent.getByToken(tagInfoTokens_[i], jetTagInfos[i]);
194  }
195  }
196 
197  // tracks Jet Track Association
201  if (addJetCharge_) iEvent.getByToken(jetChargeToken_, hJetChargeAss);
202 
203  // jet ID handle
205  if ( addJetID_ ) iEvent.getByToken( jetIDMapToken_, hJetIDMap );
206 
207  // loop over jets
208  std::auto_ptr< std::vector<Jet> > patJets ( new std::vector<Jet>() );
209 
210  std::auto_ptr<reco::GenJetCollection > genJetsOut ( new reco::GenJetCollection() );
211  std::auto_ptr<std::vector<CaloTower> > caloTowersOut( new std::vector<CaloTower> () );
212  std::auto_ptr<reco::PFCandidateCollection > pfCandidatesOut( new reco::PFCandidateCollection() );
213  std::auto_ptr<edm::OwnVector<reco::BaseTagInfo> > tagInfosOut ( new edm::OwnVector<reco::BaseTagInfo>() );
214 
215 
217  edm::RefProd<std::vector<CaloTower> > h_caloTowersOut = iEvent.getRefBeforePut<std::vector<CaloTower> > ( "caloTowers" );
218  edm::RefProd<reco::PFCandidateCollection > h_pfCandidatesOut = iEvent.getRefBeforePut<reco::PFCandidateCollection > ( "pfCandidates" );
220 
221  bool first=true; // this is introduced to issue warnings only for the first jet
222  for (edm::View<reco::Jet>::const_iterator itJet = jets->begin(); itJet != jets->end(); itJet++) {
223 
224  // construct the Jet from the ref -> save ref to original object
225  unsigned int idx = itJet - jets->begin();
226  edm::RefToBase<reco::Jet> jetRef = jets->refAt(idx);
227  edm::Ptr<reco::Jet> jetPtr = jets->ptrAt(idx);
228  Jet ajet(jetRef);
229 
230  // add the FwdPtrs to the CaloTowers
231  if ( (ajet.isCaloJet() || ajet.isJPTJet() ) && embedCaloTowers_) {
232  const reco::CaloJet *cj = 0;
233  const reco::JPTJet * jptj = 0;
234  if ( ajet.isCaloJet()) cj = dynamic_cast<const reco::CaloJet *>(jetRef.get());
235  else {
236  jptj = dynamic_cast<const reco::JPTJet *>(jetRef.get() );
237  cj = dynamic_cast<const reco::CaloJet *>(jptj->getCaloJetRef().get() );
238  }
240  std::vector< CaloTowerPtr > itowers = cj->getCaloConstituents();
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 );
244  // set the "forward" ref to the thinned collection
245  edm::Ref<std::vector<CaloTower> > caloTowerRef( h_caloTowersOut, caloTowersOut->size() - 1);
246  edm::Ptr<CaloTower> caloForwardRef ( h_caloTowersOut.id(), caloTowerRef.key(), h_caloTowersOut.productGetter() );
247  // set the "backward" ref to the original collection for association
248  edm::Ptr<CaloTower> caloBackRef ( *itow );
249  // add to the list of FwdPtr's
250  itowersRef.push_back( pat::CaloTowerFwdPtrCollection::value_type ( caloForwardRef, caloBackRef ) );
251  }
252  }
253  ajet.setCaloTowers( itowersRef );
254  }
255 
256  // add the FwdPtrs to the PFCandidates
257  if (ajet.isPFJet() && embedPFCandidates_) {
258  const reco::PFJet *cj = dynamic_cast<const reco::PFJet *>(jetRef.get());
259  pat::PFCandidateFwdPtrCollection iparticlesRef;
260  std::vector< reco::PFCandidatePtr > iparticles = cj->getPFConstituents();
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 );
265  // set the "forward" ref to the thinned collection
266  edm::Ref<reco::PFCandidateCollection> pfCollectionRef( h_pfCandidatesOut, pfCandidatesOut->size() - 1);
267  edm::Ptr<reco::PFCandidate> pfForwardRef ( h_pfCandidatesOut.id(), pfCollectionRef.key(), h_pfCandidatesOut.productGetter() );
268  // set the "backward" ref to the original collection for association
269  edm::Ptr<reco::PFCandidate> pfBackRef ( *ipart );
270  // add to the list of FwdPtr's
271  iparticlesRef.push_back( pat::PFCandidateFwdPtrCollection::value_type ( pfForwardRef, pfBackRef ) );
272  }
273  ajet.setPFCandidates( iparticlesRef );
274  }
275 
276  if (addJetCorrFactors_) {
277  // add additional JetCorrs to the jet
278  for ( unsigned int i=0; i<jetCorrFactorsTokens_.size(); ++i ) {
279  const JetCorrFactors& jcf = jetCorrs[i][jetRef];
280  // uncomment for debugging
281  // jcf.print();
282  ajet.addJECFactors(jcf);
283  }
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"));
287  }
288  else if(std::find(levels.begin(), levels.end(), "L3Absolute")!=levels.end()){
289  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("L3Absolute"));
290  }
291  else{
292  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("Uncorrected"));
293  if(first){
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;
297  }
298  }
299  }
300 
301  // get the MC flavour information for this jet
303  ajet.setPartonFlavour( (*jetFlavMatch)[edm::RefToBase<reco::Jet>(jetRef)].getFlavour() );
304  }
306  if ( addJetFlavourInfo_ ) ajet.setJetFlavourInfo( (*jetFlavInfoMatch)[edm::RefToBase<reco::Jet>(jetRef)] );
307  else
308  {
309  ajet.setPartonFlavour( (*jetFlavInfoMatch)[edm::RefToBase<reco::Jet>(jetRef)].getPartonFlavour() );
310  ajet.setHadronFlavour( (*jetFlavInfoMatch)[edm::RefToBase<reco::Jet>(jetRef)].getHadronFlavour() );
311  }
312  }
313  // store the match to the generated partons
314  if (addGenPartonMatch_) {
315  reco::GenParticleRef parton = (*partonMatch)[jetRef];
316  if (parton.isNonnull() && parton.isAvailable()) {
317  ajet.setGenParton(parton, embedGenPartonMatch_);
318  } // leave empty if no match found
319  }
320  // store the match to the GenJets
321  if (addGenJetMatch_) {
322  reco::GenJetRef genjet = (*genJetMatch)[jetRef];
323  if (genjet.isNonnull() && genjet.isAvailable()) {
324  genJetsOut->push_back( *genjet );
325  // set the "forward" ref to the thinned collection
326  edm::Ref<reco::GenJetCollection > genForwardRef ( h_genJetsOut, genJetsOut->size() - 1 );
327  // set the "backward" ref to the original collection
328  edm::Ref<reco::GenJetCollection > genBackRef ( genjet );
329  // make the FwdPtr
330  edm::FwdRef<reco::GenJetCollection > genjetFwdRef ( genForwardRef, genBackRef );
331  ajet.setGenJetRef(genjetFwdRef );
332  } // leave empty if no match found
333  }
334 
335  if (efficiencyLoader_.enabled()) {
336  efficiencyLoader_.setEfficiencies( ajet, jetRef );
337  }
338 
339  // IMPORTANT: DO THIS AFTER JES CORRECTIONS
340  if (resolutionLoader_.enabled()) {
342  }
343 
344  // TO BE IMPLEMENTED FOR >=1_5_X: do the PartonJet matching
345  if (addPartonJetMatch_) {
346  }
347 
348  // add b-tag info if available & required
349  if (addBTagInfo_) {
350  if (addDiscriminators_) {
351  for (size_t k=0; k<jetDiscriminators.size(); ++k) {
352  float value = (*jetDiscriminators[k])[jetRef];
353  ajet.addBDiscriminatorPair(std::make_pair(discriminatorLabels_[k], value));
354  }
355  }
356  if (addTagInfos_) {
357  for (size_t k=0; k<jetTagInfos.size(); ++k) {
358  const edm::View<reco::BaseTagInfo> & taginfos = *jetTagInfos[k];
359  // This is not associative, so we have to search the jet
361  // Try first by 'same index'
362  if ((idx < taginfos.size()) && (taginfos[idx].jet() == jetRef)) {
363  match = taginfos.ptrAt(idx);
364  } else {
365  // otherwise fail back to a simple search
366  for (edm::View<reco::BaseTagInfo>::const_iterator itTI = taginfos.begin(), edTI = taginfos.end(); itTI != edTI; ++itTI) {
367  if (itTI->jet() == jetRef) { match = taginfos.ptrAt( itTI - taginfos.begin() ); break; }
368  }
369  }
370  if (match.isNonnull()) {
371  tagInfosOut->push_back( match->clone() );
372  // set the "forward" ptr to the thinned collection
373  edm::Ptr<reco::BaseTagInfo> tagInfoForwardPtr ( h_tagInfosOut.id(), &tagInfosOut->back(), tagInfosOut->size() - 1 );
374  // set the "backward" ptr to the original collection for association
375  edm::Ptr<reco::BaseTagInfo> tagInfoBackPtr ( match );
376  // make FwdPtr
377  TagInfoFwdPtrCollection::value_type tagInfoFwdPtr( tagInfoForwardPtr, tagInfoBackPtr ) ;
378  ajet.addTagInfo(tagInfoLabels_[k], tagInfoFwdPtr );
379  }
380  }
381  }
382  }
383 
384  if (addAssociatedTracks_) ajet.setAssociatedTracks( (*hTrackAss)[jetRef] );
385 
386  if (addJetCharge_) ajet.setJetCharge( (*hJetChargeAss)[jetRef] );
387 
388  // add jet ID for calo jets
389  if (addJetID_ && ajet.isCaloJet() ) {
390  reco::JetID jetId = (*hJetIDMap)[ jetRef ];
391  ajet.setJetID( jetId );
392  }
393  // add jet ID jpt jets
394  else if ( addJetID_ && ajet.isJPTJet() ){
395  const reco::JPTJet *jptj = dynamic_cast<const reco::JPTJet *>(jetRef.get());
396  reco::JetID jetId = (*hJetIDMap)[ jptj->getCaloJetRef() ];
397  ajet.setJetID( jetId );
398  }
399  if ( useUserData_ ) {
400  userDataHelper_.add( ajet, iEvent, iSetup );
401  }
402  patJets->push_back(ajet);
403  }
404 
405  // sort jets in pt
406  std::sort(patJets->begin(), patJets->end(), pTComparator_);
407 
408  // put genEvt in Event
409  iEvent.put(patJets);
410 
411  iEvent.put( genJetsOut, "genJets" );
412  iEvent.put( caloTowersOut, "caloTowers" );
413  iEvent.put( pfCandidatesOut, "pfCandidates" );
414  iEvent.put( tagInfosOut, "tagInfos" );
415 
416 
417 }
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
pat::helper::EfficiencyLoader efficiencyLoader_
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken_
std::vector< edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > > tagInfoTokens_
edm::EDGetTokenT< reco::JetTracksAssociation::Container > trackAssociationToken_
Jets made from CaloTowers.
Definition: CaloJet.h:29
std::vector< std::string > tagInfoLabels_
std::vector< edm::EDGetTokenT< edm::ValueMap< JetCorrFactors > > > jetCorrFactorsTokens_
std::vector< std::string > correctionLabels() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
pat::helper::KinResolutionsLoader resolutionLoader_
std::vector< GenJet > GenJetCollection
collection of GenJet objects
std::vector< std::string > discriminatorLabels_
const edm::RefToBase< reco::Jet > & getCaloJetRef() const
Definition: JPTJet.h:130
bool isAvailable() const
Definition: Ref.h:276
Jet ID object.
Definition: JetID.h:16
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
virtual std::vector< CaloTowerPtr > getCaloConstituents() const
get all constituents
Definition: CaloJet.cc:93
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_
bool isRealData() const
Definition: EventBase.h:60
Jets made from PFObjects.
Definition: PFJet.h:21
GreaterByPt< Jet > pTComparator_
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
edm::EDGetTokenT< reco::JetFloatAssociation::Container > jetChargeToken_
Ptr< value_type > ptrAt(size_type i) const
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:29
Class for the storage of jet correction factors.
vector< PseudoJet > jets
edm::EDGetTokenT< reco::JetIDValueMap > jetIDMapToken_
bool first
Definition: L1TdeRCT.cc:75
Container::value_type value_type
RefProd< PROD > getRefBeforePut()
Definition: Event.h:128
int k[5][pyjets_maxn]
pat::PATUserDataHelper< pat::Jet > userDataHelper_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
edm::EDGetTokenT< reco::JetFlavourMatchingCollection > jetPartonMapToken_
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
std::vector< edm::FwdPtr< CaloTower > > CaloTowerFwdPtrCollection
Definition: Jet.h:70
std::vector< edm::FwdPtr< reco::PFCandidate > > PFCandidateFwdPtrCollection
Definition: Jet.h:69
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
size_type size() const
Analysis-level calorimeter jet class.
Definition: Jet.h:73
edm::EDGetTokenT< edm::Association< reco::GenJetCollection > > genJetToken_
std::vector< edm::EDGetTokenT< reco::JetFloatAssociation::Container > > discriminatorTokens_
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > genPartonToken_
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
Definition: PFJet.cc:52
const_iterator begin() const
const_iterator end() const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
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
Definition: RefToBase.h:212
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.

Member Data Documentation

bool pat::PATJetProducer::addAssociatedTracks_
private

Definition at line 89 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::addBTagInfo_
private

Definition at line 80 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::addDiscriminators_
private

Definition at line 81 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::addEfficiencies_
private

Definition at line 99 of file PATJetProducer.h.

bool pat::PATJetProducer::addGenJetMatch_
private

Definition at line 72 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addGenPartonMatch_
private

Definition at line 69 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetCharge_
private

Definition at line 91 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::addJetCorrFactors_
private

Definition at line 77 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetFlavourInfo_
private

Definition at line 66 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetID_
private

Definition at line 93 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::addPartonJetMatch_
private

Definition at line 75 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addResolutions_
private

Definition at line 102 of file PATJetProducer.h.

bool pat::PATJetProducer::addTagInfos_
private

Definition at line 85 of file PATJetProducer.h.

Referenced by produce().

GreaterByPt<CaloTower> pat::PATJetProducer::caloPTComparator_
private

Definition at line 97 of file PATJetProducer.h.

std::vector<std::string> pat::PATJetProducer::discriminatorLabels_
private

Definition at line 84 of file PATJetProducer.h.

Referenced by produce().

std::vector<edm::InputTag> pat::PATJetProducer::discriminatorTags_
private

Definition at line 82 of file PATJetProducer.h.

std::vector<edm::EDGetTokenT<reco::JetFloatAssociation::Container> > pat::PATJetProducer::discriminatorTokens_
private

Definition at line 83 of file PATJetProducer.h.

Referenced by produce().

pat::helper::EfficiencyLoader pat::PATJetProducer::efficiencyLoader_
private

Definition at line 100 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::embedCaloTowers_
private

Definition at line 62 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::embedGenJetMatch_
private

Definition at line 73 of file PATJetProducer.h.

Referenced by PATJetProducer().

bool pat::PATJetProducer::embedGenPartonMatch_
private

Definition at line 70 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::embedPFCandidates_
private

Definition at line 63 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::EDGetTokenT<edm::Association<reco::GenJetCollection> > pat::PATJetProducer::genJetToken_
private

Definition at line 74 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > pat::PATJetProducer::genPartonToken_
private

Definition at line 71 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::getJetMCFlavour_
private

Definition at line 64 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::EDGetTokenT<reco::JetFloatAssociation::Container> pat::PATJetProducer::jetChargeToken_
private

Definition at line 92 of file PATJetProducer.h.

Referenced by produce().

std::vector<edm::EDGetTokenT<edm::ValueMap<JetCorrFactors> > > pat::PATJetProducer::jetCorrFactorsTokens_
private

Definition at line 78 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::EDGetTokenT<reco::JetFlavourInfoMatchingCollection> pat::PATJetProducer::jetFlavourInfoToken_
private

Definition at line 68 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::EDGetTokenT<reco::JetIDValueMap> pat::PATJetProducer::jetIDMapToken_
private

Definition at line 94 of file PATJetProducer.h.

Referenced by produce().

edm::EDGetTokenT<reco::JetFlavourMatchingCollection> pat::PATJetProducer::jetPartonMapToken_
private

Definition at line 67 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::EDGetTokenT<edm::View<reco::Jet> > pat::PATJetProducer::jetsToken_
private

Definition at line 61 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

GreaterByPt<Jet> pat::PATJetProducer::pTComparator_
private

Definition at line 96 of file PATJetProducer.h.

Referenced by produce().

pat::helper::KinResolutionsLoader pat::PATJetProducer::resolutionLoader_
private

Definition at line 103 of file PATJetProducer.h.

Referenced by produce().

std::vector<std::string> pat::PATJetProducer::tagInfoLabels_
private

Definition at line 88 of file PATJetProducer.h.

Referenced by produce().

std::vector<edm::InputTag> pat::PATJetProducer::tagInfoTags_
private

Definition at line 86 of file PATJetProducer.h.

std::vector<edm::EDGetTokenT<edm::View<reco::BaseTagInfo> > > pat::PATJetProducer::tagInfoTokens_
private

Definition at line 87 of file PATJetProducer.h.

Referenced by produce().

edm::EDGetTokenT<reco::JetTracksAssociation::Container> pat::PATJetProducer::trackAssociationToken_
private

Definition at line 90 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::useLegacyJetMCFlavour_
private

Definition at line 65 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

pat::PATUserDataHelper<pat::Jet> pat::PATJetProducer::userDataHelper_
private

Definition at line 106 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::useUserData_
private

Definition at line 105 of file PATJetProducer.h.

Referenced by produce().