00001
00002
00003
00004
00005
00006
00007
00008
00009 from DybPython.DybPythonAlg import DybPythonAlg
00010 from GaudiPython import SUCCESS, FAILURE
00011 from GaudiPython import gbl
00012 from array import array
00013
00014
00015 TH1F = gbl.TH1F
00016 TFile = gbl.TFile
00017 TGraph = gbl.TGraph
00018
00019
00020 class WaveDumperAlg(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
00035
00036
00037
00038
00039
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/Elec/ElecHeader"]
00050
00051 if (hdr.__class__ != gbl.DayaBay.ElecHeader ):
00052 self.warning("ElecHeader not found for this event")
00053 return SUCCESS
00054
00055 crateHeader = hdr.crateHeader()
00056 hitDt = 12.5
00057 energyDt = 5
00058 adcDt = 25
00059 tdcDt = 25./16
00060 for det,crate in crateHeader.crates():
00061 self.debug("Processing " + det.detName())
00062 crate.__class__=gbl.DayaBay.ElecFeeCrate
00063
00064 boardpath="/file1/event_%d/%s/"%(self.eventNumber,
00065 det.detName())
00066 esumAdc = crate.esumADC()
00067 energyClock = [tick*energyDt for tick in range(esumAdc.size())]
00068 print esumAdc
00069 graph = TGraph(esumAdc.size(),
00070 array('f',energyClock),
00071 array('f',esumAdc))
00072 graph.SetMarkerStyle(8)
00073 graph.SetMarkerColor(600)
00074 graph.SetTitle("esumADC")
00075 self.stats[boardpath+"esumAdc"] = graph
00076
00077 esumUpper = crate.esumUpper()
00078 energyClock = [tick*energyDt for tick in range(esumUpper.size())]
00079 graph = TGraph(esumAdc.size(),
00080 array('f',energyClock),
00081 array('f',esumUpper))
00082 graph.SetMarkerStyle(8)
00083 graph.SetMarkerColor(600)
00084 graph.SetTitle("esumUpper")
00085 self.stats[boardpath+"esumUpper"] = graph
00086
00087 esumLower = crate.esumLower()
00088 energyClock = [tick*energyDt for tick in range(esumLower.size())]
00089 graph = TGraph(esumLower.size(),
00090 array('f',energyClock),
00091 array('f',esumLower))
00092 graph.SetMarkerStyle(8)
00093 graph.SetMarkerColor(600)
00094 graph.SetTitle("esumLower")
00095 self.stats[boardpath+"esumLower"] = graph
00096
00097 esumTotal = crate.esumTotal()
00098 energyClock = [tick*energyDt for tick in range(esumTotal.size())]
00099 graph = TGraph(esumTotal.size(),
00100 array('f',energyClock),
00101 array('f',esumTotal))
00102 graph.SetMarkerStyle(8)
00103 graph.SetMarkerColor(600)
00104 graph.SetTitle("esumTotal")
00105 self.stats[boardpath+"esumTotal"] = graph
00106
00107
00108 for chID,channel in crate.channelData():
00109 path="/file1/"
00110 path+="event_%d/%s/board_%d/connector_%d/"%(self.eventNumber,
00111 det.detName(),
00112 chID.board(),
00113 chID.connector())
00114
00115
00116 tdc = channel.tdc()
00117 if tdc.size() > 0:
00118 adcHigh = channel.adcHigh()
00119 adcHighClock = [tick*adcDt for tick in range(adcHigh.size())]
00120 graph=TGraph(adcHigh.size(),
00121 array('f',adcHighClock),
00122 array('f',adcHigh))
00123 graph.SetMarkerStyle(8)
00124 graph.SetMarkerColor(600)
00125 graph.SetTitle("adcHigh")
00126 self.stats[path+"adcHigh"] = graph
00127
00128 hit = channel.hit()
00129 hitClock = [tick*hitDt for tick in range(hit.size())]
00130 graph= TGraph(hit.size(),
00131 array('f',hitClock),
00132 array('f',hit))
00133 graph.SetMarkerStyle(8)
00134 graph.SetMarkerColor(600)
00135 graph.SetTitle("nhit")
00136 self.stats[path+"nhit"]=graph
00137
00138 adcLow = channel.adcLow()
00139 adcLowClock = [tick*adcDt for tick in range(adcLow.size())]
00140 graph = TGraph(adcLow.size(),
00141 array('f',adcLowClock),
00142 array('f',adcLow))
00143 graph.SetMarkerStyle(8)
00144 graph.SetMarkerColor(600)
00145 graph.SetTitle("adcLow")
00146 self.stats[path+"adcLow"] = graph
00147
00148 return SUCCESS
00149
00150 def finalize(self):
00151 self.info("finalizing")
00152 status = DybPythonAlg.finalize(self)
00153 return status
00154
00155
00156 def configure():
00157
00158
00159
00160 return
00161