CMS 3D CMS Logo

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

ShiftedParticleProducerT< T > Class Template Reference

#include <ShiftedParticleProducerT.h>

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

List of all members.

Classes

struct  binningEntryType

Public Member Functions

 ShiftedParticleProducerT (const edm::ParameterSet &cfg)
 ~ShiftedParticleProducerT ()

Private Types

typedef std::vector< TParticleCollection

Private Member Functions

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

Private Attributes

std::vector< binningEntryType * > binning_
std::string moduleLabel_
double shiftBy_
edm::InputTag src_

Detailed Description

template<typename T>
class ShiftedParticleProducerT< T >

Vary energy of electrons/muons/tau-jets by +/- 1 standard deviation, in order to estimate resulting uncertainty on MET

NOTE: energy scale uncertainties need to be specified in python config

Author:
Christian Veelken, LLR
Version:
Revision:
1.2
Id:
ShiftedParticleProducerT.h,v 1.2 2011/11/02 14:03:07 veelken Exp

Definition at line 32 of file ShiftedParticleProducerT.h.


Member Typedef Documentation

template<typename T >
typedef std::vector<T> ShiftedParticleProducerT< T >::ParticleCollection [private]

Definition at line 34 of file ShiftedParticleProducerT.h.


Constructor & Destructor Documentation

template<typename T >
ShiftedParticleProducerT< T >::ShiftedParticleProducerT ( const edm::ParameterSet cfg) [inline, explicit]

Definition at line 38 of file ShiftedParticleProducerT.h.

References ShiftedParticleProducerT< T >::binning_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), ShiftedParticleProducerT< T >::shiftBy_, and ShiftedParticleProducerT< T >::src_.

    : moduleLabel_(cfg.getParameter<std::string>("@module_label"))
  {
    src_ = cfg.getParameter<edm::InputTag>("src");

    shiftBy_ = cfg.getParameter<double>("shiftBy");

    if ( cfg.exists("binning") ) {
      typedef std::vector<edm::ParameterSet> vParameterSet;
      vParameterSet cfgBinning = cfg.getParameter<vParameterSet>("binning");
      for ( vParameterSet::const_iterator cfgBinningEntry = cfgBinning.begin();
            cfgBinningEntry != cfgBinning.end(); ++cfgBinningEntry ) {
        binning_.push_back(new binningEntryType(*cfgBinningEntry));
      }
    } else {
      double uncertainty = cfg.getParameter<double>("uncertainty");
      binning_.push_back(new binningEntryType(uncertainty));
    }
    
    produces<ParticleCollection>();
  }
template<typename T >
ShiftedParticleProducerT< T >::~ShiftedParticleProducerT ( ) [inline]

Definition at line 59 of file ShiftedParticleProducerT.h.

References ShiftedParticleProducerT< T >::binning_.

  {
    for ( typename std::vector<binningEntryType*>::const_iterator it = binning_.begin();
          it != binning_.end(); ++it ) {
      delete (*it);
    }
  }

Member Function Documentation

template<typename T >
void ShiftedParticleProducerT< T >::produce ( edm::Event evt,
const edm::EventSetup es 
) [inline, private, virtual]

Implements edm::EDProducer.

Definition at line 69 of file ShiftedParticleProducerT.h.

References ShiftedParticleProducerT< T >::binning_, edm::Event::getByLabel(), edm::Event::put(), edm::shift, ShiftedParticleProducerT< T >::shiftBy_, and ShiftedParticleProducerT< T >::src_.

  {
    edm::Handle<ParticleCollection> originalParticles;
    evt.getByLabel(src_, originalParticles);

    std::auto_ptr<ParticleCollection> shiftedParticles(new ParticleCollection);

    for ( typename ParticleCollection::const_iterator originalParticle = originalParticles->begin();
          originalParticle != originalParticles->end(); ++originalParticle ) {

      double uncertainty = 0.;
      for ( typename std::vector<binningEntryType*>::iterator binningEntry = binning_.begin();
            binningEntry != binning_.end(); ++binningEntry ) {
        if ( (!(*binningEntry)->binSelection_) || (*(*binningEntry)->binSelection_)(*originalParticle) ) {
          uncertainty = (*binningEntry)->binUncertainty_;
          break;
        }
      }
      
      double shift = shiftBy_*uncertainty;

      reco::Candidate::LorentzVector shiftedParticleP4 = originalParticle->p4();
      shiftedParticleP4 *= (1. + shift);

      T shiftedParticle(*originalParticle);      
      shiftedParticle.setP4(shiftedParticleP4);

      shiftedParticles->push_back(shiftedParticle);
    }

    evt.put(shiftedParticles);
  }

Member Data Documentation

template<typename T >
std::vector<binningEntryType*> ShiftedParticleProducerT< T >::binning_ [private]
template<typename T >
std::string ShiftedParticleProducerT< T >::moduleLabel_ [private]

Definition at line 102 of file ShiftedParticleProducerT.h.

template<typename T >
double ShiftedParticleProducerT< T >::shiftBy_ [private]
template<typename T >
edm::InputTag ShiftedParticleProducerT< T >::src_ [private]