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

In This Package:

CoincData.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 '''
00003 Usage:
00004 '''
00005 
00006 from UserTagging.UserTaggingAlg import UserTaggingAlg
00007 from GaudiPython import SUCCESS, FAILURE
00008 from GaudiPython import gbl
00009 import GaudiKernel.SystemOfUnits as units
00010 
00011 class CoincData(UserTaggingAlg):
00012     '''Add Coincidence info to UserData'''
00013         
00014     # ===========================================    
00015     def initTagList(self):
00016         self.addTag('Dummy', '')
00017         self.getTag('Dummy').addData('CoincData'  , '/Event/UserData/Coinc/CoincData')
00018         self.getTag('Dummy').addData('PromptData' , '/Event/UserData/Coinc/PromptData')
00019         self.getTag('Dummy').addData('DelayedData', '/Event/UserData/Coinc/DelayedData')
00020         
00021         myData = self.getTag('Dummy').getData('CoincData')
00022         myData.addInt('multiplicity')
00023         
00024         for name in ['PromptData', 'DelayedData']:
00025             myData = self.getTag('Dummy').getData(name)
00026             myData.addIntArray('t_sec', 't_nsec', 'triggerType', 'detID'
00027                  ).addFloatArray('energy', 'x', 'y', 'z')
00028         
00029     # ===========================================
00030     def check(self, evt):
00031         coincHdr = evt['/Event/UserTag/Coinc/All']
00032         if not coincHdr:  # not a coincidence event
00033             return False
00034         promptHdr  = evt['/Event/UserTag/Coinc/Prompt']
00035         if not promptHdr: 
00036             self.warning('missing prompt header')
00037             return
00038         delayedHdr = evt['/Event/UserTag/Coinc/Delayed']
00039         if not delayedHdr: 
00040             self.warning('missing delayed header')
00041             return
00042         self.SaveConicData(coincHdr, promptHdr, delayedHdr)            
00043         
00044         self.tagIt('Dummy')
00045         
00046     # ===========================================
00047     def SaveConicData(self, coincHdr, promptHdr, delayedHdr):
00048         '''Save Coincidence Info to UserData'''
00049         
00050         hdr_dispatcher = {
00051             'PromptData' : promptHdr,
00052             'DelayedData' : delayedHdr,
00053         }
00054         
00055         for name, tagHeader in hdr_dispatcher.items():
00056             myData = self.getTag('Dummy').getData(name)
00057             for recHdr in tagHeader.inputHeaders():
00058                 result = recHdr.recTrigger()
00059                 myData.append("energy", result.energy()/units.MeV
00060                     ).append("x", result.position().x()/units.mm
00061                     ).append("y", result.position().y()/units.mm
00062                     ).append("z", result.position().z()/units.mm
00063                     ).append("t_sec", recHdr.timeStamp().GetSec()
00064                     ).append("t_nsec", recHdr.timeStamp().GetNanoSec()
00065                     ).append("triggerType", result.triggerType()
00066                     ).append("detID", result.detector().detectorId())
00067         
00068         coincData = self.getTag('Dummy').getData('CoincData')
00069         coincRecHdrs = coincHdr.inputHeaders()
00070         coincData.set("multiplicity", len(coincRecHdrs))        
00071             
00072 #####  Job Configuration for nuwa.py ########################################
00073 
00074 def configure(argv=[]):
00075     pass
00076 
00077 def run(app):
00078     myAlg = CoincData("UserData::CoincData")
00079     app.addAlgorithm(myAlg)
00080     pass                    
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:02:01 for UserTagging by doxygen 1.7.4