Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:19

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