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)
 

Private Attributes

bool addAssociatedTracks_
 
bool addBTagInfo_
 
bool addDiscriminators_
 
bool addEfficiencies_
 
bool addGenJetMatch_
 
bool addGenPartonMatch_
 
bool addJetCharge_
 
bool addJetCorrFactors_
 
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 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_
 
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.25 2010/06/28 14:45:50 srappocc Exp

Definition at line 45 of file PATJetProducer.h.

Constructor & Destructor Documentation

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

Definition at line 45 of file PATJetProducer.cc.

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

45  :
46  useUserData_(iConfig.exists("userData"))
47 {
48  // initialize the configurables
49  jetsSrc_ = iConfig.getParameter<edm::InputTag> ( "jetSource" );
50  embedCaloTowers_ = iConfig.getParameter<bool> ( "embedCaloTowers" );
51  embedPFCandidates_ = iConfig.getParameter<bool> ( "embedPFCandidates" );
52  getJetMCFlavour_ = iConfig.getParameter<bool> ( "getJetMCFlavour" );
53  jetPartonMapSource_ = iConfig.getParameter<edm::InputTag> ( "JetPartonMapSource" );
54  addGenPartonMatch_ = iConfig.getParameter<bool> ( "addGenPartonMatch" );
55  embedGenPartonMatch_ = iConfig.getParameter<bool> ( "embedGenPartonMatch" );
56  genPartonSrc_ = iConfig.getParameter<edm::InputTag> ( "genPartonMatch" );
57  addGenJetMatch_ = iConfig.getParameter<bool> ( "addGenJetMatch" );
58  embedGenJetMatch_ = iConfig.getParameter<bool> ( "embedGenJetMatch" );
59  genJetSrc_ = iConfig.getParameter<edm::InputTag> ( "genJetMatch" );
60  addPartonJetMatch_ = iConfig.getParameter<bool> ( "addPartonJetMatch" );
61  partonJetSrc_ = iConfig.getParameter<edm::InputTag> ( "partonJetSource" );
62  addJetCorrFactors_ = iConfig.getParameter<bool> ( "addJetCorrFactors" );
63  jetCorrFactorsSrc_ = iConfig.getParameter<std::vector<edm::InputTag> >( "jetCorrFactorsSource" );
64  addBTagInfo_ = iConfig.getParameter<bool> ( "addBTagInfo" );
65  addDiscriminators_ = iConfig.getParameter<bool> ( "addDiscriminators" );
66  discriminatorTags_ = iConfig.getParameter<std::vector<edm::InputTag> >( "discriminatorSources" );
67  addTagInfos_ = iConfig.getParameter<bool> ( "addTagInfos" );
68  tagInfoTags_ = iConfig.getParameter<std::vector<edm::InputTag> >( "tagInfoSources" );
69  addAssociatedTracks_ = iConfig.getParameter<bool> ( "addAssociatedTracks" );
70  trackAssociation_ = iConfig.getParameter<edm::InputTag> ( "trackAssociationSource" );
71  addJetCharge_ = iConfig.getParameter<bool> ( "addJetCharge" );
72  jetCharge_ = iConfig.getParameter<edm::InputTag> ( "jetChargeSource" );
73  addJetID_ = iConfig.getParameter<bool> ( "addJetID");
74  jetIDMapLabel_ = iConfig.getParameter<edm::InputTag> ( "jetIDMap");
75 
76  // Efficiency configurables
77  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
78  if (addEfficiencies_) {
80  }
81 
82  // Resolution configurables
83  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
84  if (addResolutions_) {
86  }
87 
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 
114  if (!addBTagInfo_) { addDiscriminators_ = false; addTagInfos_ = false; }
115 
116  // Check to see if the user wants to add user data
117  if ( useUserData_ ) {
119  }
120 
121  // produces vector of jets
122  produces<std::vector<Jet> >();
123  produces<reco::GenJetCollection> ("genJets");
124  produces<std::vector<CaloTower> > ("caloTowers");
125  produces<reco::PFCandidateCollection > ("pfCandidates");
126  produces<edm::OwnVector<reco::BaseTagInfo> > ("tagInfos");
127 }
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_
const std::string & label
Definition: MVAComputer.cc:186
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 genPartonSrc_
edm::InputTag jetPartonMapSource_
PATJetProducer::~PATJetProducer ( )

Definition at line 130 of file PATJetProducer.cc.

130  {
131 
132 }

Member Function Documentation

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

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

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

References addAssociatedTracks_, pat::Jet::addBDiscriminatorPair(), addBTagInfo_, addDiscriminators_, addGenJetMatch_, addGenPartonMatch_, pat::Jet::addJECFactors(), addJetCharge_, addJetCorrFactors_, 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_, jetIDMapLabel_, jetPartonMapSource_, analyzePatCleaning_cfg::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::setJetCharge(), pat::Jet::setJetID(), pat::Jet::setPartonFlavour(), pat::Jet::setPFCandidates(), pat::helper::KinResolutionsLoader::setResolutions(), edm::View< T >::size(), python.multivaluedict::sort(), tagInfoLabels_, tagInfoTags_, trackAssociation_, userDataHelper_, useUserData_, and relativeConstraints::value.

135  {
136 
137  // check whether dealing with MC or real data
138  if (iEvent.isRealData()){
139  getJetMCFlavour_ = false;
140  addGenPartonMatch_ = false;
141  addGenJetMatch_ = false;
142  addPartonJetMatch_ = false;
143  }
144 
145  // Get the vector of jets
147  iEvent.getByLabel(jetsSrc_, jets);
148 
150  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
151 
152  // for jet flavour
154  if (getJetMCFlavour_) iEvent.getByLabel (jetPartonMapSource_, jetFlavMatch);
155 
156  // Get the vector of generated particles from the event if needed
158  if (addGenPartonMatch_) iEvent.getByLabel(genPartonSrc_, partonMatch);
159  // Get the vector of GenJets from the event if needed
161  if (addGenJetMatch_) iEvent.getByLabel(genJetSrc_, genJetMatch);
162 /* TO BE IMPLEMENTED FOR >= 1_5_X
163  // Get the vector of PartonJets from the event if needed
164  edm::Handle<edm::View<reco::SomePartonJetType> > partonJets;
165  if (addPartonJetMatch_) iEvent.getByLabel(partonJetSrc_, partonJets);
166 */
167 
168  // read in the jet correction factors ValueMap
169  std::vector<edm::ValueMap<JetCorrFactors> > jetCorrs;
170  if (addJetCorrFactors_) {
171  for ( size_t i = 0; i < jetCorrFactorsSrc_.size(); ++i ) {
173  iEvent.getByLabel(jetCorrFactorsSrc_[i], jetCorr);
174  jetCorrs.push_back( *jetCorr );
175  }
176  }
177 
178  // Get the vector of jet tags with b-tagging info
179  std::vector<edm::Handle<reco::JetFloatAssociation::Container> > jetDiscriminators;
181  jetDiscriminators.resize(discriminatorTags_.size());
182  for (size_t i = 0; i < discriminatorTags_.size(); ++i) {
183  iEvent.getByLabel(discriminatorTags_[i], jetDiscriminators[i]);
184  }
185  }
186  std::vector<edm::Handle<edm::View<reco::BaseTagInfo> > > jetTagInfos;
187  if (addBTagInfo_ && addTagInfos_) {
188  jetTagInfos.resize(tagInfoTags_.size());
189  for (size_t i = 0; i < tagInfoTags_.size(); ++i) {
190  iEvent.getByLabel(tagInfoTags_[i], jetTagInfos[i]);
191  }
192  }
193 
194  // tracks Jet Track Association
196  if (addAssociatedTracks_) iEvent.getByLabel(trackAssociation_, hTrackAss);
198  if (addJetCharge_) iEvent.getByLabel(jetCharge_, hJetChargeAss);
199 
200  // jet ID handle
202  if ( addJetID_ ) iEvent.getByLabel( jetIDMapLabel_, hJetIDMap );
203 
204  // loop over jets
205  std::auto_ptr< std::vector<Jet> > patJets ( new std::vector<Jet>() );
206 
207  std::auto_ptr<reco::GenJetCollection > genJetsOut ( new reco::GenJetCollection() );
208  std::auto_ptr<std::vector<CaloTower> > caloTowersOut( new std::vector<CaloTower> () );
209  std::auto_ptr<reco::PFCandidateCollection > pfCandidatesOut( new reco::PFCandidateCollection() );
210  std::auto_ptr<edm::OwnVector<reco::BaseTagInfo> > tagInfosOut ( new edm::OwnVector<reco::BaseTagInfo>() );
211 
212 
214  edm::RefProd<std::vector<CaloTower> > h_caloTowersOut = iEvent.getRefBeforePut<std::vector<CaloTower> > ( "caloTowers" );
215  edm::RefProd<reco::PFCandidateCollection > h_pfCandidatesOut = iEvent.getRefBeforePut<reco::PFCandidateCollection > ( "pfCandidates" );
217 
218 
219 
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(),
242  towEnd = itowers.end(), itow = towBegin;
243  itow != towEnd; ++itow ) {
244  caloTowersOut->push_back( **itow );
245  // set the "forward" ref to the thinned collection
246  edm::Ref<std::vector<CaloTower> > caloTowerRef( h_caloTowersOut, caloTowersOut->size() - 1);
247  edm::Ptr<CaloTower> caloForwardRef ( h_caloTowersOut.id(), caloTowerRef.key(), h_caloTowersOut.productGetter() );
248  // set the "backward" ref to the original collection for association
249  edm::Ptr<CaloTower> caloBackRef ( *itow );
250  // add to the list of FwdPtr's
251  itowersRef.push_back( pat::CaloTowerFwdPtrCollection::value_type ( caloForwardRef, caloBackRef ) );
252 
253  }
254  ajet.setCaloTowers( itowersRef );
255  }
256 
257  // add the FwdPtrs to the PFCandidates
258  if (ajet.isPFJet() && embedPFCandidates_) {
259  const reco::PFJet *cj = dynamic_cast<const reco::PFJet *>(jetRef.get());
260  pat::PFCandidateFwdPtrCollection iparticlesRef;
261  std::vector< reco::PFCandidatePtr > iparticles = cj->getPFConstituents();
262  for ( std::vector<reco::PFCandidatePtr>::const_iterator partBegin = iparticles.begin(),
263  partEnd = iparticles.end(), ipart = partBegin;
264  ipart != partEnd; ++ipart ) {
265  pfCandidatesOut->push_back( **ipart );
266  // set the "forward" ref to the thinned collection
267  edm::Ref<reco::PFCandidateCollection> pfCollectionRef( h_pfCandidatesOut, pfCandidatesOut->size() - 1);
268  edm::Ptr<reco::PFCandidate> pfForwardRef ( h_pfCandidatesOut.id(), pfCollectionRef.key(), h_pfCandidatesOut.productGetter() );
269  // set the "backward" ref to the original collection for association
270  edm::Ptr<reco::PFCandidate> pfBackRef ( *ipart );
271  // add to the list of FwdPtr's
272  iparticlesRef.push_back( pat::PFCandidateFwdPtrCollection::value_type ( pfForwardRef, pfBackRef ) );
273  }
274  ajet.setPFCandidates( iparticlesRef );
275  }
276 
277  if (addJetCorrFactors_) {
278  // add additional JetCorrs to the jet
279  for ( unsigned int i=0; i<jetCorrFactorsSrc_.size(); ++i ) {
280  const JetCorrFactors& jcf = jetCorrs[i][jetRef];
281  // uncomment for debugging
282  // jcf.print();
283  ajet.addJECFactors(jcf);
284  }
285  std::vector<std::string> levels = jetCorrs[0][jetRef].correctionLabels();
286  if(std::find(levels.begin(), levels.end(), "L2L3Residual")!=levels.end()){
287  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("L2L3Residual"));
288  }
289  else if(std::find(levels.begin(), levels.end(), "L3Absolute")!=levels.end()){
290  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("L3Absolute"));
291  }
292  else{
293  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("Uncorrected"));
294  if(first){
295  edm::LogWarning("L3Absolute not found") << "L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n"
296  << "of module " << jetCorrs[0][jetRef].jecSet() << " jets will remain"
297  << " uncorrected."; first=false;
298  }
299  }
300  }
301 
302  // get the MC flavour information for this jet
303  if (getJetMCFlavour_) {
304  ajet.setPartonFlavour( (*jetFlavMatch)[edm::RefToBase<reco::Jet>(jetRef)].getFlavour() );
305  }
306  // store the match to the generated partons
307  if (addGenPartonMatch_) {
308  reco::GenParticleRef parton = (*partonMatch)[jetRef];
309  if (parton.isNonnull() && parton.isAvailable()) {
310  ajet.setGenParton(parton, embedGenPartonMatch_);
311  } // leave empty if no match found
312  }
313  // store the match to the GenJets
314  if (addGenJetMatch_) {
315  reco::GenJetRef genjet = (*genJetMatch)[jetRef];
316  if (genjet.isNonnull() && genjet.isAvailable()) {
317  genJetsOut->push_back( *genjet );
318  // set the "forward" ref to the thinned collection
319  edm::Ref<reco::GenJetCollection > genForwardRef ( h_genJetsOut, genJetsOut->size() - 1 );
320  // set the "backward" ref to the original collection
321  edm::Ref<reco::GenJetCollection > genBackRef ( genjet );
322  // make the FwdPtr
323  edm::FwdRef<reco::GenJetCollection > genjetFwdRef ( genForwardRef, genBackRef );
324  ajet.setGenJetRef(genjetFwdRef );
325  } // leave empty if no match found
326  }
327 
328  if (efficiencyLoader_.enabled()) {
329  efficiencyLoader_.setEfficiencies( ajet, jetRef );
330  }
331 
332  // IMPORTANT: DO THIS AFTER JES CORRECTIONS
333  if (resolutionLoader_.enabled()) {
335  }
336 
337  // TO BE IMPLEMENTED FOR >=1_5_X: do the PartonJet matching
338  if (addPartonJetMatch_) {
339  }
340 
341  // add b-tag info if available & required
342  if (addBTagInfo_) {
343  if (addDiscriminators_) {
344  for (size_t k=0; k<jetDiscriminators.size(); ++k) {
345  float value = (*jetDiscriminators[k])[jetRef];
346  ajet.addBDiscriminatorPair(std::make_pair(discriminatorLabels_[k], value));
347  }
348  }
349  if (addTagInfos_) {
350  for (size_t k=0; k<jetTagInfos.size(); ++k) {
351  const edm::View<reco::BaseTagInfo> & taginfos = *jetTagInfos[k];
352  // This is not associative, so we have to search the jet
354  // Try first by 'same index'
355  if ((idx < taginfos.size()) && (taginfos[idx].jet() == jetRef)) {
356  match = taginfos.ptrAt(idx);
357  } else {
358  // otherwise fail back to a simple search
359  for (edm::View<reco::BaseTagInfo>::const_iterator itTI = taginfos.begin(), edTI = taginfos.end(); itTI != edTI; ++itTI) {
360  if (itTI->jet() == jetRef) { match = taginfos.ptrAt( itTI - taginfos.begin() ); break; }
361  }
362  }
363  if (match.isNonnull()) {
364  tagInfosOut->push_back( match->clone() );
365  // set the "forward" ptr to the thinned collection
366  edm::Ptr<reco::BaseTagInfo> tagInfoForwardPtr ( h_tagInfosOut.id(), &tagInfosOut->back(), tagInfosOut->size() - 1 );
367  // set the "backward" ptr to the original collection for association
368  edm::Ptr<reco::BaseTagInfo> tagInfoBackPtr ( match );
369  // make FwdPtr
370  TagInfoFwdPtrCollection::value_type tagInfoFwdPtr( tagInfoForwardPtr, tagInfoBackPtr ) ;
371  ajet.addTagInfo(tagInfoLabels_[k], tagInfoFwdPtr );
372  }
373  }
374  }
375  }
376 
377  if (addAssociatedTracks_) ajet.setAssociatedTracks( (*hTrackAss)[jetRef] );
378 
379  if (addJetCharge_) ajet.setJetCharge( (*hJetChargeAss)[jetRef] );
380 
381  // add jet ID for calo jets
382  if (addJetID_ && ajet.isCaloJet() ) {
383  reco::JetID jetId = (*hJetIDMap)[ jetRef ];
384  ajet.setJetID( jetId );
385  }
386  // add jet ID jpt jets
387  else if ( addJetID_ && ajet.isJPTJet() ){
388  const reco::JPTJet *jptj = dynamic_cast<const reco::JPTJet *>(jetRef.get());
389  reco::JetID jetId = (*hJetIDMap)[ jptj->getCaloJetRef() ];
390  ajet.setJetID( jetId );
391  }
392  if ( useUserData_ ) {
393  userDataHelper_.add( ajet, iEvent, iSetup );
394  }
395  patJets->push_back(ajet);
396  }
397 
398  // sort jets in pt
399  std::sort(patJets->begin(), patJets->end(), pTComparator_);
400 
401  // put genEvt in Event
402  iEvent.put(patJets);
403 
404  iEvent.put( genJetsOut, "genJets" );
405  iEvent.put( caloTowersOut, "caloTowers" );
406  iEvent.put( pfCandidatesOut, "pfCandidates" );
407  iEvent.put( tagInfosOut, "tagInfos" );
408 
409 
410 }
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:86
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:275
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:249
std::vector< edm::InputTag > jetCorrFactorsSrc_
Ptr< value_type > ptrAt(size_type i) const
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:157
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:29
Class for the storage of jet correction factors.
std::vector< edm::InputTag > discriminatorTags_
bool first
Definition: L1TdeRCT.cc:79
Container::value_type value_type
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
RefProd< PROD > getRefBeforePut()
Definition: Event.h:96
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:68
std::vector< edm::FwdPtr< reco::PFCandidate > > PFCandidateFwdPtrCollection
Definition: Jet.h:67
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:71
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 82 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addBTagInfo_
private

Definition at line 75 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addDiscriminators_
private

Definition at line 76 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addEfficiencies_
private

Definition at line 92 of file PATJetProducer.h.

Referenced by PATJetProducer().

bool pat::PATJetProducer::addGenJetMatch_
private

Definition at line 67 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addGenPartonMatch_
private

Definition at line 64 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetCharge_
private

Definition at line 84 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetCorrFactors_
private

Definition at line 72 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetID_
private

Definition at line 86 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addPartonJetMatch_
private

Definition at line 70 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addResolutions_
private

Definition at line 95 of file PATJetProducer.h.

Referenced by PATJetProducer().

bool pat::PATJetProducer::addTagInfos_
private

Definition at line 79 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 90 of file PATJetProducer.h.

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

Definition at line 78 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 77 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 93 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 68 of file PATJetProducer.h.

Referenced by PATJetProducer().

bool pat::PATJetProducer::embedGenPartonMatch_
private

Definition at line 65 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 69 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 66 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 85 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 73 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 87 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 63 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 71 of file PATJetProducer.h.

Referenced by PATJetProducer().

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

Definition at line 89 of file PATJetProducer.h.

Referenced by produce().

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

Definition at line 96 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 81 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 80 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 83 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 99 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::useUserData_
private

Definition at line 98 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().