CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

JetIdSelector< T > Class Template Reference

Inheritance diagram for JetIdSelector< T >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Types

typedef std::vector< TJetCollection

Public Member Functions

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

Private Attributes

JetIDSelectionFunctorjetIDFunctor
edm::InputTag jetIDMap_
std::string moduleLabel_
unsigned int nJetsPassed_
unsigned int nJetsTot_
std::string qualityStr
edm::InputTag src_
bool use_pfloose
bool use_pfmedium
bool use_pftight

Detailed Description

template<typename T>
class JetIdSelector< T >

Definition at line 59 of file JetIdSelector.cc.


Member Typedef Documentation

template<typename T >
typedef std::vector<T> JetIdSelector< T >::JetCollection

Definition at line 62 of file JetIdSelector.cc.


Constructor & Destructor Documentation

template<typename T >
JetIdSelector< T >::JetIdSelector ( const edm::ParameterSet iConfig) [explicit]

Definition at line 96 of file JetIdSelector.cc.

References Exception, JetIdSelector< T >::jetIDFunctor, JetIDSelectionFunctor::LOOSE, JetIDSelectionFunctor::LOOSE_AOD, JetIDSelectionFunctor::MINIMAL, JetIDSelectionFunctor::PURE09, JetIdSelector< T >::qualityStr, JetIDSelectionFunctor::TIGHT, JetIdSelector< T >::use_pfloose, JetIdSelector< T >::use_pfmedium, and JetIdSelector< T >::use_pftight.

  : src_    (iConfig.getParameter<edm::InputTag>         ("src"))
  , qualityStr  (iConfig.getParameter<string>            ("idLevel"))
  , jetIDMap_(iConfig.getUntrackedParameter<edm::InputTag> ("jetIDMap", edm::InputTag("ak5JetID")))
  , moduleLabel_(iConfig.getParameter<string>                ("@module_label"))
  , nJetsTot_(0)
  , nJetsPassed_(0)
{
  produces<JetCollection>();

  use_pfloose = false;
  use_pfmedium = false;
  use_pftight = false;

  if ( qualityStr == "MINIMAL" ) {
    jetIDFunctor 
      = new JetIDSelectionFunctor( JetIDSelectionFunctor::PURE09, JetIDSelectionFunctor::MINIMAL);
    use_pfloose = true;
  }
  else if ( qualityStr == "LOOSE_AOD" ) {
    jetIDFunctor 
      = new JetIDSelectionFunctor( JetIDSelectionFunctor::PURE09, JetIDSelectionFunctor::LOOSE_AOD);
    use_pfloose = true;
  }
  else if ( qualityStr == "LOOSE" ) {
    jetIDFunctor 
      = new JetIDSelectionFunctor( JetIDSelectionFunctor::PURE09, JetIDSelectionFunctor::LOOSE);   
    use_pfloose = true;
  } 
  else if ( qualityStr == "MEDIUM" ) {
    jetIDFunctor 
      = new JetIDSelectionFunctor( JetIDSelectionFunctor::PURE09, JetIDSelectionFunctor::LOOSE);  
    // There is no medium quality for CaloJet !!
    use_pfmedium = true;
  }
  else if ( qualityStr == "TIGHT" ) {
    jetIDFunctor 
      = new JetIDSelectionFunctor( JetIDSelectionFunctor::PURE09, JetIDSelectionFunctor::TIGHT);    
    use_pftight = true;
  }
  else   
    throw cms::Exception("InvalidInput") 
      << "Expect quality to be one of MINIMAL, LOOSE_AOD, LOOSE, MEDIUM, TIGHT" << std::endl;
}
template<typename T >
JetIdSelector< T >::~JetIdSelector ( ) [virtual]

Definition at line 144 of file JetIdSelector.cc.

                                {
  if(jetIDFunctor) delete jetIDFunctor;
}

Member Function Documentation

template<typename T >
void JetIdSelector< T >::endJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 251 of file JetIdSelector.cc.

References gather_cfg::cout.

{
  stringstream ss;
  ss<<"nJetsTot="<<nJetsTot_<<" nJetsPassed="<<nJetsPassed_
    <<" fJetsPassed="<<100.*(nJetsPassed_/(double)nJetsTot_)<<"%\n";
  cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++"
      <<"\n"<< moduleLabel_ << "(JetIdSelector) SUMMARY:\n"<<ss.str()
      <<"++++++++++++++++++++++++++++++++++++++++++++++++++"
      <<endl;
}
template<typename T >
void JetIdSelector< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 156 of file JetIdSelector.cc.

References reco::PFJet::chargedEmEnergy(), reco::PFJet::chargedHadronEnergy(), reco::PFJet::chargedMultiplicity(), reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), edm::Event::getByLabel(), UserOptions_cff::idx, fwrapper::jets, reco::Jet::nConstituents(), reco::PFJet::neutralEmEnergy(), reco::PFJet::neutralHadronEnergy(), and edm::Event::put().

{
  auto_ptr<JetCollection> selectedJets(new JetCollection);
  edm::Handle<reco::JetView> jets;  // uncorrected jets!
  iEvent.getByLabel(src_,jets);


 // handle to the jet ID variables
   edm::Handle<reco::JetIDValueMap> hJetIDMap;

   if(typeid((*jets)[0]) == typeid(reco::CaloJet)) 
     iEvent.getByLabel( jetIDMap_, hJetIDMap );

   unsigned int idx=0;
   bool passed = false;

   for ( edm::View<reco::Jet>::const_iterator ibegin = jets->begin(),
           iend = jets->end(), iJet = ibegin;
         iJet != iend; ++iJet ) {

     // initialize the boolean flag to false
     passed = false;

     //calculate the Calo jetID
     const std::type_info & type = typeid((*jets)[idx]);
     if( type == typeid(reco::CaloJet) ) {
       const reco::CaloJet calojet = static_cast<const reco::CaloJet &>((*jets)[idx]);
       edm::RefToBase<reco::Jet> jetRef = jets->refAt(idx);
       reco::JetID const & jetId = (*hJetIDMap)[ jetRef ];
       passed = (*jetIDFunctor)( calojet, jetId);
     }

     //calculate the PF jetID
     if ( type == typeid(reco::PFJet) ) {
       const reco::PFJet pfjet = static_cast<const reco::PFJet &>((*jets)[idx]);
       bool passingLoose=false;
       bool passingMedium=false;
       bool passingTight=false;
       bool ThisIsClean=true;
       //apply following only if |eta|<2.4: CHF>0, CEMF<0.99, chargedMultiplicity>0   
       if(( pfjet.chargedHadronEnergy()/ pfjet.energy())<= 0.0  
          && fabs(pfjet.eta())<2.4) ThisIsClean=false; 
       if( (pfjet.chargedEmEnergy()/pfjet.energy())>= 0.99 
           && fabs(pfjet.eta())<2.4 ) ThisIsClean=false;
       if( pfjet.chargedMultiplicity()<=0 && fabs(pfjet.eta())<2.4 ) 
         ThisIsClean=false;
       
       // always require #Constituents > 1
       if( pfjet.nConstituents() <=1 ) ThisIsClean=false;
       
       if(ThisIsClean && 
          (pfjet.neutralHadronEnergy()/pfjet.energy())< 0.99 
          && (pfjet.neutralEmEnergy()/pfjet.energy())<0.99) 
         passingLoose=true;
       
       if(ThisIsClean && 
          (pfjet.neutralHadronEnergy()/pfjet.energy())< 0.95 
          && (pfjet.neutralEmEnergy()/pfjet.energy())<0.95) 
         passingMedium=true;
       
       if(ThisIsClean && 
          (pfjet.neutralHadronEnergy()/pfjet.energy())< 0.90 
          && (pfjet.neutralEmEnergy()/pfjet.energy())<0.90) 
         passingTight=true;


       if ( use_pfloose && passingLoose)  passed = true;
       if ( use_pfmedium && passingMedium) passed = true;
       if ( use_pftight && passingTight) passed = true;
     }

     if ( type == typeid(reco::GenJet) || type == typeid(reco::JPTJet)) {
       edm::LogWarning( "JetId" )<< 
         "Criteria for jets other than CaloJets and PFJets are not yet implemented";
       passed = true;
     } // close GenJet, JPT jet

 
     const T& goodJet = static_cast<const T&>((*jets)[idx]);
     if(passed) selectedJets->push_back( goodJet );

     idx++;
   } // close jet iterator



  nJetsTot_  +=jets->size();
  nJetsPassed_+=selectedJets->size();  
  iEvent.put(selectedJets);
}

Member Data Documentation

template<typename T >
JetIDSelectionFunctor* JetIdSelector< T >::jetIDFunctor [private]

Definition at line 81 of file JetIdSelector.cc.

Referenced by JetIdSelector< T >::JetIdSelector().

template<typename T >
edm::InputTag JetIdSelector< T >::jetIDMap_ [private]

Definition at line 75 of file JetIdSelector.cc.

template<typename T >
std::string JetIdSelector< T >::moduleLabel_ [private]

Definition at line 76 of file JetIdSelector.cc.

template<typename T >
unsigned int JetIdSelector< T >::nJetsPassed_ [private]

Definition at line 80 of file JetIdSelector.cc.

template<typename T >
unsigned int JetIdSelector< T >::nJetsTot_ [private]

Definition at line 79 of file JetIdSelector.cc.

template<typename T >
std::string JetIdSelector< T >::qualityStr [private]

Definition at line 74 of file JetIdSelector.cc.

Referenced by JetIdSelector< T >::JetIdSelector().

template<typename T >
edm::InputTag JetIdSelector< T >::src_ [private]

Definition at line 73 of file JetIdSelector.cc.

template<typename T >
bool JetIdSelector< T >::use_pfloose [private]

Definition at line 82 of file JetIdSelector.cc.

Referenced by JetIdSelector< T >::JetIdSelector().

template<typename T >
bool JetIdSelector< T >::use_pfmedium [private]

Definition at line 83 of file JetIdSelector.cc.

Referenced by JetIdSelector< T >::JetIdSelector().

template<typename T >
bool JetIdSelector< T >::use_pftight [private]

Definition at line 84 of file JetIdSelector.cc.

Referenced by JetIdSelector< T >::JetIdSelector().