Changeset 68
- Timestamp:
- 06/19/09 08:55:28 (16 years ago)
- Location:
- drsdaq
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
drsdaq/DAQReadout.cc
r63 r68 15 15 16 16 static const char* daq_state_str[] = {"active", "stopped"}; 17 static const char* daq_runtype_str[] = {"data", "pedestal", " test"};17 static const char* daq_runtype_str[] = {"data", "pedestal", "reserved", "test"}; 18 18 19 19 static const struct CL_Struct { const char *Name; … … 121 121 drs->InitialScan(); 122 122 123 // Allocate headers and initialise to zero 123 124 RHeader = new RunHeader; 125 memset(RHeader, 0, sizeof(RunHeader)); 124 126 EHeader = new EventHeader; 127 memset(EHeader, 0, sizeof(EventHeader)); 128 129 // Scan for DRS boards 125 130 DRSFreq = new float [drs->GetNumberOfBoards()]; 126 127 // Scan for DRS boards128 131 if (drs->GetNumberOfBoards()==0) PrintMessage("No DRS boards found - check VME crate and configuration file!\n"); 129 132 … … 139 142 } 140 143 BStruct = new BoardStructure [NumBoards == 0 ? 1:drs->GetNumberOfBoards()]; 144 memset(BStruct, 0, sizeof(BoardStructure)*(NumBoards == 0 ? 1:drs->GetNumberOfBoards())); 145 141 146 WaveForm = new short [NumBoards == 0 ? 1:NumBoards][kNumberOfChips][kNumberOfChannels][kNumberOfBins]; 142 147 TriggerCell = new int [NumBoards == 0 ? 1:NumBoards][kNumberOfChips] (); // Zero initialised … … 877 882 char RunDate[MAX_COM_SIZE], Buffer[MAX_COM_SIZE]; 878 883 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); 882 890 883 891 // Create direcory if not existing (ignore error if already existing) and change to it … … 889 897 890 898 // 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); 893 901 894 902 // Open file with rwx right for owner and group, never overwrite file … … 914 922 RHeader->BoardStructureSize = sizeof(BoardStructure); 915 923 924 RHeader->Identification = IDENTIFICATION; 916 925 RHeader->Type = daq_runtype; 917 926 RHeader->RunNumber = RunNumber; … … 925 934 RHeader->NChips = kNumberOfChips; 926 935 RHeader->NChannels = kNumberOfChannels; 936 RHeader->NBytes = sizeof(short); 927 937 928 938 RHeader->Offset = fFirstSample; … … 1257 1267 1258 1268 m->FileNumber += 1; 1259 } while( m->NumEvents<m->NumEventsRequested&& !m->Stop && !WriteError);1269 } while((m->NumEvents<m->NumEventsRequested || m->NumEventsRequested==0) && !m->Stop && !WriteError); 1260 1270 1261 1271 // Print run summary to slow data file and to screen -
drsdaq/DAQReadout.h
r63 r68 19 19 20 20 #define RUN_NUM_FILE "/ct3data/LastRunNumber" 21 21 22 #define MAX_PATH 256 // also used for filename length 22 23 #define MAX_COM_SIZE 10000 … … 28 29 29 30 enum state_enum {active, stopped}; 30 enum runtype_enum {data, pedestal, test};31 enum runtype_enum {data, pedestal, reserved, test}; 31 32 32 33 class DAQReadout { -
drsdaq/History.txt
r63 r68 39 39 16/6/2009 Data is not rotated by copying in memory, but by saving to disk in 40 40 correct order using writev() (10% gain in rate) 41 18/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. 41 44 -
drsdaq/RawDataCTX.cc
r63 r68 93 93 94 94 fprintf(fptr, "Description: %s\n", RHeader->Description); 95 fprintf(fptr, "Identification: %u\n", RHeader->Identification); 95 96 fprintf(fptr, "Run type: %u\n", RHeader->Type); 96 97 fprintf(fptr, "Run number: %u\n", RHeader->RunNumber); … … 99 100 fprintf(fptr, "Events: %u\n", RHeader->Events); 100 101 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); 102 103 fprintf(fptr, "Channels/chip: %u\n", RHeader->NChannels); 103 104 fprintf(fptr, "Samples: %u\n", RHeader->Samples); 104 105 fprintf(fptr, "Offset: %u\n", RHeader->Offset); 106 fprintf(fptr, "Bytes/sample: %u\n", RHeader->NBytes); 105 107 106 108 fprintf(fptr, "Start second: %u - UTC %s", RHeader->StartSecond, asctime(gmtime((time_t *) &RHeader->StartSecond))); -
drsdaq/RawDataCTX.h
r63 r68 1 1 /* Data organisation on disk: 2 2 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 ... ... 5 5 -------------------------------- -------------------------------- 6 6 Event 1 Event 2 7 7 8 RH Run header BSx Board structures EV Event header Cx Channel (0-19 for 2 chips)9 C hannel data are written as shorts, lenght of channel data is in the runheader8 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 10 10 11 11 Structures are defined using #pragma pack (1) to not include any padding. Note that … … 15 15 The convention for the header structure is that exisitng structure entries 16 16 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. 17 18 */ 18 19 … … 24 25 25 26 #define DATA_FORMAT 1 27 #define IDENTIFICATION 1 // Raw data file identification 28 26 29 27 30 typedef char I8; … … 30 33 typedef float F32; 31 34 32 #define MAGICNUM_OPEN 0x e0e1 // Magic number for run header while file open33 #define MAGICNUM_CLOSED 0x e0e0 // ... and when file is closed34 #define MAGICNUM_ERROR 0x e0e2 // ... and when an error occurred35 #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 35 38 36 39 // Error codes 37 40 enum CTX_ErrCode {CTX_OK, CTX_FOPEN, CTX_FCLOSE, CTX_NOTOPEN, CTX_RHEADER, 38 41 CTX_BSTRUCT, CTX_EHEADER, CTX_DATA, CTX_SEEK, CTX_EOF, CTX_VERSION}; 42 39 43 40 44 #pragma pack (1) // Switch padding off … … 44 48 U32 MagicNum; 45 49 U32 DataFormat; // Increasing whenever format changes 46 I32 SoftwareRevision; // Subversion revision number (negative for modified working copy)47 50 48 51 U32 RunHeaderSize; … … 50 53 U32 BoardStructureSize; 51 54 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) 54 56 57 U32 _res1[2]; 58 U32 Identification; 59 U32 Type; // Run type: 0=data, 1=pedestal, 3=test 55 60 U32 RunNumber; 56 61 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 59 67 U32 NBoards; // Number of used mezzanine boards 60 68 U32 NChips; // Number of DRS chips per board 61 69 U32 NChannels; // Number of channels per chip 70 62 71 U32 Samples; // Number of samples 63 U32 Offset; // Offset from first sample72 U32 Offset; // Offset from trigger 64 73 74 U32 Events; // Number of events in the file 75 U32 _res4; 76 U32 NBytes; 77 I8 _res5[20]; 78 65 79 U32 StartSecond; // Opening and closing time of the file 66 80 U32 StartMicrosecond; … … 71 85 // Board structure 72 86 typedef struct { 87 I8 _res[17]; 73 88 I32 SerialNo; // Board serial number 74 89 F32 NomFreq; // Nominal sampling frequency [GHz] … … 82 97 U32 Second; // Event time stamp (result of gettimeofday()) 83 98 U32 Microsecond; 99 U32 _res[4]; 84 100 U32 TriggerType; 85 101 U32 EventSize; // Size of following data in bytes -
drsdaq/SlowData.cc
r44 r68 27 27 InternalCall = false; 28 28 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); 30 33 snprintf(Filename,sizeof(Filename),"%s/%s_%d%02d%02d.slow",Direcory,Issuer,timeinfo->tm_year+1900,timeinfo->tm_mon+1,timeinfo->tm_mday); 31 34 … … 55 58 gettimeofday(&Time, NULL); 56 59 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); 58 61 InternalCall = false; 59 62 return NewEntryCalled;
Note:
See TracChangeset
for help on using the changeset viewer.