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

in anaDACScan.py, use import statements that work in venv #168

Closed AndrewLevin closed 5 years ago

AndrewLevin commented 5 years ago

anaDACScan.py has some import statements that worked in my local gem-plotting-tools directory, but when gem-plotting-tools was installed in a virtual environment.

Description

I have updated two import statements to use a path that begins with gempython.

Types of changes

Motivation and Context

This prevented a user from running the script: https://github.com/cms-gem-daq-project/gem-plotting-tools/issues/167

How Has This Been Tested?

It has been tested in a virtual environment, and works, except for what seems to be an unrelated issue with the chamberConfig:

[amlevin@gem904daq01 amlevin]$ anaDACScan.py /data/bigdisk/GEM-Data-Taking/GE11_QC8/dacScanV3/2018.10.17.11.03/dacScanV3.root --calFileList calibration_ADC1.txt  
Analyzing: '/data/bigdisk/GEM-Data-Taking/GE11_QC8/dacScanV3/2018.10.17.11.03/dacScanV3.root'
/home/amlevin/venv/cc7/py2.7/lib/python2.7/site-packages/root_numpy/__init__.py:46: RuntimeWarning: numpy 1.14.6 is currently installed but you installed root_numpy against numpy 1.7.1. Please consider reinstalling root_numpy for this numpy version.
  RuntimeWarning)
mkdir: cannot create directory ‘/data/bigdisk/GEM-Data-Taking/GE11_QC8//GEMINIm01L1/dacScans’: Permission denied
mkdir: cannot create directory ‘/data/bigdisk/GEM-Data-Taking/GE11_QC8//GEMINIm01L2/dacScans’: Permission denied
Traceback (most recent call last):
  File "/home/amlevin/venv/cc7/py2.7/lib/python2.7/site-packages/gempython/scripts/anaDACScan.py", line 156, in <module>
    for line in open(args.calFileList):
IOError: [Errno 2] No such file or directory: 'calibration_ADC1.txt'
(py2.7)[amlevin@gem904daq01 amlevin]$ anaDACScan.py /data/bigdisk/GEM-Data-Taking/GE11_QC8/dacScanV3/2018.10.17.11.03/dacScanV3.root --calFileList calibration_ADC1.txt
Analyzing: '/data/bigdisk/GEM-Data-Taking/GE11_QC8/dacScanV3/2018.10.17.11.03/dacScanV3.root'
/home/amlevin/venv/cc7/py2.7/lib/python2.7/site-packages/root_numpy/__init__.py:46: RuntimeWarning: numpy 1.14.6 is currently installed but you installed root_numpy against numpy 1.7.1. Please consider reinstalling root_numpy for this numpy version.
  RuntimeWarning)
mkdir: cannot create directory ‘/data/bigdisk/GEM-Data-Taking/GE11_QC8//GEMINIm01L1/dacScans’: Permission denied
mkdir: cannot create directory ‘/data/bigdisk/GEM-Data-Taking/GE11_QC8//GEMINIm01L2/dacScans’: Permission denied
SysError in <TFile::TFile>: file /data/bigdisk/GEM-Data-Taking/GE11_QC8//GEMINIm01L1/dacScans/2018.10.17.11.03/DACFitData.root can not be opened (No such file or directory)
SysError in <TFile::TFile>: file /data/bigdisk/GEM-Data-Taking/GE11_QC8//GEMINIm01L2/dacScans/2018.10.17.11.03/DACFitData.root can not be opened (No such file or directory)
Warning: The fitted DAC value, -27, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -329, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -100, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -22, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -17, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -335, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -519, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -117, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -20, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -17, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -313, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -88, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -121, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -315, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Warning: The fitted DAC value, -22, is outside of the range that the register can hold: [0,63]. It will be replaced by 0.
Traceback (most recent call last):
  File "/home/amlevin/venv/cc7/py2.7/lib/python2.7/site-packages/gempython/scripts/anaDACScan.py", line 305, in <module>
    outputTxtFiles_dacVals[oh] = open(dataPath+"/"+chamber_config[oh]+"/dacScans/"+scandate+"/NominalDACValues.txt",'w')
IOError: [Errno 2] No such file or directory: '/data/bigdisk/GEM-Data-Taking/GE11_QC8//GEMINIm01L1/dacScans/2018.10.17.11.03/NominalDACValues.txt'

Screenshots (if appropriate):

Checklist:

bdorney commented 5 years ago

anaDACScan.py has some import statements that worked in my local gem-plotting-tools directory

Probably here is some misunderstanding of how tests should be perfomed...testing locally via:

% python someScript.py

Is not how this should be done, you should be testing the executable version that is in your $PATH (e.g. the version that your venv has after installation):

someScript.py

Typing which someScript.py will illustrate where the script is and confirm it's the right one tested in the right way.

bdorney commented 5 years ago

The issue shown above is that your chamberInfo.py in your venv is trying to look for chambers that do not exist, e.g. GEMINIm01L1. You need to be editing this such that the chamber_config reflects accurately what data you are trying to analyze.

Then the permissions issue is another story. First correctly configure the chamber_config dictionary for your use case.

AndrewLevin commented 5 years ago

Yes, once the chamberInfo.py is fixed the script works properly in the virtual environment:

(py2.7)[amlevin@gem904daq01 amlevin]$ anaDACScan.py /data/bigdisk/GEM-Data-Taking/GE11_QC8/dacScanV3/2018.10.31.14.28/dacScanV3.root --calFileList calibration_files_ADC0.txt 
Analyzing: '/data/bigdisk/GEM-Data-Taking/GE11_QC8/dacScanV3/2018.10.31.14.28/dacScanV3.root'
/home/amlevin/venv/cc7/py2.7/lib/python2.7/site-packages/root_numpy/__init__.py:46: RuntimeWarning: numpy 1.14.6 is currently installed but you installed root_numpy against numpy 1.7.1. Please consider reinstalling root_numpy for this numpy version.
  RuntimeWarning)
| OH | vfatN | dacVal |
| :-: | :---: | :----: |
| 0 | 0  | 89 | 
| 0 | 1  | 92 | 
| 0 | 2  | 88 | 
| 0 | 3  | 100 | 
| 0 | 4  | 87 | 
| 0 | 5  | 109 | 
| 0 | 6  | 91 | 
| 0 | 7  | 80 | 
| 0 | 8  | 88 | 
| 0 | 9  | 88 | 
| 0 | 10  | 89 | 
| 0 | 11  | 95 | 
| 0 | 12  | 94 | 
| 0 | 13  | 91 | 
| 0 | 14  | 85 | 
| 0 | 15  | 95 | 
| 0 | 16  | 87 | 
| 0 | 17  | 94 | 
| 0 | 18  | 92 | 
| 0 | 19  | 96 | 
| 0 | 20  | 90 | 
| 0 | 21  | 90 | 
| 0 | 22  | 92 | 
| 0 | 23  | 89 | 
Info in <TCanvas::Print>: png file /data/bigdisk/GEM-Data-Taking/GE11_QC8//GE11-X-S-INDIA-0002/dacScans/2018.10.31.14.28/Summary.png has been created