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

List of all members.

Public Member Functions

def __init__
def queryGain
def checkGain
def queryPmtNumber
def checkPmtNumber

Public Attributes

 timeRangeLow
 timeRangeHigh

Detailed Description

check pmt status

Definition at line 12 of file CheckPmt.py.


Constructor & Destructor Documentation

def CheckPmt::CheckPmt::__init__ (   self,
  timeRangeLow,
  timeRangeHigh 
)

Definition at line 14 of file CheckPmt.py.

00015                                                    :
00016         self.timeRangeLow = timeRangeLow
00017         self.timeRangeHigh = timeRangeHigh
00018         return


Member Function Documentation

def CheckPmt::CheckPmt::queryGain (   self,
  timeRangeLow,
  timeRangeHigh 
)
Talk to offline DB and get the time range of the run

Definition at line 19 of file CheckPmt.py.

00020                                                     :
00021         """Talk to offline DB and get the time range of the run"""
00022         try:
00023             con = MySQLdb.connect( host = "dayabaydb.lbl.gov",
00024                                    user = "ligs",
00025                                    passwd = "3Quarks",
00026                                    db = "tmp_ligs_offline_db" )
00027             cursor = con.cursor()
00028             cursor.execute( "SELECT DataQualityPmt.runNo, DataQualityPmt.fileNo, DataQualityPmt.pmtId, DataQualityPmt.gain, DataQualityPmt.gainErr FROM DataQualityPmt, DataQualityPmtVld WHERE DataQualityPmt.seqno = DataQualityPmtVld.seqno AND DataQualityPmtVld.timeStart>'%s' AND DataQualityPmtVld.timeStart<'%s' AND ( ( DataQualityPmt.status=-1 AND ( (DataQualityPmt.gain+DataQualityPmt.gainErr)<20 OR (DataQualityPmt.gain-DataQualityPmt.gainErr)>40 ) AND SQRT(DataQualityPmt.gain/DataQualityPmt.gainErr)>5 ) OR ( DataQualityPmt.Status =0 AND ( (DataQualityPmt.gain+DataQualityPmt.gainErr)<10 OR (DataQualityPmt.gain-DataQualityPmt.gainErr)>40 ) ) ) ORDER BY DataQualityPmt.runNo, DataQualityPmt.fileNo" % (timeRangeLow,timeRangeHigh) )
00029             row = cursor.fetchall()
00030             if row:
00031                 print "Successful query!"
00032         except MySQLdb.Error,e:
00033             print "Error %d: %s" % (e.args[0], e.args[1])
00034             sys.exit(1)
00035 
00036         cursor.close()
00037         con.close()
00038         return row

def CheckPmt::CheckPmt::checkGain (   self)

Definition at line 39 of file CheckPmt.py.

00040                        :
00041         badPmts = self.queryGain(self.timeRangeLow, self.timeRangeHigh)
00042         #check directory existence and open log file   
00043         if not os.path.exists('BadPmt'):
00044             os.mkdir('BadPmt')
00045 
00046         if len(badPmts) == 0:
00047             file = open('BadPmt/%s_GOOD' % (''.join(self.timeRangeLow.split()[0].split('-'))), 'w')
00048             file.write('%s --> %s\n' % (self.timeRangeLow, self.timeRangeHigh))
00049             print "All PMTs are in good condition."
00050             file.write("All PMTs are in good condition.")
00051             file.close()
00052         else:
00053             file = open('BadPmt/%s' % (''.join(self.timeRangeLow.split()[0].split('-'))), 'w')
00054             file.write('%s --> %s' % (self.timeRangeLow, self.timeRangeHigh))
00055             lastfile = None
00056             for pmt in badPmts:
00057                 thisfile = 'run%07d_seq%04d' % (pmt[0], pmt[1])
00058                 if thisfile != lastfile:
00059                     print "\n%s" % thisfile
00060                     file.write( "\n%s\n" % thisfile )
00061                 pmtData = DetectorSensor( int(pmt[2]) )
00062                 if pmtData.isAD():
00063                     adPmt = AdPmtSensor( int(pmt[2]) )
00064                     print "%s ring%02d_column%02d gain:%s gainErr:%s" % (adPmt.detName(), adPmt.ring(), adPmt.column(), pmt[3], pmt[4])
00065                     file.write( "%s ring%02d_column%02d gain:%s gainErr:%s\n" %
00066                                 (adPmt.detName(), adPmt.ring(), adPmt.column(), pmt[3], pmt[4]) )
00067                 if pmtData.isWaterShield():
00068                     poolPmt = PoolPmtSensor( int(pmt[2]) )
00069                     print "%s wall%02d_spot%02d_inwardFacing%d gain:%s gainErr:%s" % (poolPmt.detName(), poolPmt.wallNumber(), poolPmt.wallSpot(), int(poolPmt.inwardFacing()), pmt[3], pmt[4])
00070                     file.write( "%s wall%02d_spot%02d_inwardFacing%d gain:%s gainErr:%s\n" %
00071                                 (poolPmt.detName(), poolPmt.wallNumber(), poolPmt.wallSpot(),
00072                                 int(poolPmt.inwardFacing()), pmt[3], pmt[4]) )
00073                 lastfile = thisfile
00074             file.write('\n\n')
00075             file.close()

def CheckPmt::CheckPmt::queryPmtNumber (   self,
  timeRangeLow,
  timeRangeHigh 
)
Talk to offline DB and get the time range of the run

Definition at line 76 of file CheckPmt.py.

00077                                                          :
00078         """Talk to offline DB and get the time range of the run"""
00079         try:
00080             con = MySQLdb.connect( host = "dayabaydb.lbl.gov",
00081                                    user = "ligs",
00082                                    passwd = "3Quarks",
00083                                    db = "tmp_ligs_offline_db" )
00084             cursor = con.cursor()
00085             cursor.execute( "SELECT DataQualityPmt.runNo, DataQualityPmt.fileNo, DataQualityPmt.pmtId FROM DataQualityPmt, DataQualityPmtVld WHERE DataQualityPmt.seqno = DataQualityPmtVld.seqno AND DataQualityPmtVld.timeStart>'%s' AND DataQualityPmtVld.timeStart<'%s' ORDER BY DataQualityPmt.runNo, DataQualityPmt.fileNo" % (timeRangeLow,timeRangeHigh) )
00086             row = cursor.fetchall()
00087             if row:
00088                 print "Successful query!"
00089         except MySQLdb.Error,e:
00090             print "Error %d: %s" % (e.args[0], e.args[1])
00091             sys.exit(1)
00092 
00093         cursor.close()
00094         con.close()
00095         return row

def CheckPmt::CheckPmt::checkPmtNumber (   self)
check how many pmts are working in each detector

Definition at line 96 of file CheckPmt.py.

00097                             :
00098         """check how many pmts are working in each detector"""
00099         pmts = self.queryPmtNumber(self.timeRangeLow, self.timeRangeHigh)
00100         lastfile = None
00101         detPmtCounter = [0,0,0,0,0,0] 
00102         
00103         if not os.path.exists('AlivePmt'):
00104             os.mkdir('AlivePmt')
00105         file = open('AlivePmt/%s' % (''.join(self.timeRangeLow.split()[0].split('-'))), 'w')
00106         file.write('%s --> %s\n' % (self.timeRangeLow, self.timeRangeHigh))
00107         
00108         for pmt in pmts:
00109             thisfile = 'run%07d_seq%04d' % (pmt[0], pmt[1])
00110             if thisfile != lastfile:
00111                 if lastfile != None:
00112                     print "\n%s" % lastfile
00113                     # record the file in which a certain propotion of PMT is not working
00114                     if ( detPmtCounter[0]<198 or
00115                          detPmtCounter[1]<198 or
00116                          detPmtCounter[4]<200 or
00117                          detPmtCounter[5]<200 ):
00118                         file.write('\n%s\n' % lastfile)
00119                         for detIdx in range(6):
00120                             print "detID", detIdx+1, detPmtCounter[detIdx]
00121                             file.write( 'detID%d %d\n' % (detIdx+1, detPmtCounter[detIdx]) )
00122                 #a new file, initialize the counter
00123                 detPmtCounter = [0,0,0,0,0,0] 
00124             pmtData = DetectorSensor( int(pmt[2]) )
00125             detId = pmtData.detectorId() 
00126             detPmtCounter[detId-1] += 1  
00127             lastfile = thisfile
00128         file.close()
00129         return
     

Member Data Documentation

Definition at line 14 of file CheckPmt.py.

Definition at line 14 of file CheckPmt.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