Skip to content

Commit

Permalink
Merge pull request cms-sw#83 from pandolf/CMG_MiniAOD_Lite_V6_0_from-…
Browse files Browse the repository at this point in the history
…CMSSW_7_0_6

merging.
If you want the feature also in 5.3.X please make a pull request for that too (git cherry-pick or git rebase should help)
  • Loading branch information
gpetruc committed Jul 11, 2014
2 parents 664e38b + 941195f commit b73eb6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 7 additions & 7 deletions CMGTools/RootTools/python/analyzers/PileUpAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,31 @@ def process(self, iEvent, event):
return True

event.vertexWeight = 1
nPU = None
event.nPU = None
if self.cfg_comp.isMC:
event.pileUpInfo = map( PileUpSummaryInfo,
self.mchandles['pusi'].product() )
for puInfo in event.pileUpInfo:
if puInfo.getBunchCrossing()==0:
# import pdb; pdb.set_trace()
if self.cfg_ana.true is False:
nPU = puInfo.nPU()
event.nPU = puInfo.nPU()
else:
nPU = puInfo.nTrueInteractions()
event.nPU = puInfo.nTrueInteractions()

if self.doHists:
self.rawmcpileup.hist.Fill( nPU )
self.rawmcpileup.hist.Fill( event.nPU )

if nPU is None:
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:
vertices = self.handles['vertices'].product()
nPU = len(vertices)
event.nPU = len(vertices)
else:
return True

if self.enable:
bin = self.datahist.FindBin(nPU)
bin = self.datahist.FindBin(event.nPU)
if bin<1 or bin>self.datahist.GetNbinsX():
event.vertexWeight = 0
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def declareCoreVariables(self, tr, isMC):
if isMC:
## PU weights
tr.var("puWeight")
## number of true interactions
tr.var("nTrueInt")
## PDF weights
self.pdfWeights = []
if hasattr(self.cfg_ana, "PDFWeights") and len(self.cfg_ana.PDFWeights) > 0:
Expand Down Expand Up @@ -91,6 +93,7 @@ def fillCoreVariables(self, tr, iEvent, event, isMC):

if isMC:
## PU weights
tr.fill("nTrueInt", event.nPU)
tr.fill("puWeight", event.eventWeight)
## PDF weights
for (pdf,nvals) in self.pdfWeights:
Expand Down

0 comments on commit b73eb6a

Please sign in to comment.