- Timestamp:
- 07/31/11 12:03:01 (13 years ago)
- Location:
- trunk/FACT++
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/gui/FactGui.h
r11714 r11731 382 382 383 383 DimStampedInfo fDimFtmPassport; 384 DimStampedInfo fDimFtmTrigger Counter;384 DimStampedInfo fDimFtmTriggerRates; 385 385 DimStampedInfo fDimFtmError; 386 386 DimStampedInfo fDimFtmFtuList; … … 542 542 } 543 543 544 void RemoveService( const std::string &server, const std::string &service, bool iscmd)544 void RemoveService(std::string server, std::string service, bool iscmd) 545 545 { 546 546 UnsubscribeService(server+'/'+service, true); … … 1669 1669 // ===================== FTM ============================================ 1670 1670 1671 double fTimeStamp1; 1672 1673 void handleFtmTriggerCounter(const DimData &d) 1674 { 1675 if (!CheckSize(d, sizeof(FTM::DimTriggerCounter))) 1676 return; 1677 1678 const FTM::DimTriggerCounter &sdata = d.ref<FTM::DimTriggerCounter>(); 1671 void UpdateTriggerRate(const FTM::DimTriggerRates &sdata) 1672 { 1673 #ifdef HAVE_ROOT 1674 TCanvas *c = fFtmRateCanv->GetCanvas(); 1675 1676 TH1 *h = (TH1*)c->FindObject("TimeFrame"); 1677 1678 if (sdata.fTriggerRate<0) 1679 { 1680 fGraphFtmRate.Set(0); 1681 1682 const double tm = Time().RootTime(); 1683 1684 h->SetBins(1, tm, tm+60); 1685 h->GetXaxis()->SetTimeFormat("%M'%S\""); 1686 h->GetXaxis()->SetTitle("Time"); 1687 1688 c->Modified(); 1689 c->Update(); 1690 return; 1691 } 1692 1693 const double t1 = h->GetXaxis()->GetXmax(); 1694 const double t0 = h->GetXaxis()->GetXmin(); 1695 1696 const double now = t0+sdata.fTimeStamp/1000000.; 1697 1698 h->SetBins(h->GetNbinsX()+1, t0, now+1); 1699 fGraphFtmRate.SetPoint(fGraphFtmRate.GetN(), now, sdata.fTriggerRate); 1700 1701 if (t1-t0>60) 1702 { 1703 h->GetXaxis()->SetTimeFormat("%Hh%M'"); 1704 h->GetXaxis()->SetTitle("Time"); 1705 } 1706 1707 h->SetMinimum(0); 1708 1709 c->Modified(); 1710 c->Update(); 1711 #endif 1712 } 1713 1714 void UpdateRatesCam(const FTM::DimTriggerRates &sdata) 1715 { 1716 #ifdef HAVE_ROOT 1717 if (fThresholdIdx->value()>=0) 1718 { 1719 const int isw = fThresholdIdx->value(); 1720 const int ihw = fPatchMapHW[isw]; 1721 fPatchRate->setValue(sdata.fPatchRate[ihw]); 1722 } 1723 1724 valarray<double> dat(0., 1440); 1725 1726 // fPatch converts from software id to software patch id 1727 for (int i=0; i<1440; i++) 1728 { 1729 const int ihw = fPatchHW[i]; 1730 // const int isw = fPatch[i]; 1731 // const int ihw = fPatchMapHW[isw]; 1732 dat[i] = sdata.fPatchRate[ihw]; 1733 } 1734 1735 TCanvas *c = fRatesCanv->GetCanvas(); 1736 Camera *cam = (Camera*)c->FindObject("Camera"); 1737 1738 cam->SetData(dat); 1739 1740 c->Modified(); 1741 c->Update(); 1742 #endif 1743 } 1744 1745 int64_t fTimeStamp0; 1746 1747 void UpdateRatesGraphs(const FTM::DimTriggerRates &sdata) 1748 { 1749 #ifdef HAVE_ROOT 1750 if (fTimeStamp0<0) 1751 { 1752 fTimeStamp0 = sdata.fTimeStamp; 1753 return; 1754 } 1755 1756 TCanvas *c = fFtmRateCanv->GetCanvas(); 1757 1758 TH1 *h = (TH1*)c->FindObject("TimeFrame"); 1759 1760 const double tdiff = sdata.fTimeStamp-fTimeStamp0; 1761 fTimeStamp0 = sdata.fTimeStamp; 1762 1763 if (tdiff<0) 1764 { 1765 for (int i=0; i<160; i++) 1766 fGraphPatchRate[i].Set(0); 1767 for (int i=0; i<40; i++) 1768 fGraphBoardRate[i].Set(0); 1769 1770 return; 1771 } 1772 1773 //const double t1 = h->GetXaxis()->GetXmax(); 1774 const double t0 = h->GetXaxis()->GetXmin(); 1775 1776 for (int i=0; i<160; i++) 1777 fGraphPatchRate[i].SetPoint(fGraphPatchRate[i].GetN(), 1778 t0+sdata.fTimeStamp/1000000., sdata.fPatchRate[i]); 1779 for (int i=0; i<40; i++) 1780 fGraphBoardRate[i].SetPoint(fGraphBoardRate[i].GetN(), 1781 t0+sdata.fTimeStamp/1000000., sdata.fBoardRate[i]); 1782 1783 c->Modified(); 1784 c->Update(); 1785 #endif 1786 } 1787 1788 void handleFtmTriggerRates(const DimData &d) 1789 { 1790 if (!CheckSize(d, sizeof(FTM::DimTriggerRates))) 1791 return; 1792 1793 const FTM::DimTriggerRates &sdata = d.ref<FTM::DimTriggerRates>(); 1679 1794 1680 1795 fFtmTime->setText(QString::number(sdata.fTimeStamp/1000000., 'f', 6)+ " s"); … … 1686 1801 fTriggerCounterRate->setValue(0); 1687 1802 1688 1689 1803 // ---------------------------------------------- 1690 #ifdef HAVE_ROOT 1691 1692 if (fTriggerCounter0<0) 1693 { 1694 fTriggerCounter0 = sdata.fTriggerCounter; 1695 fTimeStamp1 = sdata.fTimeStamp; 1696 return; 1697 } 1698 1699 TCanvas *c = fFtmRateCanv->GetCanvas(); 1700 1701 TH1 *h = (TH1*)c->FindObject("TimeFrame"); 1702 1703 const double rate = sdata.fTriggerCounter-fTriggerCounter0; 1704 const double tdiff = sdata.fTimeStamp -fTimeStamp1; 1705 1706 fTriggerCounter0 = sdata.fTriggerCounter; 1707 fTimeStamp1 = sdata.fTimeStamp; 1708 1709 if (rate<0 && tdiff<=0) 1710 { 1711 fGraphFtmRate.Set(0); 1712 1713 const double tm = Time().RootTime(); 1714 1715 h->SetBins(1, tm, tm+60); 1716 h->GetXaxis()->SetTimeFormat("%M'%S\""); 1717 h->GetXaxis()->SetTitle("Time"); 1718 1719 c->Modified(); 1720 c->Update(); 1721 return; 1722 } 1723 1724 if (rate<0) 1725 return; 1726 1727 // const double avgrate = sdata.fTimeStamp>0 ? double(sdata.fTriggerCounter)/sdata.fTimeStamp*1000000 : 1; 1728 1729 const double t1 = h->GetXaxis()->GetXmax(); 1730 const double t0 = h->GetXaxis()->GetXmin(); 1731 1732 h->SetBins(h->GetNbinsX()+1, t0, t0+sdata.fTimeStamp/1000000.+1); 1733 fGraphFtmRate.SetPoint(fGraphFtmRate.GetN(), 1734 t0+sdata.fTimeStamp/1000000., 1000000*rate/tdiff); 1735 1736 if (t1-t0>60) 1737 { 1738 h->GetXaxis()->SetTimeFormat("%Hh%M'"); 1739 h->GetXaxis()->SetTitle("Time"); 1740 } 1741 1742 h->SetMinimum(0); 1743 // h->SetMaximum(2*avgrate); 1744 1745 c->Modified(); 1746 c->Update(); 1747 #endif 1804 1805 fOnTime->setText(QString::number(sdata.fOnTimeCounter/1000000., 'f', 6)+" s"); 1806 1807 if (sdata.fTimeStamp>0) 1808 fOnTimeRel->setValue(100.*sdata.fOnTimeCounter/sdata.fTimeStamp); 1809 else 1810 fOnTimeRel->setValue(0); 1811 1748 1812 // ---------------------------------------------- 1813 1814 UpdateTriggerRate(sdata); 1815 UpdateRatesGraphs(sdata); 1816 UpdateRatesCam(sdata); 1749 1817 } 1750 1818 … … 1764 1832 } 1765 1833 1766 int64_t fTriggerCounter0;1767 int64_t fTimeStamp0;1768 1769 1834 void handleFtmDynamicData(const DimData &d) 1770 1835 { … … 1773 1838 1774 1839 const FTM::DimDynamicData &sdata = d.ref<FTM::DimDynamicData>(); 1775 1776 fOnTime->setText(QString::number(sdata.fOnTimeCounter/1000000., 'f', 6)+" s");1777 1778 if (sdata.fTimeStamp>0)1779 fOnTimeRel->setValue(100.*sdata.fOnTimeCounter/sdata.fTimeStamp);1780 else1781 fOnTimeRel->setValue(0);1782 1840 1783 1841 fFtmTemp0->setValue(sdata.fTempSensor[0]*0.1); … … 1787 1845 1788 1846 SetLedColor(fClockCondLed, sdata.fState&FTM::kFtmLocked ? kLedGreen : kLedRed, d.time); 1789 1790 #ifdef HAVE_ROOT1791 1792 // ----------------------------------------------1793 1794 if (fTimeStamp0<0)1795 {1796 fTimeStamp0 = sdata.fTimeStamp;1797 return;1798 }1799 1800 TCanvas *c = fFtmRateCanv->GetCanvas();1801 1802 TH1 *h = (TH1*)c->FindObject("TimeFrame");1803 1804 const double tdiff = sdata.fTimeStamp-fTimeStamp0;1805 fTimeStamp0 = sdata.fTimeStamp;1806 1807 if (tdiff<0)1808 {1809 for (int i=0; i<160; i++)1810 fGraphPatchRate[i].Set(0);1811 for (int i=0; i<40; i++)1812 fGraphBoardRate[i].Set(0);1813 1814 return;1815 }1816 1817 //const double t1 = h->GetXaxis()->GetXmax();1818 const double t0 = h->GetXaxis()->GetXmin();1819 1820 for (int i=0; i<160; i++)1821 fGraphPatchRate[i].SetPoint(fGraphPatchRate[i].GetN(),1822 t0+sdata.fTimeStamp/1000000., float(sdata.fRatePatch[i])*2/fFtmStaticData.fPrescaling[i]);1823 for (int i=0; i<40; i++)1824 fGraphBoardRate[i].SetPoint(fGraphBoardRate[i].GetN(),1825 t0+sdata.fTimeStamp/1000000., float(sdata.fRateBoard[i])*2/fFtmStaticData.fPrescaling[i]);1826 1827 c->Modified();1828 c->Update();1829 1830 //fGraphFtmRate.ComputeRange(x[0], x[1], x[2], x[3]);1831 1832 // ----------------------------------------------1833 1834 if (fThresholdIdx->value()>=0)1835 {1836 const int isw = fThresholdIdx->value();1837 const int ihw = fPatchMapHW[isw];1838 fPatchRate->setValue(sdata.fRatePatch[ihw]);1839 }1840 1841 valarray<double> dat(0., 1440);1842 1843 // fPatch converts from software id to software patch id1844 for (int i=0; i<1440; i++)1845 {1846 const int ihw = fPatchHW[i];1847 // const int isw = fPatch[i];1848 // const int ihw = fPatchMapHW[isw];1849 dat[i] = sdata.fRatePatch[ihw];1850 }1851 1852 c = fRatesCanv->GetCanvas();1853 Camera *cam = (Camera*)c->FindObject("Camera");1854 1855 cam->SetData(dat);1856 1857 c->Modified();1858 c->Update();1859 1860 // ----------------------------------------------1861 #endif1862 1847 } 1863 1848 … … 2543 2528 return PostInfoHandler(&FactGui::handleLoggerFilenameRun); 2544 2529 2545 if (getInfo()==&fDimFtmTrigger Counter)2546 return PostInfoHandler(&FactGui::handleFtmTrigger Counter);2530 if (getInfo()==&fDimFtmTriggerRates) 2531 return PostInfoHandler(&FactGui::handleFtmTriggerRates); 2547 2532 2548 2533 if (getInfo()==&fDimFtmCounter) … … 2966 2951 //- 2967 2952 fDimFtmPassport ("FTM_CONTROL/PASSPORT", (void*)NULL, 0, this), 2968 fDimFtmTrigger Counter ("FTM_CONTROL/TRIGGER_COUNTER",(void*)NULL, 0, this),2953 fDimFtmTriggerRates ("FTM_CONTROL/TRIGGER_RATES", (void*)NULL, 0, this), 2969 2954 fDimFtmError ("FTM_CONTROL/ERROR", (void*)NULL, 0, this), 2970 2955 fDimFtmFtuList ("FTM_CONTROL/FTU_LIST", (void*)NULL, 0, this), … … 2992 2977 //- 2993 2978 fEventData(0), fDrsCalibration(1440*1024*6), 2994 fTimeStamp1(0),2995 fTriggerCounter0(0),2996 2979 fTimeStamp0(0) 2997 2980 … … 3199 3182 hf->GetYaxis()->SetRangeUser(0, 1010); 3200 3183 3201 fTriggerCounter0 = -1;3202 3203 3184 fGraphFtmRate.SetMarkerStyle(kFullDotSmall); 3204 3185 fGraphFtmRate.Draw("LP"); -
trunk/FACT++/src/HeadersFTM.h
r11708 r11731 147 147 } __attribute__((__packed__)); 148 148 149 /* 149 150 struct DimTriggerCounter 150 151 { … … 158 159 } 159 160 } __attribute__((__packed__)); 160 161 */ 161 162 162 163 struct StaticDataBoard … … 535 536 uint16_t fRateOverflow[40]; 536 537 538 uint16_t fPrescaling[40]; 539 537 540 uint16_t fCrcError[40]; 538 541 539 542 uint16_t fState; 540 543 541 DimDynamicData(const Header &h, const DynamicData &d ) :544 DimDynamicData(const Header &h, const DynamicData &d, const StaticData &s) : 542 545 fTimeStamp(h.fTimeStamp), 543 546 fOnTimeCounter(d.fOnTimeCounter), … … 554 557 for (int j=0; j<4; j++) 555 558 fRatePatch[i*4+j] = d[i].fRatePatch[j]; 559 560 fPrescaling[i] = s[i].fPrescaling; 561 } 562 } 563 564 } __attribute__((__packed__)); 565 566 struct DimTriggerRates 567 { 568 uint64_t fTimeStamp; 569 uint64_t fOnTimeCounter; 570 uint32_t fTriggerCounter; 571 float fTriggerRate; 572 float fBoardRate[40]; 573 float fPatchRate[160]; 574 575 DimTriggerRates(const Header &h, const DynamicData &d, const StaticData &s, float rate) : 576 fTimeStamp(h.fTimeStamp), fOnTimeCounter(d.fOnTimeCounter), 577 fTriggerCounter(h.fTriggerCounter), fTriggerRate(rate) 578 { 579 for (int i=0; i<40; i++) 580 { 581 if ((d[i].fOverflow>>4)&1) 582 fBoardRate[i] = float(UINT32_MAX+1)*2/s[i].fPrescaling; 583 else 584 fBoardRate[i] = float(d[i].fRateTotal)*2/s[i].fPrescaling; 585 586 // FIXME: Include fCrcError in calculation 587 //fRateOverflow[i] = d[i].fOverflow; 588 for (int j=0; j<4; j++) 589 if ((d[i].fOverflow>>j)&1) 590 fPatchRate[i*4+j] = float(UINT32_MAX+1)*2/s[i].fPrescaling; 591 else 592 fPatchRate[i*4+j] = float(d[i].fRatePatch[j])*2/s[i].fPrescaling; 556 593 } 557 594 } -
trunk/FACT++/src/ftmctrl.cc
r11662 r11731 1135 1135 1136 1136 DimDescribedService fDimPassport; 1137 DimDescribedService fDimTrigger Counter;1137 DimDescribedService fDimTriggerRates; 1138 1138 DimDescribedService fDimError; 1139 1139 DimDescribedService fDimFtuList; … … 1142 1142 DimDescribedService fDimCounter; 1143 1143 1144 uint64_t fTimeStamp; 1145 uint32_t fTriggerCounter; 1146 1144 1147 void UpdateFirstHeader() 1145 1148 { … … 1150 1153 } 1151 1154 1155 /* 1152 1156 void UpdateHeader() 1153 1157 { … … 1159 1163 const FTM::DimTriggerCounter data(fHeader); 1160 1164 fDimTriggerCounter.Update(data); 1161 } 1165 }*/ 1162 1166 1163 1167 void UpdateFtuList() … … 1181 1185 ConnectionFTM::UpdateDynamicData(); 1182 1186 1183 const FTM::DimDynamicData data(fHeader, fDynamicData );1187 const FTM::DimDynamicData data(fHeader, fDynamicData, fStaticData); 1184 1188 fDimDynamicData.Update(data); 1189 1190 float rate = -1; 1191 if (fHeader.fTimeStamp>=fTimeStamp && fHeader.fTriggerCounter>=fTriggerCounter) 1192 { 1193 const uint64_t tdiff = fHeader.fTimeStamp -fTimeStamp; 1194 const uint32_t cdiff = fHeader.fTriggerCounter-fTriggerCounter; 1195 1196 rate = tdiff==0 ? 0 : 1000000*float(cdiff)/tdiff; 1197 } 1198 1199 fTimeStamp = fHeader.fTimeStamp; 1200 fTriggerCounter = fHeader.fTriggerCounter; 1201 1202 const FTM::DimTriggerRates rates(fHeader, fDynamicData, fStaticData, rate); 1203 fDimTriggerRates.Update(rates); 1185 1204 } 1186 1205 … … 1214 1233 ConnectionFTM(ioservice, imp), 1215 1234 fDimPassport ("FTM_CONTROL/PASSPORT", "X:1;S:1", ""), 1216 fDimTrigger Counter("FTM_CONTROL/TRIGGER_COUNTER", "X:1;I:1", ""),1235 fDimTriggerRates ("FTM_CONTROL/TRIGGER_RATES", "X:2;I:1;F:1;F:40;F:160", ""), 1217 1236 fDimError ("FTM_CONTROL/ERROR", "X:1;S:1;S:28", ""), 1218 1237 fDimFtuList ("FTM_CONTROL/FTU_LIST", "X:1;X:1;S:1;C:4;X:40;C:40;C:40", ""), 1219 1238 fDimStaticData ("FTM_CONTROL/STATIC_DATA", "X:1;S:1;S:1;X:1;S:1;S:3;S:1;S:1;S:1;S:1;S:1;S:1;I:1;I:8;S:90;S:160;S:40;S:40", ""), 1220 fDimDynamicData ("FTM_CONTROL/DYNAMIC_DATA", "X:1;X:1;F:4;I:160;I:40;S:40;S:40;S:1", ""), 1221 fDimCounter ("FTM_CONTROL/COUNTER", "I:6", "") 1239 fDimDynamicData ("FTM_CONTROL/DYNAMIC_DATA", "X:1;X:1;F:4;I:160;I:40;S:40;S:40;S:40;S:1", ""), 1240 fDimCounter ("FTM_CONTROL/COUNTER", "I:6", ""), 1241 fTimeStamp(UINT64_MAX), 1242 fTriggerCounter(UINT32_MAX) 1222 1243 { 1223 1244 }
Note:
See TracChangeset
for help on using the changeset viewer.