Skip to content

Commit

Permalink
Improving material_plots(_2D).py scripts to take list ofmaterial stri…
Browse files Browse the repository at this point in the history
…ngs as input to be ignored and list of substrings in materials to be removed
  • Loading branch information
armin-ilg authored and BrieucF committed Sep 25, 2024
1 parent ec70266 commit 0b59886
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
15 changes: 9 additions & 6 deletions utils/material_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def main():
parser.add_argument('--angleMax', dest='angleMax', default=6, type=float, help="maximum eta/theta/cosTheta")
parser.add_argument('--angleDef', dest='angleDef', default="eta", type=str, help="angle definition to use: eta, theta, cosTheta or thetaRad, default: eta")
parser.add_argument('--angleBinning', "-b", dest='angleBinning', default=0.05, type=float, help="eta/theta/cosTheta/thetaRad bin width")
parser.add_argument('--x0max', "-x", dest='x0max', default=0.0, type=float, help="Max of x0")
parser.add_argument('--x0max', "-x", dest='x0max', default=0.0, type=float, help="Max of x0")
parser.add_argument('--removeMatsSubstrings', dest='removeMatsSubstrings', nargs='+', default=[], help="Substrings to be removed from materials strings (e.g. '66D' for reduced density materials)")
parser.add_argument('--ignoreMats', "-i", dest='ignoreMats', nargs='+', default=[], help="List of materials that should be ignored")
args = parser.parse_args()

f = ROOT.TFile.Open(args.fname, "read")
Expand All @@ -30,13 +32,14 @@ def main():
for i in range(nMat):
material = entry.material.at(i)

# If you need to replace some string in the material, add that here
material = material.replace("66D","")
material = material.replace("Vtx","")
# Removing substrings from materials
for substring in args.removeMatsSubstrings:
material = material.replace(substring,"")

# Ignore materials used in beam pipe as vertex material budget does not work without beam pipe. You can add more materials to ignore here
if material in ["Air","Tungsten","Copper","beam","LiquidNDecane", "AlBeMet162", "Gold"]:
# Ignore certain materials if specified
if material in args.ignoreMats:
continue

if material not in histDict.keys():
histDict[material] = {
"x0": ROOT.TH1F("", "", (int)((args.angleMax-args.angleMin) / args.angleBinning), args.angleMin, args.angleMax),
Expand Down
6 changes: 4 additions & 2 deletions utils/material_plots_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def main():
parser.add_argument('--angleBinning', "-b", dest='angleBinning', default=0.05, type=float, help="eta/theta/cosTheta bin width")
parser.add_argument('--nPhiBins', dest='nPhiBins', default=100, type=int, help="number of bins in phi")
parser.add_argument('--x0max', "-x", dest='x0max', default=0.0, type=float, help="Max of x0")
parser.add_argument('--ignoreMats', "-i", dest='ignoreMats', nargs='+', default=[], help="List of materials that should be ignored")
args = parser.parse_args()

ROOT.gStyle.SetNumberContours(100)
Expand All @@ -36,9 +37,10 @@ def main():

entry_x0, entry_lambda, entry_depth = 0.0, 0.0, 0.0
for i in range(nMat):
# Ignore materials used in beam pipe as vertex material budget does not work without beam pipe. You can add more materials to ignore here
if entry.material.at(i) in ["Air","Tungsten","Copper","beam","LiquidNDecane", "AlBeMet162", "Gold"]:
# Ignore certain materials if specified
if entry.material.at(i) in args.ignoreMats:
continue

entry_x0 += entry.nX0.at(i)*100.0
entry_lambda += entry.nLambda.at(i)
entry_depth += entry.matDepth.at(i)
Expand Down

0 comments on commit 0b59886

Please sign in to comment.