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 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.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 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_, diffTwoXMLs::label, partonJetSrc_, pos, resolutionLoader_, tagInfoLabels_, tagInfoTags_, trackAssociation_, userDataHelper_, and useUserData_.

45  :
46  useUserData_(iConfig.exists("userData"))
47 {
48  // initialize 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  // Efficiency configurables
76  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
77  if (addEfficiencies_) {
79  }
80  // Resolution configurables
81  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
82  if (addResolutions_) {
84  }
85  if (discriminatorTags_.empty()) {
86  addDiscriminators_ = false;
87  } else {
88  for (std::vector<edm::InputTag>::const_iterator it = discriminatorTags_.begin(), ed = discriminatorTags_.end(); it != ed; ++it) {
89  std::string label = it->label();
90  std::string::size_type pos = label.find("JetTags");
91  if ((pos != std::string::npos) && (pos != label.length() - 7)) {
92  label.erase(pos+7); // trim a tail after "JetTags"
93  }
94  discriminatorLabels_.push_back(label);
95  }
96  }
97  if (tagInfoTags_.empty()) {
98  addTagInfos_ = false;
99  } else {
100  for (std::vector<edm::InputTag>::const_iterator it = tagInfoTags_.begin(), ed = tagInfoTags_.end(); it != ed; ++it) {
101  std::string label = it->label();
102  std::string::size_type pos = label.find("TagInfos");
103  if ((pos != std::string::npos) && (pos != label.length() - 8)) {
104  label.erase(pos+8); // trim a tail after "TagInfos"
105  }
106  tagInfoLabels_.push_back(label);
107  }
108  }
109  if (!addBTagInfo_) { addDiscriminators_ = false; addTagInfos_ = false; }
110  // Check to see if the user wants to add user data
111  if ( useUserData_ ) {
113  }
114  // produces vector of jets
115  produces<std::vector<Jet> >();
116  produces<reco::GenJetCollection> ("genJets");
117  produces<std::vector<CaloTower> > ("caloTowers");
118  produces<reco::PFCandidateCollection > ("pfCandidates");
119  produces<edm::OwnVector<reco::BaseTagInfo> > ("tagInfos");
120 }
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 genPartonSrc_
edm::InputTag jetPartonMapSource_
PATJetProducer::~PATJetProducer ( )

Definition at line 123 of file PATJetProducer.cc.

123  {
124 
125 }

Member Function Documentation

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

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

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

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