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
SmearedJetProducerT< T, Textractor > Class Template Reference

#include <SmearedJetProducerT.h>

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

Public Member Functions

 SmearedJetProducerT (const edm::ParameterSet &cfg)
 
 ~SmearedJetProducerT ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::vector< TJetCollection
 

Private Member Functions

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

Private Attributes

SmearedJetProducer_namespace::GenJetMatcherT
< T
genJetMatcher_
 
TFile * inputFile_
 
double jetCorrEtaMax_
 
Textractor jetCorrExtractor_
 
std::string jetCorrLabel_
 
SmearedJetProducer_namespace::JetResolutionExtractorT
< T
jetResolutionExtractor_
 
TH2 * lut_
 
std::string moduleLabel_
 
TRandom3 rnd_
 
double shiftBy_
 
double sigmaMaxGenJetMatch_
 
double skipCorrJetPtThreshold_
 
StringCutObjectSelector< T > * skipJetSelection_
 
double skipRawJetPtThreshold_
 
double smearBy_
 
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
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 SmearedJetProducerT< T, Textractor >

Produce collection of "smeared" jets. The aim of this correction is to account for the difference in jet energy resolution between Monte Carlo simulation and Data. The jet energy resolutions have been measured in QCD di-jet and gamma + jets events selected in 2010 data, as documented in the PAS JME-10-014.

Author
Christian Veelken, LLR

Definition at line 141 of file SmearedJetProducerT.h.

Member Typedef Documentation

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

Definition at line 143 of file SmearedJetProducerT.h.

Constructor & Destructor Documentation

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

Definition at line 147 of file SmearedJetProducerT.h.

References edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), SmearedJetProducerT< T, Textractor >::inputFile_, SmearedJetProducerT< T, Textractor >::jetCorrEtaMax_, SmearedJetProducerT< T, Textractor >::jetCorrLabel_, SmearedJetProducerT< T, Textractor >::lut_, SmearedJetProducerT< T, Textractor >::shiftBy_, SmearedJetProducerT< T, Textractor >::sigmaMaxGenJetMatch_, SmearedJetProducerT< T, Textractor >::skipCorrJetPtThreshold_, SmearedJetProducerT< T, Textractor >::skipJetSelection_, SmearedJetProducerT< T, Textractor >::skipRawJetPtThreshold_, SmearedJetProducerT< T, Textractor >::smearBy_, SmearedJetProducerT< T, Textractor >::src_, AlCaHLTBitMon_QueryRunRegistry::string, edm::FileInPath::Unknown, and SmearedJetProducerT< T, Textractor >::verbosity_.

148  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
149  genJetMatcher_(cfg),
152  {
153  //std::cout << "<SmearedJetProducer::SmearedJetProducer>:" << std::endl;
154  //std::cout << " moduleLabel = " << moduleLabel_ << std::endl;
155 
156  src_ = cfg.getParameter<edm::InputTag>("src");
157 
158  edm::FileInPath inputFileName = cfg.getParameter<edm::FileInPath>("inputFileName");
159  std::string lutName = cfg.getParameter<std::string>("lutName");
160  if (inputFileName.location() == edm::FileInPath::Unknown)
161  throw cms::Exception("JetMETsmearInputProducer")
162  << " Failed to find File = " << inputFileName << " !!\n";
163 
164  inputFile_ = new TFile(inputFileName.fullPath().data());
165  lut_ = dynamic_cast<TH2*>(inputFile_->Get(lutName.data()));
166  if ( !lut_ )
167  throw cms::Exception("SmearedJetProducer")
168  << " Failed to load LUT = " << lutName.data() << " from file = " << inputFileName.fullPath().data() << " !!\n";
169 
170  jetCorrLabel_ = ( cfg.exists("jetCorrLabel") ) ?
171  cfg.getParameter<std::string>("jetCorrLabel") : "";
172  jetCorrEtaMax_ = ( cfg.exists("jetCorrEtaMax") ) ?
173  cfg.getParameter<double>("jetCorrEtaMax") : 9.9;
174 
175  sigmaMaxGenJetMatch_ = cfg.getParameter<double>("sigmaMaxGenJetMatch");
176 
177  smearBy_ = ( cfg.exists("smearBy") ) ? cfg.getParameter<double>("smearBy") : 1.0;
178  //std::cout << "smearBy = " << smearBy_ << std::endl;
179 
180  shiftBy_ = ( cfg.exists("shiftBy") ) ? cfg.getParameter<double>("shiftBy") : 0.;
181  //std::cout << "shiftBy = " << shiftBy_ << std::endl;
182 
183  if ( cfg.exists("skipJetSelection") ) {
184  std::string skipJetSelection_string = cfg.getParameter<std::string>("skipJetSelection");
185  skipJetSelection_ = new StringCutObjectSelector<T>(skipJetSelection_string);
186  }
187 
188  skipRawJetPtThreshold_ = ( cfg.exists("skipRawJetPtThreshold") ) ?
189  cfg.getParameter<double>("skipRawJetPtThreshold") : 1.e-2;
190  skipCorrJetPtThreshold_ = ( cfg.exists("skipCorrJetPtThreshold") ) ?
191  cfg.getParameter<double>("skipCorrJetPtThreshold") : 1.e-2;
192 
193  verbosity_ = ( cfg.exists("verbosity") ) ?
194  cfg.getParameter<int>("verbosity") : 0;
195 
196  produces<JetCollection>();
197  }
T getParameter(std::string const &) const
StringCutObjectSelector< T > * skipJetSelection_
bool exists(std::string const &parameterName) const
checks if a parameter exists
SmearedJetProducer_namespace::GenJetMatcherT< T > genJetMatcher_
SmearedJetProducer_namespace::JetResolutionExtractorT< T > jetResolutionExtractor_
template<typename T , typename Textractor >
SmearedJetProducerT< T, Textractor >::~SmearedJetProducerT ( )
inline

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 207 of file SmearedJetProducerT.h.

References gather_cfg::cout, reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), SmearedJetProducerT< T, Textractor >::genJetMatcher_, edm::Event::getByLabel(), metsig::jet, SmearedJetProducerT< T, Textractor >::jetCorrEtaMax_, SmearedJetProducerT< T, Textractor >::jetCorrExtractor_, SmearedJetProducerT< T, Textractor >::jetCorrLabel_, SmearedJetProducerT< T, Textractor >::jetResolutionExtractor_, fwrapper::jets, edm::InputTag::label(), SmearedJetProducerT< T, Textractor >::lut_, siStripFEDMonitor_P5_cff::Max, SmearedJetProducerT< T, Textractor >::moduleLabel_, reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), edm::Event::put(), SmearedJetProducerT< T, Textractor >::rnd_, SmearedJetProducerT< T, Textractor >::shiftBy_, SmearedJetProducerT< T, Textractor >::sigmaMaxGenJetMatch_, SmearedJetProducerT< T, Textractor >::skipCorrJetPtThreshold_, SmearedJetProducerT< T, Textractor >::skipJetSelection_, SmearedJetProducerT< T, Textractor >::skipRawJetPtThreshold_, SmearedJetProducerT< T, Textractor >::smearBy_, SmearedJetProducerT< T, Textractor >::src_, SmearedJetProducerT< T, Textractor >::verbosity_, x, and detailsBasic3DVector::y.

208  {
209  if ( verbosity_ ) {
210  std::cout << "<SmearedJetProducerT::produce>:" << std::endl;
211  std::cout << " moduleLabel = " << moduleLabel_ << std::endl;
212  std::cout << " src = " << src_.label() << std::endl;
213  }
214 
215  std::auto_ptr<JetCollection> smearedJets(new JetCollection);
216 
218  evt.getByLabel(src_, jets);
219 
220  int numJets = jets->size();
221  for ( int jetIndex = 0; jetIndex < numJets; ++jetIndex ) {
222  const T& jet = jets->at(jetIndex);
223 
225  reco::Candidate::LorentzVector rawJetP4 = rawJetExtractor(jet);
226  if ( verbosity_ ) {
227  std::cout << "rawJet: Pt = " << rawJetP4.pt() << ", eta = " << rawJetP4.eta() << ", phi = " << rawJetP4.phi() << std::endl;
228  }
229 
230  reco::Candidate::LorentzVector corrJetP4 = jet.p4();
231  if ( jetCorrLabel_ != "" ) corrJetP4 = jetCorrExtractor_(jet, jetCorrLabel_, &evt, &es, jetCorrEtaMax_, &rawJetP4);
232  if ( verbosity_ ) {
233  std::cout << "corrJet: Pt = " << corrJetP4.pt() << ", eta = " << corrJetP4.eta() << ", phi = " << corrJetP4.phi() << std::endl;
234  }
235 
236  double smearFactor = 1.;
237  double x = TMath::Abs(corrJetP4.eta());
238  double y = corrJetP4.pt();
239  if ( x > lut_->GetXaxis()->GetXmin() && x < lut_->GetXaxis()->GetXmax() &&
240  y > lut_->GetYaxis()->GetXmin() && y < lut_->GetYaxis()->GetXmax() ) {
241  int binIndex = lut_->FindBin(x, y);
242 
243  if ( smearBy_ > 0. ) smearFactor += smearBy_*(lut_->GetBinContent(binIndex) - 1.);
244  double smearFactorErr = lut_->GetBinError(binIndex);
245  if ( verbosity_ ) std::cout << "smearFactor = " << smearFactor << " +/- " << smearFactorErr << std::endl;
246 
247  if ( shiftBy_ != 0. ) {
248  smearFactor += (shiftBy_*smearFactorErr);
249  if ( verbosity_ ) std::cout << "smearFactor(shifted) = " << smearFactor << std::endl;
250  }
251  }
252 
253  double smearedJetEn = jet.energy();
254  double sigmaEn = jetResolutionExtractor_(jet)*TMath::Sqrt(smearFactor*smearFactor - 1.);
255  const reco::GenJet* genJet = genJetMatcher_(jet, &evt);
256  bool isGenMatched = false;
257  if ( genJet ) {
258  if ( verbosity_ ) {
259  std::cout << "genJet: Pt = " << genJet->pt() << ", eta = " << genJet->eta() << ", phi = " << genJet->phi() << std::endl;
260  }
261  double dEn = corrJetP4.E() - genJet->energy();
262  if ( dEn < (sigmaMaxGenJetMatch_*sigmaEn) ) {
263 //--- case 1: reconstructed jet matched to generator level jet,
264 // smear difference between reconstructed and "true" jet energy
265 
266  if ( verbosity_ ) {
267  std::cout << " successfully matched to genJet" << std::endl;
268  std::cout << "corrJetEn = " << corrJetP4.E() << ", genJetEn = " << genJet->energy() << " --> dEn = " << dEn << std::endl;
269  }
270 
271  smearedJetEn = jet.energy()*(1. + (smearFactor - 1.)*dEn/TMath::Max(rawJetP4.E(), corrJetP4.E()));
272  isGenMatched = true;
273  }
274  }
275  if ( !isGenMatched ) {
276 //--- case 2: reconstructed jet **not** matched to generator level jet,
277 // smear jet energy using MC resolution functions implemented in PFMEt significance algorithm (CMS AN-10/400)
278 
279  if ( verbosity_ ) {
280  std::cout << " not matched to genJet" << std::endl;
281  std::cout << "corrJetEn = " << corrJetP4.E() << ", sigmaEn = " << sigmaEn << std::endl;
282  }
283 
284  if ( smearFactor > 1. ) {
285  // CV: MC resolution already accounted for in reconstructed jet,
286  // add additional Gaussian smearing of width = sqrt(smearFactor^2 - 1)
287  // to account for Data/MC **difference** in jet resolutions.
288  // Take maximum(rawJetEn, corrJetEn) to avoid pathological cases
289  // (e.g. corrJetEn << rawJetEn, due to L1Fastjet corrections)
290 
291  smearedJetEn = jet.energy()*(1. + rnd_.Gaus(0., sigmaEn)/TMath::Max(rawJetP4.E(), corrJetP4.E()));
292  }
293  }
294 
295  // CV: keep minimum jet energy, in order not to loose direction information
296  const double minJetEn = 1.e-2;
297  if ( smearedJetEn < minJetEn ) smearedJetEn = minJetEn;
298 
299  // CV: skip smearing in case either "raw" or "corrected" jet energy is very low
300  // or jet passes selection configurable via python
301  // (allows for protection against "pathological cases",
302  // cf. PhysicsTools/PatUtils/python/tools/metUncertaintyTools.py)
303  reco::Candidate::LorentzVector smearedJetP4 = jet.p4();
304  if ( !((skipJetSelection_ && (*skipJetSelection_)(jet)) ||
305  rawJetP4.pt() < skipRawJetPtThreshold_ ||
306  corrJetP4.pt() < skipCorrJetPtThreshold_ ) ) {
307  if ( verbosity_ ) {
308  std::cout << " smearing jetP4 by factor = " << (smearedJetEn/jet.energy()) << " --> smearedJetEn = " << smearedJetEn << std::endl;
309  }
310  smearedJetP4 *= (smearedJetEn/jet.energy());
311  }
312 
313  if ( verbosity_ ) {
314  std::cout << "smearedJet: Pt = " << smearedJetP4.pt() << ", eta = " << smearedJetP4.eta() << ", phi = " << smearedJetP4.phi() << std::endl;
315  std::cout << " dPt = " << (smearedJetP4.pt() - jet.pt())
316  << " (Px = " << (smearedJetP4.px() - jet.px()) << ", Py = " << (smearedJetP4.py() - jet.py()) << ")" << std::endl;
317  }
318 
319  T smearedJet = (jet);
320  smearedJet.setP4(smearedJetP4);
321 
322  smearedJets->push_back(smearedJet);
323  }
324 
325 //--- add collection of "smeared" jets to the event
326  evt.put(smearedJets);
327  }
virtual double energy() const GCC11_FINAL
energy
StringCutObjectSelector< T > * skipJetSelection_
SmearedJetProducer_namespace::GenJetMatcherT< T > genJetMatcher_
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
vector< PseudoJet > jets
Jets made from MC generator particles.
Definition: GenJet.h:25
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
SmearedJetProducer_namespace::JetResolutionExtractorT< T > jetResolutionExtractor_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
std::string const & label() const
Definition: InputTag.h:42
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10
virtual float pt() const GCC11_FINAL
transverse momentum
long double T
std::vector< T > JetCollection

Member Data Documentation

template<typename T , typename Textractor >
SmearedJetProducer_namespace::GenJetMatcherT<T> SmearedJetProducerT< T, Textractor >::genJetMatcher_
private
template<typename T , typename Textractor >
TFile* SmearedJetProducerT< T, Textractor >::inputFile_
private
template<typename T , typename Textractor >
double SmearedJetProducerT< T, Textractor >::jetCorrEtaMax_
private
template<typename T , typename Textractor >
Textractor SmearedJetProducerT< T, Textractor >::jetCorrExtractor_
private
template<typename T , typename Textractor >
std::string SmearedJetProducerT< T, Textractor >::jetCorrLabel_
private
template<typename T , typename Textractor >
SmearedJetProducer_namespace::JetResolutionExtractorT<T> SmearedJetProducerT< T, Textractor >::jetResolutionExtractor_
private
template<typename T , typename Textractor >
TH2* SmearedJetProducerT< T, Textractor >::lut_
private
template<typename T , typename Textractor >
std::string SmearedJetProducerT< T, Textractor >::moduleLabel_
private
template<typename T , typename Textractor >
TRandom3 SmearedJetProducerT< T, Textractor >::rnd_
private
template<typename T , typename Textractor >
double SmearedJetProducerT< T, Textractor >::shiftBy_
private
template<typename T , typename Textractor >
double SmearedJetProducerT< T, Textractor >::sigmaMaxGenJetMatch_
private
template<typename T , typename Textractor >
double SmearedJetProducerT< T, Textractor >::skipCorrJetPtThreshold_
private
template<typename T , typename Textractor >
StringCutObjectSelector<T>* SmearedJetProducerT< T, Textractor >::skipJetSelection_
private
template<typename T , typename Textractor >
double SmearedJetProducerT< T, Textractor >::skipRawJetPtThreshold_
private
template<typename T , typename Textractor >
double SmearedJetProducerT< T, Textractor >::smearBy_
private
template<typename T , typename Textractor >
edm::InputTag SmearedJetProducerT< T, Textractor >::src_
private
template<typename T , typename Textractor >
int SmearedJetProducerT< T, Textractor >::verbosity_
private