/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
prodIHEP::FindFile Class Reference

List of all members.

Public Member Functions

def __init__
def find
def getfiles
def getdates

Public Attributes

 files
 options

Detailed Description

Definition at line 132 of file prodIHEP.py.


Constructor & Destructor Documentation

def prodIHEP::FindFile::__init__ (   self,
  options 
)

Definition at line 134 of file prodIHEP.py.

00135                               :
00136 
00137         self.files = []
00138         self.options = options
00139         runinfo = "Run %s" % options.run_start
00140         if options.run_end >= options.run_start:
00141             runinfo += " to run %s" % options.run_end
00142         if options.debug > 0:
00143             print runinfo


Member Function Documentation

def prodIHEP::FindFile::find (   self)

Definition at line 144 of file prodIHEP.py.

00145                   :
00146 
00147         files = self.getfiles(self.options.run_start, self.options.run_end, \
00148                 self.options.file_start, self.options.file_end)
00149         if files == None:
00150             print "Can't find any raw data file in offline_db"
00151             return
00152         seq_start = files[0][0]
00153         seq_end = files[-1][0]
00154         dates = self.getdates(seq_start,seq_end)
00155 
00156         #print len(files),len(dates)
00157 
00158         dates_dict = {}
00159         for date in dates:
00160             dates_dict[date[0]] = date[1]
00161 
00162         for file in files:
00163 
00164             seqno = file[0]
00165             filename = file[1]
00166             runno = file[2]
00167             strdate = str(dates_dict[int(seqno)])
00168 
00169             fileyear = strdate[0:4]
00170             filemonth = strdate[5:7]
00171             fileday = strdate[8:10]
00172     
00173             # Skip test data and RPC only data
00174             if filename.find('test') > -1 or filename.find('RPC') > -1 or filename.find('Test') > -1:        
00175                 continue
00176                     
00177             # Only process physics and calibration data
00178             if self.options.run_type == 'All':
00179                 if filename.find('Physics') < 0 and filename.find('Calib') < 0:
00180                     continue
00181             else:
00182                 if filename.find(self.options.run_type) < 0:
00183                     continue
00184             #if filename.find('Physics') < 0 and filename.find('Calib') < 0:
00185     
00186             #if filename.find('-Merged') < 0:
00187             #    continue
00188 
00189             #if self.options.site != 'All':
00190             #    if filename.find(self.options.site + '-Merged') < 0:
00191             #        continue
00192 
00193             words = filename.split('.')
00194             subpath = words[1]
00195             basepath = 'daq'
00196             if int(runno) < 18822:
00197                 basepath = 'TestDAQ'
00198             elif int(runno) < 19478:
00199                 if subpath == 'NoTag':
00200                     subpath = 'Neutrino'
00201             if subpath == 'MCS':
00202                 subpath = 'mcs'
00203             if subpath == 'StrongRef':
00204                 subpath = 'strongAmC'
00205             if subpath == 'StrongAmC':
00206                 subpath = 'strongAmC'
00207 
00208             if int(runno) > 24734:
00209                 self.options.raw_path = '/dybfs/rawdata/ingest_data/data/exp/dayabay/'
00210     
00211             file = self.options.raw_path + fileyear + '/' + basepath + '/' + subpath + '/' + filemonth + fileday + '/' + filename
00212             date = datetime.datetime(int(fileyear),int(filemonth),int(fileday))
00213             
00214             # Check file exists or not
00215             if not os.path.isfile(file):
00216                 date = date + datetime.timedelta(1)
00217                 file = self.options.raw_path + str(date.year) + '/' + basepath + '/' + subpath + '/' + '%02d'%date.month + '%02d'%date.day+ '/' + filename
00218             
00219                 if not os.path.isfile(file):
00220                     #fileday = '%02d' % int(int(fileday)-2)
00221                     #file = filepath + fileyear + '/TestDAQ/NoTag/' + filemonth + fileday + '/' + filename
00222                     date = date - datetime.timedelta(2)
00223                     file = self.options.raw_path + str(date.year) + '/' + basepath + '/' + subpath + '/' + '%02d'%date.month + '%02d'%date.day+ '/' + filename
00224             
00225                     if not os.path.isfile(file):
00226                         print 'Can not find raw data: %s' %filename
00227                         continue
00228     
00229             self.files.append(file)

def prodIHEP::FindFile::getfiles (   self,
  run_start,
  run_end,
  file_start,
  file_end 
)

Definition at line 231 of file prodIHEP.py.

00232                                                             :
00233         try:
00234             connect = MySQLdb.connect(host=dbhost, user=dbuser, passwd=dbpasswd, db=database)
00235             cursor = connect.cursor()
00236           
00237             str_query = " SELECT seqno, filename, runno, transferState FROM DaqRawDataFileInfo where runno >= " + str(run_start) + " && runno <= " + str(run_end)
00238             if file_start > 0:
00239                 str_query = str_query + " && fileNo >= " + str(file_start) + " && fileNo <= " + str(file_end)
00240 
00241             cursor.execute(str_query)
00242     
00243             rows = cursor.fetchall()
00244             if not rows:
00245                 return
00246     
00247         except MySQLdb.Error, e:
00248             print "Error %d: %s" % (e.args[0], e.args[1])
00249             sys.exit (1)
00250     
00251         cursor.close()
00252         connect.close()
00253         
00254         return rows
    
def prodIHEP::FindFile::getdates (   self,
  seq_start,
  seq_end 
)

Definition at line 256 of file prodIHEP.py.

00257                                         :
00258         try:
00259             connect = MySQLdb.connect(host=dbhost, user=dbuser, passwd=dbpasswd, db=database)
00260             cursor = connect.cursor()
00261           
00262             cursor.execute(" SELECT seqno, timeend FROM DaqRawDataFileInfoVld where seqno >= " + str(seq_start) + " && seqno <=" + str(seq_end))
00263 
00264             rows = cursor.fetchall()
00265             if not rows:
00266                 return
00267     
00268         except MySQLdb.Error, e:
00269             print "Error %d: %s" % (e.args[0], e.args[1])
00270             sys.exit (1)
00271     
00272         cursor.close()
00273         connect.close()
00274         
00275         return rows
00276     
00277 


Member Data Documentation

Definition at line 134 of file prodIHEP.py.

Definition at line 134 of file prodIHEP.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:55 for KUP11a by doxygen 1.7.4