Public Member Functions | |
def | __init__ |
def | initialize |
def | execute |
def | finalize |
def | isNewChannel |
def | isNewDetector |
def | prepareDetectorHistograms |
def | prepareChannelHistograms |
def | runPath |
Public Attributes | |
runNumber | |
lastReadoutTime | |
activeChannelIds | |
activeDetectors |
Definition at line 31 of file Tester.py.
def Tester::TesterAlg::__init__ | ( | self, | ||
name | ||||
) |
Definition at line 33 of file Tester.py.
00033 : 00034 DybPythonAlg.__init__(self,name) 00035 return 00036 def initialize(self):
def Tester::TesterAlg::initialize | ( | self | ) |
Definition at line 37 of file Tester.py.
00037 : 00038 status = DybPythonAlg.initialize(self) 00039 if status.isFailure(): return status 00040 self.info("initializing") 00041 00042 self.runNumber=None 00043 self.lastReadoutTime = None 00044 self.activeChannelIds = [] 00045 self.activeDetectors = [] 00046 00047 return SUCCESS 00048 def execute(self):
def Tester::TesterAlg::execute | ( | self | ) |
Definition at line 49 of file Tester.py.
00049 : 00050 self.info("executing") 00051 00052 # Access current data 00053 evt = self.evtSvc() 00054 readoutHdr = evt["/Event/Readout/ReadoutHeader"] 00055 if readoutHdr == None: 00056 self.error("Failed to get current readout header") 00057 return FAILURE 00058 00059 readout = readoutHdr.readout() 00060 if readout == None: 00061 self.error("Failed to get readout from header") 00062 return FAILURE 00063 00064 if not self.runNumber: 00065 # Initialize run number from raw data block 00066 self.runNumber = readout.rawEvent().runNumber() 00067 00068 detector = readout.detector() 00069 if self.isNewDetector( detector ): 00070 self.prepareDetectorHistograms( detector ) 00071 runPath = "/file1/diagnostics/run_%06d" % self.runNumber 00072 detectorName = readout.detector().detName() 00073 detectorPath = runPath + "/detector_" + detectorName 00074 # Loop over channel data 00075 nChannels = 0 00076 for channelPair in readout.channelReadout(): 00077 channel = channelPair.second 00078 channelId = channel.channelId() 00079 if self.isNewChannel( channelId ): 00080 self.prepareChannelHistograms( channelId ) 00081 00082 # Make path for histograms 00083 path = "%s/channel_board%02d_connector%02d" % (detectorPath, 00084 channelId.board(), 00085 channelId.connector()) 00086 self.debug("Processing channel with path: "+path) 00087 # TDC data by channel 00088 for hitIdx in range(channel.size()): 00089 self.stats[path + "/tdc"].Fill( channel.tdc(hitIdx) ) 00090 self.stats[path + "/adc"].Fill( channel.adc(hitIdx) ) 00091 # Hit Rate 00092 channelIndex = channelId.board()*16 + channelId.connector() 00093 self.stats[detectorPath + "/hitRate"].Fill( channelIndex ) 00094 nChannels += 1 00095 00096 # Readout histograms 00097 # Number of hit channels 00098 self.stats[detectorPath + "/nChannels"].Fill( nChannels ) 00099 # Number of Triggers by type 00100 self.stats[detectorPath + "/triggerType"].Fill( readout.triggerType() ) 00101 # Time Between Triggered Readout 00102 if self.lastReadoutTime != None: 00103 # Skip first readout 00104 dT_trigger = TimeStamp( readout.triggerTime() ) 00105 dT_trigger.Subtract( self.lastReadoutTime ) 00106 self.debug("Dt Readout: "+str(dT_trigger.GetSeconds())) 00107 self.stats[detectorPath + "/dT_trigger"].Fill( 00108 dT_trigger.GetSeconds() ) 00109 00110 # Set time of last readout 00111 self.lastReadoutTime = TimeStamp(readout.triggerTime()) 00112 self.debug("done execute") 00113 return SUCCESS 00114 def finalize(self):
def Tester::TesterAlg::finalize | ( | self | ) |
Definition at line 115 of file Tester.py.
00115 : 00116 self.info("finalizing") 00117 # Fill summary histograms 00118 for channelInt in self.activeChannelIds: 00119 channelId = FeeChannelId( channelInt ) 00120 runPath = "/file1/diagnostics/run_%06d" % self.runNumber 00121 detectorName = channelId.detName() 00122 detectorPath = runPath + "/detector_" + detectorName 00123 path = "%s/channel_board%02d_connector%02d" % (detectorPath, 00124 channelId.board(), 00125 channelId.connector()) 00126 channelIndex = channelId.board()*16 + channelId.connector() 00127 # ADC summary 00128 meanAdc = self.stats[path + "/adc"].GetMean() 00129 rmsAdc = self.stats[path + "/adc"].GetRMS() 00130 self.stats[detectorPath + "/meanAdc"].Fill(channelIndex, meanAdc) 00131 self.stats[detectorPath + "/rmsAdc"].Fill(channelIndex, rmsAdc) 00132 for detectorInt in self.activeDetectors: 00133 # Hit Rate summary 00134 detector = Detector( detectorInt ) 00135 runPath = "/file1/diagnostics/run_%06d" % self.runNumber 00136 detectorPath = runPath + "/detector_" + detector.detName() 00137 nReadouts = self.stats[detectorPath + "/nChannels"].GetEntries() 00138 self.stats[detectorPath + "/hitRate"].Scale( 1 / nReadouts ) 00139 self.stats[detectorPath + "/hitRate"].SetBit( TH1.kIsAverage ) 00140 00141 status = DybPythonAlg.finalize(self) 00142 return status 00143 def isNewChannel(self, channelId):
def Tester::TesterAlg::isNewChannel | ( | self, | ||
channelId | ||||
) |
Definition at line 144 of file Tester.py.
00144 : 00145 # Check if this channel has been seen 00146 if channelId.fullPackedData() in self.activeChannelIds: 00147 return False 00148 return True 00149 def isNewDetector(self, detector):
def Tester::TesterAlg::isNewDetector | ( | self, | ||
detector | ||||
) |
Definition at line 150 of file Tester.py.
00150 : 00151 # Check if this detector has been seen 00152 if detector.fullPackedData() in self.activeDetectors: 00153 return False 00154 return True 00155 def prepareDetectorHistograms(self, detector):
def Tester::TesterAlg::prepareDetectorHistograms | ( | self, | ||
detector | ||||
) |
Definition at line 156 of file Tester.py.
00156 : 00157 # Prepare the empty histograms for this detector 00158 path = self.runPath() + "/detector_" + detector.detName() 00159 self.debug("Making histograms at path: "+path) 00160 # Number of hit channels in each readout 00161 self.stats[path + "/nChannels"] = TH1F("nChannels", 00162 "Number of Hit Channels", 00163 250,0,250) 00164 hist = self.stats[path + "/nChannels"] 00165 hist.GetXaxis().SetTitle("Number of Hit Channels") 00166 hist.GetYaxis().SetTitle("Number of Triggered Readouts") 00167 # Number of Triggers by type 00168 self.stats[path + "/triggerType"] = TH1F("triggerType", 00169 "Trigger Type", 00170 4096,0,4096) 00171 hist = self.stats[path + "/triggerType"] 00172 hist.GetXaxis().SetTitle("Trigger Type") 00173 hist.GetYaxis().SetTitle("Number of Triggered Readouts") 00174 # Time Between Triggered Readout 00175 self.stats[path + "/dT_trigger"] = TH1F("dT_trigger", 00176 "Time between triggers [s]", 00177 1000,0,1) 00178 hist = self.stats[path + "/dT_trigger"] 00179 hist.GetXaxis().SetTitle("Time Between Triggered Readouts [s]") 00180 hist.GetYaxis().SetTitle("Number of Triggered Readouts / 1 ms") 00181 # Summary Histograms 00182 # Mean ADC by channel 00183 self.stats[path + "/meanAdc"] = TH1F("meanAdc", 00184 "Mean ADC by channel", 00185 300,0,300) 00186 hist = self.stats[path + "/meanAdc"] 00187 hist.GetXaxis().SetTitle("Channel Index (Board*16 + Connector)") 00188 hist.GetYaxis().SetTitle("Mean ADC value") 00189 # RMS ADC by channel 00190 self.stats[path + "/rmsAdc"] = TH1F("rmsAdc", 00191 "RMS ADC by channel (board*16 + connector)", 00192 300,0,300) 00193 hist = self.stats[path + "/rmsAdc"] 00194 hist.GetXaxis().SetTitle("Channel Index (Board*16 + Connector)") 00195 hist.GetYaxis().SetTitle("RMS of ADC values") 00196 # Hit Rate by channel 00197 self.stats[path + "/hitRate"] = TH1F("hitRate", 00198 "Hit Rate by channel", 00199 300,0,300) 00200 hist = self.stats[path + "/hitRate"] 00201 hist.GetXaxis().SetTitle("Channel Index (Board*16 + Connector)") 00202 hist.GetYaxis().SetTitle("Number of Hits / Number of Triggered Readouts") 00203 self.activeDetectors.append( detector.fullPackedData() ) 00204 return 00205 def prepareChannelHistograms(self, channelId):
def Tester::TesterAlg::prepareChannelHistograms | ( | self, | ||
channelId | ||||
) |
Definition at line 206 of file Tester.py.
00206 : 00207 # Prepare the empty histograms for this channel 00208 path = "%s/detector_%s/channel_board%02d_connector%02d" % ( 00209 self.runPath(), 00210 channelId.detName(), 00211 channelId.board(), 00212 channelId.connector()) 00213 self.debug("Making histograms at path: "+path) 00214 # TDC data by channel 00215 self.stats[path + "/tdc"] = TH1F("tdc", 00216 "TDC Values", 00217 4096,0,4096) 00218 hist = self.stats[path + "/tdc"] 00219 hist.GetXaxis().SetTitle("TDC value") 00220 hist.GetYaxis().SetTitle("Number of TDCs") 00221 # ADC data by channel 00222 self.stats[path + "/adc"] = TH1F("adc", 00223 "ADC Values", 00224 4096,0,4096) 00225 hist = self.stats[path + "/adc"] 00226 hist.GetXaxis().SetTitle("ADC value") 00227 hist.GetYaxis().SetTitle("Number of ADCs") 00228 self.activeChannelIds.append( channelId.fullPackedData() ) 00229 return 00230 def runPath(self):
def Tester::TesterAlg::runPath | ( | self | ) |