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 Request: Plotting Temperature Data (Good for newcomer) #156

Closed bdorney closed 4 years ago

bdorney commented 5 years ago

Brief summary of issue

The monitorTemperatures.py routine can query one or more optohybrid's worth of links on an AMC and track temperature data as a function of time.

We need a tool which can make plots of this temperature.

Types of issue

Expected Behavior

 # Define ADC to degrees celsius conversion for VFAT3
def vfatAdc2Temp(adcVal):
   See vfat3 manual, figures 31 & 32
   return temperature

# SCA measures temperature of 9 PT100 sensors, define a conversion from ADC to deg C
def pt100toTemp(adcVal):
   See discussion below at "PT100 Temperature Conversion"

# SCA has an internal temperature sensor, define a conversion from ADC to deg C
def scaADC2Temp(adcVal):
   @evka85 writes: "see SCA manual page 52, which shows linear dependence of temperature from -37.5 deg C to 79 deg C corresponding to 790 counts for -37.5degC and going down to about 570 counts for 79degC."

def utime2datetime(utime)
   # takes a utime and converts it to a datetime ...?
   return datetime

if __name__ == '__main__':
   setup an argparse.ArgumentParser instance
   get arguments from a user

   # Determine which links present suggest using root_numpy, something like:
   import root_numpy as rp
   import numpy as np
   bNames = ['link']
   ohArray = rp.tree2array(tree=calTree, branches=bNames)
   ohArray = np.unique(ohArray) # now ohArray will have one entry for each unmasked optohybrid

   # Get ADC0 and ADC1 calibration
   # Temperature measurements are recorded against the internally referenced and externally referenced ADC's per each VFAT
   # use parseCalFile(...) from gem-plotting-tools/utils/anautilities.py
   # Note this calibration is unique to each (vfat,ohN) pairing
   # In future this is where a DB query based on vfatID would take place 

   # Make output plots, suggest TGraphErrors objects (the error on the temperature comes from the LSB of the ADC used to read it and the slope of ADC to physical unit)
   # I would suggest you use a nesteddict object (gempython/utils/nesteddict.py) to index these by [oh][vfat]
   for link in ohArray:
      for vfat in range(0,24):
           dict_tempResults[link][vfat] = r.TGraphErrors(...) # declare TGraphErrors
           # You'll probably need additional containers for OH FPGA Core temp & SCA temp's

   # Loop over events in the tree and fill plots
   for event in calTree:
       Convert ADC values to temperatures using conversion functions above (and also VFAT conversion)
       Note that OH FPGA Core Temperature is already in degrees Celsius       
       assign to the TGraphErrors the temperature

    # Make plots
    For the VFATs make our standard 3x8 grid plot of the DAC scan results, see make3x8Canvas(...), one such grid plot should be made for each entry in ohArray
    Then I would suggest one plot that tracks the SCA PT100 measurements for each link
    And finally I would suggest one plot that tracks the FPGA Core Temp & SCA Temp for each link

    Store plots in an output TFile (use TDirectories to organize logically)

    Exit

Info on datetime can be found in p2.7 documentation.

You can take inspiration from anaUltraScurve.py.

Referencing the vfat3 manual may be necessary.

Several useful functions in the API:

https://github.com/cms-gem-daq-project/gem-plotting-tools/blob/d7b78cef238894998fc350377c3e4ace1a0b4484/utils/anautilities.py#L341 https://github.com/cms-gem-daq-project/gem-plotting-tools/blob/d7b78cef238894998fc350377c3e4ace1a0b4484/utils/anautilities.py#L438

PT100 Temperature Conversion

@evka85 writes:

For PT100 measurements, a more complex conversion is necessary to covert the ADC counts to temperature. The way it works is that the ADC supplies 100uA current that goes through the PT100 sensor to ground, and the voltage drop over the sensor then corresponds to the temperature. The exact part number of the PT100 sensor we are using is P0K1.1206.2P.B, which has a resistance of 100 Ohms at 0 deg C, and changes by 0.385% per each degree C cumulatively (more info can be found here: http://www.farnell.com/datasheets/2207165.pdf?_ga=2.247382788.1064362929.1535377707-998824428.1535377707 and here: https://www.intech.co.nz/products/temperature/typert/RTD-Pt100-Conversion.pdf). This means that at 0 deg C the voltage drop over the PT100 will be 100uA

  • 100 Ohms = 10mV, so the ADC will read 1.0V - 10mV = 0.99V, and if the temperature is 30 degC, the PT100 will have a resistance of 111.67 Ohms, and so the voltage drop will be 100uA * 111.67 Ohms = 11.167mV, so the ADC will read 1.0V - 11.167mV = 0.988833V.

Context (for feature requests)

Need to be able to plot changes in temperature wrt time.

lpetre-ulb commented 4 years ago

No new features are to be implemented in legacy.