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 Attributes
ZmumuEvtSelEffCorrWeightProducer Class Reference

#include <ZmumuEvtSelEffCorrWeightProducer.h>

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

Public Member Functions

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

TH2 * lutEffCorrEta_
 
TH2 * lutEfficiencyPt_
 
double maxWeight_
 
double minWeight_
 
edm::InputTag srcSelectedMuons_
 
int verbosity_
 
TAxis * xAxisEffCorrEta_
 
TAxis * xAxisEfficiencyPt_
 
TAxis * yAxisEffCorrEta_
 
TAxis * yAxisEfficiencyPt_
 

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 weight factor and uncertainty for correcting Embedded samples for efficiency with which Zmumu events used as input for Embedding production were selected

Authors
Christian Veelken
Version
Revision:
1.1
Id:
ZmumuEvtSelEffCorrWeightProducer.h,v 1.1 2013/02/21 14:08:41 veelken Exp

Definition at line 32 of file ZmumuEvtSelEffCorrWeightProducer.h.

Constructor & Destructor Documentation

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

Definition at line 17 of file ZmumuEvtSelEffCorrWeightProducer.cc.

References python.multivaluedict::append(), edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), analyzePatCleaning_cfg::inputFile, PFRecoTauDiscriminationAgainstElectronMVA5_cfi::inputFileName, lutEffCorrEta_, lutEfficiencyPt_, maxWeight_, minWeight_, srcSelectedMuons_, AlCaHLTBitMon_QueryRunRegistry::string, edm::FileInPath::Unknown, verbosity_, xAxisEffCorrEta_, xAxisEfficiencyPt_, yAxisEffCorrEta_, and yAxisEfficiencyPt_.

18  : lutEfficiencyPt_(0),
20 {
21  srcSelectedMuons_ = cfg.getParameter<edm::InputTag>("selectedMuons");
22 
24  if ( inputFileName.location() == edm::FileInPath::Unknown)
25  throw cms::Exception("MuonRadiationCorrWeightProducer")
26  << " Failed to find File = " << inputFileName << " !!\n";
27  std::auto_ptr<TFile> inputFile(new TFile(inputFileName.fullPath().data()));
28 
29  std::string lutEfficiencyPtName = cfg.getParameter<std::string>("lutEfficiencyPt");
30  TH2* lutEfficiencyPt = dynamic_cast<TH2*>(inputFile->Get(lutEfficiencyPtName.data()));
31  if ( !lutEfficiencyPt )
32  throw cms::Exception("MuonRadiationCorrWeightProducer")
33  << " Failed to load LUT = " << lutEfficiencyPtName << " from file = " << inputFile->GetName() << " !!\n";
34  lutEfficiencyPt_ = (TH2*)lutEfficiencyPt->Clone(std::string(lutEfficiencyPt->GetName()).append("_cloned").data());
37 
38  std::string lutEffCorrEtaName = cfg.getParameter<std::string>("lutEffCorrEta");
39  TH2* lutEffCorrEta = dynamic_cast<TH2*>(inputFile->Get(lutEffCorrEtaName.data()));
40  if ( !lutEffCorrEta )
41  throw cms::Exception("MuonRadiationCorrWeightProducer")
42  << " Failed to load LUT = " << lutEffCorrEtaName << " from file = " << inputFile->GetName() << " !!\n";
43  lutEffCorrEta_ = (TH2*)lutEffCorrEta->Clone(std::string(lutEffCorrEta->GetName()).append("_cloned").data());
44  xAxisEffCorrEta_ = lutEffCorrEta_->GetXaxis();
45  yAxisEffCorrEta_ = lutEffCorrEta_->GetYaxis();
46 
47  minWeight_ = cfg.getParameter<double>("minWeight");
48  maxWeight_ = cfg.getParameter<double>("maxWeight");
49 
50  verbosity_ = ( cfg.exists("verbosity") ) ?
51  cfg.getParameter<int>("verbosity") : 0;
52 
53  produces<double>("weight");
54  produces<double>("weightUp");
55  produces<double>("weightDown");
56 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
ZmumuEvtSelEffCorrWeightProducer::~ZmumuEvtSelEffCorrWeightProducer ( )

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 80 of file ZmumuEvtSelEffCorrWeightProducer.cc.

References gather_cfg::cout, postValidation_cfi::efficiency, reco::Candidate::eta(), getSelMuons(), getTheMuMinus(), getTheMuPlus(), edm::RefToBase< T >::isNonnull(), lutEffCorrEta_, lutEfficiencyPt_, maxWeight_, minWeight_, reco::Candidate::phi(), reco::Candidate::pt(), edm::Event::put(), Clusterizer1DCommons::square(), srcSelectedMuons_, verbosity_, histoStyle::weight, xAxisEffCorrEta_, xAxisEfficiencyPt_, yAxisEffCorrEta_, and yAxisEfficiencyPt_.

81 {
82  if ( verbosity_ ) {
83  std::cout << "<ZmumuEvtSelEffCorrWeightProducer::produce>:" << std::endl;
84  std::cout << " srcSelectedMuons = " << srcSelectedMuons_ << std::endl;
85  }
86 
87  double weight = 1.;
88  double weightUp = 2.*maxWeight_;
89  double weightDown = 0.;
90 
91  std::vector<reco::CandidateBaseRef> selMuons = getSelMuons(evt, srcSelectedMuons_);
92  const reco::CandidateBaseRef muPlus = getTheMuPlus(selMuons);
93  const reco::CandidateBaseRef muMinus = getTheMuMinus(selMuons);
94  if ( muPlus.isNonnull() && muMinus.isNonnull() ) {
95  if ( verbosity_ ) {
96  std::cout << "Mu+: Pt = " << muPlus->pt() << ", eta = " << muPlus->eta() << ", phi = " << muPlus->phi() << std::endl;
97  std::cout << "Mu-: Pt = " << muMinus->pt() << ", eta = " << muMinus->eta() << ", phi = " << muMinus->phi() << std::endl;
98  }
99 
100  int binX_efficiencyPt = findBin(xAxisEfficiencyPt_, muPlus->pt());
101  int binY_efficiencyPt = findBin(yAxisEfficiencyPt_, muMinus->pt());
102  double efficiencyPt = lutEfficiencyPt_->GetBinContent(binX_efficiencyPt, binY_efficiencyPt);
103  double efficiencyPtErr = lutEfficiencyPt_->GetBinError(binX_efficiencyPt, binY_efficiencyPt);
104 
105  int binX_effCorrEta = findBin(xAxisEffCorrEta_, muPlus->eta());
106  int binY_effCorrEta = findBin(yAxisEffCorrEta_, muMinus->eta());
107  double effCorrEta = lutEffCorrEta_->GetBinContent(binX_effCorrEta, binY_effCorrEta);
108  double effCorrEtaErr = lutEffCorrEta_->GetBinError(binX_effCorrEta, binY_effCorrEta);
109 
110  double efficiency = efficiencyPt*effCorrEta;
111  if ( efficiency > 0. ) {
112  weight = 1./efficiency;
113  if ( weight > maxWeight_ ) weight = maxWeight_;
114  if ( weight < minWeight_ ) weight = minWeight_;
115  weightUp = weight + TMath::Sqrt(square(efficiencyPtErr*effCorrEta) + square(efficiencyPt*effCorrEtaErr));
116  if ( weightUp > (2.*maxWeight_) ) weightUp = 2.*maxWeight_;
117  if ( weightUp < weight ) weightUp = weight;
118  weightDown = weight - TMath::Sqrt(square(efficiencyPtErr*effCorrEta) + square(efficiencyPt*effCorrEtaErr));
119  if ( weightDown > weight ) weightDown = weight;
120  if ( weightDown < 0. ) weightDown = 0.;
121  } else {
122  weight = maxWeight_;
123  weightUp = 2.*maxWeight_;
124  weightDown = 0.;
125  }
126  }
127 
128  if ( verbosity_ ) {
129  std::cout << "--> weight = " << weight << " + " << (weightUp - weight) << " - " << (weight - weightDown) << std::endl;
130  }
131 
132  std::auto_ptr<double> weightPtr(new double(weight));
133  evt.put(weightPtr, "weight");
134  std::auto_ptr<double> weightUpPtr(new double(weightUp));
135  evt.put(weightUpPtr, "weightUp");
136  std::auto_ptr<double> weightDownPtr(new double(weightDown));
137  evt.put(weightDownPtr, "weightDown");
138 }
reco::CandidateBaseRef getTheMuMinus(const std::vector< reco::CandidateBaseRef > &)
virtual float eta() const =0
momentum pseudorapidity
virtual float phi() const =0
momentum azimuthal angle
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:280
virtual float pt() const =0
transverse momentum
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
double square(const double a)
tuple cout
Definition: gather_cfg.py:121
std::vector< reco::CandidateBaseRef > getSelMuons(const edm::Event &, const edm::InputTag &)
int weight
Definition: histoStyle.py:50
reco::CandidateBaseRef getTheMuPlus(const std::vector< reco::CandidateBaseRef > &)

Member Data Documentation

TH2* ZmumuEvtSelEffCorrWeightProducer::lutEffCorrEta_
private
TH2* ZmumuEvtSelEffCorrWeightProducer::lutEfficiencyPt_
private
double ZmumuEvtSelEffCorrWeightProducer::maxWeight_
private

Definition at line 51 of file ZmumuEvtSelEffCorrWeightProducer.h.

Referenced by produce(), and ZmumuEvtSelEffCorrWeightProducer().

double ZmumuEvtSelEffCorrWeightProducer::minWeight_
private

Definition at line 50 of file ZmumuEvtSelEffCorrWeightProducer.h.

Referenced by produce(), and ZmumuEvtSelEffCorrWeightProducer().

edm::InputTag ZmumuEvtSelEffCorrWeightProducer::srcSelectedMuons_
private

Definition at line 41 of file ZmumuEvtSelEffCorrWeightProducer.h.

Referenced by produce(), and ZmumuEvtSelEffCorrWeightProducer().

int ZmumuEvtSelEffCorrWeightProducer::verbosity_
private

Definition at line 53 of file ZmumuEvtSelEffCorrWeightProducer.h.

Referenced by produce(), and ZmumuEvtSelEffCorrWeightProducer().

TAxis* ZmumuEvtSelEffCorrWeightProducer::xAxisEffCorrEta_
private

Definition at line 47 of file ZmumuEvtSelEffCorrWeightProducer.h.

Referenced by produce(), and ZmumuEvtSelEffCorrWeightProducer().

TAxis* ZmumuEvtSelEffCorrWeightProducer::xAxisEfficiencyPt_
private

Definition at line 44 of file ZmumuEvtSelEffCorrWeightProducer.h.

Referenced by produce(), and ZmumuEvtSelEffCorrWeightProducer().

TAxis* ZmumuEvtSelEffCorrWeightProducer::yAxisEffCorrEta_
private

Definition at line 48 of file ZmumuEvtSelEffCorrWeightProducer.h.

Referenced by produce(), and ZmumuEvtSelEffCorrWeightProducer().

TAxis* ZmumuEvtSelEffCorrWeightProducer::yAxisEfficiencyPt_
private

Definition at line 45 of file ZmumuEvtSelEffCorrWeightProducer.h.

Referenced by produce(), and ZmumuEvtSelEffCorrWeightProducer().