Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
357 changes: 339 additions & 18 deletions TPCQCVis/reports/TPC_AQC_Template_ComparePasses.ipynb

Large diffs are not rendered by default.

2,290 changes: 2,063 additions & 227 deletions TPCQCVis/reports/TPC_AQC_Template_CompareRunToMC.ipynb

Large diffs are not rendered by default.

72 changes: 47 additions & 25 deletions TPCQCVis/reports/TPC_AQC_Template_Period.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "6ba04481",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -44,7 +44,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "1e556f7f-d199-4a14-bb9f-0515fb139009",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -193,7 +193,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "0b4c56f8-1009-40aa-8a1f-12c5bd2e1ffb",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -406,7 +406,7 @@
"metadata": {},
"source": [
"<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
"<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Run-Parameters\"data-toc-modified-id=\"Run-Parameters-1\">Run Parameters</a></span></li></ul><ul class=\"toc-item\"><li><span><a href=\"#Quality-Observer\" data-toc-modified-id=\"Quality-Observer-1\">Quality Observer</a></span><ul class=\"toc-item\"><li><span><a href=\"#Clusters\" data-toc-modified-id=\"Clusters-1.1\">Clusters</a></span></li><li><span><a href=\"#Tracks\" data-toc-modified-id=\"Tracks-1.2\">Tracks</a></span></li></ul></li><li><span><a href=\"#Trendings\" data-toc-modified-id=\"Trendings-2\">Trendings</a></span><ul class=\"toc-item\"><li><span><a href=\"#Mean-phi-of-tracks\" data-toc-modified-id=\"Mean-phi-of-tracks-2.1\">Mean phi of tracks</a></span></li><li><span><a href=\"#Mean-eta-of-tracks\" data-toc-modified-id=\"Mean-eta-of-tracks-2.2\">Mean eta of tracks</a></span></li><li><span><a href=\"#Mean-tracks-transverse-momentum-of-tracks\" data-toc-modified-id=\"Mean-tracks-transverse-momentum-of-tracks-2.3\">Mean tracks transverse momentum of tracks</a></span></li><li><span><a href=\"#Mean-charge-sign-of-tracks\" data-toc-modified-id=\"Mean-charge-sign-of-tracks-2.4\">Mean charge sign of tracks</a></span></li><li><span><a href=\"#Mean-dEdxTot-of-MIPs-tracks\" data-toc-modified-id=\"Mean-dEdxTot-of-MIPs-tracks-2.5\">Mean dEdxTot of MIPs tracks</a></span></li></ul></li><li><span><a href=\"#Plots\" data-toc-modified-id=\"Plots-3\">Plots</a></span><ul class=\"toc-item\"><li><span><a href=\"#Clusters\" data-toc-modified-id=\"Clusters-3.1\">Clusters</a></span></li><li><span><a href=\"#Tracks\" data-toc-modified-id=\"Tracks-3.2\">Tracks</a></span><ul class=\"toc-item\"><li><span><a href=\"#Geometrical-distributions-of-tracks\" data-toc-modified-id=\"Geometrical-distributions-of-tracks-3.2.1\">Geometrical distributions of tracks</a></span></li><li><span><a href=\"#Track-properties\" data-toc-modified-id=\"Track-properties-3.2.2\">Track properties</a></span></li></ul></li><li><span><a href=\"#DCAr\" data-toc-modified-id=\"DCAr-3.3\">DCAr</a></span><ul class=\"toc-item\"><li><span><a href=\"#DCAr-vs-phi\" data-toc-modified-id=\"DCAr-vs-phi-3.3.1\">DCAr vs phi</a></span></li><li><span><a href=\"#DCAr-vs-eta\" data-toc-modified-id=\"DCAr-vs-eta-3.3.2\">DCAr vs eta</a></span></li><li><span><a href=\"#DCAr-vs-pT\" data-toc-modified-id=\"DCAr-vs-pT-3.3.3\">DCAr vs pT</a></span></li><li><span><a href=\"#DCAr-vs-nClusters\" data-toc-modified-id=\"DCAr-vs-nClusters-3.3.4\">DCAr vs nClusters</a></span></li></ul></li><li><span><a href=\"#PID\" data-toc-modified-id=\"PID-3.4\">PID</a></span><ul class=\"toc-item\"><li><span><a href=\"#dEdxTot-of-MIP\" data-toc-modified-id=\"dEdxTot-of-MIP-3.4.1\">dEdxTot of MIP</a></span></li><li><span><a href=\"#TPC-Gain-calibration\" data-toc-modified-id=\"TPC-Gain-calibration-3.4.2\">TPC Gain calibration</a></span></li><li><span><a href=\"#PID-Hypothesis-Profile\" data-toc-modified-id=\"PID-Hypothesis-Profile-3.4.3\">PID Hypothesis Profile</a></span></li></ul></li></ul></li></ul></div>"
"<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Run-Parameters\"data-toc-modified-id=\"Run-Parameters-1\">Run Parameters</a></span></li></ul><ul class=\"toc-item\"><li><span><a href=\"#Quality-Observer\" data-toc-modified-id=\"Quality-Observer-1\">Quality Observer</a></span><ul class=\"toc-item\"><li><span><a href=\"#Clusters\" data-toc-modified-id=\"Clusters-1.1\">Clusters</a></span></li><li><span><a href=\"#Tracks\" data-toc-modified-id=\"Tracks-1.2\">Tracks</a></span></li></ul></li><li><span><a href=\"#Trendings\" data-toc-modified-id=\"Trendings-2\">Trendings</a></span><ul class=\"toc-item\"><li><span><a href=\"#Mean-phi-of-tracks\" data-toc-modified-id=\"Mean-phi-of-tracks-2.1\">Mean phi of tracks</a></span></li><li><span><a href=\"#Mean-eta-of-tracks\" data-toc-modified-id=\"Mean-eta-of-tracks-2.2\">Mean eta of tracks</a></span></li><li><span><a href=\"#Mean-tracks-transverse-momentum-of-tracks\" data-toc-modified-id=\"Mean-tracks-transverse-momentum-of-tracks-2.3\">Mean tracks transverse momentum of tracks</a></span></li><li><span><a href=\"#Mean-charge-sign-of-tracks\" data-toc-modified-id=\"Mean-charge-sign-of-tracks-2.4\">Mean charge sign of tracks</a></span></li><li><span><a href=\"#Mean-dEdxTot-of-MIPs-tracks\" data-toc-modified-id=\"Mean-dEdxTot-of-MIPs-tracks-2.5\">Mean dEdxTot of MIPs tracks</a></span></li><li><span><a href=\"#MIP-Mean-vs.-Interaction-Rate\" data-toc-modified-id=\"MIP-Mean-vs.-Interaction-Rate-2.6\">MIP Mean vs. Interaction Rate</a></span></li></ul></li><li><span><a href=\"#Plots\" data-toc-modified-id=\"Plots-3\">Plots</a></span><ul class=\"toc-item\"><li><span><a href=\"#Clusters\" data-toc-modified-id=\"Clusters-3.1\">Clusters</a></span></li><li><span><a href=\"#Tracks\" data-toc-modified-id=\"Tracks-3.2\">Tracks</a></span><ul class=\"toc-item\"><li><span><a href=\"#Geometrical-distributions-of-tracks\" data-toc-modified-id=\"Geometrical-distributions-of-tracks-3.2.1\">Geometrical distributions of tracks</a></span></li><li><span><a href=\"#Track-properties\" data-toc-modified-id=\"Track-properties-3.2.2\">Track properties</a></span></li></ul></li><li><span><a href=\"#DCAr\" data-toc-modified-id=\"DCAr-3.3\">DCAr</a></span><ul class=\"toc-item\"><li><span><a href=\"#DCAr-vs-phi\" data-toc-modified-id=\"DCAr-vs-phi-3.3.1\">DCAr vs phi</a></span></li><li><span><a href=\"#DCAr-vs-eta\" data-toc-modified-id=\"DCAr-vs-eta-3.3.2\">DCAr vs eta</a></span></li><li><span><a href=\"#DCAr-vs-pT\" data-toc-modified-id=\"DCAr-vs-pT-3.3.3\">DCAr vs pT</a></span></li><li><span><a href=\"#DCAr-vs-nClusters\" data-toc-modified-id=\"DCAr-vs-nClusters-3.3.4\">DCAr vs nClusters</a></span></li></ul></li><li><span><a href=\"#PID\" data-toc-modified-id=\"PID-3.4\">PID</a></span><ul class=\"toc-item\"><li><span><a href=\"#dEdxTot-of-MIP\" data-toc-modified-id=\"dEdxTot-of-MIP-3.4.1\">dEdxTot of MIP</a></span></li><li><span><a href=\"#TPC-Gain-calibration\" data-toc-modified-id=\"TPC-Gain-calibration-3.4.2\">TPC Gain calibration</a></span></li><li><span><a href=\"#PID-Hypothesis-Profile\" data-toc-modified-id=\"PID-Hypothesis-Profile-3.4.3\">PID Hypothesis Profile</a></span></li></ul></li></ul></li></ul></div>"
]
},
{
Expand All @@ -420,7 +420,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "ddd293fc",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -563,7 +563,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"id": "4052a354",
"metadata": {},
"outputs": [],
Expand All @@ -580,7 +580,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"id": "69a20633",
"metadata": {},
"outputs": [],
Expand All @@ -602,7 +602,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"id": "293f06ea",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -663,7 +663,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"id": "0969cccc",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -890,6 +890,14 @@
"canvas.Draw()\n"
]
},
{
"cell_type": "markdown",
"id": "198e2c7d",
"metadata": {},
"source": [
"### MIP Mean vs. Interaction Rate"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -919,7 +927,7 @@
"n_bins = len(MIPdata)\n",
"hMIP_IR = ROOT.TH1F(\n",
" \"hMIP_vs_IntRate\",\n",
" \"MIP Mean vs Interaction Rate;IR (Hz);MIP Mean\",\n",
" \"MIP Mean vs Interaction Rate;IR (kHz);MIP Mean\",\n",
" n_bins,\n",
" 0,\n",
" n_bins\n",
Expand All @@ -934,12 +942,16 @@
" hMIP_IR.SetBinContent(bin_idx, mip_mean)\n",
" hMIP_IR.SetBinError(bin_idx, mip_sigma)\n",
" if isinstance(int_rate, (float)):\n",
" label = f\"#splitline{{{int_rate:.2f}}}{{(run {run})}}\"\n",
" else:\n",
" label = f\"#splitline{{{int_rate}}}{{(run {run})}}\"\n",
"# label = f\"#splitline{{{int_rate/1000:.1f}}}{{({run})}}\"\n",
" label = f\"{int_rate/1000:.1f} [{run}]\"\n",
"\n",
" else: # \"?\", for example\n",
"# label = f\"#splitline{{{int_rate}}}{{(run {run})}}\"\n",
" label = f\"{int_rate} [{run}]\"\n",
" hMIP_IR.GetXaxis().SetBinLabel(bin_idx, label)\n",
" hMIP_IR.GetXaxis().SetTitleOffset(1.5)\n",
"# hMIP_IR.LabelsOption(\"v\")\n",
"MIP_IR_canvas = ROOT.TCanvas(\"MIP_IR_canvas\",\"MIP Mean vs. Interaction Rate\",1100,400)\n",
"MIP_IR_canvas = ROOT.TCanvas(\"MIP_IR_canvas\",\"MIP Mean vs. Interaction Rate\",1000,400)\n",
"hMIP_IR.Draw(\"EL\")\n",
"MIP_IR_canvas.Draw()"
]
Expand Down Expand Up @@ -1012,7 +1024,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 25,
"id": "824fe439",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -1160,7 +1172,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 30,
"id": "94dac685",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -1518,7 +1530,8 @@
" pad1.SetGridy(1)\n",
" canvas.SetCanvasSize(1000,400)\n",
" updateColors(hist,cols)\n",
" legend.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
"# legend.SetHeader(\"Normalized to integral\\n#Run polarity IRstart IRmid IRend\", \"C\")\n",
" legend.AddEntry(\"\", \"#Run polarity IRstart IRmid IRend\", \"\")\n",
" legend.Draw()\n",
" canvas.Draw()"
]
Expand Down Expand Up @@ -1560,7 +1573,8 @@
"\n",
" pad1.SetGridy(1)\n",
" canvas.SetCanvasSize(1000,400)\n",
" legend.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
"# legend.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
" legend.AddEntry(\"\", \"#Run polarity IRstart IRmid IRend\", \"\")\n",
" legend.Draw()\n",
" canvas.Draw()"
]
Expand Down Expand Up @@ -1592,7 +1606,8 @@
"\n",
" pad1.SetGrid(1)\n",
" canvas.SetCanvasSize(700,400)\n",
" legend.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
"# legend.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
" legend.AddEntry(\"\", \"#Run polarity IRstart IRmid IRend\", \"\")\n",
" legend.Draw()\n",
" canvas.Draw()"
]
Expand Down Expand Up @@ -1659,7 +1674,8 @@
" updateColors(hist,cols)\n",
" pad1.SetGrid(1)\n",
" canvas.SetCanvasSize(700,400)\n",
" legend.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
"# legend.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
" legend.AddEntry(\"\", \"#Run polarity IRstart IRmid IRend\", \"\")\n",
" legend.Draw()\n",
" canvas.Draw()"
]
Expand Down Expand Up @@ -1690,7 +1706,8 @@
" updateColors(hist,cols)\n",
" pad1.SetGrid(1)\n",
" canvas.SetCanvasSize(700,400)\n",
" legend.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
"# legend.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
" legend.AddEntry(\"\", \"#Run polarity IRstart IRmid IRend\", \"\")\n",
" legend.Draw()\n",
" canvas.Draw()"
]
Expand Down Expand Up @@ -1721,7 +1738,8 @@
" updateColors(hist,cols)\n",
" pad1.SetGrid(1)\n",
" canvas.SetCanvasSize(700,400)\n",
" legend.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
"# legend.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
" legend.AddEntry(\"\", \"#Run polarity IRstart IRmid IRend\", \"\")\n",
" legend.Draw()\n",
" canvas.Draw()"
]
Expand Down Expand Up @@ -1761,13 +1779,16 @@
" bigCanvas.cd(1)\n",
" ROOT.gPad.SetGrid(1)\n",
" for hist in hist1 : hist.Draw(\"SAME L\")\n",
" legend1.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
"# legend1.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
" legend1.AddEntry(\"\", \"#Run polarity IRstart IRmid IRend\", \"\")\n",
" \n",
" legend1.Draw()\n",
" histoOut, canvasOut = outlierDetection(objectName,hist2,runList)\n",
" bigCanvas.cd(2)\n",
" ROOT.gPad.SetGrid(1)\n",
" for hist in hist2 : hist.Draw(\"SAME L\")\n",
" legend2.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
"# legend2.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
" legend2.AddEntry(\"\", \"#Run polarity IRstart IRmid IRend\", \"\")\n",
" legend2.Draw()\n",
" histoOut, canvasOut = outlierDetection(objectName,hist3,runList)\n",
" bigCanvas.cd(3)\n",
Expand Down Expand Up @@ -2301,7 +2322,8 @@
" targets[i].SetLineColor(3)\n",
" targets[i].SetLineWidth(3)\n",
" targets[0].Draw()\n",
" legend.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
"# legend.SetHeader(\"Normalized to integral, #Run polarity IRstart IRmid IRend\", \"C\")\n",
" legend.AddEntry(\"\", \"#Run polarity IRstart IRmid IRend\", \"\")\n",
" legend.Draw()\n",
" rightPad = c.cd(2)\n",
" rightPad.Divide(2,2)\n",
Expand Down
8 changes: 6 additions & 2 deletions TPCQCVis/src/drawHistograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ def logScale(log):
if legend:
leg = ROOT.TLegend()
if normalize : leg.SetHeader("Normalized to integral")
if files > 10 : leg.SetNColumns(2)

MaxRunsPerLegColumn = 10
if files > 10:
leg.SetNColumns(math.ceil(files/MaxRunsPerLegColumn))
for i in range(files):
if i==0 or not addHistos :
hist = getHistogram(fileList[i], histogram)
Expand Down Expand Up @@ -127,6 +128,9 @@ def logScale(log):
if ratio:
if type(hist) in (ROOT.TH1D, ROOT.TH1F, ROOT.TH1C, ROOT.TH2D, ROOT.TH2F, ROOT.TH2C):
histRatio = hist.Clone("hRatio_"+str(i))
if histRatio.GetNbinsX() != histComp.GetNbinsX():
print("Histograms have different numbers of bins. Skipping creation of ratio plots.")
ratio = False
histRatio.Divide(histComp)
histRatio.SetTitle("Ratio")
histRatio.SetStats(0)
Expand Down
37 changes: 29 additions & 8 deletions TPCQCVis/src/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,40 @@ def recursiveGetHistogram(folder, title):
return hist
return None

# Older version, which does not check every file
# def checkIfExists(files, title):
# title = title.split(";")[0]
# objectAvailable = False
# hist = None
# if type(files) is list:
# file = files[0]
# else:
# file = files
# hist = getHistogram(file, title)
# if hist:
# return True
# else:
# print(title,"not found")
# return False

def checkIfExists(files, title):
title = title.split(";")[0]
objectAvailable = False
objectAvailable = True
problematicFiles = []
hist = None
if type(files) is list:
file = files[0]
else:
file = files
hist = getHistogram(file, title)
if hist:
if type(files) is not list:
files=[files]
for file in files:
hist = getHistogram(file, title)
if not hist:
objectAvailable = False
problematicFiles.append(file.GetName())
if objectAvailable:
return True
else:
print(title,"not found")
print(title, "not found in the following files:")
for file in problematicFiles:
print(file)
return False

def drawMovingWindowOverlay(histograms,timestamps,normalize=False):
Expand Down
3 changes: 2 additions & 1 deletion TPCQCVis/tools/downloadSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import time

DATADIR = os.environ['TPCQCVIS_DATA']
LOCALDIR = DATADIR+"/sim/"
# LOCALDIR = DATADIR+"/sim/"
LOCALDIR = DATADIR+"/sim"

def getPaths(path):
runs = subprocess.run(["alien_ls", path], capture_output=True)
Expand Down
13 changes: 11 additions & 2 deletions TPCQCVis/tools/generateMCComparisonReports.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,23 @@ def replace_in_ipynb(file_path, temp, patterns, replacements):
temp_run_path = temp_run.name

### Part to set
path = f"{DATADIR}/sim/2024/"
path = f"{DATADIR}/sim/2024"
period = "LHC24e2"
passName = "" #keep empty ("") if MC
pathComparison = f"{DATADIR}/2023/"
pathComparison = f"{DATADIR}/2023"
periodListComparison = ["LHC23zzf","LHC23zzg","LHC23zzh"]
passNameListComparison = ["apass3","apass3","apass3"]
#passNameListComparison = ["" for period in periodListComparison] #keep empty ("") if MC


# path = f"{DATADIR}/sim/2024"
# period = "LHC24f4"
# passName = "0" #keep empty ("") if MC
# pathComparison = f"{DATADIR}/2024"
# periodListComparison = ["LHC24af"]
# passNameListComparison = ["apass1_skimmed"]
# passNameListComparison = ["" for period in periodListComparison] #keep empty ("") if MC

# Loop over the comparison periods
for i,periodComparison in enumerate(periodListComparison):
passNameComparison = passNameListComparison[i]
Expand Down