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

List of all members.

Public Member Functions

def __init__
def getEntries
def getFileTimeInfo
def dumpTriggerInfo

Public Attributes

 thissite

Detailed Description

Get Rate from ROOT file

Definition at line 27 of file DumpTriggerInfo.py.


Constructor & Destructor Documentation

def DumpTriggerInfo::DumpTriggerInfo::__init__ (   self,
  inputFilename 
)

Definition at line 29 of file DumpTriggerInfo.py.

00030 :
    #def __init__(self):

Member Function Documentation

def DumpTriggerInfo::DumpTriggerInfo::getEntries (   self)
Constructor

Definition at line 48 of file DumpTriggerInfo.py.

00049                         :
00050         inputFile = TFile(self.inputFilename, "READ")
00051         #determine which site this file comes from
00052         for site in self.site:
00053             breakOrNot = 0
00054             for det in self.det:
00055                 histdir = "stats/diagnostics/run_%s/detector_%s%s" % (self.runNo, site, det)
00056                 dir = inputFile.GetDirectory(histdir)
00057                 if dir:
00058                     self.thissite = site
00059                     breakOrNot = 1
00060                     break
00061             if breakOrNot == 1:
00062                 break
00063 
00064         #prepare the histogram path for this site
00065         for det in self.det:
00066             if (self.thissite != 'Far') and ( (det == 'AD3') or (det=='AD4') ):
00067                 continue
00068             histdir = "stats/diagnostics/run_%s/detector_%s%s" % (self.runNo, self.thissite, det)
00069             self.histdir.append(histdir)
00070 
00071         #loop over different detectors, get the available histograms for each detector
00072         for histdir in self.histdir:
00073             dir = inputFile.GetDirectory( histdir )
00074             #if path does not exist, continue
00075             if not dir:
00076                 continue
00077             self.entries[ histdir.split('/')[-1] ] = {}
00078             #loop different histgrams
00079             for histname in self.histname:
00080                 hist = dir.Get( histname )
00081                 #if hist not exist, continue
00082                 if not hist:
00083                     continue
00084                 #print histdir+'/'+histname
00085                 if histname=='triggerBlocked':
00086                     nBins = hist.GetNbinsX()
00087                     nBlocked = hist.Integral(1,nBins)
00088                     self.entries[ (histdir.split('/'))[-1] ][histname] = nBlocked 
00089                     self.entries[ (histdir.split('/'))[-1] ]['total'] = hist.GetEntries()
00090                 if (histname=='maxPmtChargeVsAdCharge' or
00091                     histname=='maxPmtChargeVsMuonCharge'):
00092                     #max charge ratio > 0.7
00093                     minYBin = hist.GetYaxis().FindBin(0.7)
00094                     #total charge > 30 PE
00095                     minXBin = hist.GetXaxis().FindBin( math.log10(30) )
00096                     maxYBin = hist.GetNbinsY()
00097                     maxXBin = hist.GetNbinsX()
00098                     nFlasher = hist.Integral(minXBin, maxXBin, minYBin, maxYBin)
00099                     self.entries[ (histdir.split('/'))[-1] ][histname] = nFlasher 
00100         return

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

Definition at line 101 of file DumpTriggerInfo.py.

00102                                             :
00103         """Talk to offline DB and get the time range of the run"""
00104         try:
00105             con = MySQLdb.connect( host = dbhost,
00106                                    user = dbuser,
00107                                    passwd = dbpasswd,
00108                                    db = database )
00109             cursor = con.cursor()
00110             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) )
00111             row = cursor.fetchone()
00112             #if row:
00113             #    print "get file time info successfully"
00114         except MySQLdb.Error,e:
00115             print "Error %d: %s" % (e.args[0], e.args[1])
00116             sys.exit(1)
00117 
00118         cursor.close()
00119         con.close()
00120         return row
        
def DumpTriggerInfo::DumpTriggerInfo::dumpTriggerInfo (   self)
calculate rate

Definition at line 121 of file DumpTriggerInfo.py.

00122                              :
00123         """calculate rate"""
00124         #could use offline DB to get the precise run time range
00125         #or get a rough time range from historgram triggerRate
00126         runTime = self.getFileTimeInfo(self.runNo, self.fileNo)
00127         import calendar
00128         starttime = calendar.timegm( runTime[0].timetuple() )
00129         endtime = calendar.timegm( runTime[1].timetuple() )
00130         timeRange = endtime - starttime
00131         self.getEntries()
00132         #print "get entries from summary root file successfully"
00133         wrt = DQTrigger.Wrt()
00134         if self.thissite == 'DayaBay':
00135             sitectx = Site.kDayaBay
00136         if self.thissite == 'LingAo':
00137             sitectx = Site.kLingAo
00138         if self.thissite == 'Far':
00139             sitectx = Site.kFar 
00140         cr = ContextRange( sitectx,
00141                            SimFlag.kData|SimFlag.kMC,
00142                            TimeStamp(starttime),
00143                            TimeStamp(endtime) )
00144         wrt.ctx(contextrange=cr, versiondate=TimeStamp(0,0))
00145         #every detector has an entry
00146         for det,hists in self.entries.items():
00147             detId = self.det.index(det[-3:]) + 1 
00148             triggerRate = hists['total']/timeRange
00149             blockTriggerFrac = hists['triggerBlocked']/(hists['triggerBlocked']+hists['total'])
00150             #flasherRate = -1
00151             if detId>4:
00152                 flasherRate = hists['maxPmtChargeVsMuonCharge']/timeRange
00153             else:
00154                 flasherRate = hists['maxPmtChargeVsAdCharge']/timeRange
00155 
00156             #print detId,triggerRate,blockTriggerFrac,flasherRate 
00157             record = DQTrigger.Create( RunNo = int( self.runNo ),
00158                                        FileNo = int( self.fileNo ),
00159                                        DetectorId = detId,
00160                                        TrigRate = triggerRate,
00161                                        FlasherRate = flasherRate,
00162                                        BlockTrigFrac = blockTriggerFrac )
00163             wrt.Write(record)
00164         wrt.Close()
        

Member Data Documentation

Definition at line 48 of file DumpTriggerInfo.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