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

List of all members.

Public Member Functions

def __init__
def getEntries
def getFileTimeInfo
def dumpTriggerCounts

Public Attributes

 thissite

Detailed Description

Get counts from ROOT file

Definition at line 28 of file DumpDqTriggerCounts.py.


Constructor & Destructor Documentation

def DumpDqTriggerCounts::DumpTriggerCounts::__init__ (   self,
  inputFilename 
)

Definition at line 30 of file DumpDqTriggerCounts.py.

00031 :
    #def __init__(self):

Member Function Documentation

def DumpDqTriggerCounts::DumpTriggerCounts::getEntries (   self)
Constructor

Definition at line 49 of file DumpDqTriggerCounts.py.

00050                         :
00051         inputFile = TFile(self.inputFilename, "READ")
00052         #determine which site this file comes from
00053         for site in self.site:
00054             breakOrNot = 0
00055             for det in self.det:
00056                 histdir = "stats/diagnostics/run_%s/detector_%s%s" % (self.runNo, site, det)
00057                 dir = inputFile.GetDirectory(histdir)
00058                 if dir:
00059                     self.thissite = site
00060                     breakOrNot = 1
00061                     break
00062             if breakOrNot == 1:
00063                 break
00064 
00065         assert self.thissite!=None, 'Error, KUP must have some problems, ODM file is empty!'
00066         #prepare the histogram path for this site
00067         for det in self.det:
00068             if (self.thissite != 'Far') and ( (det == 'AD3') or (det=='AD4') ):
00069                 continue
00070             histdir = "stats/diagnostics/run_%s/detector_%s%s" % (self.runNo, self.thissite, det)
00071             self.histdir.append(histdir)
00072 
00073         #loop over different detectors, get the available histograms for each detector
00074         for histdir in self.histdir:
00075             dir = inputFile.GetDirectory( histdir )
00076             #if path does not exist, continue
00077             if not dir:
00078                 continue
00079             self.entries[ histdir.split('/')[-1] ] = {}
00080             #loop different histgrams
00081             for histname in self.histname:
00082                 hist = dir.Get( histname )
00083                 #if hist not exist, continue
00084                 if not hist:
00085                     continue
00086                 #print histdir+'/'+histname
00087                 if histname=='triggerBits':
00088                     self.entries[ (histdir.split('/'))[-1] ][histname] = hist.GetEntries() 
00089                     for bit in range(16):
00090                         binIdx = bit+1
00091                         binContent = hist.GetBinContent(binIdx)
00092                         if binContent>0:
00093                             self.entries[ (histdir.split('/'))[-1] ]['%s%02d' % (histname,bit)] = binContent 
00094         return

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

Definition at line 95 of file DumpDqTriggerCounts.py.

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

Definition at line 115 of file DumpDqTriggerCounts.py.

00116                                :
00117         """calculate rate"""
00118         #could use offline DB to get the precise run time range
00119         #or get a rough time range from historgram triggerRate
00120         runTime = self.getFileTimeInfo(self.runNo, self.fileNo)
00121         import calendar
00122         starttime = calendar.timegm( runTime[0].timetuple() )
00123         endtime = calendar.timegm( runTime[1].timetuple() )
00124         timeRange = endtime - starttime
00125         self.getEntries()
00126         #print "get entries from summary root file successfully"
00127         wrt = DqTriggerCounts.Wrt()
00128         if self.thissite == 'DayaBay':
00129             sitectx = Site.kDayaBay
00130         if self.thissite == 'LingAo':
00131             sitectx = Site.kLingAo
00132         if self.thissite == 'Far':
00133             sitectx = Site.kFar 
00134         cr = ContextRange( sitectx,
00135                            SimFlag.kData|SimFlag.kMC,
00136                            TimeStamp(starttime),
00137                            TimeStamp(endtime) )
00138         wrt.ctx(contextrange=cr, versiondate=TimeStamp(0,0))
00139         #every detector has an entry
00140         for det,hists in self.entries.items():
00141             detId = self.det.index(det[-3:]) + 1 
00142             crossinCounts = 0
00143             periodicCounts = 0
00144             calibCounts = 0
00145             randomCounts = 0
00146             nhitCounts = 0
00147             esumCounts = 0
00148             rpc2of4Counts = 0
00149             rpc3of4Counts = 0
00150             for hist,entries in hists.items():
00151                 if hist=='triggerBits01':
00152                     crossinCounts = entries
00153                 elif hist=='triggerBits02':
00154                     periodicCounts = entries
00155                 elif hist=='triggerBits04':
00156                     calibCounts = entries
00157                 elif hist=='triggerBits05':
00158                     randomCounts = entries
00159                 elif hist=='triggerBits08':
00160                     nhitCounts = entries
00161                 elif hist=='triggerBits12':
00162                     esumCounts = entries
00163                 #need to fix tigger bit below!!!
00164                 #elif hist=='triggerBits12':
00165                 #    rpc2of4Counts = entries
00166                 #elif hist=='triggerBits12':
00167                 #    rpc3of4Counts = entries
00168             
00169             #print detId,triggerRate,blockTriggerFrac,flasherRate 
00170             record = DqTriggerCounts.Create( RunNo = int( self.runNo ),
00171                                              FileNo = int( self.fileNo ),
00172                                              DetectorId = detId,
00173                                              CrossInCounts = crossinCounts,
00174                                              PeriodicCounts = periodicCounts,
00175                                              CalibCounts = calibCounts,
00176                                              RandomCounts = randomCounts,
00177                                              NhitCounts = nhitCounts,
00178                                              EsumCounts = esumCounts,
00179                                              Rpc2of4Counts = rpc2of4Counts,
00180                                              Rpc3of4Counts = rpc3of4Counts)
00181             wrt.Write(record)
00182         wrt.Close()
        

Member Data Documentation

Definition at line 49 of file DumpDqTriggerCounts.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