/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

RecordParser.cc
Go to the documentation of this file.
00001 #include "RawRecordPool/DaqRawEvent.h"
00002 #include "RawRecordPool/TShiftProxy.h"
00003 #include "RawRecordPool/RecordParser.h"
00004 #include "RawRecordPool/RecordBuffer.h"
00005 #include "RawRecordPool/RawRecordPoolUtil.h"
00006 
00007 using DybDaq::RecordParser;
00008 using DybDaq::RecordBuffer;
00009 
00010 RecordParser::RecordParser()
00011     : m_site(-1),
00012       m_nPmtDet(0),
00013       m_hasRpc(0),
00014       m_mask(0),
00015       m_ready(false)
00016 {
00017 }
00018 
00019 RecordParser::~RecordParser()
00020 {
00021 }
00022 
00023 bool RecordParser::getRunParams(RecordBuffer* record, bool timeAlignment)
00024 {
00025     if ( record != 0 &&
00026          marker(record) == DybDaq::RawRecordPoolUtil::RunParametersMarker ) {
00027 
00028         m_run = ((uint32_t*)record->data())[2];
00029 
00030         uint32_t detMask = ((uint32_t*)record->data())[5];
00031 
00032         for ( m_site = 0; m_site < 3; ++m_site ) {
00033             m_mask = ((detMask>>(8*m_site)) & 0xFF);
00034             if ( m_mask != 0 ) {
00035                 for ( int i = 1; i < 7; ++i ) {
00036                     if ( (m_mask & (1<<i)) != 0 ) ++m_nPmtDet;
00037                 }
00038 
00039                 if ( (m_mask&0x80) != 0 ) m_hasRpc = 1;
00040                 break;
00041             }
00042         }
00043 
00044         if ( timeAlignment ) initTimeShift();
00045 
00046         m_ready = true;
00047 
00048         return true;
00049     }
00050     return false;
00051 }
00052 
00053 bool RecordParser::isPmtEvent(RecordBuffer* record)
00054 {
00055     if ( record != 0 &&
00056          marker(record) == DybDaq::RawRecordPoolUtil::DataSeparatorMarker ) {
00057 
00058         uint32_t* event = (uint32_t*)(record->data() + 16);
00059         uint32_t  srcId = event[3];
00060 
00061         if ( (srcId&0xF0000) != 0x70000 ) {
00062             return true;
00063         }
00064     }
00065     return false;
00066 }
00067 
00068 bool RecordParser::isRpcEvent(RecordBuffer* record)
00069 {
00070     if ( record != 0 &&
00071          marker(record) == DybDaq::RawRecordPoolUtil::DataSeparatorMarker ) {
00072 
00073         uint32_t* event = (uint32_t*)(record->data() + 16);
00074         uint32_t  srcId = event[3];
00075 
00076         if ( (srcId&0xF0000) == 0x70000 ) {
00077             return true;
00078         }
00079     }
00080     return false;
00081 }
00082 
00083 int RecordParser::recordType(RecordBuffer* record)
00084 {
00085     // 0: not a DAQ event, 1:AD1,2:AD2,3:AD3,4:AD4,5:IWP,6:OWP,7:RPC
00086     int result = 0;
00087     if ( record != 0 &&
00088          marker(record) == DybDaq::RawRecordPoolUtil::DataSeparatorMarker ) {
00089 
00090         uint32_t* event = (uint32_t*)(record->data() + 16);
00091         uint32_t  srcId = event[3];
00092 
00093         // 0: not a DAQ event, 1: PMT event, 2: RPC event
00094         //result = ( (srcId&0xF0000) != 0x70000 ) ? 1 : 2;
00095         result = ((srcId>>16)&0xF);
00096     }
00097     return result;
00098 }
00099 
00100 bool RecordParser::earlier(RecordBuffer* r1, RecordBuffer* r2)
00101 {
00102     bool result = false;
00103 
00104     DaqRawEvent* evt1 = ( r1 != 0 ) ? r1->timeRevisedEvent() : 0;
00105     DaqRawEvent* evt2 = ( r2 != 0 ) ? r2->timeRevisedEvent() : 0;
00106 
00107     if ( r1 != 0 && r2 != 0 ) {
00108         if ( evt1->second() == evt2->second() ) {
00109             result = evt1->nanoSecond() < evt2->nanoSecond();
00110         }
00111         else {
00112             result = evt1->second() < evt2->second();
00113         }
00114     }
00115     else if ( r2 == 0 ) {
00116         result = true;
00117     }
00118 
00119     return result;
00120 }
00121 
00122 uint32_t RecordParser::marker(RecordBuffer* record)
00123 {
00124     return ((uint32_t*)record->data())[0];
00125 }
00126 
00127 void  RecordParser::initTimeShift()
00128 {
00129     TShiftProxy  tProxy(m_run, m_site);
00130 
00131     for ( int detId = 0; detId < 7; ++detId ) {
00132         DybDaq::RawRecordPoolUtil::EVENT_TIME_REVISE[m_site][detId] = tProxy.time_shift(detId);
00133     }
00134 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:52:46 for RawRecordPool by doxygen 1.7.4