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::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ShiftedJetProducerT (const edm::ParameterSet &cfg)
 
 ~ShiftedJetProducerT ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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
 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
 
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_
 
std::string jetCorrLabelUpToL3_
 
std::string jetCorrLabelUpToL3Res_
 
JetCorrectorParametersjetCorrParameters_
 
std::string jetCorrPayloadName_
 
std::string jetCorrUncertaintyTag_
 
std::string moduleLabel_
 
double shiftBy_
 
edm::InputTag src_
 
edm::EDGetTokenT< JetCollectionsrcToken_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- 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::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 38 of file ShiftedJetProducerT.h.

Member Typedef Documentation

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

Definition at line 40 of file ShiftedJetProducerT.h.

Constructor & Destructor Documentation

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

Definition at line 44 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, edm::FileInPath::Unknown, and ShiftedJetProducerT< T, Textractor >::verbosity_.

45  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
46  src_(cfg.getParameter<edm::InputTag>("src")),
47  srcToken_(consumes<JetCollection>(src_)),
50  jecUncertainty_(0),
52  {
53  if ( cfg.exists("jecUncertaintyValue") ) {
54  jecUncertaintyValue_ = cfg.getParameter<double>("jecUncertaintyValue");
55  } else {
56  jetCorrUncertaintyTag_ = cfg.getParameter<std::string>("jetCorrUncertaintyTag");
57  if ( cfg.exists("jetCorrInputFileName") ) {
58  jetCorrInputFileName_ = cfg.getParameter<edm::FileInPath>("jetCorrInputFileName");
59  if ( jetCorrInputFileName_.location() == edm::FileInPath::Unknown) throw cms::Exception("ShiftedJetProducerT")
60  << " Failed to find JEC parameter file = " << jetCorrInputFileName_ << " !!\n";
61  std::cout << "Reading JEC parameters = " << jetCorrUncertaintyTag_
62  << " from file = " << jetCorrInputFileName_.fullPath() << "." << std::endl;
65  } else {
66  std::cout << "Reading JEC parameters = " << jetCorrUncertaintyTag_
67  << " from DB/SQLlite file." << std::endl;
68  jetCorrPayloadName_ = cfg.getParameter<std::string>("jetCorrPayloadName");
69  }
70  }
71 
72  addResidualJES_ = cfg.getParameter<bool>("addResidualJES");
73  jetCorrLabelUpToL3_ = ( cfg.exists("jetCorrLabelUpToL3") ) ?
74  cfg.getParameter<std::string>("jetCorrLabelUpToL3") : "";
75  jetCorrLabelUpToL3Res_ = ( cfg.exists("jetCorrLabelUpToL3Res") ) ?
76  cfg.getParameter<std::string>("jetCorrLabelUpToL3Res") : "";
77  jetCorrEtaMax_ = ( cfg.exists("jetCorrEtaMax") ) ?
78  cfg.getParameter<double>("jetCorrEtaMax") : 9.9;
79 
80  shiftBy_ = cfg.getParameter<double>("shiftBy");
81 
82  verbosity_ = ( cfg.exists("verbosity") ) ?
83  cfg.getParameter<int>("verbosity") : 0;
84 
85  produces<JetCollection>();
86  }
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:165
edm::EDGetTokenT< JetCollection > srcToken_
template<typename T , typename Textractor >
ShiftedJetProducerT< T, Textractor >::~ShiftedJetProducerT ( )
inline

Definition at line 87 of file ShiftedJetProducerT.h.

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

88  {
89  delete jetCorrParameters_;
90  delete jecUncertainty_;
91  }
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 95 of file ShiftedJetProducerT.h.

References ShiftedJetProducerT< T, Textractor >::addResidualJES_, gather_cfg::cout, edm::EventSetup::get(), edm::Event::getByToken(), 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_, ShiftedJetProducerT< T, Textractor >::srcToken_, and ShiftedJetProducerT< T, Textractor >::verbosity_.

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