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

In This Package:

ReadoutDumper.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Sctipt to dump waveforms to a Root File
00004 #
00005 #  Usage:
00006 #   nuwa.py -n -1 ReadoutDumper simulationData.root
00007 
00008 # Load DybPython
00009 from DybPython.DybPythonAlg import DybPythonAlg
00010 from GaudiPython import SUCCESS, FAILURE
00011 from GaudiPython import gbl
00012 from array import array
00013 
00014 # Make shortcuts to ROOT classes
00015 TH1F = gbl.TH1F
00016 TFile = gbl.TFile
00017 TGraph = gbl.TGraph
00018 
00019 # Make your algorithm
00020 class ReadoutDumperAlg(DybPythonAlg):
00021     "Example Python Algorithm"
00022     def __init__(self,name):
00023         DybPythonAlg.__init__(self,name)
00024         self.plot={}
00025         return
00026 
00027     def initialize(self):
00028         status = DybPythonAlg.initialize(self)
00029         if status.isFailure(): return status
00030         self.info("initializing")
00031         
00032         self.eventNumber = 0
00033 
00034         # Initialize services
00035         #self.cableSvc = self.svc('ICableSvc','StaticCableSvc')
00036 
00037         #self.stats.defaultPath = "/file1/waves/"
00038         # Make the trigger time histogram
00039         #self.stats["waveform"] = TGraph
00040 
00041         return SUCCESS
00042 
00043     def execute(self):
00044         self.info("executing")
00045         
00046         self.eventNumber+=1
00047 
00048         evt = self.evtSvc()
00049         hdr = evt["/Event/Readout/ReadoutHeader"]
00050         
00051         if (hdr.__class__ != gbl.DayaBay.ReadoutHeader ): 
00052             self.warning("Readout Header not found for this event")
00053             return SUCCESS
00054         
00055         readout = hdr.readout()
00056         #readout.__class__=gbl.DayaBay.ReadoutPmtCrate
00057         self.debug(str(readout.channelReadout()))
00058         det = readout.detector()
00059         
00060         # This works 
00061         
00062         #for channel,ro in readout.channelReadout():
00063         #    self.verbose("channel: "+str(channel))
00064         #    self.debug("size="+str(ro.size())) 
00065 
00066         dt = 1
00067         
00068         for channel,fadcRo in readout.fadcReadout():
00069             self.debug("FADC channel: " + str(channel.connector()) )
00070             tmp="["
00071             for adc in fadcRo: tmp=tmp+str(adc)+","
00072             self.verbose(tmp[:-1]+"]")
00073 
00074             path="/file1/event_%d/%s/"%(self.eventNumber, det.detName())
00075 
00076             # fadc = fadcRo
00077             clock = [tick*dt for tick in range(fadcRo.size())]
00078             print fadcRo
00079             graph = TGraph(fadcRo.size(), array('f',clock), array('f',fadcRo))
00080             graph.SetMarkerStyle(8)
00081             graph.SetMarkerColor(600)
00082             graph.SetTitle("FADC")
00083             graph.GetXaxis().SetTitle("Time (ns)")
00084             graph.GetYaxis().SetTitle("FADC Value")
00085             self.verbose("array size" + str(len(clock)))
00086             #graph.GetXaxis().SetLimits(200,600)
00087             self.stats[path+"connector_%d/fadc"%channel.connector()] = graph
00088                
00089         return SUCCESS
00090         
00091     def finalize(self):        
00092         self.info("finalizing")
00093         
00094         status = DybPythonAlg.finalize(self)
00095         return status
00096 
00097 
00098 def configure():
00099     #from StatisticsSvc.StatisticsSvcConf import StatisticsSvc
00100     #statsSvc = StatisticsSvc()
00101     #statsSvc.Output ={"file1":"waveforms.root"}
00102     return
00103 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:06:07 2011 for ElecTutorial by doxygen 1.4.7