ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/ForwardAnalysis/Utilities/python/PFCandidateNoiseStringCut.py
Revision: 1.2
Committed: Wed Jan 5 13:34:42 2011 UTC (14 years, 3 months ago) by antoniov
Content type: text/x-python
Branch: MAIN
CVS Tags: V01-01-01, V01-01-00, antoniov-forwardAnalysis-09Jul2012-v1, antoniov-forwardAnalysis-29Jun2012-v1, V01-00-00, antoniov-utilities-11Jun2012-v1, antoniov-forwardAnalysis-Oct072011-v1, sfonseca_10_04_2011, antoniov-forwardAnalysis-Sep182011-v1, antoniov-forwardAnalysis-Sep102011-v1, eliza_09_02_2011, sfonseca_08_26_2011, forwardAnalysis-Aug232011-v1, forwardAnalysis-Aug172011-v1, forwardAnalysis-Aug052011-v1, forwardAnalysis-Jul222011-v1, tools-Jan062011-v1, tools-Jan052011-v1, HEAD
Changes since 1.1: +1 -1 lines
Error occurred while calculating annotation data.
Log Message:
update

File Contents

# Content
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