CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

pf2pat::IsolatedPFCandidateSelectorDefinition Class Reference

#include <IsolatedPFCandidateSelectorDefinition.h>

Inheritance diagram for pf2pat::IsolatedPFCandidateSelectorDefinition:
pf2pat::PFCandidateSelectorDefinition

List of all members.

Public Types

typedef edm::ValueMap< double > IsoMap

Public Member Functions

 IsolatedPFCandidateSelectorDefinition (const edm::ParameterSet &cfg)
void select (const HandleToCollection &hc, const edm::EventBase &e, const edm::EventSetup &s)

Private Attributes

double combinedIsolationCut_
bool isCombined_
std::vector< double > isolationCuts_
std::vector< edm::InputTagisolationValueMapLabels_
bool isRelative_

Detailed Description

Definition at line 12 of file IsolatedPFCandidateSelectorDefinition.h.


Member Typedef Documentation

Definition at line 15 of file IsolatedPFCandidateSelectorDefinition.h.


Constructor & Destructor Documentation

pf2pat::IsolatedPFCandidateSelectorDefinition::IsolatedPFCandidateSelectorDefinition ( const edm::ParameterSet cfg) [inline]

Definition at line 17 of file IsolatedPFCandidateSelectorDefinition.h.

References isolationCuts_, and isolationValueMapLabels_.

                                                                          :
      isolationValueMapLabels_(cfg.getParameter< std::vector<edm::InputTag> >("isolationValueMaps") ),
      isRelative_(cfg.getParameter<bool>("isRelative")),
      isCombined_(cfg.getParameter<bool>("isCombined")),
      isolationCuts_(cfg.getParameter< std::vector<double> >("isolationCuts")),
      combinedIsolationCut_(cfg.getParameter<double>("combinedIsolationCut")) { 
    

      if( isolationCuts_.size() != isolationValueMapLabels_.size() )
        throw cms::Exception("BadConfiguration")<<"the vector of isolation ValueMaps and the vector of the corresponding cuts must have the same size."<<std::endl;
    }

Member Function Documentation

void pf2pat::IsolatedPFCandidateSelectorDefinition::select ( const HandleToCollection hc,
const edm::EventBase e,
const edm::EventSetup s 
) [inline]

Definition at line 29 of file IsolatedPFCandidateSelectorDefinition.h.

References combinedIsolationCut_, align_tpl::cut, edm::EventBase::getByLabel(), isCombined_, isolationCuts_, isolationValueMapLabels_, isRelative_, combine::key, and pf2pat::PFCandidateSelectorDefinition::selected_.

                                         {
      selected_.clear();
    
      /*     assert( hc.isValid() ); */

      // read all isolation value maps
      std::vector< edm::Handle<IsoMap> > 
        isoMaps(isolationValueMapLabels_.size());
      for(unsigned iMap = 0; iMap<isolationValueMapLabels_.size(); ++iMap) {
        e.getByLabel(isolationValueMapLabels_[iMap], isoMaps[iMap]);
      }

      unsigned key=0;
      //    for( unsigned i=0; i<collection->size(); i++ ) {
      for( collection::const_iterator pfc = hc->begin(); 
           pfc != hc->end(); ++pfc, ++key) {
        reco::PFCandidateRef candidate(hc,key);

        bool passed = true;
        double isoSum=0.0;
        for(unsigned iMap = 0; iMap<isoMaps.size(); ++iMap) {
        
          const IsoMap & isoMap = *(isoMaps[iMap]);
        
          double val = isoMap[candidate];
          double cut = isolationCuts_[iMap];
          if(isRelative_ && candidate->pt()>0.0) val/=candidate->pt();
          isoSum+=val;
          //std::cout << "val " << iMap << " = " << val << std::endl;

          if ( !isCombined_ && val>cut ) {
            passed = false;
            break;        
          }
        }

        if ( isCombined_ && isoSum>combinedIsolationCut_ )
          {
            passed = false;
          }

        if(passed) {
          // passed all cuts, selected
          selected_.push_back( reco::PFCandidate(*pfc) );
          reco::PFCandidatePtr ptrToMother( hc, key );
          selected_.back().setSourceCandidatePtr( ptrToMother );
        }
      }
    }

Member Data Documentation

Definition at line 85 of file IsolatedPFCandidateSelectorDefinition.h.

Referenced by select().

Definition at line 83 of file IsolatedPFCandidateSelectorDefinition.h.

Referenced by select().

Definition at line 83 of file IsolatedPFCandidateSelectorDefinition.h.

Referenced by select().