CMS 3D CMS Logo

iovInspector.py

Go to the documentation of this file.
00001 #
00002 # iov info server backend
00003 #
00004 #  it assumes that all magic and incantations are done...
00005 #
00006 
00007 import pluginCondDBPyInterface as CondDB
00008 
00009 class WhatDescription :
00010        def __init__(self,w) :
00011               self.__me = w
00012               self.__ret ={}
00013        def describe(self) :
00014               _w = self.__me
00015               _atts = (att for att in dir(self.__me) if not (att[0]=='_' or att[0:4]=='set_' or att[0:6]=='descr_'))
00016               for _att in _atts:
00017                      exec('_a=_w.'+_att+'()')
00018                      if (_a.__class__==CondDB.VInt):
00019                             if(hasattr(self.__me,'descr_'+_att)) :
00020                                    self.multiple(_att)
00021                             else :
00022                                    self.commaSeparated(_att)
00023                      else :
00024                             self.single(_att,_a)
00025               return self.__ret
00026 
00027        def single(self,att,a) :
00028               self.__ret[att]=('single',[val for val in dir(a) if not (val[0]=='_' or val=='name'or val=='values')])
00029 
00030        def multiple(self,att) :
00031               _w = self.__me
00032               exec('_d=_w.descr_'+att+'()')
00033               self.__ret[att]=('multiple',[val for val in _d])
00034 
00035        def commaSeparated(self,att) :
00036               self.__ret[att]=('commaSeparated',[])
00037        
00038        
00039 def extractorWhat(db, tag) :
00040        exec('import '+db.moduleName(tag)+' as Plug')
00041        ret ={}
00042        w =  WhatDescription(Plug.What())
00043        return w.describe()
00044 
00045 def setWhat(w,ret) :
00046        for key in ret.keys():
00047               _val = ret[key]
00048               if (type(_val)==type([])) :
00049                      _vi = CondDB.VInt()
00050                      for i in _val :
00051                             _vi.append(i)
00052                      exec ('w.set_'+key+'(_vi)')
00053               else :
00054                      exec ('w.set_'+key+'(w.'+key+'().'+ret[key]+')')
00055        return w
00056 
00057 
00058 class Iov :
00059        def __init__(self, db, tag, since=0, till=0, head=0, tail=0) :
00060            self.__db = db
00061            self.__tag = tag
00062            try : 
00063                self.__modName = db.moduleName(tag)
00064                exec('import '+self.__modName+' as Plug')
00065            except RuntimeError :
00066                self.__modName = 0
00067            self.__me = db.iov(tag)
00068            if (till) : self.__me.setRange(since,till)
00069            if (head) : self.__me.head(head)
00070            if (tail) : self.__me.tail(tail)
00071 
00072        def list(self) :
00073            ret = []
00074            for elem in self.__me.elements :
00075                ret.append( (elem.payloadToken(), elem.since(), elem.till(),0))
00076            return ret
00077 
00078        def summaries(self) :
00079            if (self.__modName==0) : return ["no plugin for "  + self.__tag+" no summaries"]
00080            exec('import '+self.__modName+' as Plug')
00081            ret = []
00082            for elem in self.__me.elements :
00083                p = Plug.Object(elem)
00084                ret.append( (elem.payloadToken(), elem.since(), elem.till(), p.summary()))
00085            return ret
00086            
00087        def trend(self, what) :
00088            if (self.__modName==0) : return ["no plugin for "  + self.__tag+" no trend"]
00089            exec('import '+self.__modName+' as Plug')
00090            ret = []
00091            w = setWhat(Plug.What(),what)
00092            ex = Plug.Extractor(w)
00093            for elem in self.__me.elements :
00094                p = Plug.Object(elem)
00095                p.extract(ex)
00096                v = [i for i in ex.values()]
00097                ret.append((elem.since(),elem.till(),v))
00098            return ret  
00099 
00100 
00101 class PayLoad :
00102     def __init__(self, db, token) :
00103         self.__db = db
00104         self.__token = token
00105         exec('import '+db.moduleName(token)+' as Plug')
00106         self.__me = Plug.Object(db.payLoad(token))
00107 
00108     def __str__(self) :
00109         return self.__me.dump()
00110 
00111     def object(self) :
00112         return self.__me
00113 
00114     def summary(self) :
00115         return self.__me.summary()
00116 
00117     def plot(self, fname, s, il, fl) :
00118         vi = CondDB.VInt()
00119         vf = CondDB.VFloat()
00120         for i in il:
00121             vi.append(int(i))
00122         for i in fl:
00123             vf.append(float(i))
00124         return self.__me.plot(fname,s,vi,vf)
00125 
00126 
00127 
00128 

Generated on Tue Jun 9 17:26:15 2009 for CMSSW by  doxygen 1.5.4