1 |
import FWCore.ParameterSet.Config as cms
|
2 |
import math
|
3 |
|
4 |
def pFlowId(name):
|
5 |
types = ("X", "h", "e", "mu", "gamma", "h0", "h_HF", "egamma_HF")
|
6 |
labels = {}
|
7 |
labels["X"] = ("X","undefined")
|
8 |
labels["h"] = ("h","chargedHadron","hadronCharged")
|
9 |
labels["e"] = ("e","electron")
|
10 |
labels["mu"] = ("mu","muon")
|
11 |
labels["gamma"] = ("gamma","photon")
|
12 |
labels["h0"] = ("h0","neutralHadron","hadronNeutral")
|
13 |
labels["h_HF"] = ("h_HF","hadronHF")
|
14 |
labels["egamma_HF"] = ("egamma_HF","emHF");
|
15 |
|
16 |
id = -1
|
17 |
for type in types:
|
18 |
if name in labels[type]:
|
19 |
id = types.index(type)
|
20 |
break
|
21 |
|
22 |
return id
|
23 |
|
24 |
|
25 |
class PFCandidateNoiseStringCut:
|
26 |
def __init__(self, pset):
|
27 |
self.pset = pset
|
28 |
|
29 |
self.types = ("X", "h", "e", "mu", "gamma", "h0", "h_HF", "egamma_HF")
|
30 |
self.ranges = {}
|
31 |
self.ranges["Barrel"] = (0.0,1.4)
|
32 |
self.ranges["Endcap"] = (1.4,2.6)
|
33 |
self.ranges["Transition"] = (2.6,3.2)
|
34 |
self.ranges["Forward"] = (3.2,999.0)
|
35 |
|
36 |
def cut(self):
|
37 |
self.thresholdPSets = {}
|
38 |
self.thresholdPSets["Barrel"] = self.pset.getParameter("Barrel")
|
39 |
self.thresholdPSets["Endcap"] = self.pset.getParameter("Endcap")
|
40 |
self.thresholdPSets["Transition"] = self.pset.getParameter("Transition")
|
41 |
self.thresholdPSets["Forward"] = self.pset.getParameter("Forward")
|
42 |
|
43 |
cutStr = ""
|
44 |
for region in self.thresholdPSets:
|
45 |
if cutStr: cutStr += " ) | ( "
|
46 |
else: cutStr += "( "
|
47 |
cutStr += "(abs(eta) >= %f & abs(eta) < %f)" % (self.ranges[region][0],self.ranges[region][1])
|
48 |
|
49 |
regionPSet = self.thresholdPSets[region]
|
50 |
typePSetNames = regionPSet.parameterNames_()
|
51 |
typePSetIds = [pFlowId(item) for item in typePSetNames]
|
52 |
cutStr += " & ( "
|
53 |
idxType = 0
|
54 |
for type in self.types:
|
55 |
if idxType: cutStr += " ) | ( "
|
56 |
else: cutStr += "( "
|
57 |
typeId = pFlowId(type)
|
58 |
cutStr += "particleId == %d" % typeId
|
59 |
if typeId in typePSetIds:
|
60 |
typePSet = regionPSet.getParameter( typePSetNames[typePSetIds.index(typeId)] )
|
61 |
variablePSetNames = typePSet.parameterNames_()
|
62 |
for variable in variablePSetNames:
|
63 |
value = typePSet.getParameter(variable).value()
|
64 |
cutStr += " & ( %s >= %f )" % (variable,value)
|
65 |
|
66 |
idxType += 1
|
67 |
cutStr += " )"
|
68 |
cutStr += " )"
|
69 |
|
70 |
cutStr += " )"
|
71 |
return cutStr
|