PhysicsTools
Heppy
src
PdfWeightProducerTool.cc
Go to the documentation of this file.
1
#include "
PhysicsTools/Heppy/interface/PdfWeightProducerTool.h
"
2
#include <cassert>
3
4
namespace
LHAPDF
{
5
void
initPDFSet
(
int
nset,
const
std::string
&
filename
,
int
member = 0);
6
int
numberPDF
(
int
nset);
7
void
usePDFMember
(
int
nset,
int
member);
8
double
xfx
(
int
nset,
double
x,
double
Q,
int
fl);
9
double
getXmin
(
int
nset,
int
member);
10
double
getXmax
(
int
nset,
int
member);
11
double
getQ2min
(
int
nset,
int
member);
12
double
getQ2max
(
int
nset,
int
member);
13
void
extrapolate
(
bool
extrapolate
=
true
);
14
}
// namespace LHAPDF
15
16
namespace
heppy
{
17
18
void
PdfWeightProducerTool::addPdfSet
(
const
std::string
&
name
) {
19
pdfs_
.push_back(
name
);
20
weights_
[
name
] = std::vector<double>();
21
}
22
23
void
PdfWeightProducerTool::beginJob
() {
24
for
(
unsigned
int
i
= 0,
n
=
pdfs_
.size();
i
<
n
; ++
i
) {
25
LHAPDF::initPDFSet
(
i
+ 1,
pdfs_
[
i
]);
26
}
27
}
28
29
void
PdfWeightProducerTool::processEvent
(
const
GenEventInfoProduct
&pdfstuff) {
30
float
Q = pdfstuff.
pdf
()->
scalePDF
;
31
32
int
id1
= pdfstuff.
pdf
()->
id
.first;
33
double
x1
= pdfstuff.
pdf
()->
x
.first;
34
double
pdf1 = pdfstuff.
pdf
()->
xPDF
.first;
35
36
int
id2
= pdfstuff.
pdf
()->
id
.second;
37
double
x2
= pdfstuff.
pdf
()->
x
.second;
38
double
pdf2 = pdfstuff.
pdf
()->
xPDF
.second;
39
40
for
(
unsigned
int
i
= 0,
n
=
pdfs_
.size();
i
<
n
; ++
i
) {
41
std::vector<double> &
weights
=
weights_
[
pdfs_
[
i
]];
42
unsigned
int
nweights = 1;
43
if
(
LHAPDF::numberPDF
(
i
+ 1) > 1)
44
nweights +=
LHAPDF::numberPDF
(
i
+ 1);
45
weights
.resize(nweights);
46
47
for
(
unsigned
int
j
= 0;
j
< nweights; ++
j
) {
48
LHAPDF::usePDFMember
(
i
+ 1,
j
);
49
double
newpdf1 =
LHAPDF::xfx
(
i
+ 1,
x1
, Q,
id1
) /
x1
;
50
double
newpdf2 =
LHAPDF::xfx
(
i
+ 1,
x2
, Q,
id2
) /
x2
;
51
weights
[
j
] = newpdf1 / pdf1 * newpdf2 / pdf2;
52
}
53
}
54
}
55
56
const
std::vector<double> &
PdfWeightProducerTool::getWeights
(
const
std::string
&
name
)
const
{
57
std::map<std::string, std::vector<double> >::const_iterator
match
=
weights_
.find(
name
);
58
assert
(
match
!=
weights_
.end());
59
return
match
->second;
60
}
61
62
}
// namespace heppy
mps_fire.i
i
Definition:
mps_fire.py:429
globals_cff.id1
id1
Definition:
globals_cff.py:50
dqmiolumiharvest.j
j
Definition:
dqmiolumiharvest.py:66
heppy::PdfWeightProducerTool::pdfs_
std::vector< std::string > pdfs_
Definition:
PdfWeightProducerTool.h:25
GenEventInfoProduct
Definition:
GenEventInfoProduct.h:17
gen::PdfInfo::x
std::pair< double, double > x
Definition:
PdfInfo.h:13
corrVsCorr.filename
filename
Definition:
corrVsCorr.py:123
heppy::PdfWeightProducerTool::weights_
std::map< std::string, std::vector< double > > weights_
Definition:
PdfWeightProducerTool.h:26
heppy::PdfWeightProducerTool::addPdfSet
void addPdfSet(const std::string &name)
Definition:
PdfWeightProducerTool.cc:18
heppy::PdfWeightProducerTool::processEvent
void processEvent(const GenEventInfoProduct &pdfstuff)
Definition:
PdfWeightProducerTool.cc:29
cms::cuda::assert
assert(be >=bs)
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
dqmiodumpmetadata.n
n
Definition:
dqmiodumpmetadata.py:28
gen::PdfInfo::xPDF
std::pair< double, double > xPDF
Definition:
PdfInfo.h:14
LHAPDF::getXmax
double getXmax(int nset, int member)
LHAPDF::getQ2max
double getQ2max(int nset, int member)
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition:
testProducerWithPsetDescEmpty_cfi.py:28
heppy::PdfWeightProducerTool::beginJob
void beginJob()
Definition:
PdfWeightProducerTool.cc:23
LHAPDF::extrapolate
void extrapolate(bool extrapolate=true)
PdfWeightProducerTool.h
hltDeepSecondaryVertexTagInfosPFPuppi_cfi.weights
weights
Definition:
hltDeepSecondaryVertexTagInfosPFPuppi_cfi.py:71
LHAPDF::numberPDF
int numberPDF(int nset)
heppy
TAKEN FROM http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/ElectroWeakAnalysis/Utilities/src/PdfWeig...
Definition:
AlphaT.h:16
LHAPDF::getXmin
double getXmin(int nset, int member)
gen::PdfInfo::id
std::pair< int, int > id
Definition:
PdfInfo.h:12
LHAPDF::initPDFSet
void initPDFSet(int nset, int setid, int member=0)
LHAPDF
Definition:
LHECOMWeightProducer.cc:46
globals_cff.id2
id2
Definition:
globals_cff.py:51
GenEventInfoProduct::pdf
const PDF * pdf() const
Definition:
GenEventInfoProduct.h:45
LHAPDF::xfx
double xfx(int nset, double x, double Q, int fl)
heppy::PdfWeightProducerTool::getWeights
const std::vector< double > & getWeights(const std::string &name) const
Definition:
PdfWeightProducerTool.cc:56
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
LHAPDF::getQ2min
double getQ2min(int nset, int member)
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition:
testProducerWithPsetDescEmpty_cfi.py:33
gen::PdfInfo::scalePDF
double scalePDF
Definition:
PdfInfo.h:15
Skims_PA_cff.name
name
Definition:
Skims_PA_cff.py:17
LHAPDF::usePDFMember
void usePDFMember(int nset, int member)
Generated for CMSSW Reference Manual by
1.8.14