Changeset 11200 for trunk/FACT++/src
- Timestamp:
- 06/27/11 16:59:40 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventBuilderWrapper.h
r11199 r11200 720 720 uint32_t fNumEvts[2]; 721 721 722 DimDescribedService fDimFiles;723 722 DimDescribedService fDimRuns; 724 723 DimDescribedService fDimEvents; 725 // DimDescribedService fDimCurrentEvent;726 724 DimDescribedService fDimEventData; 727 725 DimDescribedService fDimFwVersion; 726 DimDescribedService fDimRunNumber; 728 727 DimDescribedService fDimStatus; 729 728 DimDescribedService fDimDNA; … … 741 740 EventBuilderWrapper(MessageImp &imp) : fMsg(imp), 742 741 fFileFormat(kRaw), fMaxRun(0), 743 fDimFiles ("FAD_CONTROL/FILES", "X:1", ""), 744 fDimRuns ("FAD_CONTROL/RUNS", "I:1", ""), 742 fDimRuns ("FAD_CONTROL/RUNS", "I:3", ""), 745 743 fDimEvents ("FAD_CONTROL/EVENTS", "I:2", ""), 746 // fDimCurrentEvent("FAD_CONTROL/CURRENT_EVENT", "I:1", ""),747 744 fDimEventData ("FAD_CONTROL/EVENT_DATA", "S:1;I:1;S:1;I:2;S:1;S", ""), 748 fDimFwVersion ("FAD_CONTROL/FIRMWARE_VERSION", "F:43", ""), 745 fDimFwVersion ("FAD_CONTROL/FIRMWARE_VERSION", "F:42", ""), 746 fDimRunNumber ("FAD_CONTROL/RUN_NUMBER", "I:42", ""), 749 747 fDimStatus ("FAD_CONTROL/STATUS", "S:42", ""), 750 748 fDimDNA ("FAD_CONTROL/DNA", "X:40", ""), … … 759 757 memset(fNumEvts, 0, sizeof(fNumEvts)); 760 758 761 fDimRuns.Update(uint32_t(0));762 // fDimCurrentEvent.Update(uint32_t(0));763 759 fDimEvents.Update(fNumEvts); 764 760 … … 944 940 // -------------- Mapped event builder callbacks ------------------ 945 941 942 void UpdateRuns() 943 { 944 uint32_t values[3] = 945 { 946 static_cast<uint32_t>(fFiles.size()), 947 0xffffffff, 948 0 949 }; 950 951 for (vector<DataFileImp*>::const_iterator it=fFiles.begin(); 952 it!=fFiles.end(); it++) 953 { 954 const DataFileImp *file = *it; 955 956 if (file->GetRunId()<values[1]) 957 values[1] = file->GetRunId(); 958 959 if (file->GetRunId()>values[2]) 960 values[2] = file->GetRunId(); 961 } 962 963 fDimRuns.Update(values); 964 } 965 946 966 vector<DataFileImp*> fFiles; 947 967 … … 970 990 fFiles.push_back(file); 971 991 972 if (runid>fMaxRun) 973 { 974 fMaxRun = runid; 975 fNumEvts[kCurrent] = 0; 976 977 fDimRuns.Update(fMaxRun); 978 fDimEvents.Update(fNumEvts); 979 // fDimCurrentEvent.Update(uint32_t(0)); 980 } 981 982 fDimFiles.Update(fFiles.size()); 992 UpdateRuns(); 993 994 fNumEvts[kCurrent] = 0; 995 fDimEvents.Update(fNumEvts); 996 // fDimCurrentEvent.Update(uint32_t(0)); 983 997 984 998 return reinterpret_cast<FileHandle_t>(file); … … 1037 1051 fFiles.erase(it); 1038 1052 1039 fDimFiles.Update(fFiles.size());1053 UpdateRuns(); 1040 1054 1041 1055 const bool rc = file->Close(tail); … … 1360 1374 1361 1375 template<typename T> 1362 pair<bool,boost::array<T, 43>> Compare(const FAD::EventHeader *h, const T *t, const uint64_t mask=~0, const uint8_t shift=0)1376 boost::array<T, 42> Compare(const FAD::EventHeader *h, const T *t) 1363 1377 { 1364 1378 const int offset = reinterpret_cast<const char *>(t) - reinterpret_cast<const char *>(h); … … 1368 1382 const T *max = NULL; 1369 1383 1370 boost::array<T, 4 3> vec;1384 boost::array<T, 42> vec; 1371 1385 1372 1386 bool rc = true; … … 1376 1390 const T *ref = reinterpret_cast<const T*>(base+offset); 1377 1391 1378 vec[i +3] = (*ref&mask)>>shift;1392 vec[i] = *ref; 1379 1393 1380 1394 if (gi_NumConnect[i]!=7) 1381 1395 { 1382 vec[i +3] = -1;1396 vec[i] = 0; 1383 1397 continue; 1384 1398 } … … 1397 1411 max = val; 1398 1412 1399 if ( (*val&mask)!=(*ref&mask))1413 if (*val!=*ref) 1400 1414 rc = false; 1401 1415 } 1402 1416 1403 if (!val) 1404 return make_pair(false, vec); 1405 1406 vec[0] = (*min&mask)>>shift; 1407 vec[1] = (*val&mask)>>shift; 1408 vec[2] = (*max&mask)>>shift; 1409 1410 return make_pair(rc, vec); 1417 vec[40] = val ? *min : 0xffffffff; 1418 vec[41] = val ? *max : 0; 1419 1420 return vec; 1411 1421 } 1412 1422 … … 1453 1463 1454 1464 template<typename T, size_t N> 1455 void Update(DimDescribedService &svc, const pair<bool,boost::array<T, N>> &data)1456 { 1457 svc.setQuality(data.first);1458 svc.setData(const_cast<T*>(data. second.data()), sizeof(T)*N);1465 void Update(DimDescribedService &svc, const boost::array<T, N> &data, int n=N) 1466 { 1467 // svc.setQuality(vec[40]<=vec[41]); 1468 svc.setData(const_cast<T*>(data.data()), sizeof(T)*n); 1459 1469 svc.updateService(); 1460 1470 } … … 1492 1502 if (old.fVersion != h.fVersion || changed) 1493 1503 { 1494 const pair<bool, boost::array<uint16_t,43>> ver = Compare(&h, &h.fVersion); 1495 1496 pair<bool, boost::array<float,43>> data; 1497 data.first = ver.first; 1498 1499 for (int i=0; i<43; i++) 1504 const boost::array<uint16_t,42> ver = Compare(&h, &h.fVersion); 1505 1506 boost::array<float,42> data; 1507 for (int i=0; i<42; i++) 1500 1508 { 1501 1509 ostringstream str; 1502 str << (ver .second[i]>>8) << '.' << (ver.second[i]&0xff);1503 data .second[i] = atof(str.str().c_str());1510 str << (ver[i]>>8) << '.' << (ver[i]&0xff); 1511 data[i] = atof(str.str().c_str()); 1504 1512 } 1505 1513 Update(fDimFwVersion, data); 1514 } 1515 1516 if (old.fRunNumber != h.fRunNumber || changed) 1517 { 1518 const boost::array<uint32_t,42> run = Compare(&h, &h.fRunNumber); 1519 fDimRunNumber.Update(run); 1506 1520 } 1507 1521 … … 1514 1528 uint16_t fNumTriggersToGenerate; 1515 1529 uint16_t fTriggerGeneratorPrescaler; 1516 uint64_t fDNA; // Xilinx DNA1517 1530 uint32_t fTimeStamp; 1518 1531 uint32_t fRunNumber; … … 1523 1536 if (old.fTriggerType != h.fTriggerType || changed) 1524 1537 { 1525 const pair<bool, boost::array<uint16_t,43>> typ = Compare(&h, &h.fTriggerType); 1526 Print("Typ", typ); 1527 } 1528 1529 if (old.fRunNumber != h.fRunNumber || changed) 1530 { 1531 const pair<bool, boost::array<uint32_t,43>> run = Compare(&h, &h.fRunNumber); 1532 Print("Run", run); 1538 const boost::array<uint16_t,42> typ = Compare(&h, &h.fTriggerType); 1539 //Print("Typ", typ); 1533 1540 } 1534 1541 1535 1542 if (old.fDNA != h.fDNA || changed) 1536 1543 { 1537 const pair<bool, boost::array<uint64_t,43>> dna = Compare(&h, &h.fDNA); 1538 fDimDNA.setData(const_cast<uint64_t*>(dna.second.data())+3, 40*sizeof(uint64_t)); 1539 fDimDNA.updateService(); 1544 const boost::array<uint64_t,42> dna = Compare(&h, &h.fDNA); 1545 Update(fDimDNA, dna, 40); 1540 1546 } 1541 1547 … … 1543 1549 { 1544 1550 const boost::array<uint16_t,42> sts = CompareBits(&h, &h.fStatus); 1545 fDimStatus.setData(const_cast<uint16_t*>(sts.data()), 42*sizeof(uint16_t)); 1546 fDimStatus.updateService(); 1547 } 1551 Update(fDimStatus, sts); 1552 } 1548 1553 } 1549 1554 };
Note:
See TracChangeset
for help on using the changeset viewer.