Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

EvtCli Class Reference

Event handler client. More...

Inheritance diagram for EvtCli:

Inheritance graph
[legend]
Collaboration diagram for EvtCli:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 __init__ (debug=0, port=EvtCliIO.PortNumber)
 Event client constructor.
 setDebug (debug)
 Set the debug mode.
 readEvent (dat=None)
 Read an event.
 getGGLTStatus ()
 Retrieve the GGLT status.
 getGGLTStatusStr ()
 Return the string equivalent of the GGLT status code.
 getOnlineStatus ()
 Retrieve the Online status code.
 getEvtStatus ()
 Return the event status from the event header.
 getContributionStatus ()
 Return the contribution status.
 getContributionStatusStr ()
 Return the contribution status string.
 getOnlineStatusStr ()
 Retrieve the string equivalent of the Online status code.
 getEvtSize ()
 Return the event size.
 isErrorEvent ()
 isTrgParityErrorEvent ()
 isPacketErrorEvent ()
 isSweepEvent ()
 Determine if a sweep event is received.
 isGGLTStatus (status=None)
 Determine if the current event is bad.
 checkOnlineStatus (status, mask)
 Checks if the bit mask mask matches the status that is assumed as an Online status.
 checkGGLTstatus (status, mask)
 Checks if the bit mask mask matches the status that is assumed as a GGLT status.
 readEventSocket ()
 setCurrentContribution (contributionId)
 Given a contribution id, set the current contribution data needed for the parsing routines.
 getCurrentContribution ()
 Return the integer id of the current contribution.
 getContributionList ()
 Walk through the whole event and construct a list of contribution id strings.
 dumpContributionData ()
 Prints out information pertaining to the current contribution.
 evGetTimestamp ()
 Return the timestamp of the event in seconds.
 evGetTimebase ()
 Return the timestamp of the event derived from the PPC timebase register.
 evGetEvtSeqMSW ()
 Return the MSW portion of the event sequence.
 evGetEvtSequence ()
 Return the Event Sequence.
 getUserId ()
 Return the user id passed to the event client.
 evGetTKR_Accepts (pAccept)
 Walks tower event contribution to the TKR accepts data.
 evGetCAL_NumAccepts ()
 Counts the number of hit calorimeter logs in the tower event contribution.
 evDumpGEM ()
 Parses the GEM contribution by populating the data in self.evt.gem.
 evDumpGEM_Veto_List (offset)
 Parses the Veto List block of the GEM contribution.
 getWord (wordOffset)
 Unpack and return a 16-bit word value located at wordOffset.
 getDWord (dWordOffset)
 Unpack and return a 32-bit word value located at dWordOffset.
 getByte (byteOffset)
 Unpack and return an 8-bit byte value located at byteOffset.
 evGetCAL_Logs ()
 Walks tower event contribution to the CAL log data.
 evGetCAL_LogAccepts ()
 Walks the tower event contribution to the calorimeter log accepts word.
 evDumpCAL_LogAccepts ()
 Decodes the log accepts word and stores it in evt.CAL_LogAccepts.
 evDumpCAL_Logs ()
 Decodes all the log data for the event and stores it in evt.CAL_LogData.
 evGetSummary ()
 Return the offset to the summary word of the current contribution.
 evGetTKR_StripN (pAccepts, stripN, stripData=None)
 Fetches a 12-bit strip word from pAccepts, indexed by stripN.
 evDumpTKR ()
 Decodes all the TKR event data and stores it in the event object.
 evBitCount (x)
 Count the number of set bits in x.
 evGetTKR_NumStrips ()
 evGetTKR_TOT ()
 Returns pointer to start of tracker TOT list.
 evGetTKR_NumAccepts ()
 Counts the number of accepted TKR layer-ends.
 evGetTEM_Diagnostic ()
 Returns pointer to start of diagnostic event data.
 evGetTEM_Error ()
 Returns pointer to the error word contribution of event data.
 evDumpTEM_Error (forcePrint=0)
 Decodes the event error contribution.
 evDumpDiagnostic ()
 Decodes the event diagnostic contribution.
 evDumpSummary (minEvSize=24)
 Decodes the event summary word.
 evDumpAEM_Vetos ()
 Decodes the AEM veto hit list contribution.
 evDumpAEM_Accepts ()
 Decodes the AEM accept list contribution.
 evGetAEM_PHA (cbl)
 Returns pointer to start of AEM PHA values.
 evGetAEM_Vec (cbl, type)
 Returns the 18-bit vector for cable specified by cbl and type.
 evDumpAEM_PHA ()
 Decodes the AEM PHA contribution.
 evDumpEventAEM_G2 ()
 Given a pointer to AEM event contribution print its contents.
 evDumpEventAEM ()
 The new AEM event parsing routine.
 print_EOE_Warning ()
 Print warning if we have reached the end of the contribution prematurely.

Detailed Description

Event handler client.

Contents:

Receives an event from TCP socket or a file stream and parses it into the evt object.

Overview:

The event client is responsible for communicating with the event server and retrieve events triggered by a script or an external source. The source of the event can be either a TCP socket or an archive file.

The event client uses lazy parsing to parse the event. This means the user application needs to call the parsing routines that corresponds to the section of the event that the user is interested in. The parser methods populate event objects inside the Evt class in the event client, so after the parser method is called these objects can be accessed or iterated over. The parser methods only apply to the current contribution. By default after readEvent() the first contribution after the GEM contribution is the current contribution. Use the setCurrentContribution method to change the current contribution. Use the getContributionList method to find out which contributions exist in the event.

Available parser methods:

Contribution related methods:

Retrieving the timestamp and timebase:

Usage:

For reading events from a socket:

    from gEvtCli import *
    ec = EvtCli(debug=0)
    ec.connect('gitot')
    while ec.readEvent() == 0:
      ec.setCurrentContribution(...)
      if ec.getContributionStatus() == 0:
        ec.evDumpXXX()
        :
      else:
        print "Error %s in contribution %s ",
          (ec.getContributionStatusStr(), cId)
    ec.disconnect()
For reading events from an archived event file:
    from gEvtCli import *
    ec = EvtCli(debug=0)
    ec.open('030305165528.ldf')
    while ec.readEvent() == 0:
      ec.setCurrentContribution(...)
      if ec.getContributionStatus() == 0:
        ec.evDumpXXX()
        :
      else:
        print "Error %s in contribution %s ",
          (ec.getContributionStatusStr(), cId)
    ec.close()
For looping over contributions:
    from gEvtCli import *
    ec = EvtCli(debug=0)
    ec.connect('gitot')
    status = ec.readEvent()
    contList = ec.getContributionList()
    for cId in contList:
      ec.setCurrentContribution(cId)
      if ec.getContributionStatus() == 0:
        ec.evDumpSummary()
        if cId.startswith('TEM'):
          ec.evDumpCAL_LogAccepts()
          ec.evDumpCAL_Logs()
          ec.evDumpTKR()
          ec.evDumpTEM_Error()
          ec.evDumpDiagnostic()
        elif cId == 'AEM':
          ec.evDumpEventAEM()
      else:
        print "Error %s in contribution %s ",
          (ec.getContributionStatusStr(), cId)

Definition at line 795 of file gEvtCli.py.


Member Function Documentation

__init__ debug  = 0,
port  = EvtCliIO.PortNumber
 

Event client constructor.

Parameters:
debug Debug mode (0=Debug, 1=No debug)

Reimplemented from EvtCliIO.

checkGGLTstatus status  ,
mask 
 

Checks if the bit mask mask matches the status that is assumed as a GGLT status.

Parameters:
status The status word to be checked against
mask The mask bit(s) to be checked
Returns:
1 if there is a match 0 if there is no match

checkOnlineStatus status  ,
mask 
 

Checks if the bit mask mask matches the status that is assumed as an Online status.

Parameters:
status The status word to be checked against
mask The mask bit(s) to be checked
Returns:
1 if there is a match 0 if there is no match

evBitCount  ) 
 

Count the number of set bits in x.

Parameters:
x 32-bit word value
Returns:
Set bit count

evDumpAEM_Accepts  ) 
 

Decodes the AEM accept list contribution.

This method is used by the old AEM event parser evDumpEventAEM_G2

evDumpAEM_PHA  ) 
 

Decodes the AEM PHA contribution.

This method is used by the old AEM event parser evDumpEventAEM_G2

Given a pointer to AEM event contribution print the PHA values.

evDumpAEM_Vetos  ) 
 

Decodes the AEM veto hit list contribution.

This method is used by the old AEM event parser evDumpEventAEM_G2

evDumpEventAEM  ) 
 

The new AEM event parsing routine.

This parser works according to the latest specs where not all cable contributions are guaranteed to be provided.

evDumpEventAEM_G2  ) 
 

Given a pointer to AEM event contribution print its contents.

This method is the old G2 compatible AEM event parser, please use the new event parser evDumpEventAEM for G3 based AEM events.

evDumpGEM  ) 
 

Parses the GEM contribution by populating the data in self.evt.gem.

Requires calling evtCli.setCurrentContribution(EvtCli.GEM) before usage.

evDumpGEM_Veto_List offset   ) 
 

Parses the Veto List block of the GEM contribution.

Used by evDumpGEM

Parameters:
offset 32-bit word offset to the veto list block

evDumpSummary minEvSize  = 24  ) 
 

Decodes the event summary word.

Given a pointer to tower event contribution print the event summary word.

Parameters:
minEvSize Minimum event size w/o error (default=24)

evDumpTEM_Error forcePrint  = 0  ) 
 

Decodes the event error contribution.

If an error contribution is present this prints up to 20 16-bit words of the error contribution.

Parameters:
forcePrint If specified, dump the error even if in non-debug mode

evGetAEM_PHA cbl   ) 
 

Returns pointer to start of AEM PHA values.

This method is used by the old AEM event parser evDumpEventAEM_G2

Parameters:
cbl Which cable is being decoded

evGetAEM_Vec cbl  ,
type 
 

Returns the 18-bit vector for cable specified by cbl and type.

This method is used by the old AEM event parser evDumpEventAEM_G2

Parameters:
cbl Which cable is being decoded
type ACD vector type
Returns:
18-bit vector

evGetCAL_LogAccepts  ) 
 

Walks the tower event contribution to the calorimeter log accepts word.

Given a pointer to an entire TEM event contribution walk the data structure returning a pointer to the calorimeter log accepts word.

The 32-bit calorimeter log accepts word is immediately after the event summary word, i.e. the 2nd 32-bit word in the data.

Returns:
Offset to the calorimeter log accepts word.

evGetCAL_Logs  ) 
 

Walks tower event contribution to the CAL log data.

Given a pointer to an entire TEM event contribution walk the data structure to the beginning of the calorimeter log data.

Returns:
Offset to the beginning of the calorimeter log data

evGetCAL_NumAccepts  ) 
 

Counts the number of hit calorimeter logs in the tower event contribution.

Given a pointer to an entire TEM event contribution walk the data structure to the calorimeter log accepts word and return the sum of the number of hit logs.

Returns:
Number of hit logs

evGetEvtSeqMSW  ) 
 

Return the MSW portion of the event sequence.

Returns:
MSW portion of the event sequence.

evGetEvtSequence  ) 
 

Return the Event Sequence.

Returns:
Event sequence.

evGetSummary  ) 
 

Return the offset to the summary word of the current contribution.

In a contribution, first word after the header is the summary word

Returns:
Offset to the summary word of the current contribution

evGetTEM_Diagnostic  ) 
 

Returns pointer to start of diagnostic event data.

Caller should check the event summary word if a diagnostic contribution is present before calling this function.

Returns:
Offset to start of diagnostic event data

evGetTEM_Error  ) 
 

Returns pointer to the error word contribution of event data.

Caller should check the event summary word if an error contribution is present before calling this function.

Returns:
Offset to the error word contribution

evGetTimebase  ) 
 

Return the timestamp of the event derived from the PPC timebase register.

This is a 64 bit value that increments at an SBC implementation dependant rate (60 nS on MVME2306s). The value is reset at PPC reset time.

Returns:
Timestamp of the event in PPC timebase ticks.

evGetTimestamp  ) 
 

Return the timestamp of the event in seconds.

The resolution of this timestamp is 1/60th of a second, by default. Consult VxWorks documentation for sysClkRateSet() and clock_setres() to see how to change this default. Beware that increasing the resolution from the default may cause adverse effects due to the increased interrupt rate generated.

Returns:
Timestamp of the event in seconds.

evGetTKR_Accepts pAccept   ) 
 

Walks tower event contribution to the TKR accepts data.

Fills in the evGetTKR_Accepts structure pointed to by pAccept with the TKR accepts data. Also returns a pointer to the TKR accepts information.

Parameters:
pAccept Array to be filled with TKR accepts data
Returns:
Offset to the start of TKR accepts data

evGetTKR_NumAccepts  ) 
 

Counts the number of accepted TKR layer-ends.

Returns:
Number of accepted TKR layer-ends.

evGetTKR_NumStrips  ) 
 

Returns number of hit strips in the event

Returns:
Number of hit strips

evGetTKR_StripN pAccepts  ,
stripN  ,
stripData  = None
 

Fetches a 12-bit strip word from pAccepts, indexed by stripN.

pAccepts points to the top of the accepts data ... the strip data starts 72 bits ( 8 * 9 ) from the beginning of accepts. I.e. it starts 8 bits into the 3rd 32-bit word.

Parameters:
pAccepts Pointer to 32-bit aligned tracker event data
stripN The index of the 12-bit strip to fetch from pAccepts
stripData Optional argument, if passed, avoid creating the object
Returns:
An evTKR_Strip object instance.

evGetTKR_TOT  ) 
 

Returns pointer to start of tracker TOT list.

Returns:
Offset to the tracker TOT list

getByte byteOffset   ) 
 

Unpack and return an 8-bit byte value located at byteOffset.

Parameters:
byteOffset Pointer to data
Returns:
8-bit byte value

getContributionList  ) 
 

Walk through the whole event and construct a list of contribution id strings.

Returns:
A list of contributors that have contributed to the current event

getContributionStatus  ) 
 

Return the contribution status.

Returns:
Contribution status

getContributionStatusStr  ) 
 

Return the contribution status string.

Returns:
Contribution status string

getCurrentContribution  ) 
 

Return the integer id of the current contribution.

Returns:
Current constribution id

getDWord dWordOffset   ) 
 

Unpack and return a 32-bit word value located at dWordOffset.

Parameters:
dWordOffset Pointer to data
Returns:
32-bit word value

getEvtSize  ) 
 

Return the event size.

Returns:
Event size

getGGLTStatus  ) 
 

Retrieve the GGLT status.

If this status value is non zero then the event is considered "bad"

getOnlineStatus  ) 
 

Retrieve the Online status code.

See getOnlineStatusStr method for a list of possible errors

getOnlineStatusStr  ) 
 

Retrieve the string equivalent of the Online status code.

The error can be one of the following:

GGLT_STATUS_ERROR : A bad event was received. Call getGGLTStatusStr method for the description. MINIMAL_SIZE_ERROR : The event size was below the acceptable size. EOE_ERROR : End of event was reached before the parse completed. UNPACK_ERROR : There was an error while unpacking part of the event for parsing. IO_ERROR : An I/O error occurred while retrieving the event (socket or file). EVENT_VERSION_MISMATCH: An event with an old or unsupported format was received. PLAYBACK_ERROR : End of file was received while playing back an event archive file. READ_TIMEOUT_ERROR : A read timeout occurred while waiting for the event to be retrieved (Set by rcTransitions). EOF_ERROR : End of file is reached while reading the event file.

Returns:
Online status string

getUserId  ) 
 

Return the user id passed to the event client.

Returns:
Current user id

getWord wordOffset   ) 
 

Unpack and return a 16-bit word value located at wordOffset.

Parameters:
wordOffset Pointer to data
Returns:
16-bit word value

isErrorEvent  ) 
 

Determines whether at least one contribution has the error bit set in its summary word.

Returns:
1: If at least one contribution has an error. 0: Otherwise

isGGLTStatus status  = None  ) 
 

Determine if the current event is bad.

User script can call this method in process() to determine if the current event is a bad event (gglt_status != 0).

Parameters:
Optional status value
Returns:
0: Not a bad event. 1: A bad event.

isPacketErrorEvent  ) 
 

Determines whether at least one contribution has a non-zero packet error set in the EBF contribution.

Returns:
1: If at least one contribution has an error. 0: Otherwise

isSweepEvent  ) 
 

Determine if a sweep event is received.

User script can call this method in process() to determine if the current event is a sweep event. A try block around the call should be used in case a bad event is received.

Returns:
0: Not a sweep event. 1: A sweep event.

isTrgParityErrorEvent  ) 
 

Determines whether at least one contribution has the trigger parity error bit set in its summary word.

Returns:
1: If at least one contribution has an error. 0: Otherwise

readEvent dat  = None  ) 
 

Read an event.

Reads one event from an archive file or socket

Parameters:
dat If not None then interpret this data as event instead
Returns:
oes_status

setCurrentContribution contributionId   ) 
 

Given a contribution id, set the current contribution data needed for the parsing routines.

Parameters:
contributionId Integer contribution id
Returns:
The offset to the contribution requested. -1 If the contribution requested is not found or contribution offset was found to be larger than the event size Note: Use getContributionStatus() method after calling this routine to find out if the contribution has an error.

setDebug debug   ) 
 

Set the debug mode.

Parameters:
debug Debug mode The following debug modes are available and can be added together for combinations: 0: No Debug 1: Debug All 2: Event Dump 4: Warnings 8: Parser Output 16: Error Output


The documentation for this class was generated from the following file:
Generated on Fri Jul 21 13:27:00 2006 for LATTE R04-12-00 by doxygen 1.4.3