Public Member Functions | |
def | __init__ |
def | initialize |
def | execute |
def | finalize |
def | isNewChannel |
def | isNewDetector |
def | prepareDetectorHistograms |
def | prepareChannelHistograms |
Public Attributes | |
lastReadoutTime | |
activeChannelIds | |
activeDetectors |
Definition at line 29 of file OnlineOfflineTest.py.
def DataQuality::OnlineOfflineTest::OnlineOfflineAlg::__init__ | ( | self, | ||
name | ||||
) |
Definition at line 31 of file OnlineOfflineTest.py.
00031 : 00032 DybPythonAlg.__init__(self,name) 00033 return 00034 def initialize(self):
def DataQuality::OnlineOfflineTest::OnlineOfflineAlg::initialize | ( | self | ) |
Definition at line 35 of file OnlineOfflineTest.py.
00035 : 00036 status = DybPythonAlg.initialize(self) 00037 if status.isFailure(): return status 00038 self.info("initializing") 00039 00040 self.lastReadoutTime = None 00041 self.activeChannelIds = [] 00042 self.activeDetectors = [] 00043 00044 return SUCCESS 00045 def execute(self):
def DataQuality::OnlineOfflineTest::OnlineOfflineAlg::execute | ( | self | ) |
Definition at line 46 of file OnlineOfflineTest.py.
00046 : 00047 self.info("executing") 00048 00049 # Access current data 00050 evt = self.evtSvc() 00051 readoutHdr = evt["/Event/Readout/ReadoutHeader"] 00052 if readoutHdr == None: 00053 self.error("Failed to get current readout header") 00054 return FAILURE 00055 00056 readout = readoutHdr.readout() 00057 if readout == None: 00058 self.error("Failed to get readout from header") 00059 return FAILURE 00060 00061 detector = readout.detector() 00062 if self.isNewDetector( detector ): 00063 self.prepareDetectorHistograms( detector ) 00064 detectorName = readout.detector().detName() 00065 detectorPath = "/file1/" + detectorName 00066 # Loop over channel data 00067 nChannels = 0 00068 for channelPair in readout.channelReadout(): 00069 channel = channelPair.second 00070 channelId = channel.channelId() 00071 if self.isNewChannel( channelId ): 00072 self.prepareChannelHistograms( channelId ) 00073 00074 # Make path for histograms 00075 path = "%s/board_%d_connector_%d" % (detectorPath, 00076 channelId.board(), 00077 channelId.connector()) 00078 self.debug("Processing channel with path: "+path) 00079 # TDC data by channel 00080 for tdc in channel.tdc(): 00081 self.debug("Type of tdc hist: "+str(type( self.stats[path + "/tdc"] ))) 00082 self.stats[path + "/tdc"].Fill( tdc ) 00083 self.debug("Filled path with tdc: "+str(tdc)) 00084 # ADC data by channel 00085 self.debug("Processing adc data with path: "+path) 00086 for adcPair in channel.adc(): 00087 adcClock = adcPair.first 00088 adc = adcPair.second 00089 self.stats[path + "/adc"].Fill( adc ) 00090 # Hit Rate 00091 channelIndex = channelId.board()*16 + channelId.connector() 00092 self.stats[detectorPath + "/hitRate"].Fill( channelIndex ) 00093 nChannels += 1 00094 00095 # Readout histograms 00096 self.debug("Processing readout with path: "+detectorPath) 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 DataQuality::OnlineOfflineTest::OnlineOfflineAlg::finalize | ( | self | ) |
Definition at line 115 of file OnlineOfflineTest.py.
00115 : 00116 self.info("finalizing") 00117 # Fill summary histograms 00118 for channelInt in self.activeChannelIds: 00119 channelId = FeeChannelId( channelInt ) 00120 detectorPath = "/file1/" + channelId.detName() 00121 path = "%s/board_%d_connector_%d" % (detectorPath, 00122 channelId.board(), 00123 channelId.connector()) 00124 channelIndex = channelId.board()*16 + channelId.connector() 00125 # ADC summary 00126 meanAdc = self.stats[path + "/adc"].GetMean() 00127 rmsAdc = self.stats[path + "/adc"].GetRMS() 00128 self.stats[detectorPath + "/meanAdc"].Fill(channelIndex, meanAdc) 00129 self.stats[detectorPath + "/rmsAdc"].Fill(channelIndex, rmsAdc) 00130 for detectorInt in self.activeDetectors: 00131 # Hit Rate summary 00132 detector = Detector( detectorInt ) 00133 detectorPath = "/file1/" + detector.detName() 00134 nReadouts = self.stats[detectorPath + "/nChannels"].GetEntries() 00135 self.stats[detectorPath + "/hitRate"].Scale( 1 / nReadouts ) 00136 00137 status = DybPythonAlg.finalize(self) 00138 return status 00139 def isNewChannel(self, channelId):
def DataQuality::OnlineOfflineTest::OnlineOfflineAlg::isNewChannel | ( | self, | ||
channelId | ||||
) |
Definition at line 140 of file OnlineOfflineTest.py.
00140 : 00141 # Check if this channel has been seen 00142 if channelId.fullPackedData() in self.activeChannelIds: 00143 return False 00144 return True 00145 def isNewDetector(self, detector):
def DataQuality::OnlineOfflineTest::OnlineOfflineAlg::isNewDetector | ( | self, | ||
detector | ||||
) |
Definition at line 146 of file OnlineOfflineTest.py.
00146 : 00147 # Check if this detector has been seen 00148 if detector.fullPackedData() in self.activeDetectors: 00149 return False 00150 return True 00151 def prepareDetectorHistograms(self, detector):
def DataQuality::OnlineOfflineTest::OnlineOfflineAlg::prepareDetectorHistograms | ( | self, | ||
detector | ||||
) |
Definition at line 152 of file OnlineOfflineTest.py.
00152 : 00153 # Prepare the empty histograms for this detector 00154 path = "/file1/" + detector.detName() 00155 self.debug("Making histograms at path: "+path) 00156 # Number of hit channels in each readout 00157 self.stats[path + "/nChannels"] = TH1F("nChannels", 00158 "Number of Hit Channels", 00159 250,0,250) 00160 hist = self.stats[path + "/nChannels"] 00161 hist.GetXaxis().SetTitle("Number of Hit Channels") 00162 hist.GetYaxis().SetTitle("Number of Triggered Readouts") 00163 # Number of Triggers by type 00164 self.stats[path + "/triggerType"] = TH1F("triggerType", 00165 "Trigger Type", 00166 4096,0,4096) 00167 hist = self.stats[path + "/triggerType"] 00168 hist.GetXaxis().SetTitle("Trigger Type") 00169 hist.GetYaxis().SetTitle("Number of Triggered Readouts") 00170 # Time Between Triggered Readout 00171 self.stats[path + "/dT_trigger"] = TH1F("dT_trigger", 00172 "Time between triggers [s]", 00173 1000,0,1) 00174 hist = self.stats[path + "/dT_trigger"] 00175 hist.GetXaxis().SetTitle("Time Between Triggered Readouts [s]") 00176 hist.GetYaxis().SetTitle("Number of Triggered Readouts / 1 ms") 00177 # Summary Histograms 00178 # Mean ADC by channel 00179 self.stats[path + "/meanAdc"] = TH1F("meanAdc", 00180 "Mean ADC by channel", 00181 300,0,300) 00182 hist = self.stats[path + "/meanAdc"] 00183 hist.GetXaxis().SetTitle("Channel Index (Board*16 + Connector)") 00184 hist.GetYaxis().SetTitle("Mean ADC value") 00185 # RMS ADC by channel 00186 self.stats[path + "/rmsAdc"] = TH1F("rmsAdc", 00187 "RMS ADC by channel (board*16 + connector)", 00188 300,0,300) 00189 hist = self.stats[path + "/rmsAdc"] 00190 hist.GetXaxis().SetTitle("Channel Index (Board*16 + Connector)") 00191 hist.GetYaxis().SetTitle("RMS of ADC values") 00192 # Hit Rate by channel 00193 self.stats[path + "/hitRate"] = TH1F("hitRate", 00194 "Hit Rate by channel", 00195 300,0,300) 00196 hist = self.stats[path + "/hitRate"] 00197 hist.GetXaxis().SetTitle("Channel Index (Board*16 + Connector)") 00198 hist.GetYaxis().SetTitle("Number of Hits / Number of Triggered Readouts") 00199 self.activeDetectors.append( detector.fullPackedData() ) 00200 return 00201 def prepareChannelHistograms(self, channelId):
def DataQuality::OnlineOfflineTest::OnlineOfflineAlg::prepareChannelHistograms | ( | self, | ||
channelId | ||||
) |
Definition at line 202 of file OnlineOfflineTest.py.
00202 : 00203 # Prepare the empty histograms for this channel 00204 path = "/file1/%s/board_%d_connector_%d" % (channelId.detName(), 00205 channelId.board(), 00206 channelId.connector()) 00207 self.debug("Making histograms at path: "+path) 00208 # TDC data by channel 00209 self.stats[path + "/tdc"] = TH1F("tdc", 00210 "TDC Values", 00211 4096,0,4096) 00212 hist = self.stats[path + "/tdc"] 00213 hist.GetXaxis().SetTitle("TDC value") 00214 hist.GetYaxis().SetTitle("Number of TDCs") 00215 # ADC data by channel 00216 self.stats[path + "/adc"] = TH1F("adc", 00217 "ADC Values", 00218 4096,0,4096) 00219 hist = self.stats[path + "/adc"] 00220 hist.GetXaxis().SetTitle("ADC value") 00221 hist.GetYaxis().SetTitle("Number of ADCs") 00222 self.activeChannelIds.append( channelId.fullPackedData() ) 00223 return 00224 ##### Job Configuration for nuwa.py ########################################
Definition at line 40 of file OnlineOfflineTest.py.
Definition at line 41 of file OnlineOfflineTest.py.
Definition at line 42 of file OnlineOfflineTest.py.