Skip to content

Commit

Permalink
Merge pull request cms-sw#56 from arizzi/heppyPU
Browse files Browse the repository at this point in the history
Add PU information in heppy
  • Loading branch information
cbernet committed Sep 17, 2015
2 parents 021b7a1 + 0da5b97 commit 21131b6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions PhysicsTools/Heppy/python/analyzers/core/PileUpAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
def declareHandles(self):
super(PileUpAnalyzer, self).declareHandles()
self.mchandles['pusi'] = AutoHandle(
'addPileupInfo',
'std::vector<PileupSummaryInfo>'
'slimmedAddPileupInfo',
'std::vector<PileupSummaryInfo>',
fallbackLabel="addPileupInfo"
)

if self.allVertices == '_AUTO_':
self.handles['vertices'] = AutoHandle( "offlineSlimmedPrimaryVertices", 'std::vector<reco::Vertex>', fallbackLabel="offlinePrimaryVertices" )
else:
Expand All @@ -104,6 +106,8 @@ def process(self, event):

event.vertexWeight = 1
event.nPU = None
event.pileUpVertex_z = []
event.pileUpVertex_ptHat = []
if self.cfg_comp.isMC:
event.pileUpInfo = map( PileUpSummaryInfo,
self.mchandles['pusi'].product() )
Expand All @@ -118,6 +122,13 @@ def process(self, event):
if self.doHists:
self.rawmcpileup.hist.Fill( event.nPU )

##get z position of on-time pile-up sorted by pt-hat
ptHat_zPositions = zip(puInfo.getPU_pT_hats(),puInfo.getPU_zpositions())
ptHat_zPositions.sort(reverse=True)
for ptHat_zPosition in ptHat_zPositions:
event.pileUpVertex_z.append(ptHat_zPosition[1])
event.pileUpVertex_ptHat.append(ptHat_zPosition[0])

if event.nPU is None:
raise ValueError('nPU cannot be None! means that no pu info has been found for bunch crossing 0.')
elif self.cfg_comp.isEmbed:
Expand Down

0 comments on commit 21131b6

Please sign in to comment.