CMS 3D CMS Logo

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

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

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

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

Public Member Functions

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

Static Public Member Functions

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

Private Attributes

bool addAssociatedTracks_
 
bool addBTagInfo_
 
bool addDiscriminators_
 
bool addEfficiencies_
 
bool addGenJetMatch_
 
bool addGenPartonMatch_
 
bool addJetCharge_
 
bool addJetCorrFactors_
 
bool 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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Produces pat::Jet's.

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

Author
Steven Lowette, Jeremy Andrea
Version
Id:
PATJetProducer.h,v 1.27 2013/02/27 23:26:56 wmtan Exp

Definition at line 45 of file PATJetProducer.h.

Constructor & Destructor Documentation

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

Definition at line 43 of file PATJetProducer.cc.

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

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

124  {
125 
126 }

Member Function Documentation

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

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

404 {
406  iDesc.setComment("PAT jet producer module");
407 
408  // input source
409  iDesc.add<edm::InputTag>("jetSource", edm::InputTag("no default"))->setComment("input collection");
410 
411  // embedding
412  iDesc.addOptional<bool>("embedCaloTowers", false)->setComment("embed external CaloTowers (not to be used on AOD input)");
413  iDesc.add<bool>("embedPFCandidates", true)->setComment("embed external PFCandidates");
414 
415  // MC matching configurables
416  iDesc.add<bool>("addGenPartonMatch", true)->setComment("add MC matching");
417  iDesc.add<bool>("embedGenPartonMatch", false)->setComment("embed MC matched MC information");
418  iDesc.add<edm::InputTag>("genPartonMatch", edm::InputTag())->setComment("input with MC match information");
419 
420  iDesc.add<bool>("addGenJetMatch", true)->setComment("add MC matching");
421  iDesc.add<bool>("embedGenJetMatch", false)->setComment("embed MC matched MC information");
422  iDesc.add<edm::InputTag>("genJetMatch", edm::InputTag())->setComment("input with MC match information");
423 
424  iDesc.add<bool>("addJetCharge", true);
425  iDesc.add<edm::InputTag>("jetChargeSource", edm::InputTag("patJetCharge"));
426 
427  // jet id
428  iDesc.add<bool>("addJetID", true)->setComment("Add jet ID information");
429  iDesc.add<edm::InputTag>("jetIDMap", edm::InputTag())->setComment("jet id map");
430 
431  iDesc.add<bool>("addPartonJetMatch", false);
432  iDesc.add<edm::InputTag>("partonJetSource", edm::InputTag("NOT IMPLEMENTED"));
433 
434  // track association
435  iDesc.add<bool>("addAssociatedTracks", true);
436  iDesc.add<edm::InputTag>("trackAssociationSource", edm::InputTag("ic5JetTracksAssociatorAtVertex"));
437 
438  // tag info
439  iDesc.add<bool>("addTagInfos", true);
440  std::vector<edm::InputTag> emptyVInputTags;
441  iDesc.add<std::vector<edm::InputTag> >("tagInfoSources", emptyVInputTags);
442 
443  // jet energy corrections
444  iDesc.add<bool>("addJetCorrFactors", true);
445  iDesc.add<std::vector<edm::InputTag> >("jetCorrFactorsSource", emptyVInputTags);
446 
447  // btag discriminator tags
448  iDesc.add<bool>("addBTagInfo",true);
449  iDesc.add<bool>("addDiscriminators", true);
450  iDesc.add<std::vector<edm::InputTag> >("discriminatorSources", emptyVInputTags);
451 
452  // jet flavour idetification configurables
453  iDesc.add<bool>("getJetMCFlavour", true);
454  iDesc.add<edm::InputTag>("JetPartonMapSource", edm::InputTag("jetFlavourAssociation"));
455 
457 
458  // Efficiency configurables
459  edm::ParameterSetDescription efficienciesPSet;
460  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
461  iDesc.add("efficiencies", efficienciesPSet);
462  iDesc.add<bool>("addEfficiencies", false);
463 
464  // Check to see if the user wants to add user data
465  edm::ParameterSetDescription userDataPSet;
467  iDesc.addOptional("userData", userDataPSet);
468 
469  descriptions.add("PATJetProducer", iDesc);
470 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void setAllowAnything()
allow any parameter label/value pairs
static void fillDescription(edm::ParameterSetDescription &iDesc)
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void PATJetProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 129 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, customizeTrackingMonitorSeedNumber::idx, pat::Jet::initializeJEC(), edm::Ref< C, T, F >::isAvailable(), pat::Jet::isCaloJet(), pat::Jet::isJPTJet(), edm::Ptr< T >::isNonnull(), edm::Ref< C, T, F >::isNonnull(), pat::Jet::isPFJet(), edm::EventBase::isRealData(), metsig::jet, 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.

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