CMS 3D CMS Logo

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

ShiftedJetProducerT< T, Textractor > Class Template Reference

#include <ShiftedJetProducerT.h>

Inheritance diagram for ShiftedJetProducerT< T, Textractor >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

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

Private Types

typedef std::vector< TJetCollection

Private Member Functions

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

Private Attributes

bool addResidualJES_
JetCorrectionUncertaintyjecUncertainty_
double jecUncertaintyValue_
double jetCorrEtaMax_
Textractor jetCorrExtractor_
edm::FileInPath jetCorrInputFileName_
std::string jetCorrLabelUpToL3_
std::string jetCorrLabelUpToL3Res_
JetCorrectorParametersjetCorrParameters_
std::string jetCorrPayloadName_
std::string jetCorrUncertaintyTag_
std::string moduleLabel_
double shiftBy_
edm::InputTag src_
int verbosity_

Detailed Description

template<typename T, typename Textractor>
class ShiftedJetProducerT< T, Textractor >

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

NOTE: energy scale uncertainties are taken from the Database

Author:
Christian Veelken, LLR
Version:
Revision:
1.4
Id:
ShiftedJetProducerT.h,v 1.4 2012/08/31 09:59:15 veelken Exp

Definition at line 40 of file ShiftedJetProducerT.h.


Member Typedef Documentation

template<typename T , typename Textractor >
typedef std::vector<T> ShiftedJetProducerT< T, Textractor >::JetCollection [private]

Definition at line 42 of file ShiftedJetProducerT.h.


Constructor & Destructor Documentation

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

Definition at line 46 of file ShiftedJetProducerT.h.

References ShiftedJetProducerT< T, Textractor >::addResidualJES_, gather_cfg::cout, edm::ParameterSet::exists(), edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), ShiftedJetProducerT< T, Textractor >::jecUncertainty_, ShiftedJetProducerT< T, Textractor >::jecUncertaintyValue_, ShiftedJetProducerT< T, Textractor >::jetCorrEtaMax_, ShiftedJetProducerT< T, Textractor >::jetCorrInputFileName_, ShiftedJetProducerT< T, Textractor >::jetCorrLabelUpToL3_, ShiftedJetProducerT< T, Textractor >::jetCorrLabelUpToL3Res_, ShiftedJetProducerT< T, Textractor >::jetCorrParameters_, ShiftedJetProducerT< T, Textractor >::jetCorrPayloadName_, ShiftedJetProducerT< T, Textractor >::jetCorrUncertaintyTag_, edm::FileInPath::location(), ShiftedJetProducerT< T, Textractor >::shiftBy_, AlCaHLTBitMon_QueryRunRegistry::string, Unknown, and ShiftedJetProducerT< T, Textractor >::verbosity_.

    : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
      src_(cfg.getParameter<edm::InputTag>("src")),
      jetCorrPayloadName_(""),
      jetCorrParameters_(0),
      jecUncertainty_(0),
      jecUncertaintyValue_(-1.)
  {
    if ( cfg.exists("jecUncertaintyValue") ) {
      jecUncertaintyValue_ = cfg.getParameter<double>("jecUncertaintyValue");
    } else {
      jetCorrUncertaintyTag_ = cfg.getParameter<std::string>("jetCorrUncertaintyTag");
      if ( cfg.exists("jetCorrInputFileName") ) {
        jetCorrInputFileName_ = cfg.getParameter<edm::FileInPath>("jetCorrInputFileName");
        if ( jetCorrInputFileName_.location() == edm::FileInPath::Unknown) throw cms::Exception("ShiftedJetProducerT")
          << " Failed to find JEC parameter file = " << jetCorrInputFileName_ << " !!\n";
        std::cout << "Reading JEC parameters = " << jetCorrUncertaintyTag_  
                  << " from file = " << jetCorrInputFileName_.fullPath() << "." << std::endl;
        jetCorrParameters_ = new JetCorrectorParameters(jetCorrInputFileName_.fullPath().data(), jetCorrUncertaintyTag_);
        jecUncertainty_ = new JetCorrectionUncertainty(*jetCorrParameters_);
      } else {
        std::cout << "Reading JEC parameters = " << jetCorrUncertaintyTag_
                  << " from DB/SQLlite file." << std::endl;
        jetCorrPayloadName_ = cfg.getParameter<std::string>("jetCorrPayloadName");
      }
    }

    addResidualJES_ = cfg.getParameter<bool>("addResidualJES");
    jetCorrLabelUpToL3_ = ( cfg.exists("jetCorrLabelUpToL3") ) ?
      cfg.getParameter<std::string>("jetCorrLabelUpToL3") : "";
    jetCorrLabelUpToL3Res_ = ( cfg.exists("jetCorrLabelUpToL3Res") ) ?
      cfg.getParameter<std::string>("jetCorrLabelUpToL3Res") : "";
    jetCorrEtaMax_ = ( cfg.exists("jetCorrEtaMax") ) ?
      cfg.getParameter<double>("jetCorrEtaMax") : 9.9;

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

    verbosity_ = ( cfg.exists("verbosity") ) ?
      cfg.getParameter<int>("verbosity") : 0;

    produces<JetCollection>();
  }
template<typename T , typename Textractor >
ShiftedJetProducerT< T, Textractor >::~ShiftedJetProducerT ( ) [inline]

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 96 of file ShiftedJetProducerT.h.

References ShiftedJetProducerT< T, Textractor >::addResidualJES_, gather_cfg::cout, edm::EventSetup::get(), edm::Event::getByLabel(), JetCorrectionUncertainty::getUncertainty(), ShiftedJetProducerT< T, Textractor >::jecUncertainty_, ShiftedJetProducerT< T, Textractor >::jecUncertaintyValue_, ShiftedJetProducerT< T, Textractor >::jetCorrEtaMax_, ShiftedJetProducerT< T, Textractor >::jetCorrExtractor_, ShiftedJetProducerT< T, Textractor >::jetCorrLabelUpToL3_, ShiftedJetProducerT< T, Textractor >::jetCorrLabelUpToL3Res_, ShiftedJetProducerT< T, Textractor >::jetCorrPayloadName_, ShiftedJetProducerT< T, Textractor >::jetCorrUncertaintyTag_, edm::InputTag::label(), ShiftedJetProducerT< T, Textractor >::moduleLabel_, edm::Event::put(), JetCorrectionUncertainty::setJetEta(), JetCorrectionUncertainty::setJetPt(), edm::shift, ShiftedJetProducerT< T, Textractor >::shiftBy_, ShiftedJetProducerT< T, Textractor >::src_, and ShiftedJetProducerT< T, Textractor >::verbosity_.

  {
    if ( verbosity_ ) {
      std::cout << "<ShiftedJetProducerT::produce>:" << std::endl;
      std::cout << " moduleLabel = " << moduleLabel_ << std::endl;
      std::cout << " src = " << src_.label() << std::endl;
    }

    edm::Handle<JetCollection> originalJets;
    evt.getByLabel(src_, originalJets);

    std::auto_ptr<JetCollection> shiftedJets(new JetCollection);
    
    if ( jetCorrPayloadName_ != "" ) {
      edm::ESHandle<JetCorrectorParametersCollection> jetCorrParameterSet;
      es.get<JetCorrectionsRecord>().get(jetCorrPayloadName_, jetCorrParameterSet); 
      const JetCorrectorParameters& jetCorrParameters = (*jetCorrParameterSet)[jetCorrUncertaintyTag_];
      delete jecUncertainty_;
      jecUncertainty_ = new JetCorrectionUncertainty(jetCorrParameters);
    }

    for ( typename JetCollection::const_iterator originalJet = originalJets->begin();
          originalJet != originalJets->end(); ++originalJet ) {
      reco::Candidate::LorentzVector originalJetP4 = originalJet->p4();
      if ( verbosity_ ) {
        std::cout << "originalJet: Pt = " << originalJetP4.pt() << ", eta = " << originalJetP4.eta() << ", phi = " << originalJetP4.phi() << std::endl;
      }

      double shift = 0.;
      if ( jecUncertaintyValue_ != -1. ) {
        shift = jecUncertaintyValue_;
      } else {
        jecUncertainty_->setJetEta(originalJetP4.eta());
        jecUncertainty_->setJetPt(originalJetP4.pt());
        
        shift = jecUncertainty_->getUncertainty(true);
      }
      if ( verbosity_ ) {
        std::cout << "shift = " << shift << std::endl;
      }

      if ( addResidualJES_ ) {
        static SmearedJetProducer_namespace::RawJetExtractorT<T> rawJetExtractor;
        reco::Candidate::LorentzVector rawJetP4 = rawJetExtractor(*originalJet);
        if ( rawJetP4.E() > 1.e-1 ) {
          reco::Candidate::LorentzVector corrJetP4upToL3 = 
            jetCorrExtractor_(*originalJet, jetCorrLabelUpToL3_, &evt, &es, jetCorrEtaMax_, &rawJetP4);
          reco::Candidate::LorentzVector corrJetP4upToL3Res = 
            jetCorrExtractor_(*originalJet, jetCorrLabelUpToL3Res_, &evt, &es, jetCorrEtaMax_, &rawJetP4);
          if ( corrJetP4upToL3.E() > 1.e-1 && corrJetP4upToL3Res.E() > 1.e-1 ) {
            double residualJES = (corrJetP4upToL3Res.E()/corrJetP4upToL3.E()) - 1.;
            shift = TMath::Sqrt(shift*shift + residualJES*residualJES);
          }
        }
      }

      shift *= shiftBy_;
      if ( verbosity_ ) {
        std::cout << "shift*shiftBy = " << shift << std::endl;
      }

      T shiftedJet(*originalJet);
      shiftedJet.setP4((1. + shift)*originalJetP4);
      if ( verbosity_ ) {
        std::cout << "shiftedJet: Pt = " << shiftedJet.pt() << ", eta = " << shiftedJet.eta() << ", phi = " << shiftedJet.phi() << std::endl;
      }
    
      shiftedJets->push_back(shiftedJet);
    }
  
    evt.put(shiftedJets);
  }

Member Data Documentation

template<typename T , typename Textractor >
bool ShiftedJetProducerT< T, Textractor >::addResidualJES_ [private]
template<typename T , typename Textractor >
JetCorrectionUncertainty* ShiftedJetProducerT< T, Textractor >::jecUncertainty_ [private]
template<typename T , typename Textractor >
double ShiftedJetProducerT< T, Textractor >::jecUncertaintyValue_ [private]
template<typename T , typename Textractor >
double ShiftedJetProducerT< T, Textractor >::jetCorrEtaMax_ [private]
template<typename T , typename Textractor >
Textractor ShiftedJetProducerT< T, Textractor >::jetCorrExtractor_ [private]
template<typename T , typename Textractor >
edm::FileInPath ShiftedJetProducerT< T, Textractor >::jetCorrInputFileName_ [private]
template<typename T , typename Textractor >
std::string ShiftedJetProducerT< T, Textractor >::jetCorrLabelUpToL3_ [private]
template<typename T , typename Textractor >
std::string ShiftedJetProducerT< T, Textractor >::jetCorrLabelUpToL3Res_ [private]
template<typename T , typename Textractor >
JetCorrectorParameters* ShiftedJetProducerT< T, Textractor >::jetCorrParameters_ [private]
template<typename T , typename Textractor >
std::string ShiftedJetProducerT< T, Textractor >::jetCorrPayloadName_ [private]
template<typename T , typename Textractor >
std::string ShiftedJetProducerT< T, Textractor >::jetCorrUncertaintyTag_ [private]
template<typename T , typename Textractor >
std::string ShiftedJetProducerT< T, Textractor >::moduleLabel_ [private]
template<typename T , typename Textractor >
double ShiftedJetProducerT< T, Textractor >::shiftBy_ [private]
template<typename T , typename Textractor >
edm::InputTag ShiftedJetProducerT< T, Textractor >::src_ [private]
template<typename T , typename Textractor >
int ShiftedJetProducerT< T, Textractor >::verbosity_ [private]