CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

ShiftedPFCandidateProducerForPFMEtMVA Class Reference

#include <ShiftedPFCandidateProducerForPFMEtMVA.h>

Inheritance diagram for ShiftedPFCandidateProducerForPFMEtMVA:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Classes

struct  objectEntryType

Public Member Functions

 ShiftedPFCandidateProducerForPFMEtMVA (const edm::ParameterSet &)
 ~ShiftedPFCandidateProducerForPFMEtMVA ()

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

double dRmatch_Object_
double dRmatch_PFCandidate_
std::string moduleLabel_
std::vector< objectEntryTypeobjects_
edm::InputTag srcPFCandidates_
edm::InputTag srcShiftedObjects_
edm::InputTag srcUnshiftedObjects_

Detailed Description

Vary energy of PFCandidates coinciding in eta-phi with selected electrons/muons/tau-jets/jets by electron/muon/tau-jet/jet energy uncertainty.

NOTE: Auxiliary class specific to estimating systematic uncertainty on PFMET reconstructed by MVA-based algorithm (implemented in RecoMET/METProducers/src/PFMETProducerMVA.cc)

Author:
Christian Veelken, LLR
Version:
Revision:
1.1
Id:
ShiftedPFCandidateProducerForPFMEtMVA.h,v 1.1 2012/08/31 10:06:14 veelken Exp

Definition at line 32 of file ShiftedPFCandidateProducerForPFMEtMVA.h.


Constructor & Destructor Documentation

ShiftedPFCandidateProducerForPFMEtMVA::ShiftedPFCandidateProducerForPFMEtMVA ( const edm::ParameterSet cfg) [explicit]

Definition at line 9 of file ShiftedPFCandidateProducerForPFMEtMVA.cc.

References dRmatch_Object_, dRmatch_PFCandidate_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), srcPFCandidates_, srcShiftedObjects_, and srcUnshiftedObjects_.

  : moduleLabel_(cfg.getParameter<std::string>("@module_label"))
{
  srcPFCandidates_ = cfg.getParameter<edm::InputTag>("srcPFCandidates");
  srcUnshiftedObjects_ = cfg.getParameter<edm::InputTag>("srcUnshiftedObjects");
  srcShiftedObjects_ = cfg.getParameter<edm::InputTag>("srcShiftedObjects");

  dRmatch_PFCandidate_ = cfg.getParameter<double>("dRmatch_PFCandidate");
  dRmatch_Object_ = cfg.exists("dRmatch_Object") ?
    cfg.getParameter<double>("dRmatch_Object") : 0.1;

  produces<reco::PFCandidateCollection>();
}
ShiftedPFCandidateProducerForPFMEtMVA::~ShiftedPFCandidateProducerForPFMEtMVA ( )

Definition at line 23 of file ShiftedPFCandidateProducerForPFMEtMVA.cc.

{
// nothing to be done yet...
}

Member Function Documentation

void ShiftedPFCandidateProducerForPFMEtMVA::produce ( edm::Event evt,
const edm::EventSetup es 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 28 of file ShiftedPFCandidateProducerForPFMEtMVA.cc.

References deltaR(), dRmatch_Object_, dRmatch_PFCandidate_, edm::Event::getByLabel(), dbtoconf::object, objects_, edm::Event::put(), reco::LeafCandidate::setP4(), edm::shift, srcPFCandidates_, srcShiftedObjects_, and srcUnshiftedObjects_.

{
  edm::Handle<reco::PFCandidateCollection> originalPFCandidates;
  evt.getByLabel(srcPFCandidates_, originalPFCandidates);

  typedef edm::View<reco::Candidate> CandidateView;

  edm::Handle<CandidateView> unshiftedObjects;
  evt.getByLabel(srcUnshiftedObjects_, unshiftedObjects);

  edm::Handle<CandidateView> shiftedObjects;
  evt.getByLabel(srcShiftedObjects_, shiftedObjects);

  objects_.clear();
  
  for ( CandidateView::const_iterator unshiftedObject = unshiftedObjects->begin();
        unshiftedObject != unshiftedObjects->end(); ++unshiftedObject ) {
    bool isMatched_Object = false;
    double dRbestMatch_Object = 1.e+3;
    reco::Candidate::LorentzVector shiftedObjectP4_matched;
    for ( CandidateView::const_iterator shiftedObject = shiftedObjects->begin();
        shiftedObject != shiftedObjects->end(); ++shiftedObject ) {
      double dR = deltaR(unshiftedObject->p4(), shiftedObject->p4());
      if ( dR < dRmatch_Object_ && dR < dRbestMatch_Object ) {
        shiftedObjectP4_matched = shiftedObject->p4();
        isMatched_Object = true;
        dRbestMatch_Object = dR;
      }
    }
    if ( isMatched_Object ) {
      objects_.push_back(objectEntryType(shiftedObjectP4_matched, unshiftedObject->p4(), dRbestMatch_Object));
    }
  }
 
  std::auto_ptr<reco::PFCandidateCollection> shiftedPFCandidates(new reco::PFCandidateCollection);
    
  for ( reco::PFCandidateCollection::const_iterator originalPFCandidate = originalPFCandidates->begin();
        originalPFCandidate != originalPFCandidates->end(); ++originalPFCandidate ) {
    
    double shift = 0.;
    bool applyShift = false;
    double dRbestMatch_PFCandidate = 1.e+3;
    for ( std::vector<objectEntryType>::const_iterator object = objects_.begin();
          object != objects_.end(); ++object ) {
      if ( !object->isValidMatch_ ) continue;
      double dR = deltaR(originalPFCandidate->p4(), object->unshiftedObjectP4_);
      if ( dR < dRmatch_PFCandidate_ && dR < dRbestMatch_PFCandidate ) {
        shift = object->shift_;
        applyShift = true;
        dRbestMatch_PFCandidate = dR;
      }
    }
    
    reco::Candidate::LorentzVector shiftedPFCandidateP4 = originalPFCandidate->p4();
    if ( applyShift ) shiftedPFCandidateP4 *= (1. + shift);
    
    reco::PFCandidate shiftedPFCandidate(*originalPFCandidate);      
    shiftedPFCandidate.setP4(shiftedPFCandidateP4);
    
    shiftedPFCandidates->push_back(shiftedPFCandidate);
  }
  
  evt.put(shiftedPFCandidates);
}

Member Data Documentation

Definition at line 43 of file ShiftedPFCandidateProducerForPFMEtMVA.h.

Definition at line 74 of file ShiftedPFCandidateProducerForPFMEtMVA.h.

Referenced by produce().