Changeset 15470 for trunk/FACT++/src
- Timestamp:
- 05/01/13 11:08:01 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventBuilder.c
r15469 r15470 589 589 evtCtrl[i].fEvent->StartTM[k] = -1; 590 590 591 evtCtrl[i].fEvent->NumBoards = 0; 592 evtCtrl[i].fEvent->PCTime = evtCtrl[i].pcTime[0]; 593 evtCtrl[i].fEvent->PCUsec = evtCtrl[i].pcTime[1]; 591 evtCtrl[i].fEvent->NumBoards = 0; 592 evtCtrl[i].fEvent->SoftTrig = 0; 593 evtCtrl[i].fEvent->PCTime = evtCtrl[i].pcTime[0]; 594 evtCtrl[i].fEvent->PCUsec = evtCtrl[i].pcTime[1]; 595 evtCtrl[i].fEvent->Roi = evtCtrl[i].nRoi; 596 evtCtrl[i].fEvent->RoiTM = evtCtrl[i].nRoiTM; 597 evtCtrl[i].fEvent->EventNum = evtCtrl[i].evNum; 598 evtCtrl[i].fEvent->TriggerNum = evtCtrl[i].trgNum; 599 evtCtrl[i].fEvent->TriggerType = evtCtrl[i].trgTyp; 594 600 } 595 601 … … 1261 1267 1262 1268 //get index into mBuffer for this event (create if needed) 1263 const int evID= mBufEvt(i);1269 const int idx = mBufEvt(i); 1264 1270 1265 1271 // no free entry in mBuffer, retry later 1266 if ( evID== -1)1272 if (idx == -1) 1267 1273 continue; 1268 1274 1269 1275 // We have a valid entry, but no memory has yet been allocated 1270 if ( evID >= 0 && evtCtrl[evID].FADhead == NULL)1276 if (idx >= 0 && evtCtrl[idx].FADhead == NULL) 1271 1277 { 1272 1278 // Try to get memory from the big buffer 1273 evtCtrl[ evID].FADhead = (PEVNT_HEADER*)TGB_Malloc();1274 if (evtCtrl[ evID].FADhead == NULL)1279 evtCtrl[idx].FADhead = (PEVNT_HEADER*)TGB_Malloc(); 1280 if (evtCtrl[idx].FADhead == NULL) 1275 1281 { 1276 1282 // If this works properly, this is a hack which can be removed, or 1277 1283 // replaced by a signal or dim message 1278 1284 if (rd[i].bufTyp==2) 1279 factPrintf(kError, 882, "malloc failed for event %d ", evID);1285 factPrintf(kError, 882, "malloc failed for event %d (run=%d)", evtCtrl[idx].evNum, evtCtrl[idx].runNum); 1280 1286 rd[i].bufTyp = 2; 1281 1287 continue; 1282 1288 } 1283 1289 1284 // Initiali cemBuffer[evID]->fEvent1285 initEvent( evID);1290 // Initialise contents of mBuffer[evID]->fEvent 1291 initEvent(idx); 1286 1292 1287 1293 // Some statistics … … 1295 1301 if (gj.bufTot > gj.maxEvt) 1296 1302 gj.maxEvt = gj.bufTot; 1297 1298 //register event in 'active list (reading)'1299 //mBuffer[evID].evtCtrl_idx = evtCtrl_lastPtr;1300 1301 //evtCtrl[evtCtrl_lastPtr].mBuffer_idx = evID;1302 //evtCtrl[evtCtrl_lastPtr].evtStat = 0;1303 //evtCtrl[evtCtrl.lastPtr].pcTime = g_actTime;1304 1305 //evtCtrl_lastPtr++;1306 //evtCtrl_lastPtr %= MAX_EVT * MAX_RUN;1307 1303 } 1308 1304 … … 1313 1309 1314 1310 // Fatal error occured. Event cannot be processed. Skip it. Start reading next header. 1315 if ( evID< -1000)1311 if (idx < -1000) 1316 1312 continue; 1317 1313 … … 1326 1322 } 1327 1323 1328 if (evtCtrl[ evID].board[board] != -1)1324 if (evtCtrl[idx].board[board] != -1) 1329 1325 { 1330 1326 factPrintf(kWarn, 501, "Got event %5d from board %3d (i=%3d, len=%5d) twice: Starts with %3d %3d - ends with %3d %3d", 1331 ev ID, board, i, rd[i].fadLen,1327 evtCtrl[idx].evNum, board, i, rd[i].fadLen, 1332 1328 rd[i].rBuf->B[0], rd[i].rBuf->B[1], 1333 1329 rd[i].rBuf->B[rd[i].fadLen - 2], … … 1337 1333 1338 1334 // Copy data from rd[i] to mBuffer[evID] 1339 copyData(i, evID, board);1335 copyData(i, idx, board); 1340 1336 1341 1337 // now we have stored a new board contents into Event structure 1342 1338 1343 evtCtrl[ evID].fEvent->NumBoards++;1344 evtCtrl[ evID].board[board] = board;1345 evtCtrl[ evID].nBoard++;1346 evtCtrl[ evID].evtStat = evtCtrl[evID].nBoard;1339 evtCtrl[idx].fEvent->NumBoards++; 1340 evtCtrl[idx].board[board] = board; 1341 evtCtrl[idx].nBoard++; 1342 evtCtrl[idx].evtStat = evtCtrl[idx].nBoard; 1347 1343 1348 1344 // have we already reported first (partial) event of this run ??? 1349 if (evtCtrl[ evID].nBoard==1 && evtCtrl[evID].runNum != actrun)1345 if (evtCtrl[idx].nBoard==1 && evtCtrl[idx].runNum != actrun) 1350 1346 { 1351 1347 // Signal the fadctrl that a new run has been started 1352 gotNewRun(evtCtrl[ evID].runNum, NULL);1348 gotNewRun(evtCtrl[idx].runNum, NULL); 1353 1349 1354 1350 factPrintf(kInfo, 1, "gotNewRun called, prev run %d, new run %d, event %d", 1355 actrun, evtCtrl[ evID].runNum, evtCtrl[evID].evNum);1351 actrun, evtCtrl[idx].runNum, evtCtrl[idx].evNum); 1356 1352 1357 1353 for (int j=0; j<MAX_RUN; j++) … … 1364 1360 // We got the first part of this event, so this is 1365 1361 // the number of events we expect for this run 1366 if (runCtrl[j].runId==evtCtrl[ evID].runNum)1362 if (runCtrl[j].runId==evtCtrl[idx].runNum) 1367 1363 runCtrl[j].lastEvt++; 1368 1364 } 1369 1365 1370 1366 // Change 'actrun' the the new runnumber 1371 actrun = evtCtrl[ evID].runNum;1367 actrun = evtCtrl[idx].runNum; 1372 1368 } 1373 1369 1374 1370 // event not yet complete 1375 if (evtCtrl[ evID].nBoard < actBoards)1371 if (evtCtrl[idx].nBoard < actBoards) 1376 1372 continue; 1377 1373 … … 1386 1382 1387 1383 // Flag that the event is ready for processing 1388 evtCtrl[ evID].evtStat = 99;1384 evtCtrl[idx].evtStat = 99; 1389 1385 1390 1386 } // end for loop over all sockets … … 1823 1819 1824 1820 //and set correct event header ; also check for consistency in event (not yet) 1825 evtCtrl[k0].fEvent->Roi = evtCtrl[k0].nRoi;1826 evtCtrl[k0].fEvent->RoiTM = evtCtrl[k0].nRoiTM;1827 evtCtrl[k0].fEvent->EventNum = evtCtrl[k0].evNum;1828 evtCtrl[k0].fEvent->TriggerNum = evtCtrl[k0].trgNum;1829 evtCtrl[k0].fEvent->TriggerType = evtCtrl[k0].trgTyp;1830 1821 evtCtrl[k0].fEvent->Errors[0] = evtCtrl[k0].Errors[0]; 1831 1822 evtCtrl[k0].fEvent->Errors[1] = evtCtrl[k0].Errors[1]; 1832 1823 evtCtrl[k0].fEvent->Errors[2] = evtCtrl[k0].Errors[2]; 1833 1824 evtCtrl[k0].fEvent->Errors[3] = evtCtrl[k0].Errors[3]; 1834 evtCtrl[k0].fEvent->SoftTrig = 0;1835 1836 1825 1837 1826 for (int ib=0; ib<NBOARDS; ib++)
Note:
See TracChangeset
for help on using the changeset viewer.