/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

DtData.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Example Job Module which adds some user-defined data to the output file
00004 #
00005 #  Usage:
00006 #   nuwa.py -n -1 -m"Quickstart.DtData" daq.NoTag.....data
00007 #
00008 #
00009 
00010 # Load DybPython
00011 from DybPython.DybPythonAlg import DybPythonAlg
00012 from GaudiPython import SUCCESS, FAILURE
00013 from GaudiPython import gbl
00014 from DybPython.Util import irange
00015 import GaudiKernel.SystemOfUnits as units
00016 
00017 # Make shortcuts to any ROOT classes you want to use
00018 TH1F = gbl.TH1F
00019 TimeStamp = gbl.TimeStamp
00020 Detector = gbl.DayaBay.Detector
00021 UserDataHeader = gbl.DayaBay.UserDataHeader
00022 
00023 # Make your algorithm
00024 class DtDataAlg(DybPythonAlg):
00025     "Calculate time since last trigger"
00026     def __init__(self,name):
00027         DybPythonAlg.__init__(self,name)
00028         return
00029 
00030     def initialize(self):
00031         status = DybPythonAlg.initialize(self)
00032         if status.isFailure(): return status
00033         self.info("initializing")
00034         self.lastTriggerTime = None
00035         return SUCCESS
00036 
00037     def execute(self):
00038         """Store the time since the last trigger"""
00039         evt = self.evtSvc()
00040 
00041         # Get the current detector Readout
00042         readoutHdr = evt["/Event/Readout/ReadoutHeader"]
00043         if readoutHdr == None:
00044             self.error("Failed to get current readout header")
00045             return FAILURE
00046         readout = readoutHdr.daqCrate().asPmtCrate()
00047         if readout == None:
00048             self.error("No readout this cycle?")
00049             return FAILURE
00050 
00051         # Calculate time since last trigger
00052         triggerTime = readout.triggerTime()
00053         dtLastTrigger = -1 * units.second
00054         if self.lastTriggerTime != None:
00055             dtTimeStamp = TimeStamp( triggerTime )
00056             dtTimeStamp.Subtract( self.lastTriggerTime )
00057             dtLastTrigger = dtTimeStamp.GetSeconds() * units.second
00058 
00059         # Store this user-defined data in a UserDataHeader
00060         userData = UserDataHeader()
00061         self.initializeHeader( userData )
00062 
00063         # Set user data variables here
00064         userData.setFloat('dtLastTrigger',dtLastTrigger)
00065 
00066         # Add user data to event store
00067         userData.addInputHeader( readoutHdr )
00068         self.finalizeHeader( userData )
00069         evt['/Event/UserData/Dt'] = userData
00070 
00071         self.lastTriggerTime = TimeStamp( triggerTime )
00072         return SUCCESS
00073         
00074     def finalize(self):
00075         self.info("finalizing")
00076         status = DybPythonAlg.finalize(self)
00077         return status
00078 
00079 
00080 #####  Job Configuration for nuwa.py ########################################
00081 
00082 def configure( argv=[] ):
00083     """ DtData job module """
00084     return
00085 
00086 def run(app):
00087     '''
00088     Configure and add the algorithm to job
00089     '''
00090     # Add Python algorithm to job here
00091     myAlg = DtDataAlg("MyDtDataAlg")
00092     # Add algorithm to job
00093     app.addAlgorithm(myAlg)
00094     pass
00095 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:54:33 for Quickstart by doxygen 1.7.4