18 : lutEfficiencyPt_(0),
26 <<
" Failed to find File = " << inputFileName <<
" !!\n";
27 std::auto_ptr<TFile>
inputFile(
new TFile(inputFileName.fullPath().data()));
30 TH2* lutEfficiencyPt =
dynamic_cast<TH2*
>(inputFile->Get(lutEfficiencyPtName.data()));
31 if ( !lutEfficiencyPt )
33 <<
" Failed to load LUT = " << lutEfficiencyPtName <<
" from file = " << inputFile->GetName() <<
" !!\n";
39 TH2* lutEffCorrEta =
dynamic_cast<TH2*
>(inputFile->Get(lutEffCorrEtaName.data()));
42 <<
" Failed to load LUT = " << lutEffCorrEtaName <<
" from file = " << inputFile->GetName() <<
" !!\n";
53 produces<double>(
"weight");
54 produces<double>(
"weightUp");
55 produces<double>(
"weightDown");
66 int findBin(TAxis* xAxis,
double x)
68 int bin = xAxis->FindBin(x);
69 if ( bin < 1 ) bin = 1;
70 if ( bin > xAxis->GetNbins() ) bin = xAxis->GetNbins();
83 std::cout <<
"<ZmumuEvtSelEffCorrWeightProducer::produce>:" << std::endl;
89 double weightDown = 0.;
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;
102 double efficiencyPt =
lutEfficiencyPt_->GetBinContent(binX_efficiencyPt, binY_efficiencyPt);
103 double efficiencyPtErr =
lutEfficiencyPt_->GetBinError(binX_efficiencyPt, binY_efficiencyPt);
107 double effCorrEta =
lutEffCorrEta_->GetBinContent(binX_effCorrEta, binY_effCorrEta);
108 double effCorrEtaErr =
lutEffCorrEta_->GetBinError(binX_effCorrEta, binY_effCorrEta);
111 if ( efficiency > 0. ) {
115 weightUp = weight + TMath::Sqrt(
square(efficiencyPtErr*effCorrEta) +
square(efficiencyPt*effCorrEtaErr));
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.;
129 std::cout <<
"--> weight = " << weight <<
" + " << (weightUp -
weight) <<
" - " << (weight - weightDown) << std::endl;
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");
T getParameter(std::string const &) const
reco::CandidateBaseRef getTheMuMinus(const std::vector< reco::CandidateBaseRef > &)
~ZmumuEvtSelEffCorrWeightProducer()
virtual double pt() const =0
transverse momentum
#define DEFINE_FWK_MODULE(type)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
TAxis * yAxisEfficiencyPt_
bool isNonnull() const
Checks for non-null.
TAxis * xAxisEfficiencyPt_
T x() const
Cartesian x coordinate.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void produce(edm::Event &, const edm::EventSetup &)
ZmumuEvtSelEffCorrWeightProducer(const edm::ParameterSet &)
double square(const double a)
edm::InputTag srcSelectedMuons_
std::vector< reco::CandidateBaseRef > getSelMuons(const edm::Event &, const edm::InputTag &)
reco::CandidateBaseRef getTheMuPlus(const std::vector< reco::CandidateBaseRef > &)
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity