Skip to content

Commit

Permalink
implement Thomas suggestion, exit code removed
Browse files Browse the repository at this point in the history
  • Loading branch information
atolosadelgado committed Aug 29, 2024
1 parent 47b0d5d commit 107fde5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
51 changes: 29 additions & 22 deletions DCHdigi/test/test_DCHdigi/check_DCHdigi_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,35 @@
# 2 : problem with calculation of hit-projection position onto the wire

import ROOT
import sys

exit_code=0
# open debug output file generated by DCHdigi alg
f=ROOT.TFile("dch_digi_alg_debug.root")
def main():
exit_code = 0

# Open debug output file generated by DCHdigi alg
f = ROOT.TFile("dch_digi_alg_debug.root")

# Retrieve the hit-wire distance distribution
hDpw = f.Get("hDpw")
hDpw.Rebin(10)

# Retrieve the distance at which the distance distribution has its maximum
distance_hit_wire_more_frequent = hDpw.GetXaxis().GetBinCenter(hDpw.GetMaximumBin())

# Check if the distance hit wire has the maximum around d=0.66cm
if 0.05 < abs(distance_hit_wire_more_frequent - 0.65):
exit_code += 1

# Retrieve the hit-projection onto the wire to the wire distance distribution
hDww = f.Get("hDww")

# Check the integral, excluding the first bin
hDww_integral = hDww.Integral(2, -1)
if hDww_integral != 0:
exit_code += 2

# retrieve the hit-wire distance distribution
hDpw=f.Get("hDpw")
hDpw.Rebin(10)
# retrieve the distance at which the distance distribution has its maximum
distance_hit_wire_more_frequent=hDpw.GetXaxis().GetBinCenter( hDpw.GetMaximumBin() )
# the distance hit wire has the maximum around d=0.66cm
# if it is not the case, that means something weird is going on...
if 0.05 < abs(distance_hit_wire_more_frequent - 0.65) :
exit_code+=1
return exit_code

# retrieve the hit-projection onto the wire to the wire distance distribution
hDww=f.Get("hDww")
# since the hit-projection onto the wire should be a point on the wire, the distance should be zero
# and all the counts are pushed to the bin number 1 (which is excluded from the integral)
hDww_integral=hDww.Integral(2,-1)
if hDww_integral != 0 :
exit_code+=2

# we have to print the exit code, so it can be captured by the bash script
print(exit_code)
if __name__ == "__main__":
code = main()
sys.exit(code)
5 changes: 1 addition & 4 deletions DCHdigi/test/test_DCHdigi/test_DCHdigi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,4 @@ fi
k4run runDCHdigi.py

# check distribution of distance from hit position to the wire
check_DCHdigi_output=$( (python3 check_DCHdigi_output.py) 2>&1)

# return value printed out by the previous python script
exit $check_DCHdigi_output
python3 check_DCHdigi_output.py

0 comments on commit 107fde5

Please sign in to comment.