cms-gem-daq-project / gem-plotting-tools

Repository for GEM commissioning plotting tools
GNU General Public License v3.0
1 stars 26 forks source link

Feature Implementation: Adding Generic Plotter by scandate #34

Closed bdorney closed 7 years ago

bdorney commented 7 years ago

Description

Starting to address: https://github.com/cms-gem-daq-project/gem-plotting-tools/issues/33

Types of changes

Motivation and Context

Right now if a particular plot of interest is desired a user has to make it by hand. This feature seeks to address that. The user provides a tab delimited text file listOfScanDates.txt of the form:

ChamberName scandate    <IndepVarName>
cName date    IndepVarVal1
cName date    IndepVarVal2
cName date    IndepVarVal3
...
...
cName date    IndepVarValN-1
cName date    IndepVarValN

And calls:

gemPlotter.py --anaType=trim --infilename=listOfScanDates.txt --vfatList=<comma separated list of integers> --strip=49 --branchName=<Name>

Then a plot of branchName vs IndepVarName from the scan dates specified, for each of the VFATs specified will be created. Please note that cName need not be the same for each row (however then one would imagine that IndepVar is some expression derived from Layer & Slot...)!

How Has This Been Tested?

By producing plots below.

Screenshots (if appropriate):

Calling:

gemPlotter.py -ilistOfScanDates_Trim.txt -s10 -a --anaType=trimAna --branchName=trimDAC --axisMin=0 --axisMax=31
gemplotter_trimdac_vs_runno_vfat10_strip10_summary

Calling:

gemPlotter.py -ilistOfScanDates_Trim.txt -s10 -v10 --anaType=trimAna --branchName=trimDAC --axisMin=0 --axisMax=31
gemplotter_trimdac_vs_runno_vfat10_strip10

Calling:

gemPlotter.py -ilistOfScanDates_Trim.txt -a --anaType=trimAna --branchName=trimDAC --make2D --axisMin=-1 --axisMax=31
gemplotter_strip_vs_runno_obstrimdac_summary

Calling:

gemPlotter.py -ilistOfScanDates_Trim.txt -v10 --anaType=trimAna --branchName=trimDAC --make2D --axisMin=-1 --axisMax=31
gemplotter_strip_vs_runno_obstrimdac_vfat10

Checklist:

bdorney commented 7 years ago

Does the helper script correctly handle potential misuse, i.e., failing in the right way? I suppose gemPlotter will check the validity of the things that are passed in? (Or at least fail in a non-destructive way if not)

  • anaType is valid

There's a check by gemPlotter.py to make sure that --anaType is valid at L185 and it will tell the user what values are supported if an incorrect value is given.

  • input file exists

If the argument of --infilename does not exist gemPlotter.py will raise an IOError exception, I will add a check in gemPlotterAllChannels.sh that this file exists before looping.

If a particular scandate given inside of --infilename does not exist then both arbitraryPlotter() and arbitraryPlotter2D() will raise an exception and tell the user they need to check the scandate which is responsible for the exception.

  • branchname is valid

root2array() raises an exception for this but arbitraryPlotter() and arbitraryPlotter2D() catch this inside the check that the filename associated with the scandate exists. I'll optimize.

bdorney commented 7 years ago

Added better exception handling.

Case: input file does not exist

Handled in gemPlotter.py:

gemPlotter.py -iBadFileName -v10 --anaType=trimAna --branchName=trimDAC --make2D --axisMin=-1 --axisMax=31
BadFileName does not seem to exist
[Errno 2] No such file or directory: 'BadFileName'

Handled in gemPlotterAllChannels.py:

gemPlotterAllChannels.sh BadInputFile trimAna trimRange
Input file: BadInputFile not found
Please cross-check, exiting

Note, exits after one exception and does not spam 128 bad messages

Case: anaType is bad

Handled in gemPlotter.py:

gemPlotter.py -ilistOfScanDates_Trim.txt -v10 --anaType=fail --branchName=trimDAC --make2D --axisMin=-1 --axisMax=31
Invalid analysis specificed, please select only from the list:
['trim', 'latency', 'scurveAna', 'threshold', 'trimAna', 'scurve']

Handled in gemPlotterAllChannels.py:

gemPlotterAllChannels.sh listOfScanDates_Trim.txt fail trimRange                      
gemPlotter.py -ilistOfScanDates_Trim.txt -s0 -a --anaType=fail --branchName=trimRange --rootOpt=RECREATE
Invalid analysis specificed, please select only from the list:
['trim', 'latency', 'scurveAna', 'threshold', 'trimAna', 'scurve']

Note, exits after one exception and does not spam 128 bad messages

Case: branchName is bad

Handled in gemPlotter.py:

gemPlotter.py -ilistOfScanDates_Trim.txt -v10 --anaType=trimAna --branchName=fail --make2D --axisMin=-1 --axisMax=31
Branch fail not in TTree scurveFitTree of file /data/bigdisk/GEM-Data-Taking/GE11_QC8//GE11-VI-L-CERN-0002/trim/z4.000000//2017.09.04.20.12/SCurveData_Trimmed/SCurveFitData.root
Existing Branches are:
<ROOT.TBranch object ("vfatN") at 0x2fe02c0>
<ROOT.TBranch object ("vfatCH") at 0x2fefde0>
<ROOT.TBranch object ("ROBstr") at 0x2ff0300>
<ROOT.TBranch object ("mask") at 0x2ff0840>
<ROOT.TBranch object ("maskReason") at 0x2ff0d80>
<ROOT.TBranch object ("panPin") at 0x2ff12c0>
<ROOT.TBranch object ("trimRange") at 0x2ff1800>
<ROOT.TBranch object ("vthr") at 0x2ff1d40>
<ROOT.TBranch object ("trimDAC") at 0x2ff2280>
<ROOT.TBranch object ("threshold") at 0x2ff27c0>
<ROOT.TBranch object ("noise") at 0x2ff3e80>
<ROOT.TBranch object ("pedestal") at 0x2ff43a0>
<ROOT.TBranch object ("ped_eff") at 0x2ff48e0>
<ROOT.TBranchElement object ("scurve_h") at 0x2ff4e20>
<ROOT.TBranch object ("chi2") at 0x3029220>
<ROOT.TBranch object ("ndf") at 0x3029710>
<ROOT.TBranch object ("Nhigh") at 0x3029c30>
Please try again using one of the existing branches

Handled in gemPlotterAllChannels.py:

gemPlotterAllChannels.sh listOfScanDates_Trim.txt trimAna fail                                          
gemPlotter.py -ilistOfScanDates_Trim.txt -s0 -a --anaType=trimAna --branchName=fail --rootOpt=RECREATE
Branch fail not in TTree scurveFitTree of file /data/bigdisk/GEM-Data-Taking/GE11_QC8//GE11-VI-L-CERN-0002/trim/z4.000000//2017.09.04.20.12/SCurveData_Trimmed/SCurveFitData.root
Existing Branches are:
<ROOT.TBranch object ("vfatN") at 0x3e644d0>
<ROOT.TBranch object ("vfatCH") at 0x3e73ff0>
<ROOT.TBranch object ("ROBstr") at 0x3e74510>
<ROOT.TBranch object ("mask") at 0x3e74a50>
<ROOT.TBranch object ("maskReason") at 0x3e74f90>
<ROOT.TBranch object ("panPin") at 0x3e754d0>
<ROOT.TBranch object ("trimRange") at 0x3e75a10>
<ROOT.TBranch object ("vthr") at 0x3e75f50>
<ROOT.TBranch object ("trimDAC") at 0x3e76490>
<ROOT.TBranch object ("threshold") at 0x3e769d0>
<ROOT.TBranch object ("noise") at 0x3e78090>
<ROOT.TBranch object ("pedestal") at 0x3e785b0>
<ROOT.TBranch object ("ped_eff") at 0x3e78af0>
<ROOT.TBranchElement object ("scurve_h") at 0x3e79030>
<ROOT.TBranch object ("chi2") at 0x3ead430>
<ROOT.TBranch object ("ndf") at 0x3ead920>
<ROOT.TBranch object ("Nhigh") at 0x3eade40>
Please try again using one of the existing branches

Note, exits after one exception and does not spam 128 bad messages

Case: scandate is bad

Handled in gemPlotter.py:

gemPlotter.py -ilistOfScanDates_Trim.txt -s0 -a --anaType=trimAna --branchName=trimRange --rootOpt=RECREATE
Filepath /data/bigdisk/GEM-Data-Taking/GE11_QC8//GE11-VI-L-CERN-0002/trim/z4.000000//9999.99.99.99.99 does not exist!
Please cross-check, exiting!

Handled in gemPlotterAllChannels.py:

gemPlotterAllChannels.sh listOfScanDates_Trim.txt trimAna trimRange
gemPlotter.py -ilistOfScanDates_Trim.txt -s0 -a --anaType=trimAna --branchName=trimRange --rootOpt=RECREATE
Filepath /data/bigdisk/GEM-Data-Taking/GE11_QC8//GE11-VI-L-CERN-0002/trim/z4.000000//9999.99.99.99.99 does not exist!
Please cross-check, exiting!

Note, exits after one exception and does not spam 128 bad messages

Case: ChamberName is bad

Handled in gemPlotter.py:

gemPlotter.py -ilistOfScanDates_Trim.txt -s0 -a --anaType=trimAna --branchName=trimRange --rootOpt=RECREATE
Filepath /data/bigdisk/GEM-Data-Taking/GE11_QC8//FakeDetector/trim/z4.000000//2017.09.04.20.12 does not exist!
Please cross-check, exiting!

Handled in gemPlotterAllChannels.py:

gemPlotterAllChannels.sh listOfScanDates_Trim.txt trimAna trimRange
gemPlotter.py -ilistOfScanDates_Trim.txt -s0 -a --anaType=trimAna --branchName=trimRange --rootOpt=RECREATE
Filepath /data/bigdisk/GEM-Data-Taking/GE11_QC8//FakeDetector/trim/z4.000000//2017.09.04.20.12 does not exist!
Please cross-check, exiting!

Note, exits after one exception and does not spam 128 bad messages

Rechecked Working Cases

Regenerated above screen shots of working plots using commands shown above.

Looks good.

bdorney commented 7 years ago

Error codes are now positive and follow pythonic example given above.

Performed same set of tests as shown, both to generate exceptions, and also plots. Worked out in the end.