/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes
DBChecker::DBChecker Class Reference

List of all members.

Public Member Functions

def __init__
def isValid
def hasEntry
def hasValidRG
def hasValidChannelQuality

Public Attributes

 db
 db_offline

Detailed Description

Definition at line 8 of file DBChecker.py.


Constructor & Destructor Documentation

def DBChecker::DBChecker::__init__ (   self,
  dbconf = 'offline_db' 
)

Definition at line 11 of file DBChecker.py.

00012                                            :
00013         from DybPython import DB
00014         self.db = DB(dbconf)
00015         self.db_offline = DB("offline_db")
        

Member Function Documentation

def DBChecker::DBChecker::isValid (   self,
  table_name,
  task,
  site,
  det,
  timestamp 
)

Definition at line 16 of file DBChecker.py.

00017                                                              :
00018 
00019         sql = 'select TIMESTART,VERSIONDATE,SEQNO from %s where SITEMASK=%d and \
00020 SUBSITE=%d and TASK=%d'  % (table_name, site, det, task)
00021         result = self.db(sql)
00022 
00023         dt_prev = -float('inf') 
00024         dt_next = float('inf')
00025         vd_prev = -float('inf')
00026 
00027         #these are mostly for debugging
00028         chosen_seqno = 0
00029         next_seqno=0
00030 
00031         #first loop once and find seqno dbi would choose
00032         for row in result:
00033             curr = TimeStamp.fromAssumedUTCDatetime(row['TIMESTART']).GetSeconds()
00034             vdate = TimeStamp.fromAssumedUTCDatetime(row['VERSIONDATE']).GetSeconds()
00035             
00036             dt = curr - timestamp
00037             dv = vdate - vd_prev
00038 
00039             #find the seqno that dbi would choose (it's not necessarily the closest in time, but the one with the most recent vesiondate)
00040             if dt <= 0.0 and dv >= 0.0:
00041                 vd_prev=vdate
00042                 dt_prev=dt
00043                 chosen_seqno=row['SEQNO']
00044 
00045         #loop again and see if there is a posterior one
00046         for row in result:
00047             curr = TimeStamp.fromAssumedUTCDatetime(row['TIMESTART']).GetSeconds()
00048             vdate = TimeStamp.fromAssumedUTCDatetime(row['VERSIONDATE']).GetSeconds()
00049             
00050             dt = curr - timestamp
00051             dv = vdate - vd_prev
00052             
00053             #find the next seqno (just search for an entry with a posterior time and with an equal or higher or validity date to the chosen one)
00054             if dt > 0.0 and dv >= 0.0:
00055                 dt_next = dt
00056                 next_seqno=row['SEQNO']
00057                
00058         #print "dt_prev is ",dt_prev
00059         #print "dt_next is ",dt_next
00060         #print "Chosen and next seqnos ",chosen_seqno,",",next_seqno
00061         return chosen_seqno and next_seqno and next_seqno > chosen_seqno

def DBChecker::DBChecker::hasEntry (   self,
  table_name,
  task,
  site,
  det,
  timestamp 
)

Definition at line 65 of file DBChecker.py.

00066                                                               :
00067 
00068         sql = 'select TIMESTART,TIMEEND,VERSIONDATE,SEQNO from %s where SITEMASK=%d and \
00069 SUBSITE=%d and TASK=%d'  % (table_name, site, det, task)
00070         result = self.db_offline(sql)
00071 
00072         dt_next = float('inf')
00073         vd_prev = -float('inf')
00074         dt_tokeep = float('inf')
00075 
00076         #these are mostly for debugging
00077         chosen_seqno = 0
00078         next_seqno=0
00079 
00080         #first loop once and find seqno dbi would choose
00081         for row in result:
00082             curr = TimeStamp.fromAssumedUTCDatetime(row['TIMESTART']).GetSeconds()
00083             tend = TimeStamp.fromAssumedUTCDatetime(row['TIMEEND']).GetSeconds()
00084             vdate = TimeStamp.fromAssumedUTCDatetime(row['VERSIONDATE']).GetSeconds()
00085             
00086             dt = timestamp - curr
00087             de = tend - timestamp
00088             dv = vdate - vd_prev
00089 
00090             #find the seqno that dbi would choose (it's not necessarily the closest in time, but the one with the most recent vesiondate)
00091             if dt >= 0.0 and de >= 0.0 and dv >= 0.0:
00092                 vd_prev=vdate
00093                 chosen_seqno=row['SEQNO']
00094                 dt_tokeep=dt
00095                
00096         #print "DQ:-->Chosen seqno ",chosen_seqno
00097         #print "DQ:-->dt_tokeep ",dt_tokeep
00098 
00099         #return 1 if there is an entry and the timestart is not too far
00100         return chosen_seqno and dt_tokeep < 3600*24*2

def DBChecker::DBChecker::hasValidRG (   self,
  site,
  det,
  timestamp 
)

Definition at line 101 of file DBChecker.py.

00102                                               :
00103         output=self.isValid('CalibPmtFineGainVld', 1, site, det, timestamp)
00104         print "the output of RG is ",output
00105         return output

def DBChecker::DBChecker::hasValidChannelQuality (   self,
  site,
  det,
  timestamp 
)

Definition at line 106 of file DBChecker.py.

00107                                                           :
00108         output = self.hasEntry('DqChannelPackedVld', 0, site, det, timestamp)
00109         print "the output of DQ is ",output
00110         return output


Member Data Documentation

Definition at line 11 of file DBChecker.py.

Definition at line 11 of file DBChecker.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:55:35 for ESCalibSPN by doxygen 1.7.4