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::ProductRegistryHelper

Public Member Functions

 PATJetProducer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 ~PATJetProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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_
 
pat::helper::EfficiencyLoader efficiencyLoader_
 
bool embedCaloTowers_
 
bool embedGenJetMatch_
 
bool embedGenPartonMatch_
 
bool embedPFCandidates_
 
edm::InputTag genJetSrc_
 
edm::InputTag genPartonSrc_
 
bool getJetMCFlavour_
 
edm::InputTag jetCharge_
 
std::vector< edm::InputTagjetCorrFactorsSrc_
 
edm::InputTag jetFlavourInfoSource_
 
edm::InputTag jetIDMapLabel_
 
edm::InputTag jetPartonMapSource_
 
edm::InputTag jetsSrc_
 
edm::InputTag partonJetSrc_
 
GreaterByPt< JetpTComparator_
 
pat::helper::KinResolutionsLoader resolutionLoader_
 
std::vector< std::string > tagInfoLabels_
 
std::vector< edm::InputTagtagInfoTags_
 
edm::InputTag trackAssociation_
 
bool useLegacyJetMCFlavour_
 
pat::PATUserDataHelper< pat::JetuserDataHelper_
 
bool useUserData_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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 45 of file PATJetProducer.h.

Constructor & Destructor Documentation

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

Definition at line 46 of file PATJetProducer.cc.

References addAssociatedTracks_, addBTagInfo_, addDiscriminators_, addEfficiencies_, addGenJetMatch_, addGenPartonMatch_, addJetCharge_, addJetCorrFactors_, addJetFlavourInfo_, addJetID_, addPartonJetMatch_, addResolutions_, addTagInfos_, discriminatorLabels_, discriminatorTags_, efficiencyLoader_, embedCaloTowers_, embedGenJetMatch_, embedGenPartonMatch_, embedPFCandidates_, genJetSrc_, genPartonSrc_, getJetMCFlavour_, edm::ParameterSet::getParameter(), jetCharge_, jetCorrFactorsSrc_, jetFlavourInfoSource_, jetIDMapLabel_, jetPartonMapSource_, jetsSrc_, diffTwoXMLs::label, partonJetSrc_, pos, resolutionLoader_, tagInfoLabels_, tagInfoTags_, trackAssociation_, useLegacyJetMCFlavour_, userDataHelper_, and useUserData_.

46  :
47  useUserData_(iConfig.exists("userData"))
48 {
49  // initialize configurables
50  jetsSrc_ = iConfig.getParameter<edm::InputTag>( "jetSource" );
51  embedCaloTowers_ = iConfig.getParameter<bool>( "embedCaloTowers" );
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  jetPartonMapSource_ = iConfig.getParameter<edm::InputTag>( "JetPartonMapSource" );
57  jetFlavourInfoSource_ = iConfig.getParameter<edm::InputTag>( "JetFlavourInfoSource" );
58  addGenPartonMatch_ = iConfig.getParameter<bool>( "addGenPartonMatch" );
59  embedGenPartonMatch_ = iConfig.getParameter<bool>( "embedGenPartonMatch" );
60  genPartonSrc_ = iConfig.getParameter<edm::InputTag>( "genPartonMatch" );
61  addGenJetMatch_ = iConfig.getParameter<bool>( "addGenJetMatch" );
62  embedGenJetMatch_ = iConfig.getParameter<bool>( "embedGenJetMatch" );
63  genJetSrc_ = iConfig.getParameter<edm::InputTag>( "genJetMatch" );
64  addPartonJetMatch_ = iConfig.getParameter<bool>( "addPartonJetMatch" );
65  partonJetSrc_ = iConfig.getParameter<edm::InputTag>( "partonJetSource" );
66  addJetCorrFactors_ = iConfig.getParameter<bool>( "addJetCorrFactors" );
67  jetCorrFactorsSrc_ = iConfig.getParameter<std::vector<edm::InputTag> >( "jetCorrFactorsSource" );
68  addBTagInfo_ = iConfig.getParameter<bool>( "addBTagInfo" );
69  addDiscriminators_ = iConfig.getParameter<bool>( "addDiscriminators" );
70  discriminatorTags_ = iConfig.getParameter<std::vector<edm::InputTag> >( "discriminatorSources" );
71  addTagInfos_ = iConfig.getParameter<bool>( "addTagInfos" );
72  tagInfoTags_ = iConfig.getParameter<std::vector<edm::InputTag> >( "tagInfoSources" );
73  addAssociatedTracks_ = iConfig.getParameter<bool>( "addAssociatedTracks" );
74  trackAssociation_ = iConfig.getParameter<edm::InputTag>( "trackAssociationSource" );
75  addJetCharge_ = iConfig.getParameter<bool>( "addJetCharge" );
76  jetCharge_ = iConfig.getParameter<edm::InputTag>( "jetChargeSource" );
77  addJetID_ = iConfig.getParameter<bool>( "addJetID");
78  jetIDMapLabel_ = iConfig.getParameter<edm::InputTag>( "jetIDMap");
79  // Efficiency configurables
80  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
81  if (addEfficiencies_) {
83  }
84  // Resolution configurables
85  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
86  if (addResolutions_) {
88  }
89  if (discriminatorTags_.empty()) {
90  addDiscriminators_ = false;
91  } else {
92  for (std::vector<edm::InputTag>::const_iterator it = discriminatorTags_.begin(), ed = discriminatorTags_.end(); it != ed; ++it) {
93  std::string label = it->label();
94  std::string::size_type pos = label.find("JetTags");
95  if ((pos != std::string::npos) && (pos != label.length() - 7)) {
96  label.erase(pos+7); // trim a tail after "JetTags"
97  }
98  discriminatorLabels_.push_back(label);
99  }
100  }
101  if (tagInfoTags_.empty()) {
102  addTagInfos_ = false;
103  } else {
104  for (std::vector<edm::InputTag>::const_iterator it = tagInfoTags_.begin(), ed = tagInfoTags_.end(); it != ed; ++it) {
105  std::string label = it->label();
106  std::string::size_type pos = label.find("TagInfos");
107  if ((pos != std::string::npos) && (pos != label.length() - 8)) {
108  label.erase(pos+8); // trim a tail after "TagInfos"
109  }
110  tagInfoLabels_.push_back(label);
111  }
112  }
113  if (!addBTagInfo_) { addDiscriminators_ = false; addTagInfos_ = false; }
114  // Check to see if the user wants to add user data
115  if ( useUserData_ ) {
117  }
118  // produces vector of jets
119  produces<std::vector<Jet> >();
120  produces<reco::GenJetCollection> ("genJets");
121  produces<std::vector<CaloTower> > ("caloTowers");
122  produces<reco::PFCandidateCollection > ("pfCandidates");
123  produces<edm::OwnVector<reco::BaseTagInfo> > ("tagInfos");
124 }
edm::InputTag jetsSrc_
T getParameter(std::string const &) const
pat::helper::EfficiencyLoader efficiencyLoader_
Assists in assimilating all pat::UserData into pat objects.
edm::InputTag jetCharge_
std::vector< std::string > tagInfoLabels_
edm::InputTag trackAssociation_
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
edm::InputTag jetIDMapLabel_
edm::InputTag genJetSrc_
uint16_t size_type
edm::InputTag partonJetSrc_
std::vector< edm::InputTag > jetCorrFactorsSrc_
std::vector< edm::InputTag > discriminatorTags_
pat::PATUserDataHelper< pat::Jet > userDataHelper_
edm::InputTag jetFlavourInfoSource_
edm::InputTag genPartonSrc_
edm::InputTag jetPartonMapSource_
PATJetProducer::~PATJetProducer ( )

Definition at line 127 of file PATJetProducer.cc.

127  {
128 
129 }

Member Function Documentation

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

Definition at line 422 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().

423 {
425  iDesc.setComment("PAT jet producer module");
426 
427  // input source
428  iDesc.add<edm::InputTag>("jetSource", edm::InputTag("no default"))->setComment("input collection");
429 
430  // embedding
431  iDesc.add<bool>("embedCaloTowers", true)->setComment("embed external calo towers");
432  iDesc.add<bool>("embedPFCandidates", true)->setComment("embed external PFCandidates");
433 
434  // MC matching configurables
435  iDesc.add<bool>("addGenPartonMatch", true)->setComment("add MC matching");
436  iDesc.add<bool>("embedGenPartonMatch", false)->setComment("embed MC matched MC information");
437  iDesc.add<edm::InputTag>("genPartonMatch", edm::InputTag())->setComment("input with MC match information");
438 
439  iDesc.add<bool>("addGenJetMatch", true)->setComment("add MC matching");
440  iDesc.add<bool>("embedGenJetMatch", false)->setComment("embed MC matched MC information");
441  iDesc.add<edm::InputTag>("genJetMatch", edm::InputTag())->setComment("input with MC match information");
442 
443  iDesc.add<bool>("addJetCharge", true);
444  iDesc.add<edm::InputTag>("jetChargeSource", edm::InputTag("patJetCharge"));
445 
446  // jet id
447  iDesc.add<bool>("addJetID", true)->setComment("Add jet ID information");
448  iDesc.add<edm::InputTag>("jetIDMap", edm::InputTag())->setComment("jet id map");
449 
450  iDesc.add<bool>("addPartonJetMatch", false);
451  iDesc.add<edm::InputTag>("partonJetSource", edm::InputTag("NOT IMPLEMENTED"));
452 
453  // track association
454  iDesc.add<bool>("addAssociatedTracks", true);
455  iDesc.add<edm::InputTag>("trackAssociationSource", edm::InputTag("ic5JetTracksAssociatorAtVertex"));
456 
457  // tag info
458  iDesc.add<bool>("addTagInfos", true);
459  std::vector<edm::InputTag> emptyVInputTags;
460  iDesc.add<std::vector<edm::InputTag> >("tagInfoSources", emptyVInputTags);
461 
462  // jet energy corrections
463  iDesc.add<bool>("addJetCorrFactors", true);
464  iDesc.add<std::vector<edm::InputTag> >("jetCorrFactorsSource", emptyVInputTags);
465 
466  // btag discriminator tags
467  iDesc.add<bool>("addBTagInfo",true);
468  iDesc.add<bool>("addDiscriminators", true);
469  iDesc.add<std::vector<edm::InputTag> >("discriminatorSources", emptyVInputTags);
470 
471  // jet flavour idetification configurables
472  iDesc.add<bool>("getJetMCFlavour", true);
473  iDesc.add<bool>("useLegacyJetMCFlavour", false);
474  iDesc.add<bool>("addJetFlavourInfo", false);
475  iDesc.add<edm::InputTag>("JetPartonMapSource", edm::InputTag("jetFlavourAssociationLegacy"));
476  iDesc.add<edm::InputTag>("JetFlavourInfoSource", edm::InputTag("jetFlavourAssociation"));
477 
479 
480  // Efficiency configurables
481  edm::ParameterSetDescription efficienciesPSet;
482  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
483  iDesc.add("efficiencies", efficienciesPSet);
484  iDesc.add<bool>("addEfficiencies", false);
485 
486  // Check to see if the user wants to add user data
487  edm::ParameterSetDescription userDataPSet;
489  iDesc.addOptional("userData", userDataPSet);
490 
491  descriptions.add("PATJetProducer", iDesc);
492 }
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 
)
virtual

Implements edm::EDProducer.

Definition at line 132 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_, discriminatorTags_, efficiencyLoader_, embedCaloTowers_, embedGenPartonMatch_, embedPFCandidates_, pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), edm::View< T >::end(), spr::find(), first, genJetSrc_, genPartonSrc_, edm::RefToBase< T >::get(), edm::Event::getByLabel(), reco::CaloJet::getCaloConstituents(), reco::JPTJet::getCaloJetRef(), getJetMCFlavour_, reco::PFJet::getPFConstituents(), edm::Event::getRefBeforePut(), i, 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, jetCharge_, jetCorrFactorsSrc_, jetFlavourInfoSource_, jetIDMapLabel_, jetPartonMapSource_, fwrapper::jets, jetsSrc_, 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_, tagInfoTags_, trackAssociation_, useLegacyJetMCFlavour_, userDataHelper_, useUserData_, and relativeConstraints::value.

133 {
134  // check whether dealing with MC or real data
135  if (iEvent.isRealData()){
136  getJetMCFlavour_ = false;
137  useLegacyJetMCFlavour_ = false;
138  addJetFlavourInfo_ = false;
139  addGenPartonMatch_ = false;
140  addGenJetMatch_ = false;
141  addPartonJetMatch_ = false;
142  }
143 
144  // Get the vector of jets
146  iEvent.getByLabel(jetsSrc_, jets);
147 
149  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
150 
151  // for jet flavour
155  else if (getJetMCFlavour_ && !useLegacyJetMCFlavour_) iEvent.getByLabel (jetFlavourInfoSource_, jetFlavInfoMatch);
156 
157  // Get the vector of generated particles from the event if needed
159  if (addGenPartonMatch_) iEvent.getByLabel(genPartonSrc_, partonMatch);
160  // Get the vector of GenJets from the event if needed
162  if (addGenJetMatch_) iEvent.getByLabel(genJetSrc_, genJetMatch);
163 /* TO BE IMPLEMENTED FOR >= 1_5_X
164  // Get the vector of PartonJets from the event if needed
165  edm::Handle<edm::View<reco::SomePartonJetType> > partonJets;
166  if (addPartonJetMatch_) iEvent.getByLabel(partonJetSrc_, partonJets);
167 */
168 
169  // read in the jet correction factors ValueMap
170  std::vector<edm::ValueMap<JetCorrFactors> > jetCorrs;
171  if (addJetCorrFactors_) {
172  for ( size_t i = 0; i < jetCorrFactorsSrc_.size(); ++i ) {
174  iEvent.getByLabel(jetCorrFactorsSrc_[i], jetCorr);
175  jetCorrs.push_back( *jetCorr );
176  }
177  }
178 
179  // Get the vector of jet tags with b-tagging info
180  std::vector<edm::Handle<reco::JetFloatAssociation::Container> > jetDiscriminators;
182  jetDiscriminators.resize(discriminatorTags_.size());
183  for (size_t i = 0; i < discriminatorTags_.size(); ++i) {
184  iEvent.getByLabel(discriminatorTags_[i], jetDiscriminators[i]);
185  }
186  }
187  std::vector<edm::Handle<edm::View<reco::BaseTagInfo> > > jetTagInfos;
188  if (addBTagInfo_ && addTagInfos_) {
189  jetTagInfos.resize(tagInfoTags_.size());
190  for (size_t i = 0; i < tagInfoTags_.size(); ++i) {
191  iEvent.getByLabel(tagInfoTags_[i], jetTagInfos[i]);
192  }
193  }
194 
195  // tracks Jet Track Association
197  if (addAssociatedTracks_) iEvent.getByLabel(trackAssociation_, hTrackAss);
199  if (addJetCharge_) iEvent.getByLabel(jetCharge_, hJetChargeAss);
200 
201  // jet ID handle
203  if ( addJetID_ ) iEvent.getByLabel( jetIDMapLabel_, hJetIDMap );
204 
205  // loop over jets
206  std::auto_ptr< std::vector<Jet> > patJets ( new std::vector<Jet>() );
207 
208  std::auto_ptr<reco::GenJetCollection > genJetsOut ( new reco::GenJetCollection() );
209  std::auto_ptr<std::vector<CaloTower> > caloTowersOut( new std::vector<CaloTower> () );
210  std::auto_ptr<reco::PFCandidateCollection > pfCandidatesOut( new reco::PFCandidateCollection() );
211  std::auto_ptr<edm::OwnVector<reco::BaseTagInfo> > tagInfosOut ( new edm::OwnVector<reco::BaseTagInfo>() );
212 
213 
215  edm::RefProd<std::vector<CaloTower> > h_caloTowersOut = iEvent.getRefBeforePut<std::vector<CaloTower> > ( "caloTowers" );
216  edm::RefProd<reco::PFCandidateCollection > h_pfCandidatesOut = iEvent.getRefBeforePut<reco::PFCandidateCollection > ( "pfCandidates" );
218 
219 
220 
221 
222  bool first=true; // this is introduced to issue warnings only for the first jet
223  for (edm::View<reco::Jet>::const_iterator itJet = jets->begin(); itJet != jets->end(); itJet++) {
224 
225  // construct the Jet from the ref -> save ref to original object
226  unsigned int idx = itJet - jets->begin();
227  edm::RefToBase<reco::Jet> jetRef = jets->refAt(idx);
228  edm::Ptr<reco::Jet> jetPtr = jets->ptrAt(idx);
229  Jet ajet(jetRef);
230 
231  // add the FwdPtrs to the CaloTowers
232  if ( (ajet.isCaloJet() || ajet.isJPTJet() ) && embedCaloTowers_) {
233  const reco::CaloJet *cj = 0;
234  const reco::JPTJet * jptj = 0;
235  if ( ajet.isCaloJet()) cj = dynamic_cast<const reco::CaloJet *>(jetRef.get());
236  else {
237  jptj = dynamic_cast<const reco::JPTJet *>(jetRef.get() );
238  cj = dynamic_cast<const reco::CaloJet *>(jptj->getCaloJetRef().get() );
239  }
241  std::vector< CaloTowerPtr > itowers = cj->getCaloConstituents();
242  for ( std::vector<CaloTowerPtr>::const_iterator towBegin = itowers.begin(),
243  towEnd = itowers.end(), itow = towBegin;
244  itow != towEnd; ++itow ) {
245  caloTowersOut->push_back( **itow );
246  // set the "forward" ref to the thinned collection
247  edm::Ref<std::vector<CaloTower> > caloTowerRef( h_caloTowersOut, caloTowersOut->size() - 1);
248  edm::Ptr<CaloTower> caloForwardRef ( h_caloTowersOut.id(), caloTowerRef.key(), h_caloTowersOut.productGetter() );
249  // set the "backward" ref to the original collection for association
250  edm::Ptr<CaloTower> caloBackRef ( *itow );
251  // add to the list of FwdPtr's
252  itowersRef.push_back( pat::CaloTowerFwdPtrCollection::value_type ( caloForwardRef, caloBackRef ) );
253 
254  }
255  ajet.setCaloTowers( itowersRef );
256  }
257 
258  // add the FwdPtrs to the PFCandidates
259  if (ajet.isPFJet() && embedPFCandidates_) {
260  const reco::PFJet *cj = dynamic_cast<const reco::PFJet *>(jetRef.get());
261  pat::PFCandidateFwdPtrCollection iparticlesRef;
262  std::vector< reco::PFCandidatePtr > iparticles = cj->getPFConstituents();
263  for ( std::vector<reco::PFCandidatePtr>::const_iterator partBegin = iparticles.begin(),
264  partEnd = iparticles.end(), ipart = partBegin;
265  ipart != partEnd; ++ipart ) {
266  pfCandidatesOut->push_back( **ipart );
267  // set the "forward" ref to the thinned collection
268  edm::Ref<reco::PFCandidateCollection> pfCollectionRef( h_pfCandidatesOut, pfCandidatesOut->size() - 1);
269  edm::Ptr<reco::PFCandidate> pfForwardRef ( h_pfCandidatesOut.id(), pfCollectionRef.key(), h_pfCandidatesOut.productGetter() );
270  // set the "backward" ref to the original collection for association
271  edm::Ptr<reco::PFCandidate> pfBackRef ( *ipart );
272  // add to the list of FwdPtr's
273  iparticlesRef.push_back( pat::PFCandidateFwdPtrCollection::value_type ( pfForwardRef, pfBackRef ) );
274  }
275  ajet.setPFCandidates( iparticlesRef );
276  }
277 
278  if (addJetCorrFactors_) {
279  // add additional JetCorrs to the jet
280  for ( unsigned int i=0; i<jetCorrFactorsSrc_.size(); ++i ) {
281  const JetCorrFactors& jcf = jetCorrs[i][jetRef];
282  // uncomment for debugging
283  // jcf.print();
284  ajet.addJECFactors(jcf);
285  }
286  std::vector<std::string> levels = jetCorrs[0][jetRef].correctionLabels();
287  if(std::find(levels.begin(), levels.end(), "L2L3Residual")!=levels.end()){
288  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("L2L3Residual"));
289  }
290  else if(std::find(levels.begin(), levels.end(), "L3Absolute")!=levels.end()){
291  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("L3Absolute"));
292  }
293  else{
294  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("Uncorrected"));
295  if(first){
296  edm::LogWarning("L3Absolute not found") << "L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n"
297  << "of module " << jetCorrs[0][jetRef].jecSet() << " jets will remain"
298  << " uncorrected."; first=false;
299  }
300  }
301  }
302 
303  // get the MC flavour information for this jet
305  ajet.setPartonFlavour( (*jetFlavMatch)[edm::RefToBase<reco::Jet>(jetRef)].getFlavour() );
306  }
308  if ( addJetFlavourInfo_ ) ajet.setJetFlavourInfo( (*jetFlavInfoMatch)[edm::RefToBase<reco::Jet>(jetRef)] );
309  else
310  {
311  ajet.setPartonFlavour( (*jetFlavInfoMatch)[edm::RefToBase<reco::Jet>(jetRef)].getPartonFlavour() );
312  ajet.setHadronFlavour( (*jetFlavInfoMatch)[edm::RefToBase<reco::Jet>(jetRef)].getHadronFlavour() );
313  }
314  }
315  // store the match to the generated partons
316  if (addGenPartonMatch_) {
317  reco::GenParticleRef parton = (*partonMatch)[jetRef];
318  if (parton.isNonnull() && parton.isAvailable()) {
319  ajet.setGenParton(parton, embedGenPartonMatch_);
320  } // leave empty if no match found
321  }
322  // store the match to the GenJets
323  if (addGenJetMatch_) {
324  reco::GenJetRef genjet = (*genJetMatch)[jetRef];
325  if (genjet.isNonnull() && genjet.isAvailable()) {
326  genJetsOut->push_back( *genjet );
327  // set the "forward" ref to the thinned collection
328  edm::Ref<reco::GenJetCollection > genForwardRef ( h_genJetsOut, genJetsOut->size() - 1 );
329  // set the "backward" ref to the original collection
330  edm::Ref<reco::GenJetCollection > genBackRef ( genjet );
331  // make the FwdPtr
332  edm::FwdRef<reco::GenJetCollection > genjetFwdRef ( genForwardRef, genBackRef );
333  ajet.setGenJetRef(genjetFwdRef );
334  } // leave empty if no match found
335  }
336 
337  if (efficiencyLoader_.enabled()) {
338  efficiencyLoader_.setEfficiencies( ajet, jetRef );
339  }
340 
341  // IMPORTANT: DO THIS AFTER JES CORRECTIONS
342  if (resolutionLoader_.enabled()) {
344  }
345 
346  // TO BE IMPLEMENTED FOR >=1_5_X: do the PartonJet matching
347  if (addPartonJetMatch_) {
348  }
349 
350  // add b-tag info if available & required
351  if (addBTagInfo_) {
352  if (addDiscriminators_) {
353  for (size_t k=0; k<jetDiscriminators.size(); ++k) {
354  float value = (*jetDiscriminators[k])[jetRef];
355  ajet.addBDiscriminatorPair(std::make_pair(discriminatorLabels_[k], value));
356  }
357  }
358  if (addTagInfos_) {
359  for (size_t k=0; k<jetTagInfos.size(); ++k) {
360  const edm::View<reco::BaseTagInfo> & taginfos = *jetTagInfos[k];
361  // This is not associative, so we have to search the jet
363  // Try first by 'same index'
364  if ((idx < taginfos.size()) && (taginfos[idx].jet() == jetRef)) {
365  match = taginfos.ptrAt(idx);
366  } else {
367  // otherwise fail back to a simple search
368  for (edm::View<reco::BaseTagInfo>::const_iterator itTI = taginfos.begin(), edTI = taginfos.end(); itTI != edTI; ++itTI) {
369  if (itTI->jet() == jetRef) { match = taginfos.ptrAt( itTI - taginfos.begin() ); break; }
370  }
371  }
372  if (match.isNonnull()) {
373  tagInfosOut->push_back( match->clone() );
374  // set the "forward" ptr to the thinned collection
375  edm::Ptr<reco::BaseTagInfo> tagInfoForwardPtr ( h_tagInfosOut.id(), &tagInfosOut->back(), tagInfosOut->size() - 1 );
376  // set the "backward" ptr to the original collection for association
377  edm::Ptr<reco::BaseTagInfo> tagInfoBackPtr ( match );
378  // make FwdPtr
379  TagInfoFwdPtrCollection::value_type tagInfoFwdPtr( tagInfoForwardPtr, tagInfoBackPtr ) ;
380  ajet.addTagInfo(tagInfoLabels_[k], tagInfoFwdPtr );
381  }
382  }
383  }
384  }
385 
386  if (addAssociatedTracks_) ajet.setAssociatedTracks( (*hTrackAss)[jetRef] );
387 
388  if (addJetCharge_) ajet.setJetCharge( (*hJetChargeAss)[jetRef] );
389 
390  // add jet ID for calo jets
391  if (addJetID_ && ajet.isCaloJet() ) {
392  reco::JetID jetId = (*hJetIDMap)[ jetRef ];
393  ajet.setJetID( jetId );
394  }
395  // add jet ID jpt jets
396  else if ( addJetID_ && ajet.isJPTJet() ){
397  const reco::JPTJet *jptj = dynamic_cast<const reco::JPTJet *>(jetRef.get());
398  reco::JetID jetId = (*hJetIDMap)[ jptj->getCaloJetRef() ];
399  ajet.setJetID( jetId );
400  }
401  if ( useUserData_ ) {
402  userDataHelper_.add( ajet, iEvent, iSetup );
403  }
404  patJets->push_back(ajet);
405  }
406 
407  // sort jets in pt
408  std::sort(patJets->begin(), patJets->end(), pTComparator_);
409 
410  // put genEvt in Event
411  iEvent.put(patJets);
412 
413  iEvent.put( genJetsOut, "genJets" );
414  iEvent.put( caloTowersOut, "caloTowers" );
415  iEvent.put( pfCandidatesOut, "pfCandidates" );
416  iEvent.put( tagInfosOut, "tagInfos" );
417 
418 
419 }
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
edm::InputTag jetsSrc_
pat::helper::EfficiencyLoader efficiencyLoader_
int i
Definition: DBlmapReader.cc:9
edm::InputTag jetCharge_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
Jets made from CaloTowers.
Definition: CaloJet.h:30
std::vector< std::string > tagInfoLabels_
edm::InputTag trackAssociation_
std::vector< std::string > correctionLabels() const
std::vector< edm::InputTag > tagInfoTags_
pat::helper::KinResolutionsLoader resolutionLoader_
std::vector< GenJet > GenJetCollection
collection of GenJet objects
std::vector< std::string > discriminatorLabels_
edm::InputTag jetIDMapLabel_
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
edm::InputTag genJetSrc_
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:94
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
bool isRealData() const
Definition: EventBase.h:60
Jets made from PFObjects.
Definition: PFJet.h:22
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
std::vector< edm::InputTag > jetCorrFactorsSrc_
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:85
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:29
Class for the storage of jet correction factors.
vector< PseudoJet > jets
std::vector< edm::InputTag > discriminatorTags_
bool first
Definition: L1TdeRCT.cc:94
Container::value_type value_type
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
RefProd< PROD > getRefBeforePut()
Definition: Event.h:97
int k[5][pyjets_maxn]
pat::PATUserDataHelper< pat::Jet > userDataHelper_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
std::vector< edm::FwdPtr< CaloTower > > CaloTowerFwdPtrCollection
Definition: Jet.h:69
std::vector< edm::FwdPtr< reco::PFCandidate > > PFCandidateFwdPtrCollection
Definition: Jet.h:68
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:72
edm::InputTag jetFlavourInfoSource_
edm::InputTag genPartonSrc_
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
Definition: PFJet.cc:53
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
edm::InputTag jetPartonMapSource_
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 85 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addBTagInfo_
private

Definition at line 78 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addDiscriminators_
private

Definition at line 79 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addEfficiencies_
private

Definition at line 95 of file PATJetProducer.h.

Referenced by PATJetProducer().

bool pat::PATJetProducer::addGenJetMatch_
private

Definition at line 70 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addGenPartonMatch_
private

Definition at line 67 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetCharge_
private

Definition at line 87 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetCorrFactors_
private

Definition at line 75 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetFlavourInfo_
private

Definition at line 64 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetID_
private

Definition at line 89 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addPartonJetMatch_
private

Definition at line 73 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addResolutions_
private

Definition at line 98 of file PATJetProducer.h.

Referenced by PATJetProducer().

bool pat::PATJetProducer::addTagInfos_
private

Definition at line 82 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 93 of file PATJetProducer.h.

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

Definition at line 81 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 80 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 96 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::embedCaloTowers_
private

Definition at line 60 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::embedGenJetMatch_
private

Definition at line 71 of file PATJetProducer.h.

Referenced by PATJetProducer().

bool pat::PATJetProducer::embedGenPartonMatch_
private

Definition at line 68 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::embedPFCandidates_
private

Definition at line 61 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::genJetSrc_
private

Definition at line 72 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::genPartonSrc_
private

Definition at line 69 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::getJetMCFlavour_
private

Definition at line 62 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::jetCharge_
private

Definition at line 88 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 76 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::jetFlavourInfoSource_
private

Definition at line 66 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::jetIDMapLabel_
private

Definition at line 90 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::jetPartonMapSource_
private

Definition at line 65 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::jetsSrc_
private

Definition at line 59 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::partonJetSrc_
private

Definition at line 74 of file PATJetProducer.h.

Referenced by PATJetProducer().

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

Definition at line 92 of file PATJetProducer.h.

Referenced by produce().

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

Definition at line 99 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 84 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 83 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::trackAssociation_
private

Definition at line 86 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::useLegacyJetMCFlavour_
private

Definition at line 63 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 102 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::useUserData_
private

Definition at line 101 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().