Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Cpacket.h File Reference
#include "phenixOnline.h"
#include "packetPublic.h"
#include "packetHdr.h"
#include "formatError.h"
+ Include dependency graph for Cpacket.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

INLINE_P LOGIC_ret currentPacket (PACKET_ptr)
 
INLINE_P VALUE_ret getPacketLength (PACKET_ptr)
 
INLINE_P VALUE_ret getPacketHdrLength (PACKET_ptr)
 
INLINE_P VALUE_ret getPacketHdrVersion (PACKET_ptr)
 
INLINE_P LOGIC_ret setPacketHdrVersion (PACKET_ptr, UINT)
 
INLINE_P LOGIC_ret setPacketHdrLength (PACKET_ptr, UINT)
 
INLINE_P LOGIC_ret setPacketLength (PACKET_ptr, PHDWORD)
 
PTR_ret findPacketEnd (PACKET_ptr)
 
PTR_ret findPacketDataStart (PACKET_ptr)
 
VALUE_ret extendPacketDataBlock (const PACKET_ptr, UINT, int)
 
VALUE_ret extendPacketDebugBlock (const PACKET_ptr, UINT, int)
 
VALUE_ret extendPacketErrorBlock (const PACKET_ptr, UINT, int)
 
VALUE_ret extendPacketLength (const PACKET_ptr, UINT, int)
 
LOGIC_ret removePacketPadding (PACKET_ptr)
 
INLINE_P void endianSwapError (PACKETERROR *outError, PACKETERROR *inError)
 
VALUE_ret makePacketHdr (const PACKET_ptr, UINT)
 
VALUE_ret getPacketDataLength (const PACKET_ptr)
 
VALUE_ret getPacketDebugLength (const PACKET_ptr)
 
VALUE_ret getPacketErrorLength (const PACKET_ptr)
 
VALUE_ret getPacketNumErrors (const PACKET_ptr)
 
VALUE_ret getPacketPadding (const PACKET_ptr)
 
VALUE_ret getPacketId (const PACKET_ptr)
 
VALUE_ret getPacketStatus (PACKET_ptr)
 
VALUE_ret getPacketStructure (const PACKET_ptr)
 
VALUE_ret getPacketEndianism (const PACKET_ptr)
 
VALUE_ret getPacketDataDescrLength (const PACKET_ptr)
 
LOGIC_ret setPacketDebugLength (PACKET_ptr, UINT)
 
LOGIC_ret setPacketNumErrors (PACKET_ptr, UINT)
 
LOGIC_ret setPacketEndianism (PACKET_ptr, UINT)
 
LOGIC_ret setPacketId (PACKET_ptr, UINT)
 
LOGIC_ret setPacketPadding (PACKET_ptr, UINT)
 
LOGIC_ret setPacketStructure (PACKET_ptr, UINT)
 
LOGIC_ret setPacketStatus (PACKET_ptr, UINT)
 
LOGIC_ret setPacketErrorLength (PACKET_ptr, UINT)
 
LOGIC_ret setPacketDataDescrLength (PACKET_ptr, UINT)
 
VALUE_ret orPacketStatus (PACKET_ptr, UINT)
 
LOGIC_ret validPacketHdr (PACKET_ptr)
 
LOGIC_ret emptyPacket (PACKET_ptr)
 
PTR_ret findPacketDataDescr (PACKET_ptr)
 
PTR_ret findPacketDataEnd (PACKET_ptr)
 
PTR_ret findPacketDebugStart (PACKET_ptr)
 
PTR_ret findPacketErrorStart (PACKET_ptr)
 
VALUE_ret adjustPacketDataLength (PACKET_ptr, int)
 
VALUE_ret adjustPacketErrorLength (PACKET_ptr, int)
 
VALUE_ret adjustPacketDebugLength (PACKET_ptr, int)
 

Function Documentation

VALUE_ret adjustPacketDataLength ( PACKET_ptr  ,
int   
)

Definition at line 562 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 562 of file Cpacket.C

References adjustPacketDataLengthV, getPacketHdrVersion(), and valueFailure.

Referenced by extendPacketDataBlock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_ret adjustPacketDebugLength ( PACKET_ptr  ,
int   
)

Definition at line 571 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 571 of file Cpacket.C

References adjustPacketDebugLengthV, getPacketHdrVersion(), and valueFailure.

Referenced by extendPacketDebugBlock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_ret adjustPacketErrorLength ( PACKET_ptr  ,
int   
)

Definition at line 580 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 580 of file Cpacket.C

References adjustPacketErrorLengthV, getPacketHdrVersion(), and valueFailure.

Referenced by extendPacketErrorBlock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

INLINE_D LOGIC_ret currentPacket ( PACKET_ptr  packet_ptr)

Definition at line 255 of file Cpacket.h.

View newest version in sPHENIX GitHub at line 255 of file Cpacket.h

References currentPacketHdrVersion, and getPacketHdrVersion().

+ Here is the call graph for this function:

LOGIC_ret emptyPacket ( PACKET_ptr  )

Definition at line 553 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 553 of file Cpacket.C

References emptyPacketV, getPacketHdrVersion(), logicFailure, and valueFailure.

Referenced by startUnstructDataWrite(), and storePacketHits().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

INLINE_D void endianSwapError ( PACKETERROR outError,
PACKETERROR inError 
)

Definition at line 261 of file Cpacket.h.

View newest version in sPHENIX GitHub at line 261 of file Cpacket.h

References endianSwapErrorV1().

+ Here is the call graph for this function:

VALUE_ret extendPacketDataBlock ( const PACKET_ptr  ,
UINT  ,
int   
)

Definition at line 67 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 67 of file Cpacket.C

References adjustPacketDataLength(), extendPacketLength(), and valueFailure.

Referenced by startUnstructDataWrite(), and storePacketHits().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_ret extendPacketDebugBlock ( const PACKET_ptr  ,
UINT  ,
int   
)

Definition at line 90 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 90 of file Cpacket.C

References adjustPacketDebugLength(), extendPacketLength(), and valueFailure.

Referenced by reservePacketDebugData().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_ret extendPacketErrorBlock ( const PACKET_ptr  ,
UINT  ,
int   
)

Definition at line 113 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 113 of file Cpacket.C

References adjustPacketErrorLength(), extendPacketLength(), and valueFailure.

Referenced by appendPacketError().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_ret extendPacketLength ( const PACKET_ptr  ,
UINT  ,
int   
)

Definition at line 136 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 136 of file Cpacket.C

References FORMAT_ERR_BUFFER_OVERFLOW, getPacketLength(), packetQuantum, removePacketPadding(), setPacketError(), setPacketLength(), setPacketPadding(), and valueFailure.

Referenced by extendPacketDataBlock(), extendPacketDebugBlock(), and extendPacketErrorBlock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PTR_ret findPacketDataDescr ( PACKET_ptr  )

Definition at line 534 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 534 of file Cpacket.C

References findPacketDataDescrV, getPacketHdrVersion(), ptrFailure, and valueFailure.

Referenced by getUnstructPacketDataPadding(), getUnstructPacketHitFormat(), getUnstructPacketWordSize(), makeUnstructPacketDataDescr(), setUnstructPacketDataPadding(), setUnstructPacketHitFormat(), and setUnstructPacketWordSize().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PTR_ret findPacketDataEnd ( PACKET_ptr  )

Definition at line 507 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 507 of file Cpacket.C

References findPacketDataEndV, getPacketHdrVersion(), ptrFailure, and valueFailure.

+ Here is the call graph for this function:

PTR_ret findPacketDataStart ( PACKET_ptr  )

Definition at line 53 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 53 of file Cpacket.C

References getPacketDataDescrLength(), getPacketHdrLength(), ptrFailure, and validPacketHdr().

Referenced by Packet_fvtx_dcm0::calculate_parity(), Packet_id2evt::decode(), Packet_id4evt::decode(), Packet_iddigitizerv2::decode(), Packet_iddigitizerv3::decode(), Packet_idll1v1::decode(), Packet_gl1psum::decode(), Packet_idcstr::decode(), Packet_gl1_evclocks::decode(), Packet_cdevir::decode(), Packet_starscaler::decode(), Packet_cdevwcm::decode(), Packet_cdevmadch::decode(), Packet_cdevbpm::decode(), Packet_cdevdvm::decode(), Packet_cdevpoltarget::decode(), Packet_hbd_fpgashort::decode(), Packet_hbd_fpga::decode(), Packet_cdevbuckets::decode(), Packet_cdevring::decode(), Packet_fvtx_dcm0::decode(), Packet_cdevringnopol::decode(), Packet_gl1p::decode(), Packet_id4scaler::decode(), Packet_cdevpolarimeter::decode(), Packet_gl1::decode(), Packet_fvtx_dcm0::decode_misc(), Packet_gl1p::demangle(), Packet_gl1::demangle(), Packet_gl1_evclocks::dump(), Packet_gl1p::dump(), Packet_id4scaler::dump(), Packet_gl1::dump(), dumpPacket(), fetchPacketHits(), Packet_w1::gdump(), Packet_w2::gdump(), Packet_w4::gdump(), Packet_gl1_evclocks::iValue(), Packet_id4scaler::iValue(), Packet_id4scaler::lValue(), Packet_A::standardIntArray(), startUnstructDataWrite(), and storePacketHits().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PTR_ret findPacketDebugStart ( PACKET_ptr  )

Definition at line 516 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 516 of file Cpacket.C

References findPacketDebugStartV, getPacketHdrVersion(), ptrFailure, and valueFailure.

Referenced by Packet_A::dumpDebugBlock(), and reservePacketDebugData().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PTR_ret findPacketEnd ( PACKET_ptr  )

Definition at line 35 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 35 of file Cpacket.C

References getPacketLength(), logicFailure, ptrFailure, setPacketError(), setPacketSuccess(), validPacketHdr(), and valueFailure.

Referenced by findNextFramePacket(), finishUnstructDataWrite(), makeEmptyPacket(), and makeUnstructPacket().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PTR_ret findPacketErrorStart ( PACKET_ptr  )

Definition at line 525 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 525 of file Cpacket.C

References findPacketErrorStartV, getPacketHdrVersion(), ptrFailure, and valueFailure.

Referenced by appendPacketError(), and Packet_A::dumpErrorBlock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_ret getPacketDataDescrLength ( const PACKET_ptr  )

Definition at line 411 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 411 of file Cpacket.C

References getPacketDataDescrLengthV, getPacketHdrVersion(), and valueFailure.

Referenced by findPacketDataStart(), and Packet_A::fullIdentify().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_ret getPacketDataLength ( const PACKET_ptr  )

Definition at line 338 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 338 of file Cpacket.C

References getPacketDataLengthV, getPacketHdrVersion(), and valueFailure.

Referenced by Packet_A::getDataLength(), and getUnstructPacketDataLengthBytes().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_ret getPacketDebugLength ( const PACKET_ptr  )

Definition at line 358 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 358 of file Cpacket.C

References getPacketDebugLengthV, getPacketHdrVersion(), and valueFailure.

Referenced by dumpPacket(), Packet_A::fullIdentify(), Packet_A::getDebugLength(), and getPacketV1DataLength().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_ret getPacketEndianism ( const PACKET_ptr  )

Definition at line 393 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 393 of file Cpacket.C

References getPacketEndianismV, getPacketHdrVersion(), and valueFailure.

Referenced by dumpPacket(), and Packet_A::fullIdentify().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_ret getPacketErrorLength ( const PACKET_ptr  )

Definition at line 348 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 348 of file Cpacket.C

References getPacketErrorLengthV, getPacketHdrVersion(), and valueFailure.

Referenced by appendPacketError(), dumpPacket(), Packet_A::fullIdentify(), Packet_A::getErrorLength(), getPacketV1DataLength(), and reservePacketDebugData().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

INLINE_D VALUE_ret getPacketHdrLength ( PACKET_ptr  packet_ptr)

Definition at line 171 of file Cpacket.h.

View newest version in sPHENIX GitHub at line 171 of file Cpacket.h

References getBitsMACRO, PACKET_HDR_LENGTH_MASK, PACKET_HDR_LENGTH_OFFSET_IN_DWORD, and PACKET_HDR_LENGTH_OFFSET_OF_DWORD.

Referenced by dumpPacket(), emptyPacketV1(), findPacketDataStart(), findPacketV1DataStart(), Packet_A::fullIdentify(), getPacketV1DataLength(), and validPacketV1Hdr().

+ Here is the caller graph for this function:

VALUE_ret getPacketId ( const PACKET_ptr  )

Definition at line 376 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 376 of file Cpacket.C

References getPacketHdrVersion(), getPacketIdV, and valueFailure.

Referenced by A_Event::createMap(), dumpPacket(), findFramePacketId(), findNextFramePacketId(), Packet_A::fullIdentify(), and Packet_A::getIdentifier().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

INLINE_D VALUE_ret getPacketLength ( PACKET_ptr  packet_ptr)

Definition at line 180 of file Cpacket.h.

View newest version in sPHENIX GitHub at line 180 of file Cpacket.h

References getWordMACRO, G4PLUGDOOR::length, PACKET_LENGTH_OFFSET_OF_DWORD, and valueFailure.

Referenced by dumpPacket(), emptyPacketV1(), extendPacketLength(), findPacketEnd(), findPacketV1DebugStart(), findPacketV1ErrorStart(), Packet_A::fullIdentify(), Packet_A::getLength(), getPacketV1DataLength(), removePacketPadding(), startUnstructDataWrite(), and storePacketHits().

+ Here is the caller graph for this function:

VALUE_ret getPacketNumErrors ( const PACKET_ptr  )

Definition at line 367 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 367 of file Cpacket.C

References getPacketHdrVersion(), getPacketNumErrorsV, and valueFailure.

+ Here is the call graph for this function:

VALUE_ret getPacketPadding ( const PACKET_ptr  )

Definition at line 402 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 402 of file Cpacket.C

References getPacketHdrVersion(), getPacketPaddingV, and valueFailure.

Referenced by dumpPacket(), Packet_A::fullIdentify(), getPacketV1DataLength(), Packet_A::getPadding(), and removePacketPadding().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_ret getPacketStatus ( PACKET_ptr  )

Definition at line 320 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 320 of file Cpacket.C

References getPacketHdrVersion(), getPacketStatusV, and valueFailure.

Referenced by dumpPacket(), and Packet_A::fullIdentify().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_ret getPacketStructure ( const PACKET_ptr  )

Definition at line 385 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 385 of file Cpacket.C

References getPacketHdrVersion(), getPacketStructureV, and valueFailure.

Referenced by X_Event::change_hf(), dumpPacket(), fetchPacketHits(), A_Event::getPacketList(), getPacketV1DataLength(), Packet_A::getStructure(), A_Event::makePacket(), startUnstructDataWrite(), and storePacketHits().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_ret makePacketHdr ( const PACKET_ptr  ,
UINT   
)

Definition at line 310 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 310 of file Cpacket.C

References currentPacketHdrVersion, makePacketHdrV, and valueFailure.

Referenced by makeEmptyPacket(), and makeUnstructPacket().

+ Here is the caller graph for this function:

VALUE_ret orPacketStatus ( PACKET_ptr  ,
UINT   
)

Definition at line 329 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 329 of file Cpacket.C

References getPacketHdrVersion(), orPacketStatusV, and valueFailure.

+ Here is the call graph for this function:

LOGIC_ret removePacketPadding ( PACKET_ptr  )

Definition at line 183 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 183 of file Cpacket.C

References FORMAT_ERR_HDR_INCONSISTENCY, getPacketLength(), getPacketPadding(), logicFailure, logicSuccess, packetV1HdrLength, setPacketError(), setPacketLength(), and setPacketPadding().

Referenced by extendPacketLength().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

LOGIC_ret setPacketDataDescrLength ( PACKET_ptr  ,
UINT   
)

Definition at line 498 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 498 of file Cpacket.C

References getPacketHdrVersion(), logicFailure, setPacketDataDescrLengthV, and valueFailure.

Referenced by makeUnstructPacketDataDescr().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

LOGIC_ret setPacketDebugLength ( PACKET_ptr  ,
UINT   
)
LOGIC_ret setPacketEndianism ( PACKET_ptr  ,
UINT   
)

Definition at line 462 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 462 of file Cpacket.C

References getPacketHdrVersion(), logicFailure, setPacketEndianismV, and valueFailure.

Referenced by makePacketV1Hdr().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

LOGIC_ret setPacketErrorLength ( PACKET_ptr  ,
UINT   
)

Definition at line 489 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 489 of file Cpacket.C

References getPacketHdrVersion(), logicFailure, setPacketErrorLengthV, and valueFailure.

+ Here is the call graph for this function:

INLINE_D LOGIC_ret setPacketHdrLength ( PACKET_ptr  packet_ptr,
UINT  hdrLength 
)

Definition at line 239 of file Cpacket.h.

View newest version in sPHENIX GitHub at line 239 of file Cpacket.h

References FALSE, FORMAT_ERR_INVALID_HDRLENGTH, PACKET_HDR_LENGTH_MASK, PACKET_HDR_LENGTH_OFFSET_IN_DWORD, PACKET_HDR_LENGTH_OFFSET_OF_DWORD, setBitsMACRO, setPacketError(), and TRUE.

Referenced by makePacketV1Hdr().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

INLINE_D LOGIC_ret setPacketHdrVersion ( PACKET_ptr  packet_ptr,
UINT  hdrVersion 
)

Definition at line 207 of file Cpacket.h.

View newest version in sPHENIX GitHub at line 207 of file Cpacket.h

References FORMAT_ERR_INVALID_PACKET_HDRVERSION, numPacketVersions, PACKET_HDR_VERSION_MASK, PACKET_HDR_VERSION_OFFSET_IN_DWORD, PACKET_HDR_VERSION_OFFSET_OF_DWORD, setBitsMACRO, setPacketError(), TRUE, and valueFailure.

Referenced by makePacketV1Hdr().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

LOGIC_ret setPacketId ( PACKET_ptr  ,
UINT   
)

Definition at line 444 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 444 of file Cpacket.C

References getPacketHdrVersion(), setPacketIdV, and valueFailure.

Referenced by X_Event::change_id(), makeEmptyPacket(), makeUnstructPacket(), and Packet_A::setIdentifier().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

INLINE_D LOGIC_ret setPacketLength ( PACKET_ptr  packet_ptr,
PHDWORD  length 
)

Definition at line 223 of file Cpacket.h.

View newest version in sPHENIX GitHub at line 223 of file Cpacket.h

References FALSE, FORMAT_ERR_LENGTH_OVERFLOW, PACKET_LENGTH_OFFSET_OF_DWORD, setPacketError(), setWordMACRO, and TRUE.

Referenced by extendPacketLength(), makePacketV1Hdr(), and removePacketPadding().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

LOGIC_ret setPacketNumErrors ( PACKET_ptr  ,
UINT   
)
LOGIC_ret setPacketPadding ( PACKET_ptr  ,
UINT   
)

Definition at line 471 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 471 of file Cpacket.C

References getPacketHdrVersion(), logicFailure, setPacketPaddingV, and valueFailure.

Referenced by extendPacketLength(), and removePacketPadding().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

LOGIC_ret setPacketStatus ( PACKET_ptr  ,
UINT   
)

Definition at line 480 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 480 of file Cpacket.C

References getPacketHdrVersion(), logicFailure, setPacketStatusV, utils::status, and valueFailure.

+ Here is the call graph for this function:

LOGIC_ret setPacketStructure ( PACKET_ptr  ,
UINT   
)

Definition at line 453 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 453 of file Cpacket.C

References getPacketHdrVersion(), logicFailure, setPacketStructureV, and valueFailure.

Referenced by makeUnstructPacket(), and setPacketUnstructured().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

LOGIC_ret validPacketHdr ( PACKET_ptr  )

Definition at line 544 of file Cpacket.C.

View newest version in sPHENIX GitHub at line 544 of file Cpacket.C

References getPacketHdrVersion(), logicFailure, NUM_PACKET_VERSIONS, and validPacketHdrV.

Referenced by dumpPacket(), fetchPacketHits(), findFramePacketIndex(), findPacketDataStart(), findPacketEnd(), isLastFramePacket(), and storePacketHits().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: