00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 from DybPython.DybPythonAlg import DybPythonAlg
00014 from GaudiPython import SUCCESS, FAILURE
00015 from GaudiPython import gbl
00016 from DybPython.Util import irange
00017 import GaudiKernel.SystemOfUnits as units
00018
00019
00020 TH1F = gbl.TH1F
00021 TimeStamp = gbl.TimeStamp
00022 AdPmtSensor = gbl.DayaBay.AdPmtSensor
00023 Detector = gbl.DayaBay.Detector
00024
00025
00026 gbl.gStyle.SetHistLineColor(4)
00027 gbl.gStyle.SetHistLineWidth(2)
00028 gbl.gStyle.SetMarkerColor(4)
00029 gbl.gStyle.SetMarkerStyle(8)
00030 gbl.gStyle.SetPalette(1)
00031
00032
00033 class PrintCalibDataAlg(DybPythonAlg):
00034 "Print Calib Data Example Algorithm"
00035 def __init__(self,name):
00036 DybPythonAlg.__init__(self,name)
00037 return
00038
00039 def initialize(self):
00040 status = DybPythonAlg.initialize(self)
00041 if status.isFailure(): return status
00042 self.info("initializing")
00043
00044
00045 self.stats["/file1/myhists/chargeSum"] = TH1F("chargeSum",
00046 "Sum of PMT charge for each trigger",
00047 2000,0,2000)
00048 return SUCCESS
00049
00050 def execute(self):
00051 self.info("executing")
00052
00053 evt = self.evtSvc()
00054
00055
00056
00057 calibHdr = evt["/Event/CalibReadout/CalibReadoutHeader"]
00058 if calibHdr == None:
00059 self.error("Failed to get current calib readout header")
00060 return FAILURE
00061
00062
00063 calibReadout = calibHdr.calibReadout()
00064 if calibReadout == None:
00065 self.error("Failed to get calibrated readout from header")
00066 return FAILURE
00067
00068
00069 detector = calibReadout.detector()
00070 self.info("Detector Name: "+detector.detName())
00071
00072
00073 self.info("Trigger Type: "+str( calibReadout.triggerType() ))
00074
00075 self.info("Trigger Number: "+str( calibReadout.triggerNumber() ))
00076
00077
00078 triggerTime = calibReadout.triggerTime()
00079
00080 self.info("Trigger Time [Seconds part]: "
00081 +str( triggerTime.GetSec() ))
00082
00083 self.info("Trigger Time [Nanoseconds part]: "
00084 +str( triggerTime.GetNanoSec() ))
00085
00086
00087 self.info("Full Trigger Time: "
00088 +str( triggerTime.GetSec()
00089 +triggerTime.GetNanoSec()*1.0e-9 ))
00090
00091
00092 chargeSum = 0
00093 for channel in calibReadout.channelReadout():
00094 sensorId = channel.pmtSensorId()
00095 pmtId = AdPmtSensor( sensorId.fullPackedData() )
00096
00097
00098 self.info("Pmt ID:"
00099 +" detector="
00100 +pmtId.detName()
00101 +" column="
00102 +str(pmtId.column())
00103 +" ring="
00104 +str(pmtId.ring()))
00105
00106
00107 for hitIdx in range( channel.size() ):
00108
00109 hitTime = channel.time( hitIdx )
00110 self.info("Hit Time: "+str( hitTime ))
00111
00112 hitCharge = channel.charge( hitIdx )
00113 self.info("Hit Charge: "+str( hitCharge ))
00114 chargeSum += hitCharge
00115
00116
00117 self.stats["/file1/myhists/chargeSum"].Fill( chargeSum )
00118 return SUCCESS
00119
00120 def finalize(self):
00121 self.info("finalizing")
00122 status = DybPythonAlg.finalize(self)
00123 return status
00124
00125
00126
00127 def configure( argv=[] ):
00128 """ Example of processing calibrated data """
00129
00130
00131 from StatisticsSvc.StatisticsSvcConf import StatisticsSvc
00132 statsSvc = StatisticsSvc()
00133 statsSvc.Output = {"file1":"calibDataResult.root"}
00134
00135 return
00136
00137 def run(app):
00138 '''
00139 Configure and add the algorithm to job
00140 '''
00141 app.ExtSvc += ["StatisticsSvc"]
00142 myAlg = PrintCalibDataAlg("MyPrintCalibDataAlg")
00143 app.addAlgorithm(myAlg)
00144 pass
00145