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

In This Package:

CoincTag.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 '''
00003 '''
00004 
00005 from UserTagging.UserTaggingAlg import UserTaggingAlg
00006 from GaudiPython import SUCCESS, FAILURE
00007 from GaudiPython import gbl
00008 import GaudiKernel.SystemOfUnits as units
00009 
00010 dTCut = 1 * units.ms
00011 
00012 class CoincTag(UserTaggingAlg):
00013     '''Coincidence Events'''
00014         
00015     # ===========================================    
00016     def initTagList(self):
00017         
00018         self.addTag('Coinc' , '/Event/UserTag/Coinc/All')
00019         self.addTag('Prompt' , '/Event/UserTag/Coinc/Prompt')
00020         self.addTag('Delayed', '/Event/UserTag/Coinc/Delayed')
00021         
00022         self.dTCut = dTCut
00023         self.info("dT set to %.3f microsecond" % (self.dTCut/units.microsecond,))
00024         
00025         self.lastTimeStamp = 0
00026         # initialize a list of input headers to hold the rec headers of multiplets
00027         self.inputHeaders = []
00028         
00029     # ===========================================
00030     def check(self, evt):
00031         recHdr = evt["/Event/Rec/AdSimple"]
00032         if not recHdr:
00033             self.warning('cannot find recHdr')
00034             return FAILURE
00035 
00036         timeStamp = recHdr.timeStamp().GetSeconds() * units.second
00037         # self.info("executing #%d, TS=%.6f msec" % (self.execNumber, timeStamp))
00038         
00039         if (timeStamp - self.lastTimeStamp) > self.dTCut:
00040             if len(self.inputHeaders) == 0:
00041                 self.inputHeaders += [ recHdr ]
00042             elif len(self.inputHeaders) == 1:
00043                 self.inputHeaders = [ recHdr ]
00044             else:
00045                 # write a tag header object
00046                 
00047                 # write all events
00048                 self.info( '#%d: found %d coinc events' % 
00049                     (self.execNumber, len(self.inputHeaders)) )
00050                 self.getTag('Coinc').setInputHeaders(self.inputHeaders)
00051                 
00052                 # write prompt & delayed events
00053                 promptHeader  = self.getTag('Prompt').header
00054                 delayedHeader = self.getTag('Delayed').header
00055                 
00056                 for i, hdrI in enumerate(self.inputHeaders[:-1]):
00057                     for j, hdrJ in enumerate(self.inputHeaders[i+1:]):
00058                         promptHeader.addInputHeader(hdrI)
00059                         delayedHeader.addInputHeader(hdrJ)
00060                      
00061                 # clear out the inputHeaders
00062                 self.inputHeaders = [ recHdr ]
00063                 self.lastTimeStamp = timeStamp
00064                 
00065                 self.tagIt('Coinc')
00066                 self.tagIt('Prompt')
00067                 self.tagIt('Delayed')
00068                 return
00069         else:
00070             self.inputHeaders += [ recHdr ]
00071             
00072         self.lastTimeStamp = timeStamp
00073         
00074 #####  Job Configuration for nuwa.py ########################################
00075 
00076 def configure(argv=[]):
00077     """Configuration with command line arguments"""   
00078     global dTCut 
00079     from DybPython.Tools import unitify
00080     if len(argv) < 1:
00081         dTCut = unitify('1*ms') # default
00082         return
00083     try:
00084         dTCut = unitify(argv[0], 'second')
00085     except:
00086         import sys
00087         sys.exit('dTCut: ' + argv[0] + ': unit is not available, or wrong syntax.')
00088 
00089 def run(app):
00090     myAlg = CoincTag("UserTagg::CoincTag")
00091     app.addAlgorithm(myAlg)
00092     pass
00093 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:54:29 for TaggingExample by doxygen 1.7.4