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

In This Package:

ViktorsTest.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Example analysis script for Viktor
00004 #
00005 #  Usage:
00006 #   nuwa.py -n -1 ViktorsTest simulationData.root
00007 
00008 # Load DybPython
00009 from DybPython.DybPythonAlg import DybPythonAlg
00010 from GaudiPython import SUCCESS, FAILURE
00011 from GaudiPython import gbl
00012 
00013 # Make shortcuts to ROOT classes
00014 TH1F = gbl.TH1F
00015 
00016 # Make your algorithm
00017 class ExampleAlg(DybPythonAlg):
00018     "Example Python Algorithm"
00019     def __init__(self,name):
00020         DybPythonAlg.__init__(self,name)
00021         return
00022 
00023     def initialize(self):
00024         status = DybPythonAlg.initialize(self)
00025         if status.isFailure(): return status
00026         self.info("initializing")
00027 
00028         # Initialize services
00029         #self.cableSvc = self.svc('ICableSvc','StaticCableSvc')
00030 
00031         self.stats.defaultPath = "/file1/examples/"
00032         # Make the trigger time histogram
00033         self.stats["TrigTime"] = TH1F("TrigTime","Trigger Time [s]",
00034                                       100,0.0,10.0)
00035         # Make the TDC histogram
00036         self.stats["Tdc"] = TH1F("Tdc","TDC Values",300,0,300)
00037 
00038         return SUCCESS
00039 
00040     def execute(self):
00041         self.info("executing")
00042 
00043         evt = self.evtSvc()
00044         hdr = evt["/Event/Readout/ReadoutHeader"]
00045         # Exercise 1: Print detector name
00046         ro = hdr.readout()
00047         if ro == None:
00048             self.info("No Readout this cycle")
00049             return SUCCESS
00050         print ro.detector().detName()
00051         # Exercise 2: Histogram the readout trigger time
00052         self.stats["TrigTime"].Fill( ro.triggerTime().GetSeconds() )        
00053         # Exercise 3: Histogram the TDC values
00054         channelIDs = ro.channels() # Get list of channel IDs in the readout
00055         for channelID in channelIDs:
00056             channel = ro.channel(channelID) # get the data from the channel
00057             for tdc in channel.tdc(): # loop over list of TDC values on channel
00058                 self.stats["Tdc"].Fill( tdc )
00059             for adcClock in channel.adcClocks():
00060                 adc = channel.adcByClock(adcClock)
00061                 print adcClock, adc
00062         return SUCCESS
00063         
00064     def finalize(self):        
00065         self.info("finalizing")
00066         status = DybPythonAlg.finalize(self)
00067         return status
00068 
00069 def configure():
00070     from StatisticsSvc.StatisticsSvcConf import StatisticsSvc
00071     statsSvc = StatisticsSvc()
00072     statsSvc.Output ={"file1":"exampleHist.root"}
00073     return
00074 
00075 def run(app):
00076     '''
00077     Configure and add an algorithm to job
00078     '''
00079     app.ExtSvc += ["StaticCableSvc", "StatisticsSvc"]
00080     example = ExampleAlg("MyExample")
00081     app.addAlgorithm(example)
00082     pass
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:05:58 2011 for DivingIn by doxygen 1.4.7