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

New Feature: Adding Script for Plotting Channel Loss Rate #170

Closed bdorney closed 5 years ago

bdorney commented 5 years ago

Description

Adding a script to plot channel loss as a function of time. Can also draw a secondary axis and plot an additional observable on the pad using the transparent pad trick.

Types of changes

Motivation and Context

Need a tool to plot channel loss as a function of time.

How Has This Been Tested?

Help menu:

./plotChanLossRate.py -h
usage: plotChanLossRate.py [-h] [-f FILEOBSDATA] [-c] [-d DELIMITER] [--debug]
                           [-p] [--logy1] [--logy2] [-n] [-t TOTALCHAN]
                           [-s STARTDATE] [--startDateFormat STARTDATEFORMAT]
                           [-e ENDDATE] [--endDateFormat ENDDATEFORMAT]
                           fileChanLoss

Makes a time series plot

positional arguments:
  fileChanLoss          physical filename specifying channel loss data

optional arguments:
  -h, --help            show this help message and exit
  -f FILEOBSDATA, --fileObsData FILEOBSDATA
                        If provided plots the data contained here on a
                        secondary y-axis on top of the channel loss data.
                        Format should be a delimited file (matching
                        'delimiter'), first line should be a column header.
                        Subsequent lines are delimited datetime then
                        observable data. Datetime is expected to be in format
                        'YYYY.MM.DD hh:mm:ss'.
  -c, --cummulative     If provided a cummulative channel loss plot is made
                        instead of an instantaneous loss plots
  -d DELIMITER, --delimiter DELIMITER
                        delimiter in fileChanLoss file
  --debug               print additional debugging info
  -p, --percentage      provide output data as a percentage of the total
                        number of channels in a detector
  --logy1               primary y-axis is logarithmic
  --logy2               secondary y-axis is logarithmic
  -n, --noLeg           Do not draw TLegend
  -t TOTALCHAN, --totalChan TOTALCHAN
                        Specify the total number of channels in a detector

Datetime and Datetime Formatting:
  Parameters specfiying the datetime format in fileChanLoss; if fileObsData
  is *not* provided this also specifies the starting and ending dates

  -s STARTDATE, --startDate STARTDATE
                        starting date given in format specified by
                        'startDateFormat'
  --startDateFormat STARTDATEFORMAT
                        specifiy starting datetime format, use characters
                        'Y','M','D','m','h','s' to define format, e.g.
                        '2018.11.05.23.59' is in format 'YYYY.MM.HH.DD.hh.mm'
                        while '18.25.04 12:13' is 'YY.MM.DD hh:mm'
  -e ENDDATE, --endDate ENDDATE
                        ending date given in format specified by
                        'endDateFormat'
  --endDateFormat ENDDATEFORMAT
                        specifiy ending datetime format, use characters
                        'Y','M','D','m','h','s' to define format, e.g.
                        '2018.11.05.23.59' is in format 'YYYY.MM.HH.DD.hh.mm'
                        while '18.25.04 12:13' is 'YY.MM.DD hh:mm'

Example usage:

./plotChanLossRate.py -p --logy1 --logy2 -f CMSPeakInstLumi_2017to2018.txt ChanLoss_AllDet_20181105.txt

./plotChanLossRate.py -n -c -p --logy1 --logy2 -f CMSPeakInstLumi_2017to2018.txt ChanLoss_AllDet_20181105.txt

./plotChanLossRate.py -n -c --logy1 --logy2 -f CMSPeakInstLumi_2017to2018.txt ChanLoss_AllDet_20181105.txt   

./plotChanLossRate.py  --logy2 -f CMSPeakInstLumi_2017to2018.txt ChanLoss_AllDet_20181105.txt     

Here CMSPeakInstLumi_2017to2018.txt is a csv file with datetime in YYYY.MM.DD hh:mm:ss format and looks like:

Begin time,Init Lumi (mub-1s-1)
2018.11.05 04:33:58,0.00007
2018.11.05 02:01:10,0.00007
2018.10.26 06:11:23,0.03171
...
...

Which was from CMS fill summary and I used Excel to reformat the date time.

Here ChanLoss_AllDet_20181105.txt is a csv file which gives a chamber name and a path to channel loss data:

Chamber,ChannelLossFile
GEMINIm27L1,/some/path/ChanLoss_GEMINIm27L1_20181105.txt
...
...
GEMINIm30L1,/some/path/ChanLoss_GEMINIm30L1_20181105.txt
GEMINIm30L2,/some/path/ChanLoss_GEMINIm30L2_20181105.txt

And /some/path/ChanLoss_GEMINIm27L1_20181105.txt is a csv file and looks like:

Start Date , End Date ,  Burnt Channels
2018.07.09.23.41 ,  2018.07.14.07.02 ,  12
2018.07.14.07.22 ,  2018.07.15.14.32 ,  1
2018.07.16.13.58 ,  2018.07.17.10.42 ,  7
2018.07.19.15.54 ,  2018.07.21.08.47 ,  2
2018.07.30.14.40 ,  2018.08.01.13.56 ,  9
2018.08.03.13.15 ,  2018.08.06.11.10 ,  8
2018.08.06.15.29 ,  2018.08.09.18.01 ,  3
2018.08.13.10.29 ,  2018.08.16.07.06 ,  15
2018.08.25.10.11 ,  2018.08.25.10.25 ,  2
2018.08.31.02.46 ,  2018.09.01.11.19 ,  2
2018.08.31.02.46 ,  2018.09.01.11.44 ,  2
2018.09.01.11.44 ,  2018.09.02.11.16 ,  2
2018.09.06.12.39 ,  2018.09.07.09.24 ,  9
2018.09.29.17.19 ,  2018.09.30.09.24 ,  2
2018.10.04.19.27 ,  2018.10.05.11.28 ,  7
2018.10.15.19.51 ,  2018.10.17.20.51 ,  2
2018.10.17.21.08 ,  2018.10.18.15.35 ,  4
2018.10.19.11.22 ,  2018.10.21.16.39 ,  4
2018.10.21.13.46 ,  2018.10.24.06.31 ,  2

Notice datetime is given in scandate (YYYY.MM.DD.hh.mm). Notice you can use the options menu above to change the datetime formatting here.

Screenshots (if appropriate):

canv_chanloss_chanloss_alldet_20181105_sumdelivlumi_cum_percent canv_chanloss_chanloss_alldet_20181105_initlumi

Checklist: