/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
DQDumpRpc::DumpRpcToDbAlg Class Reference
Inheritance diagram for DQDumpRpc::DumpRpcToDbAlg:
Inheritance graph
[legend]
Collaboration diagram for DQDumpRpc::DumpRpcToDbAlg:
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 DQDumpRpc.py.


Constructor & Destructor Documentation

def DQDumpRpc::DumpRpcToDbAlg::__init__ (   self,
  name 
)

Definition at line 23 of file DQDumpRpc.py.

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


Member Function Documentation

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

Definition at line 29 of file DQDumpRpc.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 DQDumpRpc::DumpRpcToDbAlg::getFileTimeInfo (   self,
  seqNo 
)
Talk to offline DB and get the time range of the run

Definition at line 49 of file DQDumpRpc.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 DQDumpRpc::DumpRpcToDbAlg::dumptodb (   self)

Definition at line 69 of file DQDumpRpc.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 = DQRpc.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='RawRPCCalib.txt'
00085         f = open(FILENAME,'r')
00086         rowCount = 0
00087         for line in f:
00088             if line[0] != '#':
00089                 line = line.strip()
00090                 para = line.split()
00091                 rpcLayerId = int( para[0] )
00092                 row = int( para[1] )
00093                 column = int( para[2] )
00094                 layer = int( para[3] )
00095                 eff = float( para[4] )
00096                 effErr = float( para[5] )
00097                 noiseRate = float( para[6] )
00098                 #noise rate error may be 'inf' calculated by RPCCalib,
00099                 #this is an ugly work-around
00100                 if para[7] == 'inf':
00101                     noiseRateErr = -1
00102                 else:
00103                     noiseRateErr = float( para[7] )
00104                 record = DQRpc.Create( RunNo = self.runNo,
00105                                        FileNo = self.fileNo,
00106                                        RpcSensorId = DayaBay.RpcSensor(rpcLayerId), 
00107                                        PanelRow = row,
00108                                        PanelColumn = column,
00109                                        Layer = layer,
00110                                        Efficiency = eff,
00111                                        EfficiencyErr = effErr,
00112                                        NoiseRate = noiseRate,
00113                                        NoiseRateErr = noiseRateErr )
00114                 wrt.Write(record)
00115         wrt.Close()
00116         return
    
def DQDumpRpc::DumpRpcToDbAlg::initialize (   self)

Definition at line 117 of file DQDumpRpc.py.

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

def DQDumpRpc::DumpRpcToDbAlg::execute (   self)

Definition at line 129 of file DQDumpRpc.py.

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

def DQDumpRpc::DumpRpcToDbAlg::finalize (   self)

Definition at line 141 of file DQDumpRpc.py.

00142                       :
00143         self.info("finalizing")
00144         self.dumptodb()
00145         os.system("mv RawRPCCalib.txt RawRPCCalib_finished.txt")
00146         status = DybPythonAlg.finalize(self)
00147         return status


Member Data Documentation

Definition at line 23 of file DQDumpRpc.py.

Definition at line 23 of file DQDumpRpc.py.

Definition at line 117 of file DQDumpRpc.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