Skip to main content

A package to handle CMS Ecal InterCalibration constants and Ecal geometry

Project description

ecalic package

This package handles CMS Ecal Intercalibration Constant (IC) and IC-like operation and visualisation. This applies to several type of Ecal conditions which have a value per crystal, for example:

  • EcalIntercalibConstantsRcd
  • EcalLaserAPDPNRatiosRcd
  • EcalChannelStatusRcd
  • EcalPedestalsRcd (pedestal or rms)

The package contains two modules:

  • ecalic.iov decodes ecal conditions (xml format)
  • ecalic.ic the main module

To install the package one needs (automatically installed)

pip install --user ecalic

All the examples below were tested in ipython, to try them:

  • install ipython
pip install --user ipython
  • start by typing ipython
  • copy-paste the block of commands

Documentation (in ipython):

import ecalic as ecal
help(ecal)

ecalic.iov

Use this module to decode an xml file downloaded from the database. The example (the commands can be run in ipython) below will transform a pedestal xml file in a txt file format (ix iy iz ic) where ic is the pedestal RMS in gain 6

import ecalic as ecal

### for python2 python3 compatibility
try:
   from urllib.request import urlopen
except ImportError:
   from urllib2 import urlopen

### input files
www = 'https://ecaldpg.web.cern.ch/ecaldpg/users/fcouderc/examples/ecalic/'
pedestal_file =  urlopen(www + '/pedestals_hlt_run324773.xml' )
i = ecal.xml( pedestal_file, type = 'noise6' )

### dump to a txt
i.dump_txt('noise_gain6.txt')

### or directly as icCMS
ic = ecal.xml( pedestal_file, type = 'noise6' ).icCMS('noise Gx6')

The available types type can be found in the help

? ecal.xml

ecalic.ic

This is the heart of the package. It contains:

  • the class icCMS which represents the IC
  • the geom variable which handles all the different crystal properties (pandas DataFrame)
  • the function icCovCor to get the correlation and covariance between different IC sets.

A first simple example to see and plot crystal properties

import matplotlib.pyplot as plt
import ecalic as ecal

### activate pyplot visualisation
plt.ion()
plt.show()

### dump the properties of 2 first crytals
ecal.geom.head(2)

### define an empty icCMS instance
i = ecal.icCMS()

### plot the FED in 2D
i.plot(var= 'FED', title = 'FED number')

### plot the crytal type (BTCP or SIC)
i.plot(var='fabric', title = 'producer')

### EB plot only
i.plot(var='fabric', title = 'producer',ecalpart = 'eb')

Note that the cmsStyle package is provided for plot polishing and is not mandatory.

The different methods from the icCMS class can be found:

help(ecal.icCMS)

use-case example

In this example we do some simple ecalic.ic operations. First, download an example file:

try:
   from urllib.request import urlopen
except ImportError:
   from urllib2 import urlopen

### getting the example txt file from the web
www = 'https://ecaldpg.web.cern.ch/ecaldpg/users/fcouderc/examples/ecalic/'
inputtxt = urlopen(www + '/ic_example.txt')
with open( 'ic.test.txt','wb') as ftest: ftest.write(inputtxt.read())
inputtxt.close()

And try the commands:

import ecalic as ecal

###create an instance of ecalic.ic
i =  ecal.icCMS( 'ic.test.txt' , 'example IC' )

### help for each method
?i.etaRingNorm

### normalize to 1 per eta ring
i.etaRingNorm()

### plot 2D
i.plot( zRange_eb = [0.98,1.02], zRange_ee = [0.95,1.05], title = 'IC test'  )

### average per harness and plot,
### remove 10% of the most tailish cristals (left and right from mean)

# add a variable with the average
# trim = remove 10% of the most tailish cristals (left and right from mean)
i['ic_av'] = i.average( groupby='harness', trim = 0.10 )
# plot the average
i.plot( var = 'ic_av', zRange_eb = [0.98,1.02], zRange_ee = [0.95,1.05], title = 'IC test average'  )
ecal.plt.show()

A more involved example

In the following example we will:

  • get the noise (in gain 12) from two different runs (xml included in the package)
  • get the corresponding channel status
  • mask the bad channel in the noise ics
  • plot the noise in 2D
  • profile these noise along ieta
  • get the correlation between the 2 ics

Get the example script at testNoise.py

And run the script

python testNoise.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ecalic-1.0.5.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

ecalic-1.0.5-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

Details for the file ecalic-1.0.5.tar.gz.

File metadata

  • Download URL: ecalic-1.0.5.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for ecalic-1.0.5.tar.gz
Algorithm Hash digest
SHA256 684469ee0df79ad97147ceb1cca571e49d3d4278c507c5b611742278f34e6091
MD5 968710d5c70a3c9d2b731fc96c98e8ad
BLAKE2b-256 f7e94185ad558ae61fbc402661f6e699ae214088b8773802efc3380cc337eedb

See more details on using hashes here.

File details

Details for the file ecalic-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: ecalic-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for ecalic-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0887bdb911e623210ced14115e6e3ce497164e686e97e6bfcf29642e71e979c7
MD5 c4f003978f2e0c15780fea52207ba1f6
BLAKE2b-256 86326486ae12c54f5b975e594a97e572829713708f2534e5ccba318c30d7dfba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page