} *payloadsHead, *payloadsTail;
int lineNo;
eventGdcIdType currGdcId;
+unsigned long32 currDetPattern;
eventLdcIdType currLdcId;
equipmentIdType currEquipmentId;
int currRunNb;
int gotAliceTrigger;
int bufferData;
+struct commonDataHeaderStruct *cdhRef = NULL;
+
void dumpPayload( const struct payloadDescriptorStruct *p ) {
char *c;
int i;
gdc = gdc->next ) {
struct ldcEventDescriptorStruct *ldc;
- printf( " GDC (%p)\n", gdc );
+ printf( " GDC (%p)\n", (void*)gdc );
for ( ldc = gdc->head; ldc != NULL; ldc = ldc->next ) {
struct equipmentEventDescriptorStruct *eq;
- printf( " LDC (%p): %d\n", ldc, ldc->id );
+ printf( " LDC (%p): %d\n", (void*)ldc, ldc->id );
for ( eq = ldc->head; eq != NULL; eq = eq->next ) {
printf( " EQUIPMENT (%p): %d PAYLOAD (%p):",
- eq,
+ (void*)eq,
eq->id,
- eq->payload );
+ (void*)eq->payload );
fflush( stdout );
printf( "\"%s\" (%d bytes)\n",
eq->payload->fileName,
printf( " LDC\n" );
for ( eq = ldc->head; eq != NULL; eq = eq->next ) {
printf( " EQUIPMENT (%p): %d PAYLOAD (%p):",
- eq,
+ (void*)eq,
eq->id,
- eq->payload );
+ (void*)eq->payload );
fflush( stdout );
printf( "\"%s\" (%d bytes)\n",
eq->payload->fileName,
printf( "%d) Payload \"%s\" loaded at %p\n",
lineNo,
fileName,
- payload );
+ (void*)payload );
if ( bufferData ) {
- if ( handleCDH ) {
+ if ( handleCDH &&
+ strncmp(fileName,"TRG_",4) != 0 ) {
struct commonDataHeaderStruct *cdh =
(struct commonDataHeaderStruct *)payload->data;
printf( "%d) Payload \"%s\" already loaded at %p\n",
lineNo,
fileName,
- payload );
+ (void*)payload );
}
currEvent->payload = payload;
lineNo );
exit( 1 );
}
- if ( sscanf( idNum, "%d", &currGdcId ) != 1 ) {
+ if ( sscanf( idNum, "%d", (int*)&currGdcId ) != 1 ) {
fprintf( stderr,
"%s: line:%d GDC declaration, numeric ID needed (%s)",
myName,
DBG_VERBOSE printf( "%d) GDC - ID:%d\n",
lineNo,
currGdcId );
+ } else if ( strcasecmp( "DetectorPattern", keyword ) == 0 ) {
+ char *detPattern;
+
+ if ( (detPattern = strtok_r( p, " \t", &p )) == NULL ) {
+ fprintf( stderr,
+ "%s: line:%d GDC declaration, DetectorPattern needed",
+ myName,
+ lineNo );
+ exit( 1 );
+ }
+ if ( sscanf( detPattern, "%u", &currDetPattern ) != 1 ) {
+ fprintf( stderr,
+ "%s: line:%d GDC declaration, numeric DetectorPattern needed (%s)",
+ myName,
+ lineNo,
+ detPattern );
+ exit( 1 );
+ }
+ DBG_VERBOSE printf( "%d) GDC - DetectorPattern:%u\n",
+ lineNo,
+ currDetPattern );
} else {
fprintf( stderr,
"%s: line:%d GDC declaration, unknown keyword \"%s\"\n",
lineNo );
exit( 1 );
}
- if ( sscanf( idNum, "%d", &currLdcId ) != 1 ) {
+ if ( sscanf( idNum, "%d", (int*)&currLdcId ) != 1 ) {
fprintf( stderr,
"%s: line:%d LDC declaration, numeric ID needed (%s)",
myName,
currLdcId = HOST_ID_MIN;
currGdcId = HOST_ID_MIN;
+ currDetPattern = 0;
for ( lineNo = 1; !feof( stdin ); lineNo++ ) {
getLine( line, sizeof(line) );
}
}
}
- } while ( !feof( stdin ) );
+ } while ( !feof( stdin ) ) {}
lineNo -= 2;
DBG_VERBOSE {
assert( ldcsHead != NULL );
assert( ldcsTail != NULL );
assert( ldcsTail->next == NULL );
- for ( ldc = ldcsHead; ldc->next != NULL; ldc = ldc->next );
+ for ( ldc = ldcsHead; ldc->next != NULL; ldc = ldc->next ) {}
assert ( ldc == ldcsTail );
}
} /* End of createEor */
void loadCdh( struct commonDataHeaderStruct * const cdh,
- eventIdType * const eventId ) {
+ eventIdType * const eventId,
+ equipmentIdType id ) {
if ( !handleCDH ) return;
+ // CTP raw-data does not contain CDH
+ if ( id == 4352) return;
+
if ( gotAliceTrigger ) {
cdh->cdhEventId1 = EVENT_ID_GET_BUNCH_CROSSING( *eventId );
cdh->cdhEventId2 = EVENT_ID_GET_ORBIT( *eventId );
cdh->cdhMiniEventId = cdh->cdhEventId1;
}
void decodeCDH( struct ldcEventDescriptorStruct * const ldc,
- const struct payloadDescriptorStruct * const payloadDesc );
+ const struct payloadDescriptorStruct * const payloadDesc,
+ equipmentIdType id );
void createEvent( void ) {
assert( workingAs == ldc || workingAs == gdc );
for ( eq = ldc->head; eq != NULL; eq = eq->next ) {
if ( !bufferData ) {
loadBuffer( eq->payload );
- if ( !currGdc->loaded ) decodeCDH( ldc, eq->payload );
+ decodeCDH( ldc, eq->payload, eq->id );
}
loadCdh( (struct commonDataHeaderStruct*)eq->payload->data,
- &currEventId );
+ &currEventId,
+ eq->id);
}
if ( !currGdc->loaded ) {
currGdc->loaded = TRUE;
}
}
+ cdhRef = NULL;
} else if ( workingAs == ldc ) {
struct equipmentEventDescriptorStruct *eq;
for ( eq = currLdc->head; eq != NULL; eq = eq->next ) {
if ( !bufferData ) {
loadBuffer( eq->payload );
- if ( !currLdc->loaded ) decodeCDH( currLdc, eq->payload );
+ decodeCDH( currLdc, eq->payload, eq->id );
}
loadCdh( (struct commonDataHeaderStruct*)eq->payload->data,
- &currEventId );
+ &currEventId,
+ eq->id);
currLdc->loaded = TRUE;
}
+ cdhRef = NULL;
}
ADD_EVENT_ID( currEventId, oneEventDelta );
handleCDH = TRUE;
} else if ( strcmp( "-D", argv[ arg ] ) == 0 ) {
bufferData = FALSE;
+ } else if ( strcmp( "-run", argv[ arg ] ) == 0 ) {
+ int runnumber;
+ if ( ++arg == argc ) exit( usage() );
+ if ( sscanf( argv[ arg ], "%d", &runnumber ) != 1 ) exit( usage() );
+ if ( runnumber < 0 ) exit( usage() );
+ currRunNb = runnumber;
} else {
fprintf( stderr, "%s: Unknown switch \"%s\"\n", myName, argv[argc] );
exit( usage() );
} /* End of initEquipment */
void decodeCDH( struct ldcEventDescriptorStruct * const ldc,
- const struct payloadDescriptorStruct * const payloadDesc ) {
- if ( handleCDH ) {
- static struct commonDataHeaderStruct *cdhRef = NULL;
+ const struct payloadDescriptorStruct * const payloadDesc,
+ equipmentIdType id ) {
+ if ( handleCDH &&
+ id != 4352 ) {
struct commonDataHeaderStruct *cdh;
static int softwareTriggerIndicator = FALSE;
int attr;
gdc->header.eventType = PHYSICS_EVENT;
SET_SYSTEM_ATTRIBUTE( gdc->header.eventTypeAttribute, ATTR_SUPER_EVENT );
gdc->header.eventGdcId = currGdcId;
+ COPY_DETECTOR_PATTERN(&currDetPattern, gdc->header.eventDetectorPattern);
for ( ldc = gdc->head; ldc != NULL; ldc = ldc->next ) {
struct equipmentEventDescriptorStruct *eq;
ldc->header.eventSize = ldc->header.eventHeadSize;
ldc->header.eventType = PHYSICS_EVENT;
ldc->header.eventGdcId = currGdcId;
+ COPY_DETECTOR_PATTERN(&currDetPattern, ldc->header.eventDetectorPattern);
ldc->header.eventLdcId = ldc->id;
for ( eq = ldc->head; eq != NULL; eq = eq->next ) {
initEquipment( &eq->header );
ATTR_ORBIT_BC );
eq->header.equipmentSize = eq->payload->size + sizeof( eq->header );
ldc->header.eventSize += eq->header.equipmentSize;
- decodeCDH( ldc, eq->payload );
+ decodeCDH( ldc, eq->payload, eq->id );
OR_ALL_ATTRIBUTES( eq->header.equipmentTypeAttribute,
ldc->header.eventTypeAttribute );
OR_ALL_ATTRIBUTES( eq->header.equipmentTypeAttribute,
}
gdc->header.eventSize += ldc->header.eventSize;
}
+ cdhRef = NULL;
}
DBG_VERBOSE {
ATTR_ORBIT_BC );
eq->header.equipmentSize = eq->payload->size + sizeof( eq->header );
ldc->header.eventSize += eq->header.equipmentSize;
- decodeCDH( ldc, eq->payload );
+ decodeCDH( ldc, eq->payload, eq->id );
OR_ALL_ATTRIBUTES( eq->header.equipmentTypeAttribute,
ldc->header.eventTypeAttribute );
}
+ cdhRef = NULL;
}
DBG_VERBOSE {
printf( "Headers:\n" );
currLdc = NULL;
currEvent = NULL;
payloadsHead = payloadsTail = NULL;
- currRunNb = 1;
+ currRunNb = -1;
numOfLdcs = 0;
numOfEvents = 1;
createSorEor = TRUE;