CMS 3D CMS Logo

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

List of all members.

Public Member Functions

 PATJetProducer (const edm::ParameterSet &iConfig)
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 ~PATJetProducer ()

Private Attributes

bool addAssociatedTracks_
bool addBTagInfo_
bool addDiscriminators_
bool addEfficiencies_
bool addGenJetMatch_
bool addGenPartonMatch_
bool addJetCharge_
bool addJetCorrFactors_
bool addPartonJetMatch_
bool addResolutions_
bool addTagInfos_
bool addTrigMatch_
std::vector< std::string > discriminatorLabels_
std::vector< edm::InputTagdiscriminatorTags_
pat::helper::EfficiencyLoader efficiencyLoader_
bool embedCaloTowers_
bool embedGenPartonMatch_
edm::InputTag genJetSrc_
edm::InputTag genPartonSrc_
bool getJetMCFlavour_
edm::InputTag jetCharge_
std::vector< edm::InputTagjetCorrFactorsSrc_
edm::InputTag jetPartonMapSource_
edm::InputTag jetsSrc_
edm::InputTag partonJetSrc_
GreaterByPt< JetpTComparator_
std::vector< std::string > tagInfoLabels_
std::vector< edm::InputTagtagInfoTags_
edm::InputTag trackAssociation_
std::vector< edm::InputTagtrigMatchSrc_
pat::PATUserDataHelper< pat::JetuserDataHelper_
bool useUserData_


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.10.4.5 2009/01/22 12:08:59 gpetrucc Exp

Definition at line 42 of file PATJetProducer.h.


Constructor & Destructor Documentation

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

Definition at line 41 of file PATJetProducer.cc.

References addAssociatedTracks_, addBTagInfo_, addDiscriminators_, addEfficiencies_, addGenJetMatch_, addGenPartonMatch_, addJetCharge_, addJetCorrFactors_, addPartonJetMatch_, addResolutions_, addTagInfos_, addTrigMatch_, discriminatorLabels_, discriminatorTags_, efficiencyLoader_, embedCaloTowers_, embedGenPartonMatch_, edm::ParameterSet::exists(), genJetSrc_, genPartonSrc_, getJetMCFlavour_, edm::ParameterSet::getParameter(), it, jetCharge_, jetCorrFactorsSrc_, jetPartonMapSource_, jetsSrc_, label, partonJetSrc_, tagInfoLabels_, tagInfoTags_, trackAssociation_, trigMatchSrc_, and useUserData_.

00041                                                               :
00042   userDataHelper_ ( iConfig.getParameter<edm::ParameterSet>("userData") )
00043 {
00044   // initialize the configurables
00045   jetsSrc_                 = iConfig.getParameter<edm::InputTag>              ( "jetSource" );
00046   embedCaloTowers_         = iConfig.getParameter<bool>                       ( "embedCaloTowers" );
00047   getJetMCFlavour_         = iConfig.getParameter<bool>                       ( "getJetMCFlavour" );
00048   jetPartonMapSource_      = iConfig.getParameter<edm::InputTag>              ( "JetPartonMapSource" );
00049   addGenPartonMatch_       = iConfig.getParameter<bool>                       ( "addGenPartonMatch" );
00050   embedGenPartonMatch_     = iConfig.getParameter<bool>                       ( "embedGenPartonMatch" );
00051   genPartonSrc_            = iConfig.getParameter<edm::InputTag>              ( "genPartonMatch" );
00052   addGenJetMatch_          = iConfig.getParameter<bool>                       ( "addGenJetMatch" );
00053   genJetSrc_               = iConfig.getParameter<edm::InputTag>              ( "genJetMatch" );
00054   addPartonJetMatch_       = iConfig.getParameter<bool>                       ( "addPartonJetMatch" );
00055   partonJetSrc_            = iConfig.getParameter<edm::InputTag>              ( "partonJetSource" );
00056   addJetCorrFactors_       = iConfig.getParameter<bool>                       ( "addJetCorrFactors" );
00057   jetCorrFactorsSrc_       = iConfig.getParameter<std::vector<edm::InputTag> >( "jetCorrFactorsSource" );
00058   addTrigMatch_            = iConfig.getParameter<bool>                       ( "addTrigMatch" );
00059   trigMatchSrc_            = iConfig.getParameter<std::vector<edm::InputTag> >( "trigPrimMatch" );
00060   addResolutions_          = iConfig.getParameter<bool>                       ( "addResolutions" );
00061   addBTagInfo_             = iConfig.getParameter<bool>                       ( "addBTagInfo" );
00062   addDiscriminators_       = iConfig.getParameter<bool>                       ( "addDiscriminators" );
00063   discriminatorTags_       = iConfig.getParameter<std::vector<edm::InputTag> >( "discriminatorSources" );
00064   addTagInfos_             = iConfig.getParameter<bool>                       ( "addTagInfos" );
00065   tagInfoTags_             = iConfig.getParameter<std::vector<edm::InputTag> >( "tagInfoSources" );
00066   addAssociatedTracks_     = iConfig.getParameter<bool>                       ( "addAssociatedTracks" ); 
00067   trackAssociation_        = iConfig.getParameter<edm::InputTag>              ( "trackAssociationSource" );
00068   addJetCharge_            = iConfig.getParameter<bool>                       ( "addJetCharge" ); 
00069   jetCharge_               = iConfig.getParameter<edm::InputTag>              ( "jetChargeSource" );
00070 
00071   // Efficiency configurables
00072   addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
00073   if (addEfficiencies_) {
00074      efficiencyLoader_ = pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"));
00075   }
00076 
00077 
00078   if (discriminatorTags_.empty()) { 
00079     addDiscriminators_ = false; 
00080   } else {
00081     for (std::vector<edm::InputTag>::const_iterator it = discriminatorTags_.begin(), ed = discriminatorTags_.end(); it != ed; ++it) {
00082         std::string label = it->label();
00083         std::string::size_type pos = label.find("JetTags");
00084         if ((pos !=  std::string::npos) && (pos != label.length() - 7)) {
00085             label.erase(pos+7); // trim a tail after "JetTags"
00086         }
00087         discriminatorLabels_.push_back(label);
00088     }
00089   }
00090   if (tagInfoTags_.empty()) { 
00091     addTagInfos_ = false; 
00092   } else {
00093     for (std::vector<edm::InputTag>::const_iterator it = tagInfoTags_.begin(), ed = tagInfoTags_.end(); it != ed; ++it) {
00094         std::string label = it->label();
00095         std::string::size_type pos = label.find("TagInfos");
00096         if ((pos !=  std::string::npos) && (pos != label.length() - 8)) {
00097             label.erase(pos+8); // trim a tail after "TagInfos"
00098         }
00099         tagInfoLabels_.push_back(label);
00100     }
00101   }
00102 
00103   if (!addBTagInfo_) { addDiscriminators_ = false; addTagInfos_ = false; }
00104 
00105   // Check to see if the user wants to add user data
00106   useUserData_ = false;
00107   if ( iConfig.exists("userData") ) {
00108     useUserData_ = true;
00109   }
00110 
00111   // produces vector of jets
00112   produces<std::vector<Jet> >();
00113 }

PATJetProducer::~PATJetProducer (  ) 

Definition at line 116 of file PATJetProducer.cc.

00116                                 {
00117 
00118 }


Member Function Documentation

void PATJetProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 121 of file PATJetProducer.cc.

References pat::PATUserDataHelper< ObjectType >::add(), addAssociatedTracks_, pat::Jet::addBDiscriminatorPair(), addBTagInfo_, pat::Jet::addCorrFactors(), addDiscriminators_, addGenJetMatch_, addGenPartonMatch_, addJetCharge_, addJetCorrFactors_, addPartonJetMatch_, pat::Jet::addTagInfo(), addTagInfos_, pat::PATObject< ObjectType >::addTriggerMatch(), addTrigMatch_, edm::View< T >::begin(), discriminatorLabels_, discriminatorTags_, efficiencyLoader_, embedCaloTowers_, embedGenPartonMatch_, pat::helper::EfficiencyLoader::enabled(), edm::View< T >::end(), genJetSrc_, genPartonSrc_, edm::RefToBase< T >::get(), edm::Event::getByLabel(), reco::CaloJet::getCaloConstituents(), getJetMCFlavour_, i, edm::Ref< C, T, F >::isAvailable(), pat::Jet::isCaloJet(), edm::Ref< C, T, F >::isNonnull(), metsig::jet, jetCharge_, jetCorrFactorsSrc_, jetPartonMapSource_, jetRef, pfTauBenchmarkGeneric_cfi::jets, jetsSrc_, k, pat::JetCorrFactors::L3, edm::match(), pat::helper::EfficiencyLoader::newEvent(), pTComparator_, edm::Event::put(), pat::Jet::setAssociatedTracks(), pat::Jet::setCaloTowers(), pat::Jet::setCorrFactors(), pat::Jet::setCorrStep(), pat::helper::EfficiencyLoader::setEfficiencies(), pat::Jet::setGenJet(), pat::Jet::setGenParton(), pat::Jet::setJetCharge(), pat::Jet::setPartonFlavour(), edm::View< T >::size(), python::multivaluedict::sort(), tagInfoLabels_, tagInfoTags_, trackAssociation_, trigMatchSrc_, userDataHelper_, useUserData_, and value.

00121                                                                             {
00122 
00123   // Get the vector of jets
00124   edm::Handle<edm::View<JetType> > jets;
00125   iEvent.getByLabel(jetsSrc_, jets);
00126 
00127   if (efficiencyLoader_.enabled()) efficiencyLoader_.newEvent(iEvent);
00128 
00129   // for jet flavour
00130   edm::Handle<reco::JetFlavourMatchingCollection> jetFlavMatch;
00131   if (getJetMCFlavour_) iEvent.getByLabel (jetPartonMapSource_, jetFlavMatch);
00132 
00133   // Get the vector of generated particles from the event if needed
00134   edm::Handle<edm::Association<reco::GenParticleCollection> > partonMatch;
00135   if (addGenPartonMatch_) iEvent.getByLabel(genPartonSrc_,  partonMatch);
00136   // Get the vector of GenJets from the event if needed
00137   edm::Handle<edm::Association<reco::GenJetCollection> > genJetMatch;
00138   if (addGenJetMatch_) iEvent.getByLabel(genJetSrc_, genJetMatch);
00139 /* TO BE IMPLEMENTED FOR >= 1_5_X
00140   // Get the vector of PartonJets from the event if needed
00141   edm::Handle<edm::View<reco::SomePartonJetType> > partonJets;
00142   if (addPartonJetMatch_) iEvent.getByLabel(partonJetSrc_, partonJets);
00143 */
00144 
00145   // read in the jet correction factors ValueMaps
00146   std::vector<edm::ValueMap<JetCorrFactors> > jetCorrs;
00147   if (addJetCorrFactors_) {
00148     for ( size_t i = 0; i < jetCorrFactorsSrc_.size(); ++i ) {
00149       edm::Handle<edm::ValueMap<JetCorrFactors> > jetCorr;
00150       iEvent.getByLabel(jetCorrFactorsSrc_[i], jetCorr);
00151       jetCorrs.push_back( *jetCorr );
00152     }
00153   }  
00154 
00155   // Get the vector of jet tags with b-tagging info
00156   std::vector<edm::Handle<reco::JetFloatAssociation::Container> > jetDiscriminators;
00157   if (addBTagInfo_ && addDiscriminators_) {
00158     jetDiscriminators.resize(discriminatorTags_.size());
00159     for (size_t i = 0; i < discriminatorTags_.size(); ++i) {
00160         iEvent.getByLabel(discriminatorTags_[i], jetDiscriminators[i]);
00161     }
00162   }
00163   std::vector<edm::Handle<edm::View<reco::BaseTagInfo> > > jetTagInfos;
00164   if (addBTagInfo_ && addTagInfos_) {
00165     jetTagInfos.resize(tagInfoTags_.size());
00166     for (size_t i = 0; i < tagInfoTags_.size(); ++i) {
00167         iEvent.getByLabel(tagInfoTags_[i], jetTagInfos[i]);
00168     }
00169   }
00170  
00171   // tracks Jet Track Association
00172   edm::Handle<reco::JetTracksAssociation::Container > hTrackAss;
00173   if (addAssociatedTracks_) iEvent.getByLabel(trackAssociation_, hTrackAss);
00174   edm::Handle<reco::JetFloatAssociation::Container > hJetChargeAss;
00175   if (addJetCharge_) iEvent.getByLabel(jetCharge_, hJetChargeAss);
00176 
00177   // loop over jets
00178   std::vector<Jet> * patJets = new std::vector<Jet>(); 
00179   for (edm::View<JetType>::const_iterator itJet = jets->begin(); itJet != jets->end(); itJet++) {
00180 
00181     // construct the Jet from the ref -> save ref to original object
00182     unsigned int idx = itJet - jets->begin();
00183     edm::RefToBase<JetType> jetRef = jets->refAt(idx);
00184     edm::Ptr<JetType> jetPtr = jets->ptrAt(idx); 
00185     Jet ajet(jetRef);
00186 
00187     // ensure the internal storage of the jet constituents
00188     if (ajet.isCaloJet() && embedCaloTowers_) {
00189         const reco::CaloJet *cj = dynamic_cast<const reco::CaloJet *>(jetRef.get());
00190         ajet.setCaloTowers( cj->getCaloConstituents() );
00191     }
00192 
00193     // add jet energy scale corrections
00194     if (addJetCorrFactors_) {
00195       // in case only one set of jet correction factors is used, clear the string
00196       // that contains the name of the jcf-module, to save storage per jet:
00197       if (jetCorrFactorsSrc_.size()<=1)
00198         jetCorrs.front()[jetRef].clearLabel();
00199       // The default jet correction is the first in the vector
00200       const JetCorrFactors & jcf = jetCorrs.front()[jetRef];
00201       // uncomment for debugging
00202       // jcf.print();
00203       //attach first (default) jet correction factors set to the jet
00204       ajet.setCorrFactors(jcf);
00205       // set current default which is JetCorrFactors::L3, change P4 of ajet 
00206       ajet.setCorrStep(JetCorrFactors::L3);
00207       
00208       // add additional JetCorrs for syst. studies, if present
00209       for ( size_t i = 1; i < jetCorrFactorsSrc_.size(); ++i ) {
00210         const JetCorrFactors & jcf = jetCorrs[i][jetRef];
00211         ajet.addCorrFactors(jcf);
00212       }
00213     }
00214 
00215     // get the MC flavour information for this jet
00216     if (getJetMCFlavour_) {
00217         ajet.setPartonFlavour( (*jetFlavMatch)[edm::RefToBase<reco::Jet>(jetRef)].getFlavour() );
00218     }
00219     // store the match to the generated partons
00220     if (addGenPartonMatch_) {
00221       reco::GenParticleRef parton = (*partonMatch)[jetRef];
00222       if (parton.isNonnull() && parton.isAvailable()) {
00223           ajet.setGenParton(parton, embedGenPartonMatch_);
00224       } // leave empty if no match found
00225     }
00226     // store the match to the GenJets
00227     if (addGenJetMatch_) {
00228       reco::GenJetRef genjet = (*genJetMatch)[jetRef];
00229       if (genjet.isNonnull() && genjet.isAvailable()) {
00230           ajet.setGenJet(*genjet);
00231       } // leave empty if no match found
00232     }
00233 
00234     if (efficiencyLoader_.enabled()) {
00235         efficiencyLoader_.setEfficiencies( ajet, jetRef );
00236     }
00237 
00238     // TO BE IMPLEMENTED FOR >=1_5_X: do the PartonJet matching
00239     if (addPartonJetMatch_) {
00240     }
00241     
00242     // matches to trigger primitives
00243     if ( addTrigMatch_ ) {
00244       for ( size_t i = 0; i < trigMatchSrc_.size(); ++i ) {
00245         edm::Handle<edm::Association<TriggerPrimitiveCollection> > trigMatch;
00246         iEvent.getByLabel(trigMatchSrc_[i], trigMatch);
00247         TriggerPrimitiveRef trigPrim = (*trigMatch)[jetRef];
00248         if ( trigPrim.isNonnull() && trigPrim.isAvailable() ) {
00249           ajet.addTriggerMatch(*trigPrim);
00250         }
00251       }
00252     }
00253 
00254     // add b-tag info if available & required
00255     if (addBTagInfo_) {
00256         if (addDiscriminators_) {
00257             for (size_t k=0; k<jetDiscriminators.size(); ++k) {
00258                 float value = (*jetDiscriminators[k])[jetRef];
00259                 ajet.addBDiscriminatorPair(std::make_pair(discriminatorLabels_[k], value));
00260             }
00261         }    
00262         if (addTagInfos_) {
00263             for (size_t k=0; k<jetTagInfos.size(); ++k) {
00264                 const edm::View<reco::BaseTagInfo> & taginfos = *jetTagInfos[k];
00265                 // This is not associative, so we have to search the jet
00266                 const reco::BaseTagInfo * match = 0;
00267                 // Try first by 'same index'
00268                 if ((idx < taginfos.size()) && (taginfos[idx].jet() == jetRef)) {
00269                     match = &taginfos[idx];
00270                 } else {
00271                     // otherwise fail back to a simple search
00272                     for (edm::View<reco::BaseTagInfo>::const_iterator itTI = taginfos.begin(), edTI = taginfos.end(); itTI != edTI; ++itTI) {
00273                         if (itTI->jet() == jetRef) { match = &*itTI; break; }
00274                     }
00275                 }
00276                 if (match != 0) ajet.addTagInfo(tagInfoLabels_[k], *match);
00277             }
00278         }    
00279     }
00280     
00281     if (addAssociatedTracks_) ajet.setAssociatedTracks( (*hTrackAss)[jetRef] );
00282 
00283     if (addJetCharge_)        ajet.setJetCharge( (*hJetChargeAss)[jetRef] );
00284 
00285 
00286     if ( useUserData_ ) {
00287       userDataHelper_.add( ajet, iEvent, iSetup );
00288     }
00289     
00290 
00291     patJets->push_back(ajet);
00292   }
00293 
00294   // sort jets in Et
00295   std::sort(patJets->begin(), patJets->end(), pTComparator_);
00296 
00297   // put genEvt  in Event
00298   std::auto_ptr<std::vector<Jet> > myJets(patJets);
00299   iEvent.put(myJets);
00300 
00301 }


Member Data Documentation

bool pat::PATJetProducer::addAssociatedTracks_ [private]

Definition at line 77 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addBTagInfo_ [private]

Definition at line 70 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addDiscriminators_ [private]

Definition at line 71 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addEfficiencies_ [private]

Definition at line 84 of file PATJetProducer.h.

Referenced by PATJetProducer().

bool pat::PATJetProducer::addGenJetMatch_ [private]

Definition at line 61 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addGenPartonMatch_ [private]

Definition at line 58 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetCharge_ [private]

Definition at line 79 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addJetCorrFactors_ [private]

Definition at line 65 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addPartonJetMatch_ [private]

Definition at line 63 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addResolutions_ [private]

Definition at line 87 of file PATJetProducer.h.

Referenced by PATJetProducer().

bool pat::PATJetProducer::addTagInfos_ [private]

Definition at line 74 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::addTrigMatch_ [private]

Definition at line 67 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 73 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 72 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

pat::helper::EfficiencyLoader pat::PATJetProducer::efficiencyLoader_ [private]

Definition at line 85 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::embedCaloTowers_ [private]

Definition at line 55 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::embedGenPartonMatch_ [private]

Definition at line 59 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::genJetSrc_ [private]

Definition at line 62 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::genPartonSrc_ [private]

Definition at line 60 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

bool pat::PATJetProducer::getJetMCFlavour_ [private]

Definition at line 56 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::jetCharge_ [private]

Definition at line 80 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 66 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::jetPartonMapSource_ [private]

Definition at line 57 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::jetsSrc_ [private]

Definition at line 54 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::partonJetSrc_ [private]

Definition at line 64 of file PATJetProducer.h.

Referenced by PATJetProducer().

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

Definition at line 82 of file PATJetProducer.h.

Referenced by produce().

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

Definition at line 76 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 75 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

edm::InputTag pat::PATJetProducer::trackAssociation_ [private]

Definition at line 78 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

std::vector<edm::InputTag> pat::PATJetProducer::trigMatchSrc_ [private]

Definition at line 68 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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

Definition at line 90 of file PATJetProducer.h.

Referenced by produce().

bool pat::PATJetProducer::useUserData_ [private]

Definition at line 89 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:49:43 2009 for CMSSW by  doxygen 1.5.4