Skip to content

Commit

Permalink
Merge branch 'OverlapValidation' of https://github.com/jhucmsresearch…
Browse files Browse the repository at this point in the history
…2019/cmssw into OverlapValidation
  • Loading branch information
VictordeHavenon authored and hroskes committed Apr 25, 2019
2 parents efef705 + a52b64c commit 04371e2
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Alignment/OfflineValidation/python/overlapValidationPlot.py
Expand Up @@ -6,10 +6,14 @@ def hist(tree_file_name, hist_name,subdet_id,module_direction,overlap_direction,
f = ROOT.TFile(tree_file_name)
t = f.Get("analysis/Overlaps")
if profile_direction is None:
h = ROOT.TH1F(hist_name, hist_name, 100, -300, 300)
if (subdet_id==4 or subdet_id==6):
h = ROOT.TH1F(hist_name, hist_name, 100, -5000, 5000)
else:
h = ROOT.TH1F(hist_name, hist_name, 100, -300, 300)

else: h = ROOT.TProfile(hist_name, hist_name, 10, -100, 100)

h.SetDirectory(0)

for entry in t:
if not ((t.subdetID == subdet_id)):
continue
Expand All @@ -19,12 +23,12 @@ def hist(tree_file_name, hist_name,subdet_id,module_direction,overlap_direction,
continue
modulePhi0 = math.atan2(t.moduleY[0], t.moduleX[0])
modulePhi1 = math.atan2(t.moduleY[1], t.moduleX[1])
phidiff = min(abs(modulePhi0-modulePhi1), math.pi - abs(modulePhi0-modulePhi1))
phidiff = min(abs(modulePhi0-modulePhi1), abs(math.pi - abs(modulePhi0-modulePhi1)))
moduleR0 = math.sqrt(t.moduleY[0]**2+t.moduleX[0]**2)
moduleR1 = math.sqrt(t.moduleY[1]**2+t.moduleX[1]**2)
if module_direction !="r" and subdet_id%2 == 0 and (abs(moduleR0 - moduleR1)<1):
continue
if module_direction !="phi" and ((moduleR0*phidiff)<2):
if module_direction !="phi" and ((moduleR0*phidiff)<1):
continue
if overlap_direction == "phi":
if modulePhi0 > modulePhi1:
Expand Down Expand Up @@ -89,7 +93,7 @@ def hist(tree_file_name, hist_name,subdet_id,module_direction,overlap_direction,

def plot(file_name,subdet_id,module_direction,overlap_direction,profile_direction,*filesTitlesColorsStyles):
hstack = ROOT.THStack("hstack","")
legend = TkAlStyle.legend(len(filesTitlesColorsStyles), 0.3)
legend = TkAlStyle.legend(len(filesTitlesColorsStyles), 1)
legend.SetBorderSize(0)
legend.SetFillStyle(0)
hs = []
Expand All @@ -98,10 +102,13 @@ def plot(file_name,subdet_id,module_direction,overlap_direction,profile_directio
h = hist(files,files.replace("/",""),subdet_id,module_direction,overlap_direction,profile_direction)
h.SetLineColor(color)
h.SetLineStyle(style)
legend.AddEntry(h, title, "l")
hMean = h.GetMean(1)
hMeanError = h.GetMeanError(1)
# legend.AddEntry(h, title, "l")
legend.AddEntry(h, title + ", mean = {0}\pm {1}\mu m ".format(round(hMean,3),round(hMeanError,3)), "l")
hstack.Add(h)
hs.append(h)

hstack.SetMaximum(hstack.GetMaximum("nostack") * 1.2)
c = ROOT.TCanvas()
hstack.Draw("nostack")
legend.Draw()
Expand Down

0 comments on commit 04371e2

Please sign in to comment.