This is a complete rewrite of
chainDump.py from scratch. Please look at the full new version of this file rather than the git diff.
Changes with respect to old script
- Drop all features based deeply on how tests were run in RTT in old times before ART. The new script doesn't care where the input and reference files come from, how they are named and how they were produced. It only reads the histograms, dumps counts and compares to reference.
- Use more modern python (passes flake8 tests)
- Add option to dump results to JSON - may be used in the future for post-processing or displaying on websites
- Add functionality to process 2D input histograms. In this case counts are taken from the last y-bin. This is needed for the Run-3 chain acceptance histogram produced by TrigSignatureMoniMT.
- Improve command-line interface and flexibility
- A slight change of logic when deciding "out of tolerance" changes wrt reference (see below)
chainDumpWorkaround.shas the new script handles both Run-2 and Run-3 chain histograms.
- Adapt scripts which were calling chainDump to the new CLI
Slight change of "out of tolerance" logic in reference comparison
Old script - divide counts by total number of events for input and reference separately and then compare the fractions:
def checkList(self,list): okay = True for n,(x,xt) in enumerate(list): #print "DMS",n, x,xt for y,yt in list[n:]: if x > -1 and y > -1 and xt > 0 and yt > 0: fx = x/xt fy = y/yt ft = float(self.fracTolerance)*min(fx,fy) it = float(self.intTolerance)*2.0/(xt+yt) #print self.fracTolerance,ft, it # note yt and xt can be greater than one for TEs if abs(fx - fy) > it and abs(fx - fy) > ft : #print x, y, xt, yt, fx, fy, it, ft self.intTolerance,self.fracTolerance #print 'out' okay = False else: okay = False return okay
New script - normalise the input counts to reference and then compare the counts:
def count_diff(count_in, count_ref, total_in, total_ref, thr_frac, thr_num): # normalise input counts to total events in reference count_in_norm = (count_in / float(total_in)) * total_ref frac = count_in_norm / float(count_ref) if count_ref != 0 else None num_diff = abs(count_in_norm - count_ref) > thr_num frac_diff = abs(frac - 1.0) > thr_frac if frac else True return num_diff and frac_diff
New command-line interface
$ chainDump.py -h usage: chainDump.py [options] files Script to dump trigger counts to a text file optional arguments: -h, --help show this help message and exit -f PATH, --inputFile PATH Name of input root file -r PATH, --referenceFile PATH Name of reference root file -v, --verbose Increase output verbosity -p, --printOnly Print counts instead of saving to file -d, --diffOnly Only store out of tolerance results (does not change JSON) --json Save outputs also to chainDump.json --fracTolerance FRAC Tolerance as a fraction, default = 0.001. Flagged diffs must exceed all tolerances --intTolerance NUM Tolerance as a number of counts, default = 2. Flagged diffs must exceed all tolerances --countHists HISTS [HISTS ...] Histograms to use for counts dump. All existing histograms from the list are used, default = ['HLTFram ework/TrigSignatureMoniMT/SignatureAcceptance', 'TrigSteer_HLT/ChainAcceptance', 'TrigSteer_HLT/NumberOfActiveTEs', 'CTPSimulation/L1ItemsAV'] --totalHists HISTS [HISTS ...] Histograms to use for total events. First existing histogram from the list is used, default = ['TrigSteer_HLT/NInitialRoIsPerEvent', 'HLTFramework/L1Decoder/RoIsEM/count'] --histDict DICT [DICT ...] Dictionary defining names of output text files for each histogram, default = ['HLTFramework/TrigSignature MoniMT/SignatureAcceptance:HLTChain', 'TrigSteer_HLT/ChainAcceptance:HLTChain', 'TrigSteer_HLT/NumberOfActiveTEs:HLTTE', 'CTPSimulation/L1ItemsAV:L1AV']