lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Drp::Jungfrau Class Reference

BEBDetector for one or more Jungfrau modules (one per PGP lane), controlled through sls::Detector and assembled from per-packet UDP data. More...

#include <Jungfrau.hh>

Inherits Drp::BEBDetector.

Public Member Functions

 Jungfrau (Parameters *para, MemPool *pool)
 Count the modules from laneMask, read segNums and slsHosts (aborting if they are missing or do not match the module count), connect sls::Detector to the hosts (stopping a running detector first if needed), initialize the BEBDetector with the epics_prefix kwarg and install a one-shot handler for SIGINT, SIGABRT and SIGTERM.
 
virtual ~Jungfrau ()
 Clear the global pointer used by the signal handler and call cleanup().
 
unsigned configureScan (const nlohmann::json &scanKeys, XtcData::Xtc &xtc, const void *bufEnd) override
 Pass scanKeys to PythonConfigScanner::configure with names index UpdateNamesIndex and the segment and serial numbers of the modules, and return its result.
 
unsigned stepScan (const nlohmann::json &stepInfo, XtcData::Xtc &xtc, const void *bufEnd) override
 Write the XTC update with PythonConfigScanner::step (returning its result if non-zero), then for each module set the sls gain mode from user.gainMode (mapped through the gainModeEnum names, and recording whether it is FIX_G1 or FIX_G2) or, if that key is absent, the trigger delay from user.trigger_delay_s.
 
unsigned beginrun (XtcData::Xtc &xtc, const void *bufEnd, const nlohmann::json &runInfo) override
 Reset the frame counter of all modules to 1 with sls setNextFrameNumber.
 
unsigned enable (XtcData::Xtc &xtc, const void *bufEnd, const nlohmann::json &info) override
 Start acquisition on all modules, then return 0 if every module reports RUNNING or WAITING, else 1.
 
unsigned disable (XtcData::Xtc &xtc, const void *bufEnd, const nlohmann::json &info) override
 Stop acquisition on all modules, then return 0 if every module reports IDLE or STOPPED, else 1.
 
void cleanup ()
 If the sls detector exists, stop it, destroy it and free its shared memory.
 
- Public Member Functions inherited from Drp::BEBDetector
 BEBDetector (Parameters *para, MemPool *pool)
 Construct the Detector base with virtual channel 1 and no Python module yet; subclasses must call _init() (or their own variant).
 
virtual ~BEBDetector ()
 Delete the config scanner and release the Python module.
 
nlohmann::json connectionInfo (const nlohmann::json &msg) override
 Call {detType}_connectionInfo in Python with the device handle and msg, store its paddr entry (aborting if it is 0, 0xffffffff or has a low byte above 15), pass the result to _connectionInfo() and return xpmInfo(paddr).
 
void connectionShutdown () override
 Call {detType}_connectionShutdown in Python if the module defines it.
 
void connect (const nlohmann::json &, const std::string &collectionId) override
 Keep the connect message and the readout group of this DRP (det_info.readout of entry collectionId).
 
unsigned configure (const std::string &config_alias, XtcData::Xtc &xtc, const void *bufEnd) override
 Call {detType}_config in Python (with segment and serial numbers in multi-segment mode), translate the returned JSON, or list of JSON per segment, into configuration XTC, let the subclass _configure() add its names, append the configuration to xtc and return the _configure() result.
 
void event (XtcData::Dgram &dgram, const void *bufEnd, PGPEvent *event, uint64_t l1count) override
 Split the DMA buffer of each lane in event->mask into batcher subframes (one more batcher level is unwrapped when m_debatch is set), keep all subframes of the first lane that has more than 2 and subframe 2 of each later one, and pass them to _event().
 
void shutdown () override
 Call {detType}_unconfig in Python with the device handle.
 
Pds::TimingHeader * getTimingHeader (uint32_t index) const override
 Return the timing header of DMA buffer index: the data after the first batcher header, or after the second one when m_debatch is set.
 
- Public Member Functions inherited from Drp::Detector
 Detector (Parameters *para, MemPool *pool)
 Set nodeId to -1u and virtChan to 0, keep para and pool, and allocate a transition buffer of para->maxTrSize bytes.
 
virtual ~Detector ()
 Does nothing; empty body.
 
virtual Gpu::Detector * gpuDetector ()
 Return nullptr; Gpu::Detector overrides it to return itself.
 
virtual unsigned beginstep (XtcData::Xtc &xtc, const void *bufEnd, const nlohmann::json &stepInfo)
 Return 0 without doing anything unless overridden.
 
virtual void slowupdate (XtcData::Xtc &xtc, const void *bufEnd)
 Reset xtc to an empty Parent Xtc whose source is nodeId.
 
virtual void event (XtcData::Dgram &dgram, const void *bufEnd, const Pds::Eb::ResultDgram &result)
 Does nothing unless overridden; called with the trigger result for an event.
 
virtual XtcData::Shape shapeCube (unsigned rawDefIndex, unsigned valueIndex, XtcData::DescData &rawData)
 Return the shape in rawData of entry valueIndex of raw definition rawDefIndex (from rawDef()).
 
virtual unsigned addToCube (unsigned rawDefIndex, unsigned valueIndex, unsigned subIndex, double *dst, unsigned bin, XtcData::DescData &rawData)
 Generic cube accumulation without calibration: add the value or array entry valueIndex of rawData, converted to double, into bin bin of dst (entries of any XTC numeric type).
 
virtual unsigned subIndices ()
 Return 0 unless overridden.
 
virtual unsigned rawNamesIndex ()
 Return 0 unless overridden.
 
virtual unsigned cubeNamesIndex ()
 Return 0 unless overridden.
 
virtual unsigned cubeBinBytes ()
 Return ten times the pebble buffer size unless overridden.
 
virtual std::vector< XtcData::VarDef > & rawDef ()
 Log an error and abort; detectors used for cube binning must override it.
 
virtual unsigned maxMonBufSize ()
 Return the pebble buffer size, times 10 when Parameters::nCubeWorkers is non-zero.
 
virtual bool scanEnabled ()
 Return false unless overridden.
 
XtcData::Xtc & transitionXtc ()
 Return the start of the transition buffer as an Xtc reference.
 
const void * trXtcBufEnd ()
 Return the end of the transition buffer.
 
XtcData::NamesLookup & namesLookup ()
 Return the names lookup table of this detector.
 

Additional Inherited Members

- Static Public Member Functions inherited from Drp::BEBDetector
static PyObject * _check (PyObject *)
 Return obj; if it is null, print the Python error, log it and abort.
 
- Public Attributes inherited from Drp::Detector
unsigned nodeId
 Node ID used as the XTC source; -1u until set.
 
unsigned virtChan
 Virtual channel number; 0 unless a subclass sets it.
 
- Protected Member Functions inherited from Drp::BEBDetector
void _init (const char *)
 
void _init_feb ()
 
std::vector< XtcData::Array< uint8_t > > _subframes (void *buffer, unsigned length)
 
std::vector< XtcData::Array< uint8_t > > _subframes (void *buffer, unsigned length, size_t nsubhint)
 
- Static Protected Member Functions inherited from Drp::BEBDetector
static std::string _string_from_PyDict (PyObject *, const char *key)
 
- Protected Attributes inherited from Drp::BEBDetector
std::string m_connect_json
 
unsigned m_readoutGroup
 
PyObject * m_module
 
PyObject * m_root
 
unsigned m_paddr
 
PythonConfigScanner * m_configScanner
 
bool m_debatch
 
bool m_multiSegment = false
 
std::string m_segNoStr {""}
 
- Protected Attributes inherited from Drp::Detector
Parameters * m_para
 
MemPool * m_pool
 
XtcData::NamesLookup m_namesLookup
 
std::vector< char > m_xtcbuf
 

Detailed Description

BEBDetector for one or more Jungfrau modules (one per PGP lane), controlled through sls::Detector and assembled from per-packet UDP data.

Constructor & Destructor Documentation

◆ Jungfrau()

Drp::Jungfrau::Jungfrau ( Parameters *  para,
MemPool *  pool 
)

Count the modules from laneMask, read segNums and slsHosts (aborting if they are missing or do not match the module count), connect sls::Detector to the hosts (stopping a running detector first if needed), initialize the BEBDetector with the epics_prefix kwarg and install a one-shot handler for SIGINT, SIGABRT and SIGTERM.

A timebase kwarg of 119M sets the extra event-batcher level.

◆ ~Jungfrau()

virtual Drp::Jungfrau::~Jungfrau ( )
virtual

Clear the global pointer used by the signal handler and call cleanup().

Member Function Documentation

◆ beginrun()

unsigned Drp::Jungfrau::beginrun ( XtcData::Xtc &  xtc,
const void *  bufEnd,
const nlohmann::json &  runInfo 
)
overridevirtual

Reset the frame counter of all modules to 1 with sls setNextFrameNumber.

Returns 0, or 1 after logging an error if sls throws a RuntimeError.

Reimplemented from Drp::Detector.

◆ cleanup()

void Drp::Jungfrau::cleanup ( )

If the sls detector exists, stop it, destroy it and free its shared memory.

◆ configureScan()

unsigned Drp::Jungfrau::configureScan ( const nlohmann::json &  scanKeys,
XtcData::Xtc &  xtc,
const void *  bufEnd 
)
overridevirtual

Pass scanKeys to PythonConfigScanner::configure with names index UpdateNamesIndex and the segment and serial numbers of the modules, and return its result.

Reimplemented from Drp::BEBDetector.

◆ disable()

unsigned Drp::Jungfrau::disable ( XtcData::Xtc &  xtc,
const void *  bufEnd,
const nlohmann::json &  info 
)
overridevirtual

Stop acquisition on all modules, then return 0 if every module reports IDLE or STOPPED, else 1.

Returns 1 after logging an error if sls throws a RuntimeError.

Reimplemented from Drp::Detector.

◆ enable()

unsigned Drp::Jungfrau::enable ( XtcData::Xtc &  xtc,
const void *  bufEnd,
const nlohmann::json &  info 
)
overridevirtual

Start acquisition on all modules, then return 0 if every module reports RUNNING or WAITING, else 1.

Returns 1 after logging an error if sls throws a RuntimeError.

Reimplemented from Drp::Detector.

◆ stepScan()

unsigned Drp::Jungfrau::stepScan ( const nlohmann::json &  stepInfo,
XtcData::Xtc &  xtc,
const void *  bufEnd 
)
overridevirtual

Write the XTC update with PythonConfigScanner::step (returning its result if non-zero), then for each module set the sls gain mode from user.gainMode (mapped through the gainModeEnum names, and recording whether it is FIX_G1 or FIX_G2) or, if that key is absent, the trigger delay from user.trigger_delay_s.

A user.gainMode value missing from gainModeEnum is ignored. Returns 1 if the gain mode name has no sls equivalent, else 0.

Reimplemented from Drp::BEBDetector.


The documentation for this class was generated from the following file: