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

List of all members.

Public Member Functions

def __init__
def cableMap
def getFileTimeInfo
def checkHist
def dumpPmt

Detailed Description

Get Rate from ROOT file

Definition at line 32 of file DumpPmtAll.py.


Constructor & Destructor Documentation

def DumpPmtAll::DumpPmt::__init__ (   self,
  inputFilename 
)

Definition at line 34 of file DumpPmtAll.py.

00035 :
    #def __init__(self):

Member Function Documentation

def DumpPmtAll::DumpPmt::cableMap (   self,
  pmtId,
  timeStamp 
)
Constructor
pmtId is [AD/POOL]PmtSensor type, 
   timeStamp should be the run start time

Definition at line 48 of file DumpPmtAll.py.

00049                                         :
00050         """pmtId is [AD/POOL]PmtSensor type, 
00051            timeStamp should be the run start time"""
00052         rpt = GCableMap.Rpt()
00053         if pmtId.fullPackedData() not in self.mapTable.keys():
00054             rpt.ctx( site = pmtId.site(),
00055                      subsite = pmtId.detectorId(),
00056                      simflag = SimFlag.kData,
00057                      timestamp = timeStamp )
00058             rptlen = len(rpt)
00059             for idx in range(rptlen):
00060                 record = rpt[idx]
00061                 self.mapTable[ record.GetSensorId().fullPackedData() ] = record.GetChannelId()
00062         return self.mapTable[pmtId.fullPackedData()]
        
def DumpPmtAll::DumpPmt::getFileTimeInfo (   self,
  runNo,
  fileNo 
)
Talk to offline DB and get the time range of the run

Definition at line 63 of file DumpPmtAll.py.

00064                                             :
00065         """Talk to offline DB and get the time range of the run"""
00066         try:
00067             con = MySQLdb.connect( host = dbhost,
00068                                    user = dbuser,
00069                                    passwd = dbpasswd,
00070                                    db = database )
00071             cursor = con.cursor()
00072             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) )
00073             row = cursor.fetchone()
00074             if row:
00075                 print "get file time info successfully"
00076         except MySQLdb.Error,e:
00077             print "Error %d: %s" % (e.args[0], e.args[1])
00078             sys.exit(1)
00079 
00080         cursor.close()
00081         con.close()
00082         return row

def DumpPmtAll::DumpPmt::checkHist (   self,
  runNo,
  rootfile,
  channelId 
)

Definition at line 83 of file DumpPmtAll.py.

00084                                                    :
00085         board = channelId.board()
00086         connector = channelId.connector()
00087         hadcpath = 'stats/diagnostics/run_%07d/detector_%s/channel_board%02d_connector%02d/adcFine' % ( runNo, channelId.detName(), board, connector )
00088         htdcpath = 'stats/diagnostics/run_%07d/detector_%s/channel_board%02d_connector%02d/tdc' % ( runNo, channelId.detName(), board, connector ) 
00089         hadc = rootfile.Get(hadcpath) 
00090         htdc = rootfile.Get(htdcpath)
00091         adcMean = hadc.GetMean()
00092         adcRMS = hadc.GetRMS()
00093         tdcMean = htdc.GetMean()
00094         tdcRMS = htdc.GetRMS()
00095         histValue = [adcMean,adcRMS,tdcMean,tdcRMS]
00096         return histValue

def DumpPmtAll::DumpPmt::dumpPmt (   self)
calculate rate

Definition at line 97 of file DumpPmtAll.py.

00098                      :
00099         """calculate rate"""
00100         runTime = self.getFileTimeInfo(self.runNo, self.fileNo)
00101         import calendar
00102         starttime = calendar.timegm( runTime[0].timetuple() )
00103         endtime = calendar.timegm( runTime[1].timetuple() )
00104 
00105         rootfile = TFile(self.inputFilename)
00106         tree = rootfile.Get(self.treepath)
00107         nEntries = tree.GetEntriesFast()
00108         
00109         # a work around to get the site info
00110         tree.GetEntry(0)
00111         pmt = DetectorSensor( int(tree.GetLeaf("pmtID").GetValue()) )
00112         site = pmt.site()
00113 
00114         wrt = DQPmt.Wrt()
00115         cr = ContextRange( site,
00116                            SimFlag.kData|SimFlag.kMC,
00117                            TimeStamp(starttime),
00118                            TimeStamp(endtime) )
00119         wrt.ctx(contextrange=cr, versiondate=TimeStamp(0,0))
00120         
00121         for i in range(nEntries):
00122             tree.GetEntry(i)
00123 
00124             pmtId = DetectorSensor( int(tree.GetLeaf("pmtID").GetValue()) )
00125             self.alivePmt.append( pmtId.fullPackedData() )
00126             
00127             if pmtId.isAD():
00128                 adPmt = AdPmtSensor( int(tree.GetLeaf("pmtID").GetValue()) )
00129                 channelId = self.cableMap(adPmt, TimeStamp(starttime))
00130                 histValue = self.checkHist( int(self.runNo), rootfile, channelId )
00131                 #print adPmt.ring(),adPmt.column(),channelId.board(),channelId.connector(),histValue
00132             if pmtId.isWaterShield():
00133                 poolPmt = PoolPmtSensor( int(tree.GetLeaf("pmtID").GetValue()) )
00134                 channelId = self.cableMap(poolPmt, TimeStamp(starttime))
00135                 histValue = self.checkHist( int(self.runNo), rootfile, channelId )
00136                 #print channelId.board(),channelId.connector(),histValue
00137 
00138             record = DQPmt.Create( RunNo = int(self.runNo),
00139                                    FileNo = int(self.fileNo),
00140                                    PmtId = DetectorSensor( int(tree.GetLeaf("pmtID").GetValue()) ),
00141                                    Status = tree.GetLeaf("fitStatus").GetValue(),
00142                                    Chi2ndf = tree.GetLeaf("chiSquare").GetValue(),
00143                                    Gain = tree.GetLeaf("gain").GetValue(),
00144                                    GainErr = tree.GetLeaf("gainErr").GetValue(),
00145                                    DarkRate = tree.GetLeaf("darkRate").GetValue(),
00146                                    DarkRateErr = tree.GetLeaf("darkRateErr").GetValue(),
00147                                    ElecNoiseRate = tree.GetLeaf("elecNoiseRate").GetValue(),
00148                                    ElecNoiseRateErr = tree.GetLeaf("elecNoiseRateErr").GetValue(),
00149                                    PreAdc = tree.GetLeaf("preADC").GetValue(),
00150                                    PreAdcErr = tree.GetLeaf("preADCErr").GetValue(),
00151                                    AdcMean = histValue[0],  #DataQualityPmt Table structrure need to be 
00152                                    AdcRMS = histValue[1],   #updated to include the adc/tdc value in table
00153                                    TdcMean = histValue[2],
00154                                    TdcRMS = histValue[3] )
00155             wrt.Write(record) 
00156         
00157         # finding HV-off PMTs
00158         for pmtId in self.mapTable.keys():
00159             if pmtId not in self.alivePmt:
00160                 record = DQPmt.Create( Flag = "off"
00161                 
00162                                      )
00163                 wrt.Write(record)
00164         wrt.Close()
00165         return


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