CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Attributes

pat::PATJetProducer Class Reference

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

#include <PhysicsTools/PatAlgos/interface/PATJetProducer.h>

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

List of all members.

Public Member Functions

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

Static Public Member Functions

static void fillDescriptions (edm::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_

Detailed Description

Produces pat::Jet's.

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

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

Definition at line 45 of file PATJetProducer.h.


Constructor & Destructor Documentation

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

Definition at line 45 of file PATJetProducer.cc.

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

                                                              :
  useUserData_(iConfig.exists("userData"))
{
  // initialize the configurables
  jetsSrc_                 = iConfig.getParameter<edm::InputTag>              ( "jetSource" );
  embedCaloTowers_         = iConfig.getParameter<bool>                       ( "embedCaloTowers" );
  embedPFCandidates_       = iConfig.getParameter<bool>                       ( "embedPFCandidates" );
  getJetMCFlavour_         = iConfig.getParameter<bool>                       ( "getJetMCFlavour" );
  jetPartonMapSource_      = iConfig.getParameter<edm::InputTag>              ( "JetPartonMapSource" );
  addGenPartonMatch_       = iConfig.getParameter<bool>                       ( "addGenPartonMatch" );
  embedGenPartonMatch_     = iConfig.getParameter<bool>                       ( "embedGenPartonMatch" );
  genPartonSrc_            = iConfig.getParameter<edm::InputTag>              ( "genPartonMatch" );
  addGenJetMatch_          = iConfig.getParameter<bool>                       ( "addGenJetMatch" );
  embedGenJetMatch_        = iConfig.getParameter<bool>                       ( "embedGenJetMatch" );
  genJetSrc_               = iConfig.getParameter<edm::InputTag>              ( "genJetMatch" );
  addPartonJetMatch_       = iConfig.getParameter<bool>                       ( "addPartonJetMatch" );
  partonJetSrc_            = iConfig.getParameter<edm::InputTag>              ( "partonJetSource" );
  addJetCorrFactors_       = iConfig.getParameter<bool>                       ( "addJetCorrFactors" );
  jetCorrFactorsSrc_       = iConfig.getParameter<std::vector<edm::InputTag> >( "jetCorrFactorsSource" );
  addBTagInfo_             = iConfig.getParameter<bool>                       ( "addBTagInfo" );
  addDiscriminators_       = iConfig.getParameter<bool>                       ( "addDiscriminators" );
  discriminatorTags_       = iConfig.getParameter<std::vector<edm::InputTag> >( "discriminatorSources" );
  addTagInfos_             = iConfig.getParameter<bool>                       ( "addTagInfos" );
  tagInfoTags_             = iConfig.getParameter<std::vector<edm::InputTag> >( "tagInfoSources" );
  addAssociatedTracks_     = iConfig.getParameter<bool>                       ( "addAssociatedTracks" ); 
  trackAssociation_        = iConfig.getParameter<edm::InputTag>              ( "trackAssociationSource" );
  addJetCharge_            = iConfig.getParameter<bool>                       ( "addJetCharge" ); 
  jetCharge_               = iConfig.getParameter<edm::InputTag>              ( "jetChargeSource" );
  addJetID_                = iConfig.getParameter<bool>                       ( "addJetID");
  jetIDMapLabel_           = iConfig.getParameter<edm::InputTag>              ( "jetIDMap");

  // Efficiency configurables
  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
  if (addEfficiencies_) {
     efficiencyLoader_ = pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"));
  }

  // Resolution configurables
  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
  if (addResolutions_) {
     resolutionLoader_ = pat::helper::KinResolutionsLoader(iConfig.getParameter<edm::ParameterSet>("resolutions"));
  }


  if (discriminatorTags_.empty()) { 
    addDiscriminators_ = false; 
  } else {
    for (std::vector<edm::InputTag>::const_iterator it = discriminatorTags_.begin(), ed = discriminatorTags_.end(); it != ed; ++it) {
        std::string label = it->label();
        std::string::size_type pos = label.find("JetTags");
        if ((pos !=  std::string::npos) && (pos != label.length() - 7)) {
            label.erase(pos+7); // trim a tail after "JetTags"
        }
        discriminatorLabels_.push_back(label);
    }
  }
  if (tagInfoTags_.empty()) { 
    addTagInfos_ = false; 
  } else {
    for (std::vector<edm::InputTag>::const_iterator it = tagInfoTags_.begin(), ed = tagInfoTags_.end(); it != ed; ++it) {
        std::string label = it->label();
        std::string::size_type pos = label.find("TagInfos");
        if ((pos !=  std::string::npos) && (pos != label.length() - 8)) {
            label.erase(pos+8); // trim a tail after "TagInfos"
        }
        tagInfoLabels_.push_back(label);
    }
  }

  if (!addBTagInfo_) { addDiscriminators_ = false; addTagInfos_ = false; }

  // Check to see if the user wants to add user data
  if ( useUserData_ ) {
    userDataHelper_ = PATUserDataHelper<Jet>(iConfig.getParameter<edm::ParameterSet>("userData"));
  }

  // produces vector of jets
  produces<std::vector<Jet> >();
  produces<reco::GenJetCollection> ("genJets");
  produces<std::vector<CaloTower>  > ("caloTowers");
  produces<reco::PFCandidateCollection > ("pfCandidates");
  produces<edm::OwnVector<reco::BaseTagInfo> > ("tagInfos");
}
PATJetProducer::~PATJetProducer ( )

Definition at line 130 of file PATJetProducer.cc.

                                {

}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 413 of file PATJetProducer.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addOptional(), pat::helper::KinResolutionsLoader::fillDescription(), edm::ParameterSetDescription::setAllowAnything(), and edm::ParameterSetDescription::setComment().

{
  edm::ParameterSetDescription iDesc;
  iDesc.setComment("PAT jet producer module");

  // input source 
  iDesc.add<edm::InputTag>("jetSource", edm::InputTag("no default"))->setComment("input collection");

  // embedding
  iDesc.add<bool>("embedCaloTowers", true)->setComment("embed external calo towers");
  iDesc.add<bool>("embedPFCandidates", true)->setComment("embed external PFCandidates");

  // MC matching configurables
  iDesc.add<bool>("addGenPartonMatch", true)->setComment("add MC matching");
  iDesc.add<bool>("embedGenPartonMatch", false)->setComment("embed MC matched MC information");
  iDesc.add<edm::InputTag>("genPartonMatch", edm::InputTag())->setComment("input with MC match information");

  iDesc.add<bool>("addGenJetMatch", true)->setComment("add MC matching");
  iDesc.add<bool>("embedGenJetMatch", false)->setComment("embed MC matched MC information");
  iDesc.add<edm::InputTag>("genJetMatch", edm::InputTag())->setComment("input with MC match information");

  iDesc.add<bool>("addJetCharge", true);
  iDesc.add<edm::InputTag>("jetChargeSource", edm::InputTag("patJetCharge"));
  
  // jet id
  iDesc.add<bool>("addJetID", true)->setComment("Add jet ID information");
  iDesc.add<edm::InputTag>("jetIDMap", edm::InputTag())->setComment("jet id map");

  iDesc.add<bool>("addPartonJetMatch", false);
  iDesc.add<edm::InputTag>("partonJetSource", edm::InputTag("NOT IMPLEMENTED"));

  // track association
  iDesc.add<bool>("addAssociatedTracks", true);
  iDesc.add<edm::InputTag>("trackAssociationSource", edm::InputTag("ic5JetTracksAssociatorAtVertex"));

  // tag info
  iDesc.add<bool>("addTagInfos", true);
  std::vector<edm::InputTag> emptyVInputTags;
  iDesc.add<std::vector<edm::InputTag> >("tagInfoSources", emptyVInputTags);

  // jet energy corrections
  iDesc.add<bool>("addJetCorrFactors", true);
  iDesc.add<std::vector<edm::InputTag> >("jetCorrFactorsSource", emptyVInputTags);

  // btag discriminator tags
  iDesc.add<bool>("addBTagInfo",true);
  iDesc.add<bool>("addDiscriminators", true);
  iDesc.add<std::vector<edm::InputTag> >("discriminatorSources", emptyVInputTags);

  // jet flavour idetification configurables
  iDesc.add<bool>("getJetMCFlavour", true);
  iDesc.add<edm::InputTag>("JetPartonMapSource", edm::InputTag("jetFlavourAssociation"));

  pat::helper::KinResolutionsLoader::fillDescription(iDesc);

  // Efficiency configurables
  edm::ParameterSetDescription efficienciesPSet;
  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
  iDesc.add("efficiencies", efficienciesPSet);
  iDesc.add<bool>("addEfficiencies", false);

  // Check to see if the user wants to add user data
  edm::ParameterSetDescription userDataPSet;
  PATUserDataHelper<Jet>::fillDescription(userDataPSet);
  iDesc.addOptional("userData", userDataPSet);

  descriptions.add("PATJetProducer", iDesc);
}
void PATJetProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 135 of file PATJetProducer.cc.

References pat::PATUserDataHelper< ObjectType >::add(), 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::KinResolutionsLoader::enabled(), pat::helper::EfficiencyLoader::enabled(), edm::View< T >::end(), spr::find(), first, genJetSrc_, genPartonSrc_, edm::RefToBase< T >::get(), edm::Event::getByLabel(), reco::CaloJet::getCaloConstituents(), reco::JPTJet::getCaloJetRef(), getJetMCFlavour_, reco::PFJet::getPFConstituents(), edm::Event::getRefBeforePut(), i, pat::Jet::initializeJEC(), edm::Ref< C, T, F >::isAvailable(), pat::Jet::isCaloJet(), pat::Jet::isJPTJet(), edm::Ptr< T >::isNonnull(), edm::Ref< C, T, F >::isNonnull(), pat::Jet::isPFJet(), edm::EventBase::isRealData(), metsig::jet, jetCharge_, jetCorrFactorsSrc_, jetIDMapLabel_, jetPartonMapSource_, analyzePatCleaning_cfg::jets, jetsSrc_, gen::k, match(), pat::helper::EfficiencyLoader::newEvent(), pat::helper::KinResolutionsLoader::newEvent(), jetProducer_cfi::patJets, pTComparator_, edm::View< T >::ptrAt(), edm::Event::put(), resolutionLoader_, pat::Jet::setAssociatedTracks(), pat::Jet::setCaloTowers(), pat::helper::EfficiencyLoader::setEfficiencies(), pat::Jet::setGenJetRef(), pat::Jet::setGenParton(), pat::Jet::setJetCharge(), pat::Jet::setJetID(), pat::Jet::setPartonFlavour(), pat::Jet::setPFCandidates(), pat::helper::KinResolutionsLoader::setResolutions(), edm::View< T >::size(), python::multivaluedict::sort(), tagInfoLabels_, tagInfoTags_, trackAssociation_, userDataHelper_, useUserData_, and relativeConstraints::value.

                                                                            {

  // check whether dealing with MC or real data
  if (iEvent.isRealData()){
    getJetMCFlavour_ = false;
    addGenPartonMatch_ = false;
    addGenJetMatch_ = false;
    addPartonJetMatch_ = false;
  }

  // Get the vector of jets
  edm::Handle<edm::View<reco::Jet> > jets;
  iEvent.getByLabel(jetsSrc_, jets);

  if (efficiencyLoader_.enabled()) efficiencyLoader_.newEvent(iEvent);
  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);

  // for jet flavour
  edm::Handle<reco::JetFlavourMatchingCollection> jetFlavMatch;
  if (getJetMCFlavour_) iEvent.getByLabel (jetPartonMapSource_, jetFlavMatch);

  // Get the vector of generated particles from the event if needed
  edm::Handle<edm::Association<reco::GenParticleCollection> > partonMatch;
  if (addGenPartonMatch_) iEvent.getByLabel(genPartonSrc_,  partonMatch);
  // Get the vector of GenJets from the event if needed
  edm::Handle<edm::Association<reco::GenJetCollection> > genJetMatch;
  if (addGenJetMatch_) iEvent.getByLabel(genJetSrc_, genJetMatch);
/* TO BE IMPLEMENTED FOR >= 1_5_X
  // Get the vector of PartonJets from the event if needed
  edm::Handle<edm::View<reco::SomePartonJetType> > partonJets;
  if (addPartonJetMatch_) iEvent.getByLabel(partonJetSrc_, partonJets);
*/

  // read in the jet correction factors ValueMap
  std::vector<edm::ValueMap<JetCorrFactors> > jetCorrs;
  if (addJetCorrFactors_) {
    for ( size_t i = 0; i < jetCorrFactorsSrc_.size(); ++i ) {
      edm::Handle<edm::ValueMap<JetCorrFactors> > jetCorr;
      iEvent.getByLabel(jetCorrFactorsSrc_[i], jetCorr);
      jetCorrs.push_back( *jetCorr );
    }
  }  

  // Get the vector of jet tags with b-tagging info
  std::vector<edm::Handle<reco::JetFloatAssociation::Container> > jetDiscriminators;
  if (addBTagInfo_ && addDiscriminators_) {
    jetDiscriminators.resize(discriminatorTags_.size());
    for (size_t i = 0; i < discriminatorTags_.size(); ++i) {
        iEvent.getByLabel(discriminatorTags_[i], jetDiscriminators[i]);
    }
  }
  std::vector<edm::Handle<edm::View<reco::BaseTagInfo> > > jetTagInfos;
  if (addBTagInfo_ && addTagInfos_) {
    jetTagInfos.resize(tagInfoTags_.size());
    for (size_t i = 0; i < tagInfoTags_.size(); ++i) {
      iEvent.getByLabel(tagInfoTags_[i], jetTagInfos[i]);
    }
  }
 
  // tracks Jet Track Association
  edm::Handle<reco::JetTracksAssociation::Container > hTrackAss;
  if (addAssociatedTracks_) iEvent.getByLabel(trackAssociation_, hTrackAss);
  edm::Handle<reco::JetFloatAssociation::Container > hJetChargeAss;
  if (addJetCharge_) iEvent.getByLabel(jetCharge_, hJetChargeAss);

  // jet ID handle
  edm::Handle<reco::JetIDValueMap> hJetIDMap;
  if ( addJetID_ ) iEvent.getByLabel( jetIDMapLabel_, hJetIDMap );

  // loop over jets
  std::auto_ptr< std::vector<Jet> > patJets ( new std::vector<Jet>() ); 

  std::auto_ptr<reco::GenJetCollection > genJetsOut ( new reco::GenJetCollection() );
  std::auto_ptr<std::vector<CaloTower>  >  caloTowersOut( new std::vector<CaloTower> () );
  std::auto_ptr<reco::PFCandidateCollection > pfCandidatesOut( new reco::PFCandidateCollection() );
  std::auto_ptr<edm::OwnVector<reco::BaseTagInfo> > tagInfosOut ( new edm::OwnVector<reco::BaseTagInfo>() );  


  edm::RefProd<reco::GenJetCollection > h_genJetsOut = iEvent.getRefBeforePut<reco::GenJetCollection >( "genJets" );
  edm::RefProd<std::vector<CaloTower>  >  h_caloTowersOut = iEvent.getRefBeforePut<std::vector<CaloTower>  > ( "caloTowers" );
  edm::RefProd<reco::PFCandidateCollection > h_pfCandidatesOut = iEvent.getRefBeforePut<reco::PFCandidateCollection > ( "pfCandidates" );
  edm::RefProd<edm::OwnVector<reco::BaseTagInfo> > h_tagInfosOut = iEvent.getRefBeforePut<edm::OwnVector<reco::BaseTagInfo> > ( "tagInfos" );


  

  bool first=true; // this is introduced to issue warnings only for the first jet
  for (edm::View<reco::Jet>::const_iterator itJet = jets->begin(); itJet != jets->end(); itJet++) {

    // construct the Jet from the ref -> save ref to original object
    unsigned int idx = itJet - jets->begin();
    edm::RefToBase<reco::Jet> jetRef = jets->refAt(idx);
    edm::Ptr<reco::Jet> jetPtr = jets->ptrAt(idx); 
    Jet ajet(jetRef);

    // add the FwdPtrs to the CaloTowers
    if ( (ajet.isCaloJet() || ajet.isJPTJet() ) && embedCaloTowers_) {
      const reco::CaloJet *cj = 0;
      const reco::JPTJet * jptj = 0;
      if ( ajet.isCaloJet()) cj = dynamic_cast<const reco::CaloJet *>(jetRef.get());      
      else { 
        jptj = dynamic_cast<const reco::JPTJet *>(jetRef.get() );
        cj = dynamic_cast<const reco::CaloJet *>(jptj->getCaloJetRef().get() );
      }
      pat::CaloTowerFwdPtrCollection itowersRef;
      std::vector< CaloTowerPtr > itowers = cj->getCaloConstituents();
      for ( std::vector<CaloTowerPtr>::const_iterator towBegin = itowers.begin(),
              towEnd = itowers.end(), itow = towBegin;
            itow != towEnd; ++itow ) {
        caloTowersOut->push_back( **itow );
        // set the "forward" ref to the thinned collection
        edm::Ref<std::vector<CaloTower> > caloTowerRef( h_caloTowersOut, caloTowersOut->size() - 1);
        edm::Ptr<CaloTower> caloForwardRef ( h_caloTowersOut.id(), caloTowerRef.key(), h_caloTowersOut.productGetter() );
        // set the "backward" ref to the original collection for association
        edm::Ptr<CaloTower> caloBackRef ( *itow );      
        // add to the list of FwdPtr's
        itowersRef.push_back( pat::CaloTowerFwdPtrCollection::value_type ( caloForwardRef, caloBackRef ) );
        
      }
      ajet.setCaloTowers( itowersRef );
    }

    // add the FwdPtrs to the PFCandidates
    if (ajet.isPFJet() && embedPFCandidates_) {
      const reco::PFJet *cj = dynamic_cast<const reco::PFJet *>(jetRef.get());
      pat::PFCandidateFwdPtrCollection iparticlesRef;
      std::vector< reco::PFCandidatePtr > iparticles = cj->getPFConstituents();
      for ( std::vector<reco::PFCandidatePtr>::const_iterator partBegin = iparticles.begin(),
              partEnd = iparticles.end(), ipart = partBegin;
            ipart != partEnd; ++ipart ) {
        pfCandidatesOut->push_back( **ipart );
        // set the "forward" ref to the thinned collection
        edm::Ref<reco::PFCandidateCollection> pfCollectionRef( h_pfCandidatesOut, pfCandidatesOut->size() - 1);
        edm::Ptr<reco::PFCandidate> pfForwardRef ( h_pfCandidatesOut.id(), pfCollectionRef.key(),  h_pfCandidatesOut.productGetter() );
        // set the "backward" ref to the original collection for association
        edm::Ptr<reco::PFCandidate> pfBackRef ( *ipart );
        // add to the list of FwdPtr's
        iparticlesRef.push_back( pat::PFCandidateFwdPtrCollection::value_type ( pfForwardRef, pfBackRef ) );
      }
      ajet.setPFCandidates( iparticlesRef );
    }

    if (addJetCorrFactors_) {
      // add additional JetCorrs to the jet 
      for ( unsigned int i=0; i<jetCorrFactorsSrc_.size(); ++i ) {
        const JetCorrFactors& jcf = jetCorrs[i][jetRef];
        // uncomment for debugging
        // jcf.print();
        ajet.addJECFactors(jcf);
      }
      std::vector<std::string> levels = jetCorrs[0][jetRef].correctionLabels();
      if(std::find(levels.begin(), levels.end(), "L2L3Residual")!=levels.end()){
        ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("L2L3Residual"));
      }
      else if(std::find(levels.begin(), levels.end(), "L3Absolute")!=levels.end()){
        ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("L3Absolute"));
      }
      else{
        ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("Uncorrected"));
        if(first){        
          edm::LogWarning("L3Absolute not found") << "L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n"
                                                  << "of module " <<  jetCorrs[0][jetRef].jecSet() << " jets will remain"
                                                  << " uncorrected."; first=false;
        }
      }
    }

    // get the MC flavour information for this jet
    if (getJetMCFlavour_) {
        ajet.setPartonFlavour( (*jetFlavMatch)[edm::RefToBase<reco::Jet>(jetRef)].getFlavour() );
    }
    // store the match to the generated partons
    if (addGenPartonMatch_) {
      reco::GenParticleRef parton = (*partonMatch)[jetRef];
      if (parton.isNonnull() && parton.isAvailable()) {
          ajet.setGenParton(parton, embedGenPartonMatch_);
      } // leave empty if no match found
    }
    // store the match to the GenJets
    if (addGenJetMatch_) {
      reco::GenJetRef genjet = (*genJetMatch)[jetRef];
      if (genjet.isNonnull() && genjet.isAvailable()) {
        genJetsOut->push_back( *genjet );
        // set the "forward" ref to the thinned collection
        edm::Ref<reco::GenJetCollection > genForwardRef ( h_genJetsOut, genJetsOut->size() - 1 );
        // set the "backward" ref to the original collection
        edm::Ref<reco::GenJetCollection > genBackRef ( genjet );
        // make the FwdPtr
        edm::FwdRef<reco::GenJetCollection > genjetFwdRef ( genForwardRef, genBackRef );
        ajet.setGenJetRef(genjetFwdRef );
      } // leave empty if no match found
    }

    if (efficiencyLoader_.enabled()) {
        efficiencyLoader_.setEfficiencies( ajet, jetRef );
    }

    // IMPORTANT: DO THIS AFTER JES CORRECTIONS
    if (resolutionLoader_.enabled()) {
        resolutionLoader_.setResolutions(ajet);
    }

    // TO BE IMPLEMENTED FOR >=1_5_X: do the PartonJet matching
    if (addPartonJetMatch_) {
    }

    // add b-tag info if available & required
    if (addBTagInfo_) {
        if (addDiscriminators_) {
            for (size_t k=0; k<jetDiscriminators.size(); ++k) {
                float value = (*jetDiscriminators[k])[jetRef];
                ajet.addBDiscriminatorPair(std::make_pair(discriminatorLabels_[k], value));
            }
        }    
        if (addTagInfos_) {
          for (size_t k=0; k<jetTagInfos.size(); ++k) {
            const edm::View<reco::BaseTagInfo> & taginfos = *jetTagInfos[k];
            // This is not associative, so we have to search the jet
            edm::Ptr<reco::BaseTagInfo> match;
            // Try first by 'same index'
            if ((idx < taginfos.size()) && (taginfos[idx].jet() == jetRef)) {
              match = taginfos.ptrAt(idx);
            } else {
              // otherwise fail back to a simple search
              for (edm::View<reco::BaseTagInfo>::const_iterator itTI = taginfos.begin(), edTI = taginfos.end(); itTI != edTI; ++itTI) {
                if (itTI->jet() == jetRef) { match = taginfos.ptrAt( itTI - taginfos.begin() ); break; }
              }
            }
            if (match.isNonnull()) {
              tagInfosOut->push_back( match->clone() );
              // set the "forward" ptr to the thinned collection
              edm::Ptr<reco::BaseTagInfo> tagInfoForwardPtr ( h_tagInfosOut.id(), &tagInfosOut->back(), tagInfosOut->size() - 1 );
              // set the "backward" ptr to the original collection for association
              edm::Ptr<reco::BaseTagInfo> tagInfoBackPtr ( match );
              // make FwdPtr
              TagInfoFwdPtrCollection::value_type tagInfoFwdPtr( tagInfoForwardPtr, tagInfoBackPtr ) ;
              ajet.addTagInfo(tagInfoLabels_[k], tagInfoFwdPtr );
            }
          }
        }    
    }
    
    if (addAssociatedTracks_) ajet.setAssociatedTracks( (*hTrackAss)[jetRef] );

    if (addJetCharge_) ajet.setJetCharge( (*hJetChargeAss)[jetRef] );

    // add jet ID for calo jets
    if (addJetID_ && ajet.isCaloJet() ) {
      reco::JetID jetId = (*hJetIDMap)[ jetRef ];
      ajet.setJetID( jetId );
    }
    // add jet ID jpt jets
    else if ( addJetID_ && ajet.isJPTJet() ){
      const reco::JPTJet *jptj = dynamic_cast<const reco::JPTJet *>(jetRef.get());
      reco::JetID jetId = (*hJetIDMap)[ jptj->getCaloJetRef() ];
      ajet.setJetID( jetId );
    } 
    if ( useUserData_ ) {
      userDataHelper_.add( ajet, iEvent, iSetup );
    }
    patJets->push_back(ajet);
  }

  // sort jets in pt
  std::sort(patJets->begin(), patJets->end(), pTComparator_);

  // put genEvt  in Event
  iEvent.put(patJets);

  iEvent.put( genJetsOut, "genJets" );
  iEvent.put( caloTowersOut, "caloTowers" );
  iEvent.put( pfCandidatesOut, "pfCandidates" );
  iEvent.put( tagInfosOut, "tagInfos" );
  

}

Member Data Documentation

Definition at line 82 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 75 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 76 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 92 of file PATJetProducer.h.

Referenced by PATJetProducer().

Definition at line 67 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 64 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 84 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 72 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 86 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 70 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 95 of file PATJetProducer.h.

Referenced by PATJetProducer().

Definition at line 79 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

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().

Definition at line 77 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 93 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 60 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 68 of file PATJetProducer.h.

Referenced by PATJetProducer().

Definition at line 65 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 61 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 69 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 66 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 62 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 85 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 73 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 87 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 63 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 59 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 71 of file PATJetProducer.h.

Referenced by PATJetProducer().

Definition at line 89 of file PATJetProducer.h.

Referenced by produce().

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().

Definition at line 80 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 83 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 99 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().

Definition at line 98 of file PATJetProducer.h.

Referenced by PATJetProducer(), and produce().