CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Attributes
EmbeddingKineReweightProducer Class Reference

#include <EmbeddingKineReweightProducer.h>

Inheritance diagram for EmbeddingKineReweightProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  lutEntryType
 

Public Member Functions

 EmbeddingKineReweightProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &)
 
 ~EmbeddingKineReweightProducer ()
 
- 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 Attributes

std::vector< lutEntryType * > lutEntries_
 
double maxWeight_
 
double minWeight_
 
edm::InputTag srcGenDiTaus_
 
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

Compute reweighting factors compensating (small) biases of the embedding procedure

Authors
Christian Veelken
Version
Revision:
1.3
Id:
EmbeddingKineReweightProducer.h,v 1.3 2013/04/17 07:11:37 veelken Exp

Definition at line 35 of file EmbeddingKineReweightProducer.h.

Constructor & Destructor Documentation

EmbeddingKineReweightProducer::EmbeddingKineReweightProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 15 of file EmbeddingKineReweightProducer.cc.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), analyzePatCleaning_cfg::inputFile, PFRecoTauDiscriminationAgainstMuonMVA_cfi::inputFileName, lutEntries_, maxWeight_, minWeight_, srcGenDiTaus_, AlCaHLTBitMon_QueryRunRegistry::string, edm::FileInPath::Unknown, makeLayoutFileForGui::variables, and verbosity_.

16 {
17  srcGenDiTaus_ = cfg.getParameter<edm::InputTag>("srcGenDiTaus");
18 
20  if ( inputFileName.location() == edm::FileInPath::Unknown)
21  throw cms::Exception("EmbeddingReweightProducer")
22  << " Failed to find File = " << inputFileName << " !!\n";
23  std::auto_ptr<TFile> inputFile(new TFile(inputFileName.fullPath().data()));
24 
25  edm::ParameterSet cfgLUTs = cfg.getParameter<edm::ParameterSet>("lutNames");
26  std::vector<std::string> variables = cfgLUTs.getParameterNamesForType<std::string>();
27  for ( std::vector<std::string>::const_iterator variable = variables.begin();
28  variable != variables.end(); ++variable ) {
29  std::string lutName = cfgLUTs.getParameter<std::string>(*variable);
30  lutEntryType* lutEntry =
31  new lutEntryType(*inputFile, *variable, lutName);
32  lutEntries_.push_back(lutEntry);
33  }
34 
35  minWeight_ = cfg.getParameter<double>("minWeight");
36  maxWeight_ = cfg.getParameter<double>("maxWeight");
37 
38  verbosity_ = ( cfg.exists("verbosity") ) ?
39  cfg.getParameter<int>("verbosity") : 0;
40 
41  for ( std::vector<lutEntryType*>::iterator lutEntry = lutEntries_.begin();
42  lutEntry != lutEntries_.end(); ++lutEntry ) {
43  produces<double>((*lutEntry)->variableName_);
44  }
45 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:192
std::vector< lutEntryType * > lutEntries_
EmbeddingKineReweightProducer::~EmbeddingKineReweightProducer ( )

Definition at line 47 of file EmbeddingKineReweightProducer.cc.

References lutEntries_.

48 {
49  for ( std::vector<lutEntryType*>::iterator it = lutEntries_.begin();
50  it != lutEntries_.end(); ++it ) {
51  delete (*it);
52  }
53 }
std::vector< lutEntryType * > lutEntries_

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 55 of file EmbeddingKineReweightProducer.cc.

References gather_cfg::cout, reco::Candidate::eta(), edm::Event::getByLabel(), lutEntries_, reco::Candidate::mass(), maxWeight_, minWeight_, reco::Candidate::phi(), reco::Candidate::pt(), edm::Event::put(), srcGenDiTaus_, verbosity_, and histoStyle::weight.

56 {
57  if ( verbosity_ ) {
58  std::cout << "<EmbeddingKineReweightProducer::produce>:" << std::endl;
59  }
60 
63  evt.getByLabel(srcGenDiTaus_, genDiTaus);
64  if ( genDiTaus->size() != 1 )
65  throw cms::Exception("EmbeddingKineReweightProducer")
66  << "Failed to find unique genDiTau object !!\n";
67  const reco::Candidate& genDiTau = genDiTaus->front();
68  if ( verbosity_ ) {
69  std::cout << "diTau: Pt = " << genDiTau.pt() << ", eta = " << genDiTau.eta() << ", phi = " << genDiTau.phi() << ", mass = " << genDiTau.mass() << std::endl;
70  }
71 
72  for ( std::vector<lutEntryType*>::const_iterator lutEntry = lutEntries_.begin();
73  lutEntry != lutEntries_.end(); ++lutEntry ) {
74  double weight = (**lutEntry)(genDiTau);
75  if ( weight < minWeight_ ) weight = minWeight_;
76  if ( weight > maxWeight_ ) weight = maxWeight_;
77  if ( verbosity_ ) {
78  std::cout << " " << (*lutEntry)->variableName_ << " = " << weight << std::endl;
79  }
80  std::auto_ptr<double> weightPtr(new double(weight));
81  evt.put(weightPtr, (*lutEntry)->variableName_);
82  }
83 }
virtual float mass() const =0
mass
virtual float eta() const =0
momentum pseudorapidity
virtual float phi() const =0
momentum azimuthal angle
edm::View< reco::Candidate > CandidateView
virtual float pt() const =0
transverse momentum
std::vector< lutEntryType * > lutEntries_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
tuple cout
Definition: gather_cfg.py:121
int weight
Definition: histoStyle.py:50

Member Data Documentation

std::vector<lutEntryType*> EmbeddingKineReweightProducer::lutEntries_
private
double EmbeddingKineReweightProducer::maxWeight_
private

Definition at line 166 of file EmbeddingKineReweightProducer.h.

Referenced by EmbeddingKineReweightProducer(), and produce().

double EmbeddingKineReweightProducer::minWeight_
private

Definition at line 165 of file EmbeddingKineReweightProducer.h.

Referenced by EmbeddingKineReweightProducer(), and produce().

edm::InputTag EmbeddingKineReweightProducer::srcGenDiTaus_
private

Definition at line 44 of file EmbeddingKineReweightProducer.h.

Referenced by EmbeddingKineReweightProducer(), and produce().

int EmbeddingKineReweightProducer::verbosity_
private

Definition at line 168 of file EmbeddingKineReweightProducer.h.

Referenced by EmbeddingKineReweightProducer(), and produce().