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::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ShiftedJetProducerT (const edm::ParameterSet &cfg)
 
 ~ShiftedJetProducerT ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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_
 
edm::InputTag jetCorrLabelUpToL3_
 
edm::InputTag jetCorrLabelUpToL3Res_
 
JetCorrectorParametersjetCorrParameters_
 
std::string jetCorrPayloadName_
 
edm::EDGetTokenT
< reco::JetCorrector
jetCorrTokenUpToL3_
 
edm::EDGetTokenT
< reco::JetCorrector
jetCorrTokenUpToL3Res_
 
std::string jetCorrUncertaintyTag_
 
std::string moduleLabel_
 
double shiftBy_
 
edm::InputTag src_
 
edm::EDGetTokenT< JetCollectionsrcToken_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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

Definition at line 37 of file ShiftedJetProducerT.h.

Member Typedef Documentation

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

Definition at line 39 of file ShiftedJetProducerT.h.

Constructor & Destructor Documentation

template<typename T , typename Textractor >
ShiftedJetProducerT< T, Textractor >::ShiftedJetProducerT ( const edm::ParameterSet cfg)
inlineexplicit

Definition at line 43 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 >::jetCorrTokenUpToL3_, ShiftedJetProducerT< T, Textractor >::jetCorrTokenUpToL3Res_, ShiftedJetProducerT< T, Textractor >::jetCorrUncertaintyTag_, edm::FileInPath::location(), ShiftedJetProducerT< T, Textractor >::shiftBy_, AlCaHLTBitMon_QueryRunRegistry::string, edm::FileInPath::Unknown, and ShiftedJetProducerT< T, Textractor >::verbosity_.

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

Definition at line 90 of file ShiftedJetProducerT.h.

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

91  {
92  delete jetCorrParameters_;
93  delete jecUncertainty_;
94  }
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::stream::EDProducerBase.

Definition at line 98 of file ShiftedJetProducerT.h.

References ShiftedJetProducerT< T, Textractor >::addResidualJES_, gather_cfg::cout, edm::EventSetup::get(), edm::Event::getByToken(), JetCorrectionUncertainty::getUncertainty(), edm::EventBase::isRealData(), 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 >::jetCorrTokenUpToL3_, ShiftedJetProducerT< T, Textractor >::jetCorrTokenUpToL3Res_, ShiftedJetProducerT< T, Textractor >::jetCorrUncertaintyTag_, edm::InputTag::label(), ShiftedJetProducerT< T, Textractor >::moduleLabel_, edm::Handle< T >::product(), edm::Event::put(), JetCorrectionUncertainty::setJetEta(), JetCorrectionUncertainty::setJetPt(), edm::shift, ShiftedJetProducerT< T, Textractor >::shiftBy_, mathSSE::sqrt(), ShiftedJetProducerT< T, Textractor >::src_, ShiftedJetProducerT< T, Textractor >::srcToken_, relativeConstraints::value, and ShiftedJetProducerT< T, Textractor >::verbosity_.

99  {
100  if ( verbosity_ ) {
101  std::cout << "<ShiftedJetProducerT::produce>:" << std::endl;
102  std::cout << " moduleLabel = " << moduleLabel_ << std::endl;
103  std::cout << " src = " << src_.label() << std::endl;
104  }
105 
106  edm::Handle<JetCollection> originalJets;
107  evt.getByToken(srcToken_, originalJets);
108  edm::Handle<reco::JetCorrector> jetCorrUpToL3;
109  evt.getByToken(jetCorrTokenUpToL3_, jetCorrUpToL3);
110  edm::Handle<reco::JetCorrector> jetCorrUpToL3Res;
111  evt.getByToken(jetCorrTokenUpToL3Res_, jetCorrUpToL3Res);
112 
113  std::auto_ptr<JetCollection> shiftedJets(new JetCollection);
114 
115  if ( jetCorrPayloadName_ != "" ) {
117  es.get<JetCorrectionsRecord>().get(jetCorrPayloadName_, jetCorrParameterSet);
118  const JetCorrectorParameters& jetCorrParameters = (*jetCorrParameterSet)[jetCorrUncertaintyTag_];
119  delete jecUncertainty_;
120  jecUncertainty_ = new JetCorrectionUncertainty(jetCorrParameters);
121  }
122 
123  for ( typename JetCollection::const_iterator originalJet = originalJets->begin();
124  originalJet != originalJets->end(); ++originalJet ) {
125  reco::Candidate::LorentzVector originalJetP4 = originalJet->p4();
126  if ( verbosity_ ) {
127  std::cout << "originalJet: Pt = " << originalJetP4.pt() << ", eta = " << originalJetP4.eta() << ", phi = " << originalJetP4.phi() << std::endl;
128  }
129 
130  double shift = 0.;
131  if ( jecUncertaintyValue_ != -1. ) {
132  shift = jecUncertaintyValue_;
133  } else {
134  jecUncertainty_->setJetEta(originalJetP4.eta());
135  jecUncertainty_->setJetPt(originalJetP4.pt());
136 
137  shift = jecUncertainty_->getUncertainty(true);
138  }
139  if ( verbosity_ ) {
140  std::cout << "shift = " << shift << std::endl;
141  }
142 
143  if ( evt.isRealData() && addResidualJES_ ) {
144  const static SmearedJetProducer_namespace::RawJetExtractorT<T> rawJetExtractor;
145  reco::Candidate::LorentzVector rawJetP4 = rawJetExtractor(*originalJet);
146  if ( rawJetP4.E() > 1.e-1 ) {
147  reco::Candidate::LorentzVector corrJetP4upToL3 =
149  jetCorrExtractor_(*originalJet, jetCorrLabelUpToL3_.label(), jetCorrEtaMax_, &rawJetP4) :
150  jetCorrExtractor_(*originalJet, jetCorrUpToL3.product(), jetCorrEtaMax_, &rawJetP4);
151  reco::Candidate::LorentzVector corrJetP4upToL3Res =
153  jetCorrExtractor_(*originalJet, jetCorrLabelUpToL3Res_.label(), jetCorrEtaMax_, &rawJetP4) :
154  jetCorrExtractor_(*originalJet, jetCorrUpToL3Res.product(), jetCorrEtaMax_, &rawJetP4);
155  if ( corrJetP4upToL3.E() > 1.e-1 && corrJetP4upToL3Res.E() > 1.e-1 ) {
156  double residualJES = (corrJetP4upToL3Res.E()/corrJetP4upToL3.E()) - 1.;
157  shift = sqrt(shift*shift + residualJES*residualJES);
158  }
159  }
160  }
161 
162  shift *= shiftBy_;
163  if ( verbosity_ ) {
164  std::cout << "shift*shiftBy = " << shift << std::endl;
165  }
166 
167  T shiftedJet(*originalJet);
168  shiftedJet.setP4((1. + shift)*originalJetP4);
169  if ( verbosity_ ) {
170  std::cout << "shiftedJet: Pt = " << shiftedJet.pt() << ", eta = " << shiftedJet.eta() << ", phi = " << shiftedJet.phi() << std::endl;
171  }
172 
173  shiftedJets->push_back(shiftedJet);
174  }
175 
176  evt.put(shiftedJets);
177  }
edm::EDGetTokenT< reco::JetCorrector > jetCorrTokenUpToL3_
edm::InputTag jetCorrLabelUpToL3Res_
edm::InputTag jetCorrLabelUpToL3_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
bool isRealData() const
Definition: EventBase.h:64
std::string jetCorrUncertaintyTag_
edm::EDGetTokenT< reco::JetCorrector > jetCorrTokenUpToL3Res_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
T sqrt(T t)
Definition: SSEVec.h:48
JetCorrectionUncertainty * jecUncertainty_
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:55
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
std::string const & label() const
Definition: InputTag.h:42
static unsigned int const shift
tuple cout
Definition: gather_cfg.py:121
float getUncertainty(bool fDirection)
std::vector< T > JetCollection
long double T
edm::EDGetTokenT< JetCollection > srcToken_

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 >
edm::InputTag ShiftedJetProducerT< T, Textractor >::jetCorrLabelUpToL3_
private
template<typename T , typename Textractor >
edm::InputTag 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 >
edm::EDGetTokenT<reco::JetCorrector> ShiftedJetProducerT< T, Textractor >::jetCorrTokenUpToL3_
private
template<typename T , typename Textractor >
edm::EDGetTokenT<reco::JetCorrector> ShiftedJetProducerT< T, Textractor >::jetCorrTokenUpToL3Res_
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 >
edm::EDGetTokenT<JetCollection> ShiftedJetProducerT< T, Textractor >::srcToken_
private
template<typename T , typename Textractor >
int ShiftedJetProducerT< T, Textractor >::verbosity_
private