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

List of all members.

Public Member Functions

def __init__
def getEntries
def getFileTimeInfo
def dumpDetector

Public Attributes

 thissite

Detailed Description

Get counts from ROOT file

Definition at line 28 of file DumpDqDetectorExt.py.


Constructor & Destructor Documentation

def DumpDqDetectorExt::DumpDetectorExt::__init__ (   self,
  inputFilename 
)

Definition at line 30 of file DumpDqDetectorExt.py.

00031 :
    #def __init__(self):

Member Function Documentation

def DumpDqDetectorExt::DumpDetectorExt::getEntries (   self)
Constructor

Definition at line 49 of file DumpDqDetectorExt.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                 #print histdir+'/'+histname
00085                 if not hist:
00086                     continue
00087                 #print histdir+'/'+histname
00088                 self.entries[ (histdir.split('/'))[-1] ][histname] = hist.GetEntries()
00089         return

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

Definition at line 90 of file DumpDqDetectorExt.py.

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

Definition at line 110 of file DumpDqDetectorExt.py.

00111                           :
00112         """calculate rate"""
00113         #could use offline DB to get the precise run time range
00114         #or get a rough time range from historgram triggerRate
00115         runTime = self.getFileTimeInfo(self.runNo, self.fileNo)
00116         import calendar
00117         starttime = calendar.timegm( runTime[0].timetuple() )
00118         endtime = calendar.timegm( runTime[1].timetuple() )
00119         timeRange = endtime - starttime
00120         self.getEntries()
00121         #print "get entries from summary root file successfully"
00122         wrt = DqDetectorExt.Wrt()
00123         if self.thissite == 'DayaBay':
00124             sitectx = Site.kDayaBay
00125         if self.thissite == 'LingAo':
00126             sitectx = Site.kLingAo
00127         if self.thissite == 'Far':
00128             sitectx = Site.kFar 
00129         cr = ContextRange( sitectx,
00130                            SimFlag.kData|SimFlag.kMC,
00131                            TimeStamp(starttime),
00132                            TimeStamp(endtime) )
00133         wrt.ctx(contextrange=cr, versiondate=TimeStamp(0,0))
00134         #every detector has an entry
00135         for det,hists in self.entries.items():
00136             detId = self.det.index(det[-3:]) + 1 
00137             adMuCounts = -1
00138             iwsTaggedADMuCounts = -1
00139             owsTaggedADMuCounts = -1
00140             wsTaggedADMuCounts = -1
00141             var1 = -1
00142             var2 = -1
00143             var3 = -1
00144             var4 = -1
00145             var5 = -1
00146             var6 = -1
00147             var7 = -1
00148             var8 = -1
00149             var9 = -1
00150             var10 = -1
00151             
00152             #print det, hists
00153             for histname,entries in hists.items():
00154             #element of self.entries[det] is loop over all the hist in self.histname
00155                 if histname == 'ADmuEvt':
00156                     adMuCounts = entries
00157                 elif histname == 'IWStagADmuEvt':
00158                     iwsTaggedADMuCounts = entries
00159                 elif histname == 'OWStagADmuEvt':
00160                     owsTaggedADMuCounts = entries
00161                 elif histname == 'IWSOWStagADmuEvt':
00162                     wsTaggedADMuCounts = entries
00163 
00164             #print detId, adMuCounts, iwsTaggedADMuCounts, owsTaggedADMuCounts, wsTaggedADMuCounts
00165             record = DqDetectorExt.Create( RunNo = int( self.runNo ),
00166                                            FileNo = int( self.fileNo ),
00167                                            DetectorId = detId,
00168                                            ADMuonCounts = adMuCounts,
00169                                            IWSTaggedCounts = iwsTaggedADMuCounts,
00170                                            OWSTaggedCounts = owsTaggedADMuCounts,
00171                                            WSTaggedCounts = wsTaggedADMuCounts,
00172                                            Var1 = var1,
00173                                            Var2 = var2,
00174                                            Var3 = var3,
00175                                            Var4 = var4,
00176                                            Var5 = var5,
00177                                            Var6 = var6,
00178                                            Var7 = var7,
00179                                            Var8 = var8,
00180                                            Var9 = var9,
00181                                            Var10 = var10)
00182             wrt.Write(record)
00183         wrt.Close()
        

Member Data Documentation

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