Changeset 15469 for trunk/FACT++
- Timestamp:
- 05/01/13 10:57:07 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventBuilder.c
r15468 r15469 1405 1405 for (int k0=evtCtrl_frstPtr; k0!=evtCtrl_lastPtr; k0++, k0 %= MAX_EVT*MAX_RUN) 1406 1406 { 1407 /*1408 if (k0==evtCtrl_frstPtr && evtCtrl[k0].evtStat<0)1409 {1410 evtCtrl_frstPtr++;1411 evtCtrl_frstPtr %= MAX_EVT * MAX_RUN;1412 1413 // Continue because evtCtrl.evtStat[k0] must be <01414 continue;1415 }*/1416 1417 1407 // Check the more likely case first: incomplete events 1418 1408 if (evtCtrl[k0].evtStat>0 && evtCtrl[k0].evtStat<92) … … 1421 1411 1422 1412 // Event has not yet timed out or was reported already 1423 const int id = k0;//vtCtrl[k0].mBuffer_idx; 1424 1425 if (evtCtrl[k0].evtStat>=90 || evtCtrl[id].pcTime[0]/*evtCtrl[k0].lastRecv*/>=g_actTime - 30) 1413 if (evtCtrl[k0].evtStat>=90 || evtCtrl[k0].pcTime[0]/*evtCtrl[k0].lastRecv*/>=g_actTime - 30) 1426 1414 continue; 1427 1415 1428 reportIncomplete( id);1416 reportIncomplete(k0); 1429 1417 1430 1418 //timeout for incomplete events … … 1442 1430 if (evtCtrl[k0].evtStat==0 || evtCtrl[k0].evtStat >= 9000) 1443 1431 { 1444 const int id = k0;//evtCtrl[k0].mBuffer_idx; 1445 #ifdef EVTDEBUG 1446 factPrintf(kDebug, -1, "%5d free event buffer, nb=%3d", evtCtrl[id].evNum, evtCtrl[id].nBoard); 1447 #endif 1448 mBufFree (id); //event written--> free memory 1432 mBufFree(k0); //event written--> free memory 1449 1433 evtCtrl[k0].evtStat = -1; 1450 1434 … … 1456 1440 else 1457 1441 factPrintf(kDebug, -1, "Freed a non-first slot"); 1458 1459 1442 1460 1443 gj.evtWrite++; … … 1569 1552 if (evtCtrl[k0].evtStat > minclear) 1570 1553 { 1571 const int id = k0;//evtCtrl[k0].mBuffer_idx; 1572 #ifdef EVTDEBUG 1573 factPrintf(kDebug, -1, "ev %5d free event buffer, nb=%3d", evtCtrl[id].evNum, evtCtrl[id].nBoard); 1574 #endif 1575 mBufFree (id); //event written--> free memory 1554 mBufFree(k0); //event written--> free memory 1576 1555 evtCtrl[k0].evtStat = -1; 1577 1556 1578 if (k0==evtCtrl_frstPtr)1579 {1580 evtCtrl_frstPtr++;1581 evtCtrl_frstPtr %= MAX_EVT * MAX_RUN;1582 }1583 else1584 factPrintf(kDebug, -1, "Freed a non-first slot");1557 if (k0==evtCtrl_frstPtr) 1558 { 1559 evtCtrl_frstPtr++; 1560 evtCtrl_frstPtr %= MAX_EVT * MAX_RUN; 1561 } 1562 else 1563 factPrintf(kDebug, -1, "Freed a non-first slot"); 1585 1564 } 1586 1565 else 1587 1566 if (evtCtrl[k0].evtStat > 0) 1588 1567 numclear++; //writing is still ongoing... 1589 1590 /*1591 if (k0 == evtCtrl_frstPtr && evtCtrl[k0].evtStat < 0)1592 {1593 evtCtrl_frstPtr++;1594 evtCtrl_frstPtr %= MAX_EVT * MAX_RUN;1595 }*/1596 1568 } 1597 1569 … … 1654 1626 } 1655 1627 1656 /*** if (evtCtrl.evtStat[k0] == 1000 + threadID) ****/1657 1658 1628 int jret = 9100; // flag to be deleted (gi_resetR>1 : flush buffers asap) 1659 1629 1660 1630 if (gi_resetR<=1) 1661 1631 { 1662 const int id = k0;//evtCtrl[k0].mBuffer_idx; 1663 1664 jret = subProcEvt(threadID, evtCtrl[id].FADhead, 1665 evtCtrl[id].fEvent, NULL/*mBuffer[id].buffer*/); 1632 jret = subProcEvt(threadID, evtCtrl[k0].FADhead, 1633 evtCtrl[k0].fEvent, NULL/*mBuffer[id].buffer*/); 1666 1634 1667 1635 … … 1762 1730 //-------- it is better to open the run already here, so call can be used to initialize 1763 1731 //-------- buffers etc. needed to interprete run (e.g. DRS calibration) 1764 const int id = k0;//evtCtrl[k0].mBuffer_idx; 1765 1766 const uint32_t irun = evtCtrl[id].runNum; 1767 const int32_t ievt = evtCtrl[id].evNum; 1732 const uint32_t irun = evtCtrl[k0].runNum; 1733 const int32_t ievt = evtCtrl[k0].evNum; 1768 1734 1769 1735 // Find entry in runCtrl which belongs to the event mBuffer[id] … … 1779 1745 if (j>=MAX_RUN) 1780 1746 { 1781 factPrintf(kFatal, 901, "writeEvt: Can not find run %d for event %d in %d", irun, ievt, id);1747 factPrintf(kFatal, 901, "writeEvt: Can not find run %d for event %d in %d", irun, ievt, k0); 1782 1748 // FIXME: What is the right action? (Flag event for deletion?) 1783 1749 continue; … … 1808 1774 actRun.Version = 1; 1809 1775 actRun.RunType = -1; //to be adapted 1810 actRun.Nroi = evtCtrl[ id].nRoi; //runCtrl[lastRun].roi0;1811 actRun.NroiTM = evtCtrl[ id].nRoiTM; //runCtrl[lastRun].roi8;1812 actRun.RunTime = evtCtrl[ id].pcTime[0]; //runCtrl[lastRun].firstTime;1813 actRun.RunUsec = evtCtrl[ id].pcTime[1]; //runCtrl[lastRun].firstUsec;1776 actRun.Nroi = evtCtrl[k0].nRoi; //runCtrl[lastRun].roi0; 1777 actRun.NroiTM = evtCtrl[k0].nRoiTM; //runCtrl[lastRun].roi8; 1778 actRun.RunTime = evtCtrl[k0].pcTime[0]; //runCtrl[lastRun].firstTime; 1779 actRun.RunUsec = evtCtrl[k0].pcTime[1]; //runCtrl[lastRun].firstUsec; 1814 1780 actRun.NBoard = NBOARDS; 1815 1781 actRun.NPix = NPIX; 1816 1782 actRun.NTm = NTMARK; 1817 1783 1818 memcpy(actRun.FADhead, evtCtrl[ id].FADhead, NBOARDS*sizeof(PEVNT_HEADER));1784 memcpy(actRun.FADhead, evtCtrl[k0].FADhead, NBOARDS*sizeof(PEVNT_HEADER)); 1819 1785 1820 1786 runCtrl[lastRun].fileHd = runOpen (irun, &actRun, sizeof (actRun)); … … 1856 1822 //-------- 1857 1823 1858 //const int roi = mBuffer[id].nRoi;1859 //const int roiTM = mBuffer[id].nRoiTM;1860 1861 //make sure unused pixels/tmarks are cleared to zero1862 //ETIENNE don't reset it to zero as it is taken care of in DataWriteFits1863 // if (roiTM == roi)1864 // roiTM = 0;1865 /*1866 for (int ip=0; ip<NPIX; ip++)1867 {1868 if (mBuffer[id].fEvent->StartPix[ip] == -1)1869 {1870 const int dest = ip * roi;1871 memset(&mBuffer[id].fEvent->Adc_Data[dest], 0, roi * 2);1872 }1873 }1874 1875 for (int it=0; it<NTMARK; it++)1876 {1877 if (mBuffer[id].fEvent->StartTM[it] == -1)1878 {1879 const int dest = it * roi + NPIX * roi;1880 memset(&mBuffer[id].fEvent->Adc_Data[dest], 0, roi * 2);1881 }1882 }*/1883 1884 1824 //and set correct event header ; also check for consistency in event (not yet) 1885 evtCtrl[ id].fEvent->Roi = evtCtrl[id].nRoi;1886 evtCtrl[ id].fEvent->RoiTM = evtCtrl[id].nRoiTM;1887 evtCtrl[ id].fEvent->EventNum = evtCtrl[id].evNum;1888 evtCtrl[ id].fEvent->TriggerNum = evtCtrl[id].trgNum;1889 evtCtrl[ id].fEvent->TriggerType = evtCtrl[id].trgTyp;1890 evtCtrl[ id].fEvent->Errors[0] = evtCtrl[id].Errors[0];1891 evtCtrl[ id].fEvent->Errors[1] = evtCtrl[id].Errors[1];1892 evtCtrl[ id].fEvent->Errors[2] = evtCtrl[id].Errors[2];1893 evtCtrl[ id].fEvent->Errors[3] = evtCtrl[id].Errors[3];1894 evtCtrl[ id].fEvent->SoftTrig = 0;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 evtCtrl[k0].fEvent->Errors[0] = evtCtrl[k0].Errors[0]; 1831 evtCtrl[k0].fEvent->Errors[1] = evtCtrl[k0].Errors[1]; 1832 evtCtrl[k0].fEvent->Errors[2] = evtCtrl[k0].Errors[2]; 1833 evtCtrl[k0].fEvent->Errors[3] = evtCtrl[k0].Errors[3]; 1834 evtCtrl[k0].fEvent->SoftTrig = 0; 1895 1835 1896 1836 … … 1898 1838 { 1899 1839 // board is not read 1900 if (evtCtrl[ id].board[ib] == -1)1840 if (evtCtrl[k0].board[ib] == -1) 1901 1841 { 1902 evtCtrl[ id].FADhead[ib].start_package_flag = 0;1903 evtCtrl[ id].fEvent->BoardTime[ib] = 0;1842 evtCtrl[k0].FADhead[ib].start_package_flag = 0; 1843 evtCtrl[k0].fEvent->BoardTime[ib] = 0; 1904 1844 } 1905 1845 else 1906 1846 { 1907 evtCtrl[ id].fEvent->BoardTime[ib] = evtCtrl[id].FADhead[ib].time;1847 evtCtrl[k0].fEvent->BoardTime[ib] = evtCtrl[k0].FADhead[ib].time; 1908 1848 } 1909 1849 } 1910 1850 1911 const int rc = eventCheck(evtCtrl[ id].runNum, evtCtrl[id].FADhead,1912 evtCtrl[ id].fEvent);1851 const int rc = eventCheck(evtCtrl[k0].runNum, evtCtrl[k0].FADhead, 1852 evtCtrl[k0].fEvent); 1913 1853 //gi.procTot++; 1914 1854 numProc++;
Note:
See TracChangeset
for help on using the changeset viewer.