/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
DQDumpPmt::DumpPmtToDbAlg Class Reference
Inheritance diagram for DQDumpPmt::DumpPmtToDbAlg:
Inheritance graph
[legend]
Collaboration diagram for DQDumpPmt::DumpPmtToDbAlg:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def getSeqNo
def getFileTimeInfo
def dumptodb
def initialize
def execute
def finalize

Public Attributes

 runNo
 fileNo
 daqDetailsSvc

Detailed Description

Definition at line 21 of file DQDumpPmt.py.


Constructor & Destructor Documentation

def DQDumpPmt::DumpPmtToDbAlg::__init__ (   self,
  name 
)

Definition at line 23 of file DQDumpPmt.py.

00024                            :
00025         DybPythonAlg.__init__(self,name)
00026         self.runNo = 0
00027         self.fileNo = 0
00028         return


Member Function Documentation

def DQDumpPmt::DumpPmtToDbAlg::getSeqNo (   self,
  runNo,
  fileNo 
)
Get file seqno by runno and fileno

Definition at line 29 of file DQDumpPmt.py.

00030                                      :
00031         """Get file seqno by runno and fileno"""
00032         try:
00033             con = MySQLdb.connect( host = "dayabaydb.lbl.gov",
00034                                    user = "dayabay",
00035                                    passwd = "3quarks",
00036                                    db = "offline_db" )
00037             cursor = con.cursor()
00038             cursor.execute("SELECT seqno FROM DaqRawDataFileInfo WHERE runNo = "
00039                             + str(runNo) + " AND " + "fileNo = " + str(fileNo))
00040             row = cursor.fetchone()
00041             if row:
00042                 print "get seqno successful"
00043         except MySQLdb.Error,e:
00044             print "Error %d: %s" % (e.args[0], e.args[1])
00045             sys.exit(1)
00046         cursor.close()
00047         con.close()
00048         return row[0]

def DQDumpPmt::DumpPmtToDbAlg::getFileTimeInfo (   self,
  seqNo 
)
Talk to offline DB and get the time range of the run

Definition at line 49 of file DQDumpPmt.py.

00050                                     :
00051         """Talk to offline DB and get the time range of the run"""
00052         try:
00053             con = MySQLdb.connect( host = "dayabaydb.lbl.gov",
00054                                    user = "dayabay",
00055                                    passwd = "3quarks",
00056                                    db = "offline_db" )
00057             cursor = con.cursor()
00058             cursor.execute("SELECT timestart,timeend FROM DaqRawDataFileInfoVld WHERE seqno = " + str(seqNo))
00059             row = cursor.fetchone()
00060             if row:
00061                 print "get file time info successfully"
00062         except MySQLdb.Error,e:
00063             print "Error %d: %s" % (e.args[0], e.args[1])
00064             sys.exit(1)
00065 
00066         cursor.close()
00067         con.close()
00068         return row

def DQDumpPmt::DumpPmtToDbAlg::dumptodb (   self)

Definition at line 69 of file DQDumpPmt.py.

00070                       :
00071         seqNo = self.getSeqNo(self.runNo, self.fileNo)
00072         fileTime = self.getFileTimeInfo(seqNo)
00073         import calendar
00074         starttime = calendar.timegm( fileTime[0].timetuple() )
00075         endtime = calendar.timegm( fileTime[1].timetuple() )
00076         
00077         wrt = DQPmt.Wrt()
00078         cr = ContextRange( Site.kAll,
00079                            SimFlag.kData|SimFlag.kMC,
00080                            TimeStamp(starttime),
00081                            TimeStamp(endtime) )
00082         wrt.ctx(contextrange=cr, versiondate=TimeStamp(0,0))
00083 
00084         FILENAME='pmtDataTable_01.txt'
00085         f = open(FILENAME,'r')
00086         for line in f:
00087             if line[0] != '#':
00088                 line = line.strip()
00089                 para = line.split()
00090                 status = int( para[2] )
00091                 chi2ndf = float( para[5] )
00092                 pmtID = para[0]
00093                 pmtInfo = para[1]
00094                 gain = float( para[6] )
00095                 gainErr = float( para[7] )
00096                 darkRate = float( para[15] )
00097                 darkRateErr = float( para[16] )
00098                 elecNoiseRate = float( para[17] )
00099                 elecNoiseRateErr = float( para[18] )
00100                 preAdc = float( para[19] )
00101                 preAdcErr = float( para[20] )
00102                 record = DQPmt.Create( RunNo = self.runNo,
00103                                        FileNo = self.fileNo,
00104                                        PmtId = DetectorSensor( int(pmtID) ),
00105                                        Describ = pmtInfo,
00106                                        Status = status,
00107                                        Chi2ndf = chi2ndf,
00108                                        Gain = gain,
00109                                        GainErr = gainErr,
00110                                        DarkRate = darkRate,
00111                                        DarkRateErr = darkRateErr,
00112                                        ElecNoiseRate = elecNoiseRate,
00113                                        ElecNoiseRateErr = elecNoiseRateErr,
00114                                        PreAdc = preAdc,
00115                                        PreAdcErr = preAdcErr )
00116                 wrt.Write(record)
00117         wrt.Close()
00118         return

def DQDumpPmt::DumpPmtToDbAlg::initialize (   self)

Definition at line 119 of file DQDumpPmt.py.

00120                         :
00121         status = DybPythonAlg.initialize(self)
00122         if status.isFailure(): return status
00123         
00124         self.daqDetailsSvc = self.svc('IDaqDetailsSvc','DetailsFromRecordSvc')
00125         if self.daqDetailsSvc == None:
00126             self.error("Failed to get IDaqDetailsSvc")
00127             return FAILURE
00128         
00129         self.info("initializing")
00130         return SUCCESS

def DQDumpPmt::DumpPmtToDbAlg::execute (   self)

Definition at line 131 of file DQDumpPmt.py.

00132                      :
00133         if((self.runNo == 0) and (self.fileNo == 0) ):
00134             evt = self.evtSvc()
00135             readoutHdr = evt["/Event/Readout/ReadoutHeader"]
00136             if readoutHdr == None:
00137                 self.error("Failed to get current readout header")
00138                 return FAILURE
00139             svcMode = ServiceMode(readoutHdr.context(), 0)
00140             self.runNo = self.daqDetailsSvc.runDetails(svcMode).runNumber()
00141             self.fileNo = self.daqDetailsSvc.fileDetails(svcMode).fileNumber() 
00142         return SUCCESS
        
def DQDumpPmt::DumpPmtToDbAlg::finalize (   self)

Definition at line 143 of file DQDumpPmt.py.

00144                       :
00145         self.info("finalizing")
00146         self.dumptodb()
00147         os.system("mv pmtDataTable_01.txt pmtDataTable_01_finished.txt")
00148         status = DybPythonAlg.finalize(self)
00149         return status


Member Data Documentation

Definition at line 23 of file DQDumpPmt.py.

Definition at line 23 of file DQDumpPmt.py.

Definition at line 119 of file DQDumpPmt.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