/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 | Static Public Attributes
DumpDqLivetime::DumpLivetime Class Reference

List of all members.

Public Member Functions

def __init__
def getFileTimeInfo
def calcLiveTime
def dumpLivetime

Public Attributes

 thissite
 runTime

Static Public Attributes

tuple inputFilename = inputFilename.strip()

Detailed Description

Get counts from ROOT file

Definition at line 28 of file DumpDqLivetime.py.


Constructor & Destructor Documentation

def DumpDqLivetime::DumpLivetime::__init__ (   self,
  inputFilename 
)

Definition at line 30 of file DumpDqLivetime.py.

00031 :
    #def __init__(self):

Member Function Documentation

def DumpDqLivetime::DumpLivetime::getFileTimeInfo (   self,
  runNo,
  fileNo 
)
Talk to offline DB and get the time range of the run

Definition at line 46 of file DumpDqLivetime.py.

00047                                             :
00048         """Talk to offline DB and get the time range of the run"""
00049         try:
00050             con = MySQLdb.connect( host = dbhost,
00051                                    user = dbuser,
00052                                    passwd = dbpasswd,
00053                                    db = database )
00054             cursor = con.cursor()
00055             cursor.execute( "SELECT DaqRawDataFileInfoVld.timestart, DaqRawDataFileInfoVld.timeend FROM DaqRawDataFileInfoVld, DaqRawDataFileInfo WHERE DaqRawDataFileInfoVld.seqno = DaqRawDataFileInfo.seqno AND DaqRawDataFileInfo.runNo = %s AND DaqRawDataFileInfo.fileNo = %s" % (runNo, fileNo) )
00056             row = cursor.fetchone()
00057             #if row:
00058             #    print "get file time info successfully"
00059         except MySQLdb.Error,e:
00060             print "Error %d: %s" % (e.args[0], e.args[1])
00061             sys.exit(1)
00062 
00063         cursor.close()
00064         con.close()
00065         return row

def DumpDqLivetime::DumpLivetime::calcLiveTime (   self,
  reconfile 
)

Definition at line 66 of file DumpDqLivetime.py.

00067                                     :
00068         file = TFile(reconfile,"read")
00069         calibStats = file.Get("/Event/Data/CalibStats")
00070         nEntries = calibStats.GetEntries()
00071 
00072         #get the total run time of this file (t_last_trigger - t_first_trigger) 
00073         calibStats.GetEntry(nEntries-1)
00074         self.thissite = int( calibStats.GetLeaf("context.mSite").GetValue() )
00075         runTime = calibStats.GetLeaf("integralRunTime_ms").GetValue()
00076         self.runTime = runTime*(1+1/(nEntries-1)) #1/2*deltaT correction
00077     
00078         #get total entry number of each sub-detector
00079         for idx in range(7):
00080             detId = idx + 1
00081             detEntries = calibStats.GetEntries("context.mDetId==%d" % detId)
00082             if(detEntries!=0):
00083                 self.detEntries[detId] = detEntries
00084                 #print detId,detEntries
00085 
00086         tBegin = {} # livetime place holder for first trigger of each sub-detector 
00087         for idx in range(nEntries):
00088             # check whether livetime for all detectors in this site have been obtained
00089             breakflag = 1
00090             for detId in self.detEntries.keys():
00091                 if tBegin.keys().count(detId)!=1:
00092                     breakflag = 0
00093                     break 
00094             if breakflag==1:
00095                 #print "all detectors time found!"
00096                 break
00097             calibStats.GetEntry(idx)
00098             thisDet = int( calibStats.GetLeaf("context.mDetId").GetValue() )
00099             #print idx,thisDet
00100             if tBegin.keys().count(thisDet)==1:
00101                 #print "already found detector %d, skip" % thisDet
00102                 continue
00103             liveTime_blocked = calibStats.GetLeaf("integralLiveTime_blocked_trigger_ms").GetValue()
00104             liveTime_buffer_full = calibStats.GetLeaf("integralLiveTime_buffer_full_ms").GetValue()
00105             tBegin[thisDet] = [liveTime_blocked,liveTime_buffer_full]
00106             #print thisDet,tBegin[thisDet]
00107         
00108         tEnd = {} # # livetime place holder for last trigger of each sub-detector 
00109         for idx in range(nEntries-1,-1,-1):
00110             # check whether livetime for all detectors in this site have been obtained
00111             breakflag = 1
00112             for detId in self.detEntries.keys():
00113                 if tEnd.keys().count(detId)!=1:
00114                     breakflag = 0
00115                     break 
00116             if breakflag==1:
00117                 break
00118             calibStats.GetEntry(idx)
00119             thisDet = int( calibStats.GetLeaf("context.mDetId").GetValue() )
00120             if tEnd.keys().count(thisDet)==1:
00121                 continue
00122             liveTime_blocked = calibStats.GetLeaf("integralLiveTime_blocked_trigger_ms").GetValue()
00123             liveTime_buffer_full = calibStats.GetLeaf("integralLiveTime_buffer_full_ms").GetValue()
00124             tEnd[thisDet] = [liveTime_blocked,liveTime_buffer_full]
00125             #print thisDet,tEnd[thisDet]
00126 
00127         for detId,entries in self.detEntries.items():
00128             eff_liveTime_blocked = (tEnd[detId][0] - tBegin[detId][0])*(1+1/(entries-1))
00129             eff_liveTime_buffer_full = (tEnd[detId][1] - tBegin[detId][1])*(1+1/(entries-1))
00130             self.liveTime[detId] = [eff_liveTime_blocked,eff_liveTime_buffer_full]
00131             #print detId,self.liveTime[detId]
00132 
00133 
00134         return
00135 
00136 
        
def DumpDqLivetime::DumpLivetime::dumpLivetime (   self)
calculate rate

Definition at line 137 of file DumpDqLivetime.py.

00138                           :
00139         """calculate rate"""
00140         #could use offline DB to get the precise run time range
00141         #or get a rough time range from historgram triggerRate
00142         runTime = self.getFileTimeInfo(self.runNo, self.fileNo)
00143         #print runTime[0],runTime[1]
00144         import calendar
00145         starttime = calendar.timegm( runTime[0].timetuple() )
00146         endtime = calendar.timegm( runTime[1].timetuple() )
00147         self.calcLiveTime(self.inputFilename)
00148         wrt = DqLiveTime.Wrt()
00149         cr = ContextRange( self.thissite,
00150                            SimFlag.kData|SimFlag.kMC,
00151                            TimeStamp(starttime),
00152                            TimeStamp(endtime) )
00153         wrt.ctx(contextrange=cr, versiondate=TimeStamp(0,0))
00154 
00155         for detId,liveTime in self.liveTime.items():
00156             record = DqLiveTime.Create( RunNo = int( self.runNo ),
00157                                         FileNo = int( self.fileNo ),
00158                                         DetectorId = detId,
00159                                         IntegralRunTime = self.runTime,
00160                                         IntegralLiveTimeBlocked = liveTime[0],
00161                                         IntegralLiveTimeBuffer = liveTime[1] )
00162             wrt.Write(record)
00163         wrt.Close()
        

Member Data Documentation

tuple DumpDqLivetime::DumpLivetime::inputFilename = inputFilename.strip() [static]
Constructor

Definition at line 35 of file DumpDqLivetime.py.

Definition at line 66 of file DumpDqLivetime.py.

Definition at line 66 of file DumpDqLivetime.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