Changeset 68 for drsdaq


Ignore:
Timestamp:
06/19/09 08:55:28 (15 years ago)
Author:
ogrimm
Message:
Introduced dummy, zero initialized items in raw data format to align with MAGIC format ordering, changed date rollover to 13:00 UTC
Location:
drsdaq
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • drsdaq/DAQReadout.cc

    r63 r68  
    1515
    1616static const char* daq_state_str[] = {"active", "stopped"};
    17 static const char* daq_runtype_str[] = {"data", "pedestal", "test"};
     17static const char* daq_runtype_str[] = {"data", "pedestal", "reserved", "test"};
    1818
    1919static const struct CL_Struct { const char *Name;   
     
    121121  drs->InitialScan();
    122122
     123  // Allocate headers and initialise to zero
    123124  RHeader = new RunHeader;
     125  memset(RHeader, 0, sizeof(RunHeader));
    124126  EHeader = new EventHeader;
     127  memset(EHeader, 0, sizeof(EventHeader));
     128 
     129  // Scan for DRS boards
    125130  DRSFreq = new float [drs->GetNumberOfBoards()];
    126 
    127   // Scan for DRS boards
    128131  if (drs->GetNumberOfBoards()==0) PrintMessage("No DRS boards found - check VME crate and configuration file!\n");
    129132
     
    139142  }
    140143  BStruct  = new BoardStructure [NumBoards == 0 ? 1:drs->GetNumberOfBoards()];
     144  memset(BStruct, 0, sizeof(BoardStructure)*(NumBoards == 0 ? 1:drs->GetNumberOfBoards()));
     145
    141146  WaveForm = new short [NumBoards == 0 ? 1:NumBoards][kNumberOfChips][kNumberOfChannels][kNumberOfBins];
    142147  TriggerCell = new int [NumBoards == 0 ? 1:NumBoards][kNumberOfChips] ();  // Zero initialised
     
    877882  char RunDate[MAX_COM_SIZE], Buffer[MAX_COM_SIZE];
    878883 
    879   // Write run date to status structure
    880   time(&rawtime);   timeinfo = localtime(&rawtime);
    881   snprintf(RunDate,sizeof(RunDate), "%d%02d%02d",timeinfo->tm_year+1900,timeinfo->tm_mon + 1,timeinfo->tm_mday);
     884  // Write run date to status structure (if after 13:00, use next day)
     885  time(&rawtime);
     886  timeinfo = gmtime(&rawtime);
     887  if(timeinfo->tm_hour>=13) rawtime += 12*60*60;
     888  timeinfo = gmtime(&rawtime);
     889  snprintf(RunDate,sizeof(RunDate),"%d%02d%02d",timeinfo->tm_year+1900,timeinfo->tm_mon + 1,timeinfo->tm_mday);
    882890
    883891  // Create direcory if not existing (ignore error if already existing) and change to it
     
    889897 
    890898  // Generate filename
    891   snprintf(FileName,sizeof(FileName),"%s/%s/%s_%.8u_%s_%c_%d.raw", fRawDataPath, RunDate,
    892     RunDate,RunNumber,RHeader->Description,daq_runtype_str[daq_runtype][0],FileNumber);
     899  snprintf(FileName,sizeof(FileName),"%s/%s/%s_D1_%.8u.%.3u_%c_%s.raw", fRawDataPath, RunDate,
     900    RunDate,RunNumber,FileNumber,toupper(daq_runtype_str[daq_runtype][0]),RHeader->Description);
    893901 
    894902  //  Open file with rwx right for owner and group, never overwrite file
     
    914922  RHeader->BoardStructureSize = sizeof(BoardStructure);
    915923
     924  RHeader->Identification = IDENTIFICATION;
    916925  RHeader->Type = daq_runtype;
    917926  RHeader->RunNumber  = RunNumber;
     
    925934  RHeader->NChips    = kNumberOfChips;
    926935  RHeader->NChannels = kNumberOfChannels;
     936  RHeader->NBytes    = sizeof(short);
    927937
    928938  RHeader->Offset  = fFirstSample;
     
    12571267
    12581268    m->FileNumber += 1;
    1259   } while(m->NumEvents<m->NumEventsRequested && !m->Stop && !WriteError);
     1269  } while((m->NumEvents<m->NumEventsRequested || m->NumEventsRequested==0) && !m->Stop && !WriteError);
    12601270
    12611271  // Print run summary to slow data file and to screen
  • drsdaq/DAQReadout.h

    r63 r68  
    1919
    2020#define RUN_NUM_FILE "/ct3data/LastRunNumber"
     21
    2122#define MAX_PATH 256            // also used for filename length
    2223#define MAX_COM_SIZE 10000
     
    2829
    2930enum state_enum {active, stopped};
    30 enum runtype_enum {data, pedestal, test};
     31enum runtype_enum {data, pedestal, reserved, test};
    3132
    3233class DAQReadout {
  • drsdaq/History.txt

    r63 r68  
    393916/6/2009   Data is not rotated by copying in memory, but by saving to disk in
    4040            correct order using writev() (10% gain in rate)
     4118/6/2009   Introduced dummy, zero-initialized elements in raw data format to
     42            align ordering to MAGIC format. Run date is now calculated with a
     43            change to the next date on 13:00 UTC.
    4144           
  • drsdaq/RawDataCTX.cc

    r63 r68  
    9393
    9494    fprintf(fptr, "Description:      %s\n", RHeader->Description);
     95    fprintf(fptr, "Identification:   %u\n", RHeader->Identification);
    9596    fprintf(fptr, "Run type:         %u\n", RHeader->Type);
    9697    fprintf(fptr, "Run number:       %u\n", RHeader->RunNumber);
     
    99100    fprintf(fptr, "Events:           %u\n", RHeader->Events);
    100101    fprintf(fptr, "Boards:           %u\n", RHeader->NBoards);
    101     fprintf(fptr, "DRS chips:        %u\n", RHeader->NChips);
     102    fprintf(fptr, "Chips/board:      %u\n", RHeader->NChips);
    102103    fprintf(fptr, "Channels/chip:    %u\n", RHeader->NChannels);
    103104    fprintf(fptr, "Samples:          %u\n", RHeader->Samples);
    104105    fprintf(fptr, "Offset:           %u\n", RHeader->Offset);
     106    fprintf(fptr, "Bytes/sample:     %u\n", RHeader->NBytes);
    105107
    106108    fprintf(fptr, "Start second:     %u - UTC %s", RHeader->StartSecond, asctime(gmtime((time_t *) &RHeader->StartSecond)));
  • drsdaq/RawDataCTX.h

    r63 r68  
    11/* Data organisation on disk:
    22
    3                       Board 1      Board 2      ...     Board 1      Board 2      ...
    4    RH  BS1 BS2 ... EH C1 C2 C3 ... C1 C2 C3 ... ...  EH C1 C2 C3 ... C1 C2 C3 ... ...
     3                                  Board 1      Board 2      ...     Board 1      Board 2      ...
     4   RH  BS1 BS2 ... EH TC1 TC2 ... C1 C2 C3 ... C1 C2 C3 ... ...  EH C1 C2 C3 ... C1 C2 C3 ... ...
    55                   --------------------------------  --------------------------------
    66                   Event 1                           Event 2
    77
    8   RH Run header   BSx Board structures   EV Event header   Cx Channel (0-19 for 2 chips)
    9   Channel data are written as shorts, lenght of channel data is in the run header
     8  RH Run header   BSx Board structures   EV Event header   TCx Trigger cell of chip x (int)
     9  Cx Channel (0-19 for 2 chips), Channel data are written as shorts, length of event data is in event header
    1010
    1111  Structures are defined using #pragma pack (1) to not include any padding. Note that
     
    1515  The convention for the header structure is that exisitng structure entries
    1616  should never be deleted. New items may only be added at the end.
     17  Items named _res are introduced for compatibility with the MAGIC data format and are set to zero.
    1718*/
    1819
     
    2425
    2526#define DATA_FORMAT 1
     27#define IDENTIFICATION 1    // Raw data file identification
     28
    2629
    2730typedef char I8;
     
    3033typedef float F32;
    3134
    32 #define MAGICNUM_OPEN 0xe0e1    // Magic number for run header while file open
    33 #define MAGICNUM_CLOSED 0xe0e0  //    ... and when file is closed
    34 #define MAGICNUM_ERROR 0xe0e2   //    ... and when an error occurred
     35#define MAGICNUM_OPEN 0xc0c1    // Magic number for run header while file open
     36#define MAGICNUM_CLOSED 0xc0c0  //    ... and when file is closed
     37#define MAGICNUM_ERROR 0xc0c2   //    ... and when an error occurred
    3538
    3639// Error codes
    3740enum CTX_ErrCode {CTX_OK, CTX_FOPEN, CTX_FCLOSE, CTX_NOTOPEN, CTX_RHEADER,
    3841                  CTX_BSTRUCT, CTX_EHEADER, CTX_DATA, CTX_SEEK, CTX_EOF, CTX_VERSION};
     42
    3943
    4044#pragma pack (1)  // Switch padding off
     
    4448  U32 MagicNum;
    4549  U32 DataFormat;       // Increasing whenever format changes
    46   I32 SoftwareRevision; // Subversion revision number (negative for modified working copy)
    4750
    4851  U32 RunHeaderSize;
     
    5053  U32 BoardStructureSize;
    5154
    52   I8  Description[48];
    53   U32 Type;             // Run type: 0=pedestal, 1=data, 2=test
     55  I32 SoftwareRevision; // Subversion revision number (negative for modified working copy)
    5456
     57  U32 _res1[2];
     58  U32 Identification;
     59  U32 Type;             // Run type: 0=data, 1=pedestal, 3=test
    5560  U32 RunNumber;
    5661  U32 FileNumber;
    57    
    58   U32 Events;           // Number of events in the file
     62
     63  I8  Description[100];
     64  I8  _res2[140];
     65  U32 _res3[6];
     66       
    5967  U32 NBoards;          // Number of used mezzanine boards
    6068  U32 NChips;           // Number of DRS chips per board
    6169  U32 NChannels;        // Number of channels per chip
     70
    6271  U32 Samples;          // Number of samples
    63   U32 Offset;           // Offset from first sample
     72  U32 Offset;           // Offset from trigger
    6473
     74  U32 Events;           // Number of events in the file
     75  U32  _res4;
     76  U32 NBytes;
     77  I8  _res5[20];
     78 
    6579  U32 StartSecond;      // Opening and closing time of the file
    6680  U32 StartMicrosecond;
     
    7185// Board structure
    7286typedef struct {
     87  I8  _res[17];
    7388  I32 SerialNo;     // Board serial number
    7489  F32 NomFreq;      // Nominal sampling frequency [GHz]
     
    8297  U32 Second;          // Event time stamp (result of gettimeofday())
    8398  U32 Microsecond;
     99  U32 _res[4];
    84100  U32 TriggerType;
    85101  U32 EventSize;        // Size of following data in bytes
  • drsdaq/SlowData.cc

    r44 r68  
    2727  InternalCall = false;
    2828 
    29   time(&rawtime);   timeinfo = localtime(&rawtime);
     29  time(&rawtime);
     30  timeinfo = gmtime(&rawtime);
     31  if(timeinfo->tm_hour>=13) rawtime += 12*60*60;
     32  timeinfo = gmtime(&rawtime);
    3033  snprintf(Filename,sizeof(Filename),"%s/%s_%d%02d%02d.slow",Direcory,Issuer,timeinfo->tm_year+1900,timeinfo->tm_mon+1,timeinfo->tm_mday);
    3134
     
    5558  gettimeofday(&Time, NULL);
    5659  InternalCall = true;
    57   NewEntryCalled = AddToEntry("\n%s-%s %lu %lu %d-%d-%dT%d:%d:%d ", Issuer, Variable, Time.tv_sec, Time.tv_usec, TM->tm_year+1900,TM->tm_mon+1,TM->tm_mday,TM->tm_hour,TM->tm_min,TM->tm_sec);
     60  NewEntryCalled = AddToEntry("\n%s %s %d %d %d %d %d %d %d %lu %lu", Issuer, Variable, TM->tm_year+1900,TM->tm_mon+1,TM->tm_mday,TM->tm_hour,TM->tm_min,TM->tm_sec, Time.tv_usec/1000, Time.tv_sec, Time.tv_usec);
    5861  InternalCall = false;
    5962  return NewEntryCalled;
Note: See TracChangeset for help on using the changeset viewer.