Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-02 08:21:01

0001 #include <daqPRDFEvent.h>
0002 
0003 
0004 
0005 
0006 // the constructor first ----------------
0007 daqPRDFEvent::daqPRDFEvent (int * where, const int length
0008         , const int irun, const int etype, const int evtseq)
0009 {
0010   event_base = where;
0011   evthdr = ( evtdata_ptr ) where;
0012   evthdr->evt_type = etype;
0013   max_length = length;
0014   prepare_next (evtseq, irun);
0015 }
0016 
0017 
0018 int daqPRDFEvent::addSubevent(const int etype, daq_device *dev)
0019 {
0020   int len;
0021 
0022   len = dev->put_data ( etype, &(evthdr->data[current]), left );
0023   if (left < 0) {
0024     return 0;
0025   }
0026   evthdr->evt_length += len;
0027   evthdr->data[0] += len;
0028   current += len;
0029   left -= len;
0030   return len;
0031 }
0032 
0033 int daqPRDFEvent::prepare_next()
0034 {
0035   return  prepare_next(-1,-1);
0036 }
0037 
0038 int daqPRDFEvent::prepare_next( const int evtseq, const int irun)
0039 {
0040   // re-initialize the event header length
0041   evthdr->evt_length =  EVTHEADERLENGTH + 8; // plus the frameheader
0042 
0043   // if < 0, just increment the current seq. number
0044   if ( evtseq < 0 )
0045     {
0046       evthdr->evt_sequence++;
0047     }
0048   else
0049     {
0050       evthdr->evt_sequence = evtseq;
0051     }
0052 
0053   // if > 0, adjust the run number, else just keep it.
0054   if ( irun >  0 )
0055     {
0056       evthdr->run_number=irun;
0057     }
0058   // if > 0, adjust the run number, else just keep it.
0059   evthdr->date = time(0);
0060   evthdr->time = -1;
0061   evthdr->reserved[0] = 0;
0062   evthdr->reserved[1] = 0;
0063 
0064   //now the frameheader
0065 
0066   evthdr->data[0] = 8;          //length
0067   evthdr->data[1] = 0xffffff00; //marker
0068   evthdr->data[2] = 0x01080000; //version 1 + 8 length
0069   evthdr->data[3] = 0x00002016; //source id
0070   evthdr->data[4] = 0x00040000; // frame type 0
0071   evthdr->data[5] = 0x00000200; // 2 align length
0072   evthdr->data[6] = 0x55555555; // align 
0073   evthdr->data[7] = 0x20160000; // align
0074 
0075   // reset the current data index, and the leftover counter
0076   current = 8;
0077   left = max_length - EVTHEADERLENGTH - 8 ; // 8 = framelength
0078   return 0;
0079 }
0080 
0081