Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:46:16

0001 #!/usr/bin/env python
0002 
0003 from __future__ import print_function
0004 import os,sys, DLFCN, time, datetime
0005 import matplotlib
0006 import numpy
0007 import pylab
0008 import math
0009 import cherrypy
0010 
0011 from pylab import figure, show
0012 matplotlib.use('Agg')
0013 
0014 sys.setdlopenflags(DLFCN.RTLD_GLOBAL+DLFCN.RTLD_LAZY)
0015 
0016 from pluginCondDBPyInterface import *
0017 
0018 a = FWIncantation()
0019 rdbms = RDBMS()
0020 dbName =  "sqlite_file:dati.db"
0021 rdbms = RDBMS("/afs/cern.ch/cms/DB/conddb/")
0022 dbName =  "oracle://cms_orcoff_prep/CMS_COND_30X_RPC"
0023 tagPVSS = 'test1'
0024         
0025 from CondCore.Utilities import iovInspector as inspect
0026 
0027 db = rdbms.getDB(dbName)
0028 tags = db.allTags()
0029 
0030 ##----------------------- Create assosiacion map for detectors -----------------
0031 ##tagPVSS = 'PVSS_v3'
0032 
0033 try:
0034     iov = inspect.Iov(db,tagPVSS)
0035     iovlist=iov.list()
0036     print(iovlist)
0037     detMapName = {}
0038 
0039     for p in iovlist:
0040         payload=inspect.PayLoad(db,p[0])
0041         info = payload.summary().split(" ")
0042 
0043         i = 0
0044         for e in info:
0045             
0046             try:
0047                 if int(info[i+1]) == 0:
0048                     detName = "W"+str(info[i+2])+"_S"+str(info[i+3])+"_RB"+str(info[i+4])+"_Layer"+str(info[i+5])+"_SubS"+str(info[i+6])
0049                 else:
0050                     detName = "D"+str(info[i+2])+"_S"+str(info[i+3])+"_RB"+str(info[i+4])+"_Layer"+str(info[i+5])+"_SubS"+str(info[i+6])
0051 
0052                 detMapName[info[i]] = detName
0053                 i += 7
0054             except:
0055                 pass
0056 
0057     for (k,v) in detMapName.items():
0058         print(k,v)
0059 
0060 
0061 except Exception as er :
0062     print(er)
0063 
0064 ##--------------------- Current reading -----------------------------------------
0065 
0066 ##tag = 'Imon_v3'
0067 
0068 ####tag = 'Test_70195'
0069 ##timeStart = time.mktime((2008, 11, 9, 4, 10, 0,0,0,0))
0070 ##timeEnd = time.mktime((2008, 11, 10, 5, 10, 0,0,0,0))
0071 
0072 ####print timeStart,timeEnd, time.ctime(timeStart),time.ctime(timeEnd)
0073 
0074 ##try:
0075 
0076 ##    iov1 = inspect.Iov(db,tag)
0077 ##    iovlist1=iov1.list()
0078 ##    detMap = {}
0079     
0080 ##    for p1 in iovlist1:
0081 ##        payload1=inspect.PayLoad(db,p1[0])
0082 ##        info = payload1.summary().split(" ")
0083 
0084 ##        i = 0
0085 ##        for e in info:
0086 ##            if i+2 < len(info):
0087 ##                timein = int(info[i+2])+(p1[1] >> 32)
0088 ##                if timein < int(timeEnd):
0089 ##                    if detMap.has_key(info[i]):
0090 ##                        detMap[info[i]][0].append(timein)
0091 ##                        detMap[info[i]][1].append(float(info[i+1]))
0092 ##                    else:
0093 ##                        detMap[info[i]] = [[timein],[float(info[i+1])]]
0094 
0095 ####                    if detMap.has_key((detMapName[info[i]])):
0096 ####                        print "Exist the key!"
0097 ####                        print "Current vaues: ", detMap[(detMapName[info[i]])][0], detMap[(detMapName[info[i]])][1]
0098 ####                        print "value is: ", timein, float(info[i+1])
0099 ####                        print "The det name is: ", (detMapName[info[i]])
0100 ####                        
0101 ####                        detMap[(detMapName[info[i]])][0].append(timein)
0102 ####                        detMap[(detMapName[info[i]])][1].append(float(info[i+1]))
0103 ####                    else:
0104 ####                        print "Not Exist the key!"
0105 ####                        print "Value is: ", timein, float(info[i+1])
0106 ####                        print "Det id: ", info[i]
0107 ####                        print "The det name is: ", (detMapName[info[i]])
0108 ####                        
0109 ####                        detMap[(detMapName[info[i]])] = [[timein],[float(info[i+1])]]
0110                     
0111 ##                i += 3
0112 
0113 ##    for (k,v) in  detMap.items():
0114 
0115 ##        f=pylab.figure()
0116 ##        ax = f.add_subplot(111)
0117 ##        ax.set_xlabel('Time (s)')
0118 ##        ax.set_ylabel('Current (uA)')
0119 ##        ax.set_title(str(k))
0120 ##        ax.plot(v[0],v[1],'rs-',linewidth=2)
0121 ##        f.canvas.draw()
0122 ##        f.savefig('/tmp/trentad/'+str(k),format='png')
0123 
0124 ##        average = pylab.polyfit(v[0],v[1],0)
0125 ##        sigma = 0
0126 ##        highCurrent = False
0127         
0128 ##        for c in v[1]:
0129 ##            sigma += math.pow((average[0]-c), 2)
0130 ##            if math.fabs(average[0]-c) > 1: highCurrent = True
0131 ##        sigma = math.sqrt(sigma/len(v[1]))
0132 
0133 ##        if  highCurrent:
0134 ##            print "Num points: ",len(v[0]),"   Fit coeff: ",pylab.polyfit(v[0],v[1],0), "   Sigma: ",sigma, "   HighCurrrent: ", highCurrent
0135         
0136 
0137 ##except Exception, er :
0138 ##    print er
0139 
0140