/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
DumpDqDetector::DumpDetector 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 DumpDqDetector.py.


Constructor & Destructor Documentation

def DumpDqDetector::DumpDetector::__init__ (   self,
  inputFilename 
)

Definition at line 30 of file DumpDqDetector.py.

00031 :
    #def __init__(self):

Member Function Documentation

def DumpDqDetector::DumpDetector::getEntries (   self)
Constructor

Definition at line 51 of file DumpDqDetector.py.

00052                         :
00053         inputFile = TFile(self.inputFilename, "READ")
00054         #determine which site this file comes from
00055         for site in self.site:
00056             breakOrNot = 0
00057             for det in self.det:
00058                 histdir = "stats/diagnostics/run_%s/detector_%s%s" % (self.runNo, site, det)
00059                 dir = inputFile.GetDirectory(histdir)
00060                 if dir:
00061                     self.thissite = site
00062                     breakOrNot = 1
00063                     break
00064             if breakOrNot == 1:
00065                 break
00066 
00067         #prepare the histogram path for this site
00068         for det in self.det:
00069             if (self.thissite != 'Far') and ( (det == 'AD3') or (det=='AD4') ):
00070                 continue
00071             histdir = "stats/diagnostics/run_%s/detector_%s%s" % (self.runNo, self.thissite, det)
00072             self.histdir.append(histdir)
00073 
00074         #loop over different detectors, get the available histograms for each detector
00075         for histdir in self.histdir:
00076             dir = inputFile.GetDirectory( histdir )
00077             #if path does not exist, continue
00078             if not dir:
00079                 continue
00080             self.entries[ histdir.split('/')[-1] ] = {}
00081             #loop different histgrams
00082             for histname in self.histname:
00083                 hist = dir.Get( histname )
00084                 #if hist not exist, continue
00085                 #print histdir+'/'+histname
00086                 if not hist:
00087                     continue
00088                 #print histdir+'/'+histname
00089                 if histname=='triggerBlocked':
00090                     nBins = hist.GetNbinsX()
00091                     nBlocked = hist.Integral(1,nBins)
00092                     self.entries[ (histdir.split('/'))[-1] ][histname] = nBlocked 
00093                 elif histname=='ratioQmaxQtotVsTrms': 
00094                     #Doc 6959
00095                     #max charge ratio > 0.3
00096                     minYBin = hist.GetYaxis().FindBin(0.3)
00097                     #Trms > 50
00098                     minXBin = hist.GetXaxis().FindBin(50)
00099                     maxYBin = hist.GetNbinsY()
00100                     maxXBin = hist.GetNbinsX()
00101                     #nFlasher1 = hist.Integral(0, maxXBin, minYBin, maxYBin)
00102                     #nFlasher2 = hist.Integral(minXBin, maxXBin, 0, minYBin)
00103                     #nFlasher = nFlasher1 + nFlasher2
00104                     nNonFlasher = hist.Integral(1,minXBin,1,minYBin)
00105                     nTotal = hist.Integral(1,maxXBin,1,maxYBin)
00106                     nFlasher = nTotal - nNonFlasher
00107                     self.entries[ (histdir.split('/'))[-1] ][histname] = nFlasher 
00108                 elif histname=='maxPmtChargeVsMuonCharge':
00109                     #max charge ratio > 0.7
00110                     minYBin = hist.GetYaxis().FindBin(0.7)
00111                     #total charge > 30 PE
00112                     minXBin = hist.GetXaxis().FindBin( math.log10(30) )
00113                     maxYBin = hist.GetNbinsY()
00114                     maxXBin = hist.GetNbinsX()
00115                     nFlasher = hist.Integral(minXBin, maxXBin, minYBin, maxYBin)
00116                     self.entries[ (histdir.split('/'))[-1] ][histname] = nFlasher 
00117                 elif histname=='logAdCharge':
00118                     minAdMuEnergyBin = hist.FindBin( math.log10(20*170) )  #170pe/MeV
00119                     maxBin = hist.GetNbinsX()
00120                     self.entries[ (histdir.split('/'))[-1] ][histname] = hist.Integral(minAdMuEnergyBin, maxBin) 
00121                 elif histname=='spallEnergyNCaptureGd':
00122                     hist.Fit("gaus")
00123                     func = hist.GetFunction("gaus")
00124                     #spn energy and sigma
00125                     if func:
00126                         self.entries[ (histdir.split('/'))[-1] ][histname] = func.GetParameter(1) 
00127                         self.entries[ (histdir.split('/'))[-1] ][histname+"Sigma"] = func.GetParameter(2) 
00128                     else:
00129                         #hist exists, but fit failed or just an empty hist
00130                         self.entries[ (histdir.split('/'))[-1] ][histname] = -1 
00131                         self.entries[ (histdir.split('/'))[-1] ][histname+"Sigma"] = 0 
00132                         
00133                 else:
00134                     self.entries[ (histdir.split('/'))[-1] ][histname] = hist.GetEntries()
00135         return

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

Definition at line 136 of file DumpDqDetector.py.

00137                                             :
00138         """Talk to offline DB and get the time range of the run"""
00139         try:
00140             con = MySQLdb.connect( host = dbhost,
00141                                    user = dbuser,
00142                                    passwd = dbpasswd,
00143                                    db = database )
00144             cursor = con.cursor()
00145             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) )
00146             row = cursor.fetchone()
00147             #if row:
00148             #    print "get file time info successfully"
00149         except MySQLdb.Error,e:
00150             print "Error %d: %s" % (e.args[0], e.args[1])
00151             sys.exit(1)
00152 
00153         cursor.close()
00154         con.close()
00155         return row
        
def DumpDqDetector::DumpDetector::dumpDetector (   self)
calculate rate

Definition at line 156 of file DumpDqDetector.py.

00157                           :
00158         """calculate rate"""
00159         #could use offline DB to get the precise run time range
00160         #or get a rough time range from historgram triggerRate
00161         runTime = self.getFileTimeInfo(self.runNo, self.fileNo)
00162         import calendar
00163         starttime = calendar.timegm( runTime[0].timetuple() )
00164         endtime = calendar.timegm( runTime[1].timetuple() )
00165         timeRange = endtime - starttime
00166         self.getEntries()
00167         #print "get entries from summary root file successfully"
00168         wrt = DqDetector.Wrt()
00169         if self.thissite == 'DayaBay':
00170             sitectx = Site.kDayaBay
00171         if self.thissite == 'LingAo':
00172             sitectx = Site.kLingAo
00173         if self.thissite == 'Far':
00174             sitectx = Site.kFar 
00175         cr = ContextRange( sitectx,
00176                            SimFlag.kData|SimFlag.kMC,
00177                            TimeStamp(starttime),
00178                            TimeStamp(endtime) )
00179         wrt.ctx(contextrange=cr, versiondate=TimeStamp(0,0))
00180         #every detector has an entry
00181         for det,hists in self.entries.items():
00182             detId = self.det.index(det[-3:]) + 1 
00183             triggerCounts = -1
00184             flasherCounts = -1
00185             muonCounts = -1
00186             ibdCounts = -1
00187             spnCounts = -1
00188             blockTrigCounts = -1
00189             spnEnergy = -1
00190             spnEnergySigma = -1
00191             
00192             for histname,entries in hists.items():
00193             #element of self.entries[det] is loop over all the hist in self.histname
00194                 if histname == 'triggerRate':
00195                     triggerCounts = entries
00196                 elif (histname == 'maxPmtChargeVsMuonCharge' or 
00197                     histname == 'ratioQmaxQtotVsTrms'):
00198                     flasherCounts = entries
00199                 elif (histname == 'logAdCharge' or
00200                     histname == 'MuonCharge'):
00201                     muonCounts = entries
00202                 elif histname == 'ibdCandidateTime':
00203                     ibdCounts = entries
00204                 elif histname == 'spallTimeNCaptureGd':
00205                     spnCounts = entries
00206                 elif histname == 'triggerBlocked':
00207                     blockTrigCounts = entries
00208                 elif histname == 'spallEnergyNCaptureGd':
00209                     spnEnergy = entries
00210                 elif histname == 'spallEnergyNCaptureGdSigma':
00211                     spnEnergySigma = entries
00212 
00213             #print detId,triggerRate,blockTriggerFrac,flasherRate 
00214             record = DqDetector.Create( RunNo = int( self.runNo ),
00215                                         FileNo = int( self.fileNo ),
00216                                         DetectorId = detId,
00217                                         TriggerCounts = triggerCounts,
00218                                         FlasherCounts = flasherCounts,
00219                                         MuonCounts = muonCounts,  
00220                                         IbdCounts = ibdCounts,
00221                                         SpnCounts = spnCounts, 
00222                                         BlockTrigCounts = blockTrigCounts,
00223                                         SpnEnergy = spnEnergy,
00224                                         SpnEnergySigma = spnEnergySigma)
00225             wrt.Write(record)
00226         wrt.Close()
        

Member Data Documentation

Definition at line 51 of file DumpDqDetector.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