/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
DumpDqPmt_old::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 33 of file DumpDqPmt_old.py.


Constructor & Destructor Documentation

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

Definition at line 35 of file DumpDqPmt_old.py.

00036 :
    #def __init__(self):

Member Function Documentation

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

Definition at line 49 of file DumpDqPmt_old.py.

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

Definition at line 64 of file DumpDqPmt_old.py.

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

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

Definition at line 84 of file DumpDqPmt_old.py.

00085                                                    :
00086         board = channelId.board()
00087         connector = channelId.connector()
00088         hadcpath = 'stats/diagnostics/run_%07d/detector_%s/channel_board%02d_connector%02d/adcFine' % ( runNo, channelId.detName(), board, connector )
00089         htdcpath = 'stats/diagnostics/run_%07d/detector_%s/channel_board%02d_connector%02d/tdc' % ( runNo, channelId.detName(), board, connector ) 
00090         hforcedpath = 'stats/diagnostics/run_%07d/detector_%s/channel_board%02d_connector%02d/tdcForced' % ( runNo, channelId.detName(), board, connector )
00091         hflasherpath = 'stats/diagnostics/run_%07d/detector_%s/channel_board%02d_connector%02d/qFlasherPMT' % ( runNo, channelId.detName(), board, connector ) 
00092         hadc = rootfile.Get(hadcpath) 
00093         htdc = rootfile.Get(htdcpath)
00094         hforced = rootfile.Get(hforcedpath)
00095         hflasher = rootfile.Get(hflasherpath)
00096         adcMean = hadc.GetMean()
00097         adcRMS = hadc.GetRMS()
00098         tdcMean = htdc.GetMean()
00099         tdcRMS = htdc.GetRMS()
00100         if hforced:
00101             dnCountsForced = hforced.GetEntries()
00102         else:
00103             dnCountsForced = 0
00104         if hflasher:
00105             flashingCounts = hflasher.GetEntries()
00106         else:
00107             flashingCounts = 0
00108         histValue = [adcMean,adcRMS,tdcMean,tdcRMS,dnCountsForced,flashingCounts]
00109         return histValue

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

Definition at line 110 of file DumpDqPmt_old.py.

00111                      :
00112         """calculate rate"""
00113         runTime = self.getFileTimeInfo(self.runNo, self.fileNo)
00114         import calendar
00115         starttime = calendar.timegm( runTime[0].timetuple() )
00116         endtime = calendar.timegm( runTime[1].timetuple() )
00117 
00118         rootfile = TFile(self.inputFilename)
00119         tree = rootfile.Get(self.treepath)
00120         nEntries = tree.GetEntriesFast()
00121         
00122         # a work around to get the site info
00123         tree.GetEntry(0)
00124         pmt = DetectorSensor( int(tree.GetLeaf("pmtID").GetValue()) )
00125         site = pmt.site()
00126 
00127         wrt = DqPmt.Wrt()
00128         cr = ContextRange( site,
00129                            SimFlag.kData|SimFlag.kMC,
00130                            TimeStamp(starttime),
00131                            TimeStamp(endtime) )
00132         wrt.ctx(contextrange=cr, versiondate=TimeStamp(0,0))
00133         
00134         for i in range(nEntries):
00135             tree.GetEntry(i)
00136 
00137             pmtId = DetectorSensor( int(tree.GetLeaf("pmtID").GetValue()) )
00138             self.alivePmts.append( pmtId.fullPackedData() )
00139             
00140             if pmtId.isAD():
00141                 adPmt = AdPmtSensor( int(tree.GetLeaf("pmtID").GetValue()) )
00142                 channelId = self.cableMap(adPmt, TimeStamp(starttime))
00143                 histValue = self.checkHist( int(self.runNo), rootfile, channelId )
00144                 #print adPmt.ring(),adPmt.column(),channelId.board(),channelId.connector(),histValue
00145             if pmtId.isWaterShield():
00146                 poolPmt = PoolPmtSensor( int(tree.GetLeaf("pmtID").GetValue()) )
00147                 channelId = self.cableMap(poolPmt, TimeStamp(starttime))
00148                 histValue = self.checkHist( int(self.runNo), rootfile, channelId )
00149                 #print channelId.board(),channelId.connector(),histValue
00150 
00151             gain = tree.GetLeaf("gain").GetValue()
00152             elecnoiserate = tree.GetLeaf("elecNoiseRate").GetValue()
00153             darkrate = tree.GetLeaf("darkRate").GetValue()
00154             
00155             quality = 1 #default to be good 
00156             if elecnoiserate>50000:
00157                 quality = 2
00158             #how to define bad?
00159 
00160             record = DqPmt.Create( RunNo = int(self.runNo),
00161                                    FileNo = int(self.fileNo),
00162                                    PmtId = DetectorSensor( int(tree.GetLeaf("pmtID").GetValue()) ),
00163                                    Status = tree.GetLeaf("fitStatus").GetValue(),
00164                                    Chi2ndf = tree.GetLeaf("chiSquare").GetValue(),
00165                                    Gain = tree.GetLeaf("gain").GetValue(),
00166                                    GainErr = tree.GetLeaf("gainErr").GetValue(),
00167                                    DarkRate = tree.GetLeaf("darkRate").GetValue(),
00168                                    DarkRateErr = tree.GetLeaf("darkRateErr").GetValue(),
00169                                    ElecNoiseRate = tree.GetLeaf("elecNoiseRate").GetValue(),
00170                                    ElecNoiseRateErr = tree.GetLeaf("elecNoiseRateErr").GetValue(),
00171                                    PreAdc = tree.GetLeaf("preADC").GetValue(),
00172                                    PreAdcErr = tree.GetLeaf("preADCErr").GetValue(),
00173                                    AdcMean = histValue[0],  #DataQualityPmt Table structrure need to be 
00174                                    AdcRMS = histValue[1],   #updated to include the adc/tdc value in table
00175                                    TdcMean = histValue[2],
00176                                    TdcRMS = histValue[3],
00177                                    DNCountsForced = histValue[4],
00178                                    FlashingCounts = histValue[5],
00179                                    Quality = quality ) 
00180                                    #Quality code:(0,HV-off),(1,normal),(2,noisy),(3,bad)
00181             wrt.Write(record) 
00182         
00183         # finding HV-off PMTs
00184         for pmtId in self.mapTable.keys():
00185             if pmtId not in self.alivePmts:
00186                 record = DqPmt.Create( RunNo = int(self.runNo), 
00187                                        FileNo = int(self.fileNo),
00188                                        PmtId = DetectorSensor( pmtId ),
00189                                        Status = 0,
00190                                        Chi2ndf = 0,
00191                                        Gain = 0,
00192                                        GainErr = 0,
00193                                        DarkRate = 0,
00194                                        DarkRateErr = 0,
00195                                        ElecNoiseRate = 0,
00196                                        ElecNoiseRateErr = 0,
00197                                        PreAdc = 0,
00198                                        PreAdcErr = 0,
00199                                        AdcMean = 0,   
00200                                        AdcRMS = 0,  
00201                                        TdcMean = 0,
00202                                        TdcRMS = 0,
00203                                        DNCountsForced = 0,
00204                                        FlashingCounts = 0,
00205                                        Quality = 0 ) 
00206                 wrt.Write(record)
00207         wrt.Close()
00208         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