| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

TestUserData.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 '''
00003 Make some user data
00004 
00005 
00006 CAUTION: don't use this as an example for your own stuff.  It does
00007 things at a low level.  Better to look at the
00008 RootIOTest.TestUserTagging module or even better at the
00009 UserData/Tagging documentation.
00010 
00011 '''
00012 
00013 from GaudiPython.GaudiAlgs import GaudiAlgo
00014 from GaudiPython import SUCCESS, FAILURE, Bindings, gbl
00015 import ROOT
00016 
00017 def spew(udh):
00018     s = '#%d @ %s count=%d aFloat=%f anInt=%d'%(\
00019         udh.execNumber(), udh.timeStamp().AsString(),
00020         udh.getInt("count"), udh.getFloat("aFloat"),udh.getInt("anInt"))
00021     return s
00022 
00023 
00024 class SomeUserData(GaudiAlgo):
00025     '''
00026     Place a UserDataHeader into the data stream
00027     '''
00028     def __init__(self,name='SomeUserData'):
00029         GaudiAlgo.__init__(self,name)
00030         self.count = 0;
00031         self.cache = None
00032         print 'SomeUserData: making some'
00033         return
00034 
00035     def execute(self):
00036         tes = self.evtSvc()
00037 
00038         self.count += 1
00039 
00040         print 'making UserDataHeader'
00041         udh = gbl.DayaBay.UserDataHeader()
00042         ROOT.SetOwnership(udh,False)
00043 
00044         print 'saving to TES'
00045         tes['/Event/UserData/SomeUserData'] = udh
00046 
00047         print 'setting basic values'
00048         udh.setExecNumber(self.count)
00049         now = gbl.TimeStamp(self.count*3600,self.count)
00050         udh.setEarliest(now)
00051         now = gbl.TimeStamp(self.count*3600,self.count+1)
00052         udh.setTimeStamp(now)
00053         now = gbl.TimeStamp(self.count*3600,self.count+2)
00054         udh.setLatest(now)
00055 
00056         print 'setting user data'
00057         udh.setInt("count",self.count)
00058         udh.setFloat("aFloat",6.9*self.count)
00059         udh.setInt("anInt",self.count*self.count)
00060 
00061         print 'SomeData: %s'%spew(udh)
00062 
00063         print 'Deleting Python-side UserDataHeader'
00064         del (udh)
00065 
00066         print 'bye bye'
00067         return SUCCESS
00068 
00069 class SomeMoreUserData(GaudiAlgo):
00070     '''
00071     Read some user data
00072     '''
00073     def __init__(self,name='SomeMoreUserData'):
00074         GaudiAlgo.__init__(self,name)
00075         print 'SomeMoreUserData: readin some more'
00076         return
00077 
00078     def execute(self):
00079         tes = self.evtSvc()
00080 
00081         udh = tes['/Event/UserData/SomeUserData']
00082 
00083         print 'SomeMoreUserData: %s'%spew(udh)
00084 
00085         return SUCCESS
00086     pass
00087 
00088 
00089 do_write = True
00090 do_read = True
00091 def configure(argv=None):
00092     global do_write
00093     global do_read
00094 
00095     if argv and argv[0] == "read":
00096         do_write = False
00097     if argv and argv[0] == "write":
00098         do_read = False
00099         
00100 
00101 def run(app):
00102     global do_write
00103     global do_read
00104 
00105     print 'TestUserData: configured with write="%s" and read="%s"'%(do_write,do_read)
00106 
00107     if do_write:
00108         alg = SomeUserData()
00109         app.addAlgorithm(alg)
00110     if do_read:
00111         alg = SomeMoreUserData()
00112         app.addAlgorithm(alg)
00113 
00114     return
00115     
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:58:40 2011 for RootIOTest by doxygen 1.4.7