/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
FillGoodFile::GoodFileTable Class Reference

List of all members.

Public Member Functions

def __init__
def fillGoodFileTable

Public Attributes

 revision
 r is tuple whose element is dictionary, different from MySQLdb

Detailed Description

Get Rate from ROOT file

Definition at line 32 of file FillGoodFile.py.


Constructor & Destructor Documentation

def FillGoodFile::GoodFileTable::__init__ (   self,
  inputFilename,
  rev 
)

Definition at line 34 of file FillGoodFile.py.

00035 :
    #def __init__(self):

Member Function Documentation

def FillGoodFile::GoodFileTable::fillGoodFileTable (   self)
Constructor
fill good file table

Definition at line 48 of file FillGoodFile.py.

00049                                :
00050         """fill good file table"""
00051         #neutrino flux table
00052 
00053 
00054         #pmt table
00055         # need to consider version here!!
00056         #r=dq_db('SELECT * FROM DqPmt WHERE RunNo=%s and FileNo=%s and Quality!=1' % (self.runNo,self.fileNo))
00057         r=dq_db('SELECT SEQNO FROM DqPmt WHERE RunNo=%s AND FileNo=%s GROUP BY SEQNO ORDER BY SEQNO DESC LIMIT 1' % (self.runNo,self.fileNo))
00058         #working pmt number
00059         if len(r)==0:# no pmt info yet
00060             #pmt info not yet dumped into DB
00061             status = 'undefined'
00062         #elif r[0]['COUNT(SEQNO)']>20:
00063         #    status = 'bad'
00064         #else:
00065         #    status = 'good'
00066         else:
00067             seqno = r[0]['SEQNO']
00068             r=dq_db('SELECT COUNT(SEQNO) FROM DqPmt WHERE SEQNO=%s AND Quality=0' % seqno)
00069             NHVoffPmt = r[0]['COUNT(SEQNO)']
00070             r=dq_db('SELECT COUNT(SEQNO) FROM DqPmt WHERE (Gain-3*GainErr>35 OR Gain+3*GainErr<15) AND Gainerr<2 AND Gainerr!=0 AND SEQNO=%s' % seqno)
00071             NAbnormalPmt = r[0]['COUNT(SEQNO)']
00072             if NHVoffPmt>20 or NAbnormalPmt>10:
00073                 status = 'bad'
00074             else:
00075                 status = 'good'
00076 
00077         #detector table
00078         #r=dq_db('SELECT * FROM DqDetector WHERE RunNo=%s and FileNo=%s' % (self.runNo,self.fileNo))
00079 
00080         #trigger type table
00081 
00082 
00083         #daq raw file table
00084         r=offline_db('SELECT SEQNO,streamType,stream FROM DaqRawDataFileInfo WHERE RunNo=%s and FileNo=%s' % (self.runNo,self.fileNo))
00085         ###  r is tuple whose element is dictionary, different from MySQLdb
00086         tagid = dq_db('SELECT id FROM tags WHERE tag="%s"' % r[0]['streamType'])
00087         tagid = tagid[0]['id']
00088         fileid = r[0]['SEQNO'] #fileid from file table or DaqRawFileInfo?
00089 
00090 
00091         userid = 2  # offline robot
00092         
00093         #obtain revisionid
00094         if self.revision==None:
00095             #nuwaVersion = os.getenv('SITEROOT')
00096             #nuwaVersion = nuwaVersion.split('/')
00097             #nuwaVersion = nuwaVersion[-1]
00098             nuwaVersion = os.getenv('NUWA_RELEASE')
00099             revision = self.jobVersion+'_'+nuwaVersion+'_'+self.cutVersion
00100         else:
00101             revision = self.revision
00102         r = dq_db('SELECT id FROM revisions WHERE comment="%s"' % revision)
00103         if len(r)==0:
00104             dq_db('INSERT INTO revisions(user_id, comment) VALUES(%s, "%s")' % (userid, revision))
00105         r = dq_db('SELECT id FROM revisions WHERE comment="%s"' % revision)
00106         revisionid = r[0]['id']
00107 
00108         
00109         #fill user_file_tag table
00110         lastNTags = dq_db('SELECT COUNT(file_id) AS NTags FROM user_file_tag WHERE file_id=%s GROUP BY tag_date ORDER BY tag_date DESC LIMIT 1' % fileid)
00111         if len(lastNTags)==1:#not the first time 
00112             NTags = lastNTags[0]['NTags'] 
00113             lastTags = dq_db('SELECT * FROM user_file_tag WHERE file_id=%s ORDER BY tag_date desc LIMIT %s' % (fileid, NTags))
00114             lastRevisionid = lastTags[0]['revision_id']
00115             lastUserid = lastTags[0]['user_id']
00116             r = dq_db('SELECT comment FROM revisions WHERE id=%s' % lastRevisionid)
00117             lastRevision = r[0]['comment']
00118             #if lastRevisionid != revisionid:#
00119             if lastRevision.find(revision)==-1:#
00120                 if lastRevision.startswith('mtagrev'):#auto update last time with manual tag version
00121                     tmp = lastRevision.split('_')
00122                     mRev = tmp.pop(0) #manual update rev number
00123                     #lastRevision = '-'.join(tmp)
00124                     #if lastRevision != revision:
00125                     #    revision = mRev+'_'+revision
00126                     #    dq_db('INSERT INTO revisions(user_id, comment) VALUES(%s, "%s")' % (userid, revision))
00127                     #    r = dq_db('SELECT id FROM revisions WHERE comment="%s"' % revision)
00128                     #    revisionid = r[0]['id']
00129                     revision = mRev+'_'+revision
00130                     r = dq_db('SELECT id FROM revisions WHERE comment="%s"' % revision)
00131                     if len(r)==0:
00132                         dq_db('INSERT INTO revisions(user_id, comment) VALUES(%s, "%s")' % (userid, revision))
00133                     r = dq_db('SELECT id FROM revisions WHERE comment="%s"' % revision)
00134                     revisionid = r[0]['id']
00135                     
00136                 elif lastUserid==1:# manual update last time
00137                     revision = ('mtagrev%s_'+revision) % lastRevisionid
00138                     r = dq_db('SELECT id FROM revisions WHERE comment="%s"' % revision)
00139                     if len(r)==0:
00140                         dq_db('INSERT INTO revisions(user_id, comment) VALUES(%s, "%s")' % (userid, revision))
00141                     r = dq_db('SELECT id FROM revisions WHERE comment="%s"' % revision)
00142                     revisionid = r[0]['id']
00143                     
00144 
00145                 #obtain current time
00146                 now = strftime("%Y-%m-%d %H:%M:%S",localtime())
00147                 for idx in range(NTags):
00148                     dq_db( 'INSERT INTO user_file_tag(user_id, file_id, tag_id, status, tag_date, revision_id) VALUES(%s, %s, %s, "%s", "%s", %s)' % (userid, fileid, lastTags[idx]['tag_id'], status, now, revisionid) )
00149                     #update most_recent_file_tag table
00150                     r = dq_db('SELECT * FROM most_recent_file_tag WHERE file_id=%s' % fileid)
00151                     if len(r)==1:
00152                         dq_db('UPDATE most_recent_file_tag SET last_status="%s", last_user_id=%s, last_date="%s", last_revision_id=%s WHERE file_id=%s' % (status, userid, now, revisionid, fileid))
00153                     else:
00154                         dq_db('INSERT INTO most_recent_file_tag(file_id, last_status, last_user_id, last_date, last_revision_id) VALUES(%s, "%s", %s, "%s", %s)' % (fileid, status, userid, now, revisionid))
00155                         
00156         else:
00157             now = strftime("%Y-%m-%d %H:%M:%S",localtime())
00158             dq_db('INSERT INTO user_file_tag(user_id, file_id, tag_id, status, tag_date, revision_id) VALUES(%s, %s, %s, "%s", "%s", %s)' % (userid, fileid, tagid, status, now, revisionid))
00159             #add corresponding record in most_recent_file_tag table
00160             dq_db('INSERT INTO most_recent_file_tag(file_id, last_status, last_user_id, last_date, last_revision_id) VALUES(%s, "%s", %s, "%s", %s)' % (fileid, status, userid, now, revisionid))
00161         offline_db.close()
00162         dq_db.close()
00163 
        

Member Data Documentation

r is tuple whose element is dictionary, different from MySQLdb

Definition at line 49 of file FillGoodFile.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:54:23 for DQDump by doxygen 1.7.4