Main Page
Namespaces
Classes
Package Documentation
CVS Directory
WorkBook
Offline Guide
Release schedule
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
PhysicsTools
HeppyCore
python
framework
weight.py
Go to the documentation of this file.
1
from
__future__
import
print_function
2
# Copyright (C) 2014 Colin Bernet
3
# https://github.com/cbernet/heppy/blob/master/LICENSE
4
5
def
printWeights
( weights ):
6
for
key, value
in
weights.items():
7
print
(key)
8
print
(value)
9
10
class
Weight
( object ):
11
'''make names uniform wrt Component.
12
13
COLIN: messy... should I have several types of weight (base, data, mc)?
14
COLIN: need to add other weighting factors'''
15
16
FBINV = 1000.
17
18
def
__init__
(self, genNEvents, xSection, genEff,
19
intLumi = FBINV, addWeight=1):
20
self.
genNEvents
= int(genNEvents)
21
if
xSection
is
not
None
:
22
self.
xSection
= float(xSection)
23
else
:
24
self.
xSection
=
None
25
self.
genEff
= float(genEff)
26
if
intLumi
is
not
None
:
27
self.
intLumi
= float(intLumi)
28
else
:
29
self.
intLumi
= Weight.FBINV
30
self.
addWeight
= float(addWeight)
31
32
def
GetWeight
(self):
33
'''Return the weight'''
34
if
self.
xSection
is
None
:
35
# data
36
return
1
37
else
:
38
# MC
39
return
self.
addWeight
* self.
xSection
* self.
intLumi
/ ( self.
genNEvents
* self.
genEff
)
40
41
def
SetIntLumi
(self, lumi):
42
'''Set integrated luminosity.'''
43
self.dict[
'intLumi'
] = lumi
44
45
def
__str__
(self):
46
if
self.
xSection
is
None
:
47
return
' intLumi = %5.2f, addWeight = %3.2f'
\
48
% ( self.
intLumi
,
49
self.
addWeight
)
50
else
:
51
return
' genN = %d, xsec = %5.5f pb, genEff = %2.2f, intLumi = %5.2f, addWeight = %3.2f -> weight = %3.5f'
\
52
% ( self.
genNEvents
,
53
self.
xSection
,
54
self.
genEff
,
55
self.
intLumi
,
56
self.
addWeight
,
57
self.
GetWeight
() )
58
59
weight.Weight.intLumi
intLumi
Definition:
weight.py:27
weight.Weight.__str__
def __str__
Definition:
weight.py:45
weight.Weight.xSection
xSection
Definition:
weight.py:22
weight.Weight
Definition:
weight.py:10
weight.printWeights
def printWeights
Definition:
weight.py:5
weight.Weight.genNEvents
genNEvents
Definition:
weight.py:20
weight.Weight.addWeight
addWeight
Definition:
weight.py:30
weight.Weight.SetIntLumi
def SetIntLumi
Definition:
weight.py:41
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition:
Utilities.cc:47
weight.Weight.__init__
def __init__
Definition:
weight.py:19
weight.Weight.genEff
genEff
Definition:
weight.py:25
weight.Weight.GetWeight
def GetWeight
Definition:
weight.py:32
Generated for CMSSW Reference Manual by
1.8.5