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

List of all members.

Public Member Functions

def __init__
def getEntries
def getFileTimeInfo
def dumpWP

Public Attributes

 thissite

Detailed Description

Get counts from ROOT file

Definition at line 28 of file DumpDqWP.py.


Constructor & Destructor Documentation

def DumpDqWP::DumpWP::__init__ (   self,
  inputFilename 
)

Definition at line 30 of file DumpDqWP.py.

00031 :
    #def __init__(self):

Member Function Documentation

def DumpDqWP::DumpWP::getEntries (   self)
Constructor

Definition at line 48 of file DumpDqWP.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         assert self.thissite!=None, 'Error, KUP must have some problems, ODM file is empty!'
00065         #prepare the histogram path for this site
00066         for det in self.det:
00067             histdir = "stats/diagnostics/run_%s/detector_%s%s" % (self.runNo, self.thissite, det)
00068             self.histdir.append(histdir)
00069 
00070         #loop over different detectors, get the available histograms for each detector
00071         for histdir in self.histdir:
00072             dir = inputFile.GetDirectory( histdir )
00073             #if path does not exist, continue
00074             if not dir:
00075                 continue
00076             self.entries[ histdir.split('/')[-1] ] = {}
00077             #loop different histgrams
00078             for histname in self.histname:
00079                 hist = dir.Get( histname )
00080                 #if hist not exist, continue
00081                 #print histdir+'/'+histname
00082                 if not hist:
00083                     continue
00084                 #print histdir+'/'+histname
00085                 if hist.GetEntries()==0:
00086                     continue
00087                 self.entries[ (histdir.split('/'))[-1] ][histname] = hist.GetMean()
00088                 self.entries[ (histdir.split('/'))[-1] ][histname+'Err'] = hist.GetRMS()/math.sqrt(hist.GetEntries())
00089                 #print self.entries[ (histdir.split('/'))[-1] ][histname]
00090                 #print self.entries[ (histdir.split('/'))[-1] ][histname+'Err']
00091         return

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

Definition at line 92 of file DumpDqWP.py.

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

Definition at line 112 of file DumpDqWP.py.

00113                     :
00114         """calculate rate"""
00115         #could use offline DB to get the precise run time range
00116         #or get a rough time range from historgram triggerRate
00117         runTime = self.getFileTimeInfo(self.runNo, self.fileNo)
00118         import calendar
00119         starttime = calendar.timegm( runTime[0].timetuple() )
00120         endtime = calendar.timegm( runTime[1].timetuple() )
00121         timeRange = endtime - starttime
00122         self.getEntries()
00123         #print "get entries from summary root file successfully"
00124         wrt = DqWPMonitoring.Wrt()
00125         if self.thissite == 'DayaBay':
00126             sitectx = Site.kDayaBay
00127         if self.thissite == 'LingAo':
00128             sitectx = Site.kLingAo
00129         if self.thissite == 'Far':
00130             sitectx = Site.kFar 
00131         cr = ContextRange( sitectx,
00132                            SimFlag.kData|SimFlag.kMC,
00133                            TimeStamp(starttime),
00134                            TimeStamp(endtime) )
00135         wrt.ctx(contextrange=cr, versiondate=TimeStamp(0,0))
00136         #every detector has an entry
00137         for det,hists in self.entries.items():
00138             detId = self.det.index(det[-3:]) + 3 
00139             if( detId!=5 and detId!=6 ):
00140                 continue
00141             nhit = -1
00142             nhitErr = -1
00143             nPESum = -1
00144             nPESumErr = -1
00145             
00146             for histname,value in hists.items():
00147             #element of self.entries[det] is loop over all the hist in self.histname
00148                 if histname == 'muonPmtNhit':
00149                     nhit = value
00150                 elif histname == 'muonPmtNhitErr': 
00151                     nhitErr = value
00152                 elif histname == 'muonPmtPESum': 
00153                     nPESum = value
00154                 elif histname == 'muonPmtPESumErr': 
00155                     nPESumErr = value
00156 
00157             #print detId,triggerRate,blockTriggerFrac,flasherRate 
00158             record = DqWPMonitoring.Create( RunNo = int( self.runNo ),
00159                                         FileNo = int( self.fileNo ),
00160                                         DetectorId = detId,
00161                                         MuonNhit = nhit,
00162                                         MuonNhitErr = nhitErr,
00163                                         MuonPESum = nPESum,
00164                                         MuonPESumErr = nPESumErr )
00165             wrt.Write(record)
00166         wrt.Close()
00167         return
        

Member Data Documentation

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