/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes
Tester::TesterAlg Class Reference
Inheritance diagram for Tester::TesterAlg:
Inheritance graph
[legend]
Collaboration diagram for Tester::TesterAlg:
Collaboration graph
[legend]

List of all members.

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

Detailed Description

Definition at line 31 of file Tester.py.


Constructor & Destructor Documentation

def Tester::TesterAlg::__init__ (   self,
  name 
)

Definition at line 33 of file Tester.py.

00034                            :
00035         DybPythonAlg.__init__(self,name)
00036         return


Member Function Documentation

def Tester::TesterAlg::initialize (   self)

Definition at line 37 of file Tester.py.

00038                         :
00039         status = DybPythonAlg.initialize(self)
00040         if status.isFailure(): return status
00041         self.info("initializing")
00042 
00043         self.runNumber=None
00044         self.lastReadoutTime = None
00045         self.activeChannelIds = []
00046         self.activeDetectors = []
00047 
00048         return SUCCESS

def Tester::TesterAlg::execute (   self)

Definition at line 49 of file Tester.py.

00050                      :
00051         self.info("executing")
00052         
00053         # Access current data
00054         evt = self.evtSvc()
00055         readoutHdr = evt["/Event/Readout/ReadoutHeader"]
00056         if readoutHdr == None:
00057             self.error("Failed to get current readout header")
00058             return FAILURE
00059 
00060         readout = readoutHdr.readout()
00061         if readout == None:
00062             self.error("Failed to get readout from header")
00063             return FAILURE
00064 
00065         if not self.runNumber:
00066             # Initialize run number from raw data block
00067             self.runNumber = readout.rawEvent().runNumber()
00068 
00069         detector = readout.detector()
00070         if self.isNewDetector( detector ):
00071             self.prepareDetectorHistograms( detector )
00072         runPath = "/file1/diagnostics/run_%06d" % self.runNumber
00073         detectorName = readout.detector().detName()
00074         detectorPath = runPath + "/detector_" + detectorName
00075         # Loop over channel data
00076         nChannels = 0
00077         for channelPair in readout.channelReadout():
00078             channel = channelPair.second
00079             channelId = channel.channelId()
00080             if self.isNewChannel( channelId ):
00081                 self.prepareChannelHistograms( channelId )
00082 
00083             # Make path for histograms
00084             path = "%s/channel_board%02d_connector%02d" % (detectorPath,
00085                                                          channelId.board(),
00086                                                          channelId.connector())
00087             self.debug("Processing channel with path: "+path)
00088             # TDC data by channel
00089             for hitIdx in range(channel.size()):
00090                 self.stats[path + "/tdc"].Fill( channel.tdc(hitIdx) )
00091                 self.stats[path + "/adc"].Fill( channel.adc(hitIdx) )
00092             # Hit Rate
00093             channelIndex = channelId.board()*16 + channelId.connector()
00094             self.stats[detectorPath + "/hitRate"].Fill( channelIndex )
00095             nChannels += 1
00096 
00097         # Readout histograms
00098         # Number of hit channels
00099         self.stats[detectorPath + "/nChannels"].Fill( nChannels )
00100         # Number of Triggers by type
00101         self.stats[detectorPath + "/triggerType"].Fill( readout.triggerType() )
00102         # Time Between Triggered Readout
00103         if self.lastReadoutTime != None:
00104             # Skip first readout
00105             dT_trigger = TimeStamp( readout.triggerTime() )
00106             dT_trigger.Subtract( self.lastReadoutTime )
00107             self.debug("Dt Readout: "+str(dT_trigger.GetSeconds()))
00108             self.stats[detectorPath + "/dT_trigger"].Fill(
00109                                                       dT_trigger.GetSeconds() )
00110 
00111         # Set time of last readout
00112         self.lastReadoutTime = TimeStamp(readout.triggerTime())
00113         self.debug("done execute")
00114         return SUCCESS
        
def Tester::TesterAlg::finalize (   self)

Definition at line 115 of file Tester.py.

00116                       :
00117         self.info("finalizing")
00118         # Fill summary histograms
00119         for channelInt in self.activeChannelIds:
00120             channelId = FeeChannelId( channelInt )
00121             runPath = "/file1/diagnostics/run_%06d" % self.runNumber
00122             detectorName = channelId.detName()
00123             detectorPath = runPath + "/detector_" + detectorName
00124             path = "%s/channel_board%02d_connector%02d" % (detectorPath,
00125                                                          channelId.board(),
00126                                                          channelId.connector())
00127             channelIndex = channelId.board()*16 + channelId.connector()
00128             # ADC summary
00129             meanAdc = self.stats[path + "/adc"].GetMean()
00130             rmsAdc = self.stats[path + "/adc"].GetRMS()
00131             self.stats[detectorPath + "/meanAdc"].Fill(channelIndex, meanAdc)
00132             self.stats[detectorPath + "/rmsAdc"].Fill(channelIndex, rmsAdc)
00133         for detectorInt in self.activeDetectors:
00134             # Hit Rate summary
00135             detector = Detector( detectorInt )
00136             runPath = "/file1/diagnostics/run_%06d" % self.runNumber
00137             detectorPath = runPath + "/detector_" + detector.detName()
00138             nReadouts = self.stats[detectorPath + "/nChannels"].GetEntries()
00139             self.stats[detectorPath + "/hitRate"].Scale( 1 / nReadouts )
00140             self.stats[detectorPath + "/hitRate"].SetBit( TH1.kIsAverage )
00141 
00142         status = DybPythonAlg.finalize(self)
00143         return status

def Tester::TesterAlg::isNewChannel (   self,
  channelId 
)

Definition at line 144 of file Tester.py.

00145                                      :
00146         # Check if this channel has been seen
00147         if channelId.fullPackedData() in self.activeChannelIds:
00148             return False
00149         return True

def Tester::TesterAlg::isNewDetector (   self,
  detector 
)

Definition at line 150 of file Tester.py.

00151                                      :
00152         # Check if this detector has been seen
00153         if detector.fullPackedData() in self.activeDetectors:
00154             return False
00155         return True

def Tester::TesterAlg::prepareDetectorHistograms (   self,
  detector 
)

Definition at line 156 of file Tester.py.

00157                                                  :
00158         # Prepare the empty histograms for this detector
00159         path = self.runPath() + "/detector_" + detector.detName()
00160         self.debug("Making histograms at path: "+path)
00161         # Number of hit channels in each readout
00162         self.stats[path + "/nChannels"] = TH1F("nChannels",
00163                                                "Number of Hit Channels",
00164                                                250,0,250)
00165         hist = self.stats[path + "/nChannels"]
00166         hist.GetXaxis().SetTitle("Number of Hit Channels")
00167         hist.GetYaxis().SetTitle("Number of Triggered Readouts")
00168         # Number of Triggers by type
00169         self.stats[path + "/triggerType"] = TH1F("triggerType",
00170                                                  "Trigger Type",
00171                                                  4096,0,4096)
00172         hist = self.stats[path + "/triggerType"]
00173         hist.GetXaxis().SetTitle("Trigger Type")
00174         hist.GetYaxis().SetTitle("Number of Triggered Readouts")
00175         # Time Between Triggered Readout
00176         self.stats[path + "/dT_trigger"] = TH1F("dT_trigger",
00177                                                 "Time between triggers [s]",
00178                                                 1000,0,1)
00179         hist = self.stats[path + "/dT_trigger"]
00180         hist.GetXaxis().SetTitle("Time Between Triggered Readouts [s]")
00181         hist.GetYaxis().SetTitle("Number of Triggered Readouts / 1 ms")
00182         # Summary Histograms
00183         # Mean ADC by channel
00184         self.stats[path + "/meanAdc"] = TH1F("meanAdc",
00185                                    "Mean ADC by channel",
00186                                    300,0,300)
00187         hist = self.stats[path + "/meanAdc"]
00188         hist.GetXaxis().SetTitle("Channel Index (Board*16 + Connector)")
00189         hist.GetYaxis().SetTitle("Mean ADC value")
00190         # RMS ADC by channel
00191         self.stats[path + "/rmsAdc"] = TH1F("rmsAdc",
00192                                    "RMS ADC by channel (board*16 + connector)",
00193                                    300,0,300)
00194         hist = self.stats[path + "/rmsAdc"]
00195         hist.GetXaxis().SetTitle("Channel Index (Board*16 + Connector)")
00196         hist.GetYaxis().SetTitle("RMS of ADC values")
00197         # Hit Rate by channel
00198         self.stats[path + "/hitRate"] = TH1F("hitRate",
00199                                    "Hit Rate by channel",
00200                                    300,0,300)
00201         hist = self.stats[path + "/hitRate"]
00202         hist.GetXaxis().SetTitle("Channel Index (Board*16 + Connector)")
00203         hist.GetYaxis().SetTitle("Number of Hits / Number of Triggered Readouts")
00204         self.activeDetectors.append( detector.fullPackedData() )
00205         return

def Tester::TesterAlg::prepareChannelHistograms (   self,
  channelId 
)

Definition at line 206 of file Tester.py.

00207                                                  :
00208         # Prepare the empty histograms for this channel
00209         path = "%s/detector_%s/channel_board%02d_connector%02d" % (
00210                                                         self.runPath(),
00211                                                         channelId.detName(),
00212                                                         channelId.board(),
00213                                                         channelId.connector())
00214         self.debug("Making histograms at path: "+path)
00215         # TDC data by channel
00216         self.stats[path + "/tdc"] = TH1F("tdc",
00217                                          "TDC Values",
00218                                          4096,0,4096)
00219         hist = self.stats[path + "/tdc"]
00220         hist.GetXaxis().SetTitle("TDC value")
00221         hist.GetYaxis().SetTitle("Number of TDCs")
00222         # ADC data by channel
00223         self.stats[path + "/adc"] = TH1F("adc",
00224                                          "ADC Values",
00225                                          4096,0,4096)
00226         hist = self.stats[path + "/adc"]
00227         hist.GetXaxis().SetTitle("ADC value")
00228         hist.GetYaxis().SetTitle("Number of ADCs")
00229         self.activeChannelIds.append( channelId.fullPackedData() )
00230         return

def Tester::TesterAlg::runPath (   self)

Definition at line 231 of file Tester.py.

00232                      :
00233         # Return standard run path
00234         return "/file1/diagnostics/run_%06d" % self.runNumber
    

Member Data Documentation

Definition at line 37 of file Tester.py.

Definition at line 37 of file Tester.py.

Definition at line 37 of file Tester.py.

Definition at line 37 of file Tester.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:54:09 for RunDiagnostics by doxygen 1.7.4