CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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::ProductRegistryHelper

Public Member Functions

 ShiftedJetProducerT (const edm::ParameterSet &cfg)
 
 ~ShiftedJetProducerT ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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)
inlineexplicit

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_, edm::FileInPath::Unknown, and ShiftedJetProducerT< T, Textractor >::verbosity_.

47  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
48  src_(cfg.getParameter<edm::InputTag>("src")),
51  jecUncertainty_(0),
53  {
54  if ( cfg.exists("jecUncertaintyValue") ) {
55  jecUncertaintyValue_ = cfg.getParameter<double>("jecUncertaintyValue");
56  } else {
57  jetCorrUncertaintyTag_ = cfg.getParameter<std::string>("jetCorrUncertaintyTag");
58  if ( cfg.exists("jetCorrInputFileName") ) {
59  jetCorrInputFileName_ = cfg.getParameter<edm::FileInPath>("jetCorrInputFileName");
60  if ( jetCorrInputFileName_.location() == edm::FileInPath::Unknown) throw cms::Exception("ShiftedJetProducerT")
61  << " Failed to find JEC parameter file = " << jetCorrInputFileName_ << " !!\n";
62  std::cout << "Reading JEC parameters = " << jetCorrUncertaintyTag_
63  << " from file = " << jetCorrInputFileName_.fullPath() << "." << std::endl;
66  } else {
67  std::cout << "Reading JEC parameters = " << jetCorrUncertaintyTag_
68  << " from DB/SQLlite file." << std::endl;
69  jetCorrPayloadName_ = cfg.getParameter<std::string>("jetCorrPayloadName");
70  }
71  }
72 
73  addResidualJES_ = cfg.getParameter<bool>("addResidualJES");
74  jetCorrLabelUpToL3_ = ( cfg.exists("jetCorrLabelUpToL3") ) ?
75  cfg.getParameter<std::string>("jetCorrLabelUpToL3") : "";
76  jetCorrLabelUpToL3Res_ = ( cfg.exists("jetCorrLabelUpToL3Res") ) ?
77  cfg.getParameter<std::string>("jetCorrLabelUpToL3Res") : "";
78  jetCorrEtaMax_ = ( cfg.exists("jetCorrEtaMax") ) ?
79  cfg.getParameter<double>("jetCorrEtaMax") : 9.9;
80 
81  shiftBy_ = cfg.getParameter<double>("shiftBy");
82 
83  verbosity_ = ( cfg.exists("verbosity") ) ?
84  cfg.getParameter<int>("verbosity") : 0;
85 
86  produces<JetCollection>();
87  }
JetCorrectorParameters * jetCorrParameters_
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string jetCorrUncertaintyTag_
JetCorrectionUncertainty * jecUncertainty_
LocationCode location() const
Where was the file found?
Definition: FileInPath.cc:159
std::string jetCorrLabelUpToL3Res_
tuple cout
Definition: gather_cfg.py:121
edm::FileInPath jetCorrInputFileName_
std::string fullPath() const
Definition: FileInPath.cc:171
template<typename T , typename Textractor >
ShiftedJetProducerT< T, Textractor >::~ShiftedJetProducerT ( )
inline

Definition at line 88 of file ShiftedJetProducerT.h.

References ShiftedJetProducerT< T, Textractor >::jecUncertainty_, and ShiftedJetProducerT< T, Textractor >::jetCorrParameters_.

89  {
90  delete jetCorrParameters_;
91  delete jecUncertainty_;
92  }
JetCorrectorParameters * jetCorrParameters_
JetCorrectionUncertainty * jecUncertainty_

Member Function Documentation

template<typename T , typename Textractor >
void ShiftedJetProducerT< T, Textractor >::produce ( edm::Event evt,
const edm::EventSetup es 
)
inlineprivatevirtual

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_.

97  {
98  if ( verbosity_ ) {
99  std::cout << "<ShiftedJetProducerT::produce>:" << std::endl;
100  std::cout << " moduleLabel = " << moduleLabel_ << std::endl;
101  std::cout << " src = " << src_.label() << std::endl;
102  }
103 
104  edm::Handle<JetCollection> originalJets;
105  evt.getByLabel(src_, originalJets);
106 
107  std::auto_ptr<JetCollection> shiftedJets(new JetCollection);
108 
109  if ( jetCorrPayloadName_ != "" ) {
111  es.get<JetCorrectionsRecord>().get(jetCorrPayloadName_, jetCorrParameterSet);
112  const JetCorrectorParameters& jetCorrParameters = (*jetCorrParameterSet)[jetCorrUncertaintyTag_];
113  delete jecUncertainty_;
114  jecUncertainty_ = new JetCorrectionUncertainty(jetCorrParameters);
115  }
116 
117  for ( typename JetCollection::const_iterator originalJet = originalJets->begin();
118  originalJet != originalJets->end(); ++originalJet ) {
119  reco::Candidate::LorentzVector originalJetP4 = originalJet->p4();
120  if ( verbosity_ ) {
121  std::cout << "originalJet: Pt = " << originalJetP4.pt() << ", eta = " << originalJetP4.eta() << ", phi = " << originalJetP4.phi() << std::endl;
122  }
123 
124  double shift = 0.;
125  if ( jecUncertaintyValue_ != -1. ) {
126  shift = jecUncertaintyValue_;
127  } else {
128  jecUncertainty_->setJetEta(originalJetP4.eta());
129  jecUncertainty_->setJetPt(originalJetP4.pt());
130 
131  shift = jecUncertainty_->getUncertainty(true);
132  }
133  if ( verbosity_ ) {
134  std::cout << "shift = " << shift << std::endl;
135  }
136 
137  if ( addResidualJES_ ) {
139  reco::Candidate::LorentzVector rawJetP4 = rawJetExtractor(*originalJet);
140  if ( rawJetP4.E() > 1.e-1 ) {
141  reco::Candidate::LorentzVector corrJetP4upToL3 =
142  jetCorrExtractor_(*originalJet, jetCorrLabelUpToL3_, &evt, &es, jetCorrEtaMax_, &rawJetP4);
143  reco::Candidate::LorentzVector corrJetP4upToL3Res =
144  jetCorrExtractor_(*originalJet, jetCorrLabelUpToL3Res_, &evt, &es, jetCorrEtaMax_, &rawJetP4);
145  if ( corrJetP4upToL3.E() > 1.e-1 && corrJetP4upToL3Res.E() > 1.e-1 ) {
146  double residualJES = (corrJetP4upToL3Res.E()/corrJetP4upToL3.E()) - 1.;
147  shift = TMath::Sqrt(shift*shift + residualJES*residualJES);
148  }
149  }
150  }
151 
152  shift *= shiftBy_;
153  if ( verbosity_ ) {
154  std::cout << "shift*shiftBy = " << shift << std::endl;
155  }
156 
157  T shiftedJet(*originalJet);
158  shiftedJet.setP4((1. + shift)*originalJetP4);
159  if ( verbosity_ ) {
160  std::cout << "shiftedJet: Pt = " << shiftedJet.pt() << ", eta = " << shiftedJet.eta() << ", phi = " << shiftedJet.phi() << std::endl;
161  }
162 
163  shiftedJets->push_back(shiftedJet);
164  }
165 
166  evt.put(shiftedJets);
167  }
std::string jetCorrUncertaintyTag_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
JetCorrectionUncertainty * jecUncertainty_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
const T & get() const
Definition: EventSetup.h:55
std::string jetCorrLabelUpToL3Res_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:38
std::string const & label() const
Definition: InputTag.h:25
static unsigned int const shift
tuple cout
Definition: gather_cfg.py:121
float getUncertainty(bool fDirection)
std::vector< T > JetCollection
long double T

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