Skip to content

Commit

Permalink
updates for 7 GeV pions, use larger cone for matching
Browse files Browse the repository at this point in the history
  • Loading branch information
clelange committed Dec 11, 2017
1 parent e6229c1 commit adf1541
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
10 changes: 5 additions & 5 deletions hgcalHistHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def histsPrintSaveSameCanvas(histsAndProps, outDir, tag="hists1D_", latexComment
if (type(hist) == ROOT.TH1F) or (type(hist) == ROOT.TH2F) or (type(hist) == ROOT.TH3F):
if hist.GetEntries() == 0:
continue
if (type(hist) == ROOT.TH1F):
hist.Rebin()
# if (type(hist) == ROOT.TH1F):
# hist.Rebin()
x_maxs.append(hist.GetBinCenter(hist.FindLastBinAbove(1)))
hist.Scale(1./hist.Integral())
hist.GetYaxis().SetTitle("a.u.")
Expand Down Expand Up @@ -298,14 +298,14 @@ def fitResolution(graph, fitLineColor = ROOT.kBlue, fitLineStyle = 1, rangeLimit
stochasticTermLimitDn = 0
stochasticTermLimitUp = 300
constantTermLimitDn = 0
constantTermLimitUp = 10
constantTermLimitUp = 100
noiseTermLimitDn = 0
noiseTermLimitUp = 30
noiseTermLimitUp = 500
# define the fitting gausian and range of its parameters
fResolution = ROOT.TF1("f", "sqrt([1]*[1] + [0]*[0]/x + [2]*[2]/(x*x))", rangeLimitDn, rangeLimitUp)
fResolution.SetParLimits(0, stochasticTermLimitDn, stochasticTermLimitUp) # stochastic term
fResolution.SetParLimits(1, constantTermLimitDn, constantTermLimitUp) # constant term
# fResolution.SetParLimits(2, noiseTermLimitDn, noiseTermLimitUp) # noise term
fResolution.SetParLimits(2, noiseTermLimitDn, noiseTermLimitUp) # noise term
fResolution.SetLineColor(fitLineColor)
fResolution.SetLineStyle(fitLineStyle)
# perform fit and extract params
Expand Down
8 changes: 6 additions & 2 deletions megaClustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ def getMegaClusters(genParticles, multiClusters, layerClusters, recHits, gun_typ

if multiClusters.shape[0] == 0:
return pd.DataFrame(columns=['pt', 'eta', 'phi', 'energy'])
# for the mega cluster axis, take highest energy multicluster within dR = 0.1
bestMultiClusterIndices = hgcalHelpers.getHighestEnergyObjectIndex(selectedGen[['eta', 'phi']], multiClusters[['eta', 'phi']], multiClusters['energy'], 0.1)
# for the mega cluster axis, take highest energy multicluster within dR = 0.1, 0.2 for 7 GeV guns
bestMultiClusterIndices = None
if GEN_engpt <= 7.5:
bestMultiClusterIndices = hgcalHelpers.getHighestEnergyObjectIndex(selectedGen[['eta', 'phi']], multiClusters[['eta', 'phi']], multiClusters['energy'], 0.2)
else:
bestMultiClusterIndices = hgcalHelpers.getHighestEnergyObjectIndex(selectedGen[['eta', 'phi']], multiClusters[['eta', 'phi']], multiClusters['energy'], 0.1)
# print bestMultiClusterIndices

megaClusters = []
Expand Down
16 changes: 14 additions & 2 deletions resolutionScalePlotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def plotComparisons(histsFilesAndInfoMap, resScale_values, pidSelected, GEN_engp
# prepare basic info and plot these histograms on top of each other
gMeanCalibEnergy = (resScale_values[etaBinName][phiBinName]['mean'] / 100. + 1.) * GEN_engpt
gMeanCalibEnergyError = (resScale_values[etaBinName][phiBinName]['meanError'] / 100.) * GEN_engpt
# plotComments = ["p_{T,fit} = " + "{0:.2f}".format(gMeanCalibEnergy) + " #pm " + "{0:.2f}".format(gMeanCalibEnergyError) + " GeV",
plotComments = []
plotComments = ["p_{T,fit} = " + "{0:.2f}".format(gMeanCalibEnergy) + " #pm " + "{0:.2f}".format(gMeanCalibEnergyError) + " GeV"]
# plotComments = []
plotFileTag = "obj_histsOverlayed_" + etaBinName + "_" + phiBinName + "_pid" + str(pidSelected) + "_engpt" + str(int(GEN_engpt))
# plot and save comparison hists
hgcalHistHelpers.histsPrintSaveSameCanvas(histsAndProps, outDir, tag=plotFileTag, latexComment=plotComments)
Expand Down Expand Up @@ -173,6 +173,18 @@ def setupResScaleScenario(inputdir, gun_type, pidSelected, GEN_engpt, refName, s
"cmp_Pt": {'file': filePFuncalib, 'hist_prefix': "obj_Pt", 'leg': "PF (non-calibrated) cluster", 'color': ROOT.kGreen - 6}}
resolutionFileAndInfoMap = {'file': filePF, 'hist_prefix': "obj_dEoverE", 'leg': "PF (calibrated) cluster", 'color': ROOT.kBlue,
'renormNoPU': {'file': fileRenormNoPU, 'hist_prefix': "obj_Pt"}}
elif (scenario == "PC_noPU"): # scenario: noPU, resolutoin from PC
# list of files and corresponding info
filePF = ROOT.TFile.Open(inputdir + "/{}_{}_{}GeV_{}_{}_{}.root".format(gun_type, pidSelected, int(GEN_engpt), refName, "pfcandidate", "noPU"), "read") # info based on PF energy
# filePFuncalib = ROOT.TFile.Open(inputdir + "/{}_{}_{}GeV_{}_{}_{}.root".format(gun_type, pidSelected, int(GEN_engpt), refName, "pfcluster_uncalib", "PU200"), "read") # info based on PF energy
fileRenormNoPU = ROOT.TFile.Open(inputdir + "/{}_{}_{}GeV_{}_{}_{}.root".format(gun_type, pidSelected, int(GEN_engpt), refName, "pfcandidate", "noPU"), "read") # info based on megacluster energy, noPU
# map of histograms and files
histsFilesAndInfoMap = {"obj_Pt": {'file': filePF, 'hist_prefix': "obj_Pt", 'leg': "PF candidate", 'color': ROOT.kBlue},
# "ref_Pt": {'file': filePF, 'hist_prefix': "ref_Pt", 'leg': "GEN particle (" + gun_type + "={0:.1f} GeV".format(GEN_engpt) + ")", 'color': ROOT.kRed},
# "cmp_Pt": {'file': filePFuncalib, 'hist_prefix': "obj_Pt", 'leg': "PF (non-calibrated) cluster", 'color': ROOT.kGreen - 6}
}
resolutionFileAndInfoMap = {'file': filePF, 'hist_prefix': "obj_dEoverE", 'leg': "PF candidate", 'color': ROOT.kBlue,
'renormNoPU': {'file': fileRenormNoPU, 'hist_prefix': "obj_Pt"}}
elif (scenario == "Mega_PU200"): # scenario: PU, resolutoin from Mega cluster, comparison "Mega vs. PF corrected.
# list of files and corresponding info
filePF = ROOT.TFile.Open(inputdir + "/{}_{}_{}GeV_{}_{}_{}.root".format(gun_type, pidSelected, int(GEN_engpt), refName, "pfcluster", "PU200"), "read") # info based on PF energy
Expand Down

0 comments on commit adf1541

Please sign in to comment.