/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 | Static Public Attributes | Private Member Functions
SpadeSvc::SpadeAlgo::SpadeAlgo Class Reference
Inheritance diagram for SpadeSvc::SpadeAlgo::SpadeAlgo:
Inheritance graph
[legend]
Collaboration diagram for SpadeSvc::SpadeAlgo::SpadeAlgo:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def initialize
def execute
def finalize
def fileBase
def getCommandLine

Public Attributes

 fss
 opened
 tomark
 marked
 site
 startTime
 endTime

Static Public Attributes

int SITE_SAB = 32

Private Member Functions

def _make_sems
def _listify
def _update_output_files
def _make_one_sem

Detailed Description

Definition at line 5 of file SpadeAlgo.py.


Constructor & Destructor Documentation

def SpadeSvc::SpadeAlgo::SpadeAlgo::__init__ (   self,
  name = "SpadeAlg" 
)

Definition at line 9 of file SpadeAlgo.py.

00010                                        :
00011         DybPythonAlg.__init__(self, name)
00012         self.fss = None
00013         self.opened = []
00014         self.tomark = []
00015         self.marked = []
00016         import DybPython.Control
00017         DybPython.Control.nuwa.spadeSvc = self
00018         return
00019 


Member Function Documentation

def SpadeSvc::SpadeAlgo::SpadeAlgo::initialize (   self)

Definition at line 20 of file SpadeAlgo.py.

00021                         :
00022         status = DybPythonAlg.initialize(self)
00023         if status.isFailure(): return status
00024 
00025         self.site = None
00026         self.startTime = None
00027         self.endTime = None
00028         self.fss = self.svc('IRootIOFileStateSvc','RootIOFileStateSvc')
00029 
00030         self.debug('Initialized "%s"' % self.name())
00031         return status
00032 

def SpadeSvc::SpadeAlgo::SpadeAlgo::execute (   self)

Definition at line 33 of file SpadeAlgo.py.

00034                      :
00035         # Get this event's time from the TES
00036         #eventTime = self.get('/Event/...')
00037         header = self.get('/Event/Readout/ReadoutHeader')
00038         if None == header:
00039             self.debug("Got no ReadoutHeader")
00040             return SUCCESS
00041         from time import gmtime, strftime, timezone
00042         data = header.daqCrate()
00043         if not data:
00044             self.warning("got no daqcrate from ReadoutHeader")
00045             return SUCCESS
00046 
00047         if data.hasTriggers():
00048             eventTime = data.triggerTime().GetSeconds()
00049 
00050             #self.debug('Site Value: %s'% header.context().GetSite())
00051             #self.debug( "event time %s thish is %s" % \
00052             #     ( eventTime strftime('%Y-%m-%dT%H:%M:%S', gmtime(eventTime))))
00053             if None == self.startTime:
00054                 self.site = header.context().GetSite()
00055                 self.startTime = eventTime
00056             self.endTime = eventTime
00057 
00058         self._update_output_files()        
00059         self._make_sems(self.tomark)
00060         return SUCCESS
00061 

def SpadeSvc::SpadeAlgo::SpadeAlgo::finalize (   self)

Definition at line 62 of file SpadeAlgo.py.

00063                       :
00064         # NB: this is not a race condition as we delay the .meta.xml
00065         # to .sem conversion until after the running stops.  This is
00066         # done in DybPython.Control.nuwa
00067         self.debug("final cleanup")
00068         self._update_output_files()        
00069         self._make_sems(self.tomark)
00070         self._make_sems(self.opened)
00071         if None != self.finished:
00072             self._make_one_sem(self.finished)
00073         return DybPythonAlg.finalize(self)
00074 

def SpadeSvc::SpadeAlgo::SpadeAlgo::_make_sems (   self,
  filenames 
) [private]

Definition at line 75 of file SpadeAlgo.py.

00076                                   :
00077         'Make sem files corresponding to all given filenames'
00078         self.debug('marking: %s'%filenames)
00079 
00080         # make copy so the .remove() later doesn't mess up what we are
00081         # iterating on
00082         filenames = list(filenames) 
00083 
00084         for fn in filenames:
00085             self._make_one_sem(fn)
00086             self.marked.append(fn)
00087             self.debug('marked= %s' % self.marked)
00088             self.debug('tomark= %s' % self.tomark)
00089             try:
00090                 self.tomark.remove(fn)
00091             except ValueError:
00092                 pass
00093             continue
00094         return
00095         

def SpadeSvc::SpadeAlgo::SpadeAlgo::_listify (   self,
  vector 
) [private]

Definition at line 96 of file SpadeAlgo.py.

00097                              :
00098         'Turn an STL vector into a Python list'
00099         l = []
00100         siz = vector.size()
00101         for ind in range(siz):
00102             l.append(vector[ind])
00103         return l
00104 

def SpadeSvc::SpadeAlgo::SpadeAlgo::_update_output_files (   self) [private]

Definition at line 105 of file SpadeAlgo.py.

00106                                   :
00107         'Update list of opened and tomark files'
00108         self.opened = self._listify(self.fss.openOutput())
00109 
00110         closed = self._listify(self.fss.closedOutput())
00111         for fn in closed:
00112             if fn not in self.marked and fn not in self.tomark:
00113                 self.debug('new file to mark: "%s"'%fn)
00114                 self.tomark.append(fn)
00115                 pass
00116             continue
00117         return

def SpadeSvc::SpadeAlgo::SpadeAlgo::_make_one_sem (   self,
  filename 
) [private]

Definition at line 118 of file SpadeAlgo.py.

00119                                     :
00120         'Make a sem file based on given filename'
00121 
00122         self.debug('making sem file for "%s"'%filename)
00123 
00124         from Metadata import Metadata
00125         from os.path import basename
00126 
00127         basePath = self.fileBase(filename)
00128         metadata = Metadata(basename(basePath))
00129 
00130         try:
00131             metadata.category = self.category
00132         except AttributeError:
00133             metadata.category = 'calibration'
00134         try:
00135             hallKey = self.hall
00136         except AttributeError:
00137             hallKey = 'ALL'
00138         metadata.sensor = metadata.SENSOR_HALL[hallKey]
00139         try:
00140             realData = self.realData
00141         except AttributeError:
00142             realData = True
00143         if realData:
00144             metadata.source = metadata.SOURCE_EXPERIMENT
00145         else:
00146             metadata.source = metadata.SOURCE_SIMULATION
00147         try:
00148             metadata.subcategory = self.subcategory
00149         except AttributeError:
00150             metadata.subcategory = 'unclassified'
00151             
00152         from time import gmtime, strftime
00153         if None == self.startTime:
00154             start = gmtime()
00155         else:
00156             start = gmtime(int(self.startTime) - 1)
00157             pass
00158         metadata.startTime = start
00159         if None == self.endTime:
00160             end = gmtime()
00161         else:
00162             end = gmtime(int(self.endTime) + 1)
00163             pass
00164         metadata.endTime = end
00165 
00166         metadata.commandLine = self.getCommandLine()
00167         outFile = open(basePath + '.meta.xml', 'w')
00168         outFile.write(metadata.createXML().toxml())
00169         outFile.close()
00170         return SUCCESS

def SpadeSvc::SpadeAlgo::SpadeAlgo::fileBase (   self,
  filename 
)

Definition at line 171 of file SpadeAlgo.py.

00173                           :
00174         cut = filename.rfind('.')
00175         if -1 == cut:
00176             return filename
00177         return  filename[:cut]

def SpadeSvc::SpadeAlgo::SpadeAlgo::getCommandLine (   self)

Definition at line 178 of file SpadeAlgo.py.

00179                             :
00180         import sys
00181         result = ''
00182         for arg in sys.argv:
00183             if 0 != len(result):
00184                 result += ' '
00185             quote = ''
00186             if -1 != arg.find(' '):
00187                 quote = '"'
00188                 result += quote
00189             result += arg.replace('"',
00190                                   '\\"') + quote
00191         return result

Member Data Documentation

Definition at line 7 of file SpadeAlgo.py.

Definition at line 9 of file SpadeAlgo.py.

Definition at line 9 of file SpadeAlgo.py.

Definition at line 9 of file SpadeAlgo.py.

Definition at line 9 of file SpadeAlgo.py.

Definition at line 20 of file SpadeAlgo.py.

Definition at line 20 of file SpadeAlgo.py.

Definition at line 20 of file SpadeAlgo.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:55:24 for SpadeSvc by doxygen 1.7.4