CMS 3D CMS Logo

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

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

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

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

Public Member Functions

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

Static Public Member Functions

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

Private Attributes

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

Additional Inherited Members

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

Detailed Description

Produces pat::Jet's.

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

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

Definition at line 46 of file PATJetProducer.h.

Constructor & Destructor Documentation

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

Definition at line 43 of file PATJetProducer.cc.

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

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

Definition at line 126 of file PATJetProducer.cc.

126  {
127 
128 }

Member Function Documentation

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

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

406 {
408  iDesc.setComment("PAT jet producer module");
409 
410  // input source
411  iDesc.add<edm::InputTag>("jetSource", edm::InputTag("no default"))->setComment("input collection");
412 
413  // embedding
414  iDesc.addOptional<bool>("embedCaloTowers", false)->setComment("embed external CaloTowers (not to be used on AOD input)");
415  iDesc.add<bool>("embedPFCandidates", true)->setComment("embed external PFCandidates");
416 
417  // MC matching configurables
418  iDesc.add<bool>("addGenPartonMatch", true)->setComment("add MC matching");
419  iDesc.add<bool>("embedGenPartonMatch", false)->setComment("embed MC matched MC information");
420  iDesc.add<edm::InputTag>("genPartonMatch", edm::InputTag())->setComment("input with MC match information");
421 
422  iDesc.add<bool>("addGenJetMatch", true)->setComment("add MC matching");
423  iDesc.add<bool>("embedGenJetMatch", false)->setComment("embed MC matched MC information");
424  iDesc.add<edm::InputTag>("genJetMatch", edm::InputTag())->setComment("input with MC match information");
425 
426  iDesc.add<bool>("addJetCharge", true);
427  iDesc.add<edm::InputTag>("jetChargeSource", edm::InputTag("patJetCharge"));
428 
429  // jet id
430  iDesc.add<bool>("addJetID", true)->setComment("Add jet ID information");
431  iDesc.add<edm::InputTag>("jetIDMap", edm::InputTag())->setComment("jet id map");
432 
433  iDesc.add<bool>("addPartonJetMatch", false);
434  iDesc.add<edm::InputTag>("partonJetSource", edm::InputTag("NOT IMPLEMENTED"));
435 
436  // track association
437  iDesc.add<bool>("addAssociatedTracks", true);
438  iDesc.add<edm::InputTag>("trackAssociationSource", edm::InputTag("ic5JetTracksAssociatorAtVertex"));
439 
440  // tag info
441  iDesc.add<bool>("addTagInfos", true);
442  std::vector<edm::InputTag> emptyVInputTags;
443  iDesc.add<std::vector<edm::InputTag> >("tagInfoSources", emptyVInputTags);
444 
445  // jet energy corrections
446  iDesc.add<bool>("addJetCorrFactors", true);
447  iDesc.add<std::vector<edm::InputTag> >("jetCorrFactorsSource", emptyVInputTags);
448 
449  // btag discriminator tags
450  iDesc.add<bool>("addBTagInfo",true);
451  iDesc.add<bool>("addDiscriminators", true);
452  iDesc.add<std::vector<edm::InputTag> >("discriminatorSources", emptyVInputTags);
453 
454  // jet flavour idetification configurables
455  iDesc.add<bool>("getJetMCFlavour", true);
456  iDesc.add<edm::InputTag>("JetPartonMapSource", edm::InputTag("jetFlavourAssociation"));
457 
459 
460  // Efficiency configurables
461  edm::ParameterSetDescription efficienciesPSet;
462  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
463  iDesc.add("efficiencies", efficienciesPSet);
464  iDesc.add<bool>("addEfficiencies", false);
465 
466  // Check to see if the user wants to add user data
467  edm::ParameterSetDescription userDataPSet;
469  iDesc.addOptional("userData", userDataPSet);
470 
471  descriptions.add("PATJetProducer", iDesc);
472 }
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 131 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_, discriminatorTokens_, efficiencyLoader_, embedCaloTowers_, embedGenPartonMatch_, embedPFCandidates_, pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), edm::View< T >::end(), spr::find(), first, genJetToken_, genPartonToken_, edm::RefToBase< T >::get(), edm::Event::getByToken(), reco::CaloJet::getCaloConstituents(), reco::JPTJet::getCaloJetRef(), getJetMCFlavour_, reco::PFJet::getPFConstituents(), edm::Event::getRefBeforePut(), i, customizeTrackingMonitorSeedNumber::idx, pat::Jet::initializeJEC(), edm::Ref< C, T, F >::isAvailable(), pat::Jet::isCaloJet(), pat::Jet::isJPTJet(), edm::Ptr< T >::isNonnull(), edm::Ref< C, T, F >::isNonnull(), pat::Jet::isPFJet(), edm::EventBase::isRealData(), metsig::jet, jetChargeToken_, jetCorrFactorsTokens_, jetIDMapToken_, jetPartonMapToken_, fwrapper::jets, jetsToken_, gen::k, match(), pat::helper::EfficiencyLoader::newEvent(), pat::helper::KinResolutionsLoader::newEvent(), jetProducer_cfi::patJets, pTComparator_, edm::View< T >::ptrAt(), edm::Event::put(), resolutionLoader_, pat::Jet::setAssociatedTracks(), pat::Jet::setCaloTowers(), pat::helper::EfficiencyLoader::setEfficiencies(), pat::Jet::setGenJetRef(), pat::Jet::setGenParton(), pat::Jet::setJetCharge(), pat::Jet::setJetID(), pat::Jet::setPartonFlavour(), pat::Jet::setPFCandidates(), pat::helper::KinResolutionsLoader::setResolutions(), edm::View< T >::size(), python.multivaluedict::sort(), tagInfoLabels_, tagInfoTokens_, trackAssociationToken_, userDataHelper_, useUserData_, and relativeConstraints::value.

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

Member Data Documentation

bool pat::PATJetProducer::addAssociatedTracks_
private

Definition at line 85 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::addBTagInfo_
private

Definition at line 76 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::addDiscriminators_
private

Definition at line 77 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::addEfficiencies_
private

Definition at line 95 of file PATJetProducer.h.

bool pat::PATJetProducer::addGenJetMatch_
private

Definition at line 68 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addGenPartonMatch_
private

Definition at line 65 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetCharge_
private

Definition at line 87 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::addJetCorrFactors_
private

Definition at line 73 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetID_
private

Definition at line 89 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::addPartonJetMatch_
private

Definition at line 71 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addResolutions_
private

Definition at line 98 of file PATJetProducer.h.

bool pat::PATJetProducer::addTagInfos_
private

Definition at line 81 of file PATJetProducer.h.

Referenced by produce().

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

Definition at line 93 of file PATJetProducer.h.

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

Definition at line 80 of file PATJetProducer.h.

Referenced by produce().

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

Definition at line 78 of file PATJetProducer.h.

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

Definition at line 79 of file PATJetProducer.h.

Referenced by produce().

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

Definition at line 96 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::embedCaloTowers_
private

Definition at line 61 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::embedGenJetMatch_
private

Definition at line 69 of file PATJetProducer.h.

Referenced by PATJetProducer().

bool pat::PATJetProducer::embedGenPartonMatch_
private

Definition at line 66 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::embedPFCandidates_
private

Definition at line 62 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 70 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 67 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::getJetMCFlavour_
private

Definition at line 63 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 88 of file PATJetProducer.h.

Referenced by produce().

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

Definition at line 74 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 90 of file PATJetProducer.h.

Referenced by produce().

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

Definition at line 64 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 60 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 92 of file PATJetProducer.h.

Referenced by produce().

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

Definition at line 99 of file PATJetProducer.h.

Referenced by produce().

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

Definition at line 84 of file PATJetProducer.h.

Referenced by produce().

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

Definition at line 82 of file PATJetProducer.h.

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

Definition at line 83 of file PATJetProducer.h.

Referenced by produce().

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

Definition at line 86 of file PATJetProducer.h.

Referenced by produce().

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

Definition at line 102 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::useUserData_
private

Definition at line 101 of file PATJetProducer.h.

Referenced by produce().