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

In This Package:

ReadoutDetector.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # Load DybPython
00004 import math
00005 from DybPython.DybPythonAlg import DybPythonAlg
00006 from GaudiPython import SUCCESS, FAILURE
00007 from GaudiPython import gbl, loaddict
00008 from DybPython.Util import irange
00009 
00010 TH1F = gbl.TH1F
00011 TH2F = gbl.TH2F
00012 
00013 loaddict("libCLHEPRflx")
00014 loaddict("libHepMCRflx")
00015 Detector = gbl.DayaBay.Detector
00016 AdPmtSensor = gbl.DayaBay.AdPmtSensor
00017 ServiceMode = gbl.ServiceMode
00018 ReconStatus = gbl.ReconStatus
00019 
00020 
00021 class ReadoutDetectorAlg(DybPythonAlg):
00022     "Algorithm to make ReadoutDetector file"
00023     detList = ['DayaBayAD1', 'DayaBayAD2','LingAoAD1','LingAoAD2',
00024                 'FarAD1','FarAD2','FarAD3','FarAD4']   
00025    
00026     def findDetector(instance, detname, detlist = detList):
00027         for i in range(0,len(detlist)):
00028             if (detlist[i] == detname):
00029                 instance.stats["/file0/readout/DetectorName"].Fill(detlist[i],scale)
00030     
00031     def __init__(self,name):
00032         DybPythonAlg.__init__(self,name)
00033         return
00034 
00035     def initialize(self):
00036         status = DybPythonAlg.initialize(self)
00037         if status.isFailure(): return status
00038         self.info("initializing")
00039 
00040         self.cableSvc = self.svc('ICableSvc','StaticCableSvc')
00041         if self.cableSvc == None:
00042             self.error("Failed to get StaticCableSvc")
00043             return FAILURE
00044 
00045         hist = TH1F("Events","The Readout Detector" ,16, 0.0, 16.0)
00046         hist.GetXaxis().SetTitle("Readout Detector")
00047         hist.GetYaxis().SetTitle("Events/Day")
00048         for i in range(0,len(self.detList)):
00049             hist.GetXaxis().SetBinLabel(2 * (i + 1),self.detList[i])
00050         self.stats["/file0/readout/DetectorName"] = hist
00051         
00052         return SUCCESS
00053 
00054     def execute(self):
00055         self.info("executing")
00056         evt = self.evtSvc()
00057 
00058         readoutHdr = evt["/Event/Readout/ReadoutHeader"]
00059         if readoutHdr == None:
00060             self.error("Failed to get ReadoutHeader")
00061             return FAILURE
00062 
00063         readout = readoutHdr.readout()
00064         if readout != None:
00065             detectorName = readout.detector().detName()
00066             self.findDetector(detectorName)
00067         
00068         return SUCCESS
00069         
00070     def finalize(self):
00071         self.info("finalizing")
00072         status = DybPythonAlg.finalize(self)
00073         return status
00074 
00075 
00076 #####  Job Configuration for nuwa.py ########################################
00077 scale = 1.0
00078 
00079 def configure(argv = []):
00080     import sys,getopt
00081     opts,args = getopt.getopt(argv,"s:")
00082     global scale
00083     for opt,arg in opts:
00084         if opt == '-s':
00085             scale = float(arg)    
00086 
00087 
00088     from StatisticsSvc.StatisticsSvcConf import StatisticsSvc
00089     statsSvc = StatisticsSvc()
00090     statsSvc.Output ={"file0":"ReadoutDetector.root"}
00091     import DataSvc
00092     DataSvc.Configure()
00093     return
00094 
00095 def run(app):
00096     '''
00097     Configure and add an algorithm to job
00098     '''
00099     app.ExtSvc += ["StaticCableSvc", "StatisticsSvc"]
00100     readoutDetectorAlg = ReadoutDetectorAlg("MyReadoutDetector")
00101     app.addAlgorithm(readoutDetectorAlg)
00102     pass
00103 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:11:24 2011 for Calibration by doxygen 1.4.7