From a2ad4f65a3ccf1fd058919c936c2c713056bd90d Mon Sep 17 00:00:00 2001 From: tkuhr Date: Thu, 15 Jul 2004 15:03:17 +0000 Subject: [PATCH] remove raw2date program (functionality now provided by DATE tool dateStream) --- RAW/binraw2date.pkg | 7 -- RAW/raw2date.c | 278 -------------------------------------------- 2 files changed, 285 deletions(-) delete mode 100644 RAW/binraw2date.pkg delete mode 100644 RAW/raw2date.c diff --git a/RAW/binraw2date.pkg b/RAW/binraw2date.pkg deleted file mode 100644 index 6f3e00934e6..00000000000 --- a/RAW/binraw2date.pkg +++ /dev/null @@ -1,7 +0,0 @@ -CSRCS:=raw2date.c - -ELIBS:= pythia6 pdf microcern - -ifdef DATE_ROOT -EINCLUDE+= ${DATE_COMMON_DEFS} -endif diff --git a/RAW/raw2date.c b/RAW/raw2date.c deleted file mode 100644 index 62d549e4079..00000000000 --- a/RAW/raw2date.c +++ /dev/null @@ -1,278 +0,0 @@ -/* raw2date.c -** -** Take a raw data file and produce a DATE-formatted data file -** -** Revision history: -** 19/03/03 RD Created -*/ - -#include -#include -#include -#include -#include -#include - -#ifdef ALI_DATE - -#include "event.h" - -#ifndef TRUE -# define TRUE (0 == 0) -#endif -#ifndef FALSE -# define FALSE (0 == 1) -#endif - -const char *whoAmI; -int numFiles = 0; -char **fileNames = NULL; -int *dataBlockSizes = NULL; -void **dataBlocks = NULL; -int doSor = FALSE; -int doEor = FALSE; -int numLoops = 1; -struct eventHeaderStruct h; -struct eventHeaderStruct sh; -struct equipmentHeaderStruct eh; - -int usage() { - fprintf( stderr, "Usage: %s [-s][-e][-#=N] FILE [FILE]...\n", - whoAmI ); - return FALSE; -} - -int handleArgs( const int argc, char * const * const argv ) { - int inFile = FALSE; - int arg; - - if ( argc <= 1 ) return usage(); - - for ( arg = 1; arg < argc; arg++ ) { - if ( !inFile ) { - if ( strcmp( argv[arg], "--" ) == 0 ) { - inFile = TRUE; - continue; - } - if ( strcmp( argv[arg], "-s" ) == 0 ) { - doSor = TRUE; - continue; - } - if ( strcmp( argv[arg], "-e" ) == 0 ) { - doEor = TRUE; - continue; - } - if ( strncmp( argv[arg], "-#=", 3 ) == 0 ) { - if ( sscanf( &argv[arg][3], "%d", &numLoops ) != 1 ) { - fprintf( stderr, - "Failed to scan \"%s\" (expected: -#=number)\n", - argv[arg] ); - return usage(); - } - continue; - } - if ( argv[arg][0] == '-' ) return usage(); - inFile = TRUE; - } - if ( (fileNames = realloc( fileNames, - ++numFiles * sizeof( char* ) )) == NULL ) { - perror( "malloc failed " ); - return FALSE; - } - if ( (fileNames[ numFiles-1 ] = malloc( strlen(argv[arg])+1 )) == NULL ) { - perror( "malloc failed " ); - return FALSE; - } - if ( (strcpy( fileNames[ numFiles-1 ], argv[arg] )) == NULL ) { - perror( "strcpy failed " ); - return FALSE; - } - } - - if ( numFiles < 1 ) return usage(); - return TRUE; -} - -int readData() { - int f; - - if ( (dataBlockSizes = malloc( sizeof(int) * numFiles )) == NULL ) { - perror( "malloc failed " ); - return FALSE; - } - if ( (dataBlocks = malloc( sizeof( void * ) * numFiles )) == NULL ) { - perror( "malloc failed" ); - return FALSE; - } - for ( f = 0; f != numFiles; f++ ) { - FILE *in; - struct stat statData; - - if ( stat( fileNames[f], &statData ) != 0 ) { - fprintf( stderr, "Cannot stat file \"%s\"", fileNames[f] ); - perror( " " ); - return FALSE; - } - - if ( (dataBlockSizes[f] = statData.st_size) < 0 ) { - fprintf( stderr, - "Stat for file \"%s\" returns size: %d\n", - fileNames[f], (int)statData.st_size ); - return FALSE; - } - if ( dataBlockSizes[f] == 0 ) { - dataBlocks[f] = NULL; - continue; - } - if ( (dataBlocks[f] = malloc( dataBlockSizes[f] )) == NULL ) { - fprintf( stderr, - "Failed to malloc for file \"%s\" size:%d", - fileNames[f], dataBlockSizes[f] ); - perror( " " ); - return FALSE; - } - if ( (in = fopen( fileNames[f], "r" )) == NULL ) { - fprintf( stderr, "Failed to open input file \"%s\"", fileNames[f] ); - perror( " " ); - return FALSE; - } - if ( fread( dataBlocks[f], - dataBlockSizes[f], - 1, in ) != 1 ) { - fprintf( stderr, - "Failed to read from file \"%s\"", - fileNames[f] ); - perror( " " ); - return FALSE; - } - fclose( in ); - } - return TRUE; -} - -void initStructs() { - h.eventMagic = EVENT_MAGIC_NUMBER; - h.eventHeadSize = EVENT_HEAD_BASE_SIZE; - h.eventVersion = EVENT_CURRENT_VERSION; - h.eventRunNb = 1; - ZERO_TRIGGER_PATTERN( h.eventTriggerPattern ); - ZERO_DETECTOR_PATTERN( h.eventDetectorPattern ); - RESET_ATTRIBUTES( h.eventTypeAttribute ); - h.eventLdcId = h.eventGdcId = VOID_ID; - memcpy( &sh, &h, sizeof( h ) ); - - eh.equipmentType = 0; - eh.equipmentId = 0; - RESET_ATTRIBUTES( eh.equipmentTypeAttribute ); - eh.equipmentBasicElementSize = 1; -} - -void dumpDummy( const int size ) { - int i; - char pat; - - for ( i = 0, pat = 0; i != size; i++, pat++ ) - fwrite( &pat, 1, 1, stdout ); -} - -void createSorEor( eventTypeType eventType ) { - int l; - int i; - - sh.eventSize = 10872; - h.eventType = sh.eventType = eventType; - LOAD_RAW_EVENT_ID( h.eventId, 1, 0, 1 ); - LOAD_RAW_EVENT_ID( sh.eventId, 1, 0, 1 ); - RESET_ATTRIBUTES( h.eventTypeAttribute ); - RESET_ATTRIBUTES( sh.eventTypeAttribute ); - SET_SYSTEM_ATTRIBUTE( h.eventTypeAttribute, ATTR_P_START ); - SET_SYSTEM_ATTRIBUTE( sh.eventTypeAttribute, ATTR_P_START ); - h.eventGdcId = sh.eventGdcId = 0; - - for ( i = 0; i != 2; i++ ) { - h.eventSize = sh.eventSize; - CLEAR_SYSTEM_ATTRIBUTE( h.eventTypeAttribute, ATTR_SUPER_EVENT ); - fwrite( &h, sizeof(h), 1, stdout ); - dumpDummy( h.eventSize - EVENT_HEAD_BASE_SIZE ); - - SET_SYSTEM_ATTRIBUTE( h.eventTypeAttribute, ATTR_SUPER_EVENT ); - h.eventSize = sh.eventSize + EVENT_HEAD_BASE_SIZE; - - for ( l = 0; l != numFiles; l++ ) { - fwrite( &h, sizeof(h), 1, stdout ); - sh.eventLdcId = l; - fwrite( &sh, sizeof(sh), 1, stdout ); - dumpDummy( sh.eventSize - EVENT_HEAD_BASE_SIZE ); - } - CLEAR_SYSTEM_ATTRIBUTE( h.eventTypeAttribute, ATTR_P_START ); - CLEAR_SYSTEM_ATTRIBUTE( sh.eventTypeAttribute, ATTR_P_START ); - SET_SYSTEM_ATTRIBUTE( h.eventTypeAttribute, ATTR_P_END ); - SET_SYSTEM_ATTRIBUTE( sh.eventTypeAttribute, ATTR_P_END ); - } -} - -void createSor() { - createSorEor( START_OF_RUN ); -} - -void createEor() { - createSorEor( END_OF_RUN ); -} - -void createData( const int loopNo ) { - int n; - int l; - int totSize; - - for ( totSize = EVENT_HEAD_BASE_SIZE, l = 0; - l != numFiles; - l++ ) - totSize += EVENT_HEAD_BASE_SIZE + sizeof( eh ) + dataBlockSizes[l]; - - h.eventSize = totSize; - h.eventType = sh.eventType = PHYSICS_EVENT; - RESET_ATTRIBUTES( h.eventTypeAttribute ); - SET_SYSTEM_ATTRIBUTE( h.eventTypeAttribute, ATTR_SUPER_EVENT ); - RESET_ATTRIBUTES( sh.eventTypeAttribute ); - h.eventGdcId = sh.eventGdcId = 0; - - for ( n = 0; n != loopNo; n++ ) { - LOAD_RAW_EVENT_ID( h.eventId, n, 0, n ); - LOAD_RAW_EVENT_ID( sh.eventId, n, 0, n ); - fwrite( &h, sizeof(h), 1, stdout ); - - for ( l = 0; l != numFiles; l++ ) { - sh.eventLdcId = l; - sh.eventSize = EVENT_HEAD_BASE_SIZE + sizeof( eh ) + dataBlockSizes[l]; - eh.equipmentSize = dataBlockSizes[l]; - fwrite( &sh, sizeof(sh), 1, stdout ); - fwrite( &eh, sizeof(eh), 1, stdout ); - fwrite( dataBlocks[l], dataBlockSizes[l], 1, stdout ); - } - } -} - -void createStream() { - if ( doSor ) createSor(); - createData( numLoops ); - if ( doEor ) createEor(); -} - -int main( int argc, char **argv ) { - whoAmI = argv[0]; - - if ( !handleArgs( argc, argv ) ) return 1; - if ( !readData() ) return 1; - initStructs(); - createStream(); - return 0; -} - -#else - -int main( int argc, char **argv ) { - fprintf( stderr, "%s was compiled without DATE\n", argv[0] ); - return 1; -} - -#endif -- 2.43.5