#include <RawData.h>
Inheritance diagram for DayaBay::RawModule:
Public Member Functions | |
RawModule (unsigned int *buffer=0, unsigned int majorVersion=0, unsigned int minorVersion=0, bool isOwner=false) | |
~RawModule () | |
unsigned int | size () const |
unsigned int | headerSize () const |
unsigned int | siteId () const |
unsigned int | detectorId () const |
unsigned int | moduleType () const |
unsigned int | slot () const |
bool | isLocalTriggerModule () const |
bool | isPmtFeeModule () const |
bool | isFlashAdcModule () const |
bool | isRpcRomModule () const |
bool | isRpcRtmModule () const |
DayaBay::HeadFragment * | headFragment () |
DayaBay::DataFragment * | nextDataFragment () |
void | resetDataFragment () |
virtual std::ostream & | dump (std::ostream &str) |
DayaBay::RawFragment * | makeNewFragment (unsigned int *buffer=0, unsigned int majorVersion=0, unsigned int minorVersion=0, bool isOwner=false) |
DayaBay::HeadFragment * | makeNewHeadFragment (unsigned int *buffer=0, unsigned int majorVersion=0, unsigned int minorVersion=0, bool isOwner=false) |
DayaBay::TailFragment * | makeNewTailFragment (unsigned int *buffer=0, unsigned int majorVersion=0, unsigned int minorVersion=0, bool isOwner=false) |
DayaBay::DataFragment * | makeNewDataFragment (unsigned int *buffer=0, unsigned int majorVersion=0, unsigned int minorVersion=0, bool isOwner=false) |
unsigned int | type () const |
unsigned int | majorVersion () const |
unsigned int | minorVersion () const |
bool | isEventType () const |
bool | isModuleType () const |
unsigned int * | buffer () const |
unsigned int | bufferSize () const |
bool | isOwner () const |
void | setOwner (bool isOwner=true) |
virtual bool | isValid () const |
unsigned int * | getPointer (const unsigned int &line) const |
unsigned int | getValue (const unsigned int &line, const unsigned int &firstBit=0, const unsigned int &bitLength=32) const |
char * | getString (const unsigned int &line, const unsigned int &byteOffset=0) const |
Static Public Member Functions | |
static DayaBay::RawData * | makeNewData (unsigned int *buffer=0, unsigned int majorVersion=0, unsigned int minorVersion=0, bool isOwner=false) |
Protected Attributes | |
unsigned int | m_majorVersion |
unsigned int | m_minorVersion |
Private Attributes | |
unsigned int | m_currentFragmentLine |
Definition at line 218 of file RawData.h.
DayaBay::RawModule::RawModule | ( | unsigned int * | buffer = 0 , |
|
unsigned int | majorVersion = 0 , |
|||
unsigned int | minorVersion = 0 , |
|||
bool | isOwner = false | |||
) |
Definition at line 316 of file RawData.cc.
00320 : RawData(buffer,majorVersion,minorVersion,isOwner), 00321 m_currentFragmentLine(0) 00322 { 00323 // Default constructor 00324 }
DayaBay::RawModule::~RawModule | ( | ) |
Definition at line 326 of file RawData.cc.
00327 { 00328 // Destructor 00329 m_currentFragmentLine=0; 00330 }
unsigned int DayaBay::RawModule::size | ( | ) | const |
Definition at line 332 of file RawData.cc.
00333 { 00334 return this->getValue(DataFormat::Module::totalSizeLine, 00335 DataFormat::Module::totalSizeBitOffset, 00336 DataFormat::Module::totalSizeBitLength); 00337 }
unsigned int DayaBay::RawModule::headerSize | ( | ) | const |
Definition at line 339 of file RawData.cc.
00340 { 00341 return this->getValue(DataFormat::Module::headerSizeLine, 00342 DataFormat::Module::headerSizeBitOffset, 00343 DataFormat::Module::headerSizeBitLength); 00344 }
unsigned int DayaBay::RawModule::siteId | ( | ) | const |
Definition at line 347 of file RawData.cc.
00348 { 00349 return this->getValue(DataFormat::Module::siteIdLine, 00350 DataFormat::Module::siteIdBitOffset, 00351 DataFormat::Module::siteIdBitLength); 00352 }
unsigned int DayaBay::RawModule::detectorId | ( | ) | const |
Definition at line 354 of file RawData.cc.
00355 { 00356 return this->getValue(DataFormat::Module::detectorIdLine, 00357 DataFormat::Module::detectorIdBitOffset, 00358 DataFormat::Module::detectorIdBitLength); 00359 }
unsigned int DayaBay::RawModule::moduleType | ( | ) | const |
Definition at line 361 of file RawData.cc.
00362 { 00363 return this->getValue(DataFormat::Module::moduleTypeLine, 00364 DataFormat::Module::moduleTypeBitOffset, 00365 DataFormat::Module::moduleTypeBitLength); 00366 }
unsigned int DayaBay::RawModule::slot | ( | ) | const |
Definition at line 368 of file RawData.cc.
00369 { 00370 return this->getValue(DataFormat::Module::slotLine, 00371 DataFormat::Module::slotBitOffset, 00372 DataFormat::Module::slotBitLength); 00373 }
bool DayaBay::RawModule::isLocalTriggerModule | ( | ) | const |
Definition at line 375 of file RawData.cc.
00376 { 00377 // Is this a Local Trigger Board Module block? 00378 return (this->moduleType()==DataFormat::Module::LocalTrigger); 00379 }
bool DayaBay::RawModule::isPmtFeeModule | ( | ) | const |
Definition at line 381 of file RawData.cc.
00382 { 00383 // Is this a PMT FEE Board Module block? 00384 return (this->moduleType()==DataFormat::Module::PmtFee); 00385 }
bool DayaBay::RawModule::isFlashAdcModule | ( | ) | const |
Definition at line 387 of file RawData.cc.
00388 { 00389 // Is this a Flash ADC Module block? 00390 return (this->moduleType()==DataFormat::Module::FlashAdc); 00391 }
bool DayaBay::RawModule::isRpcRomModule | ( | ) | const |
Definition at line 393 of file RawData.cc.
00394 { 00395 // Is this an RPC ROM Module block? 00396 return (this->moduleType()==DataFormat::Module::RpcRom); 00397 }
bool DayaBay::RawModule::isRpcRtmModule | ( | ) | const |
Definition at line 399 of file RawData.cc.
00400 { 00401 // Is this an RPC RTM Module block? 00402 return (this->moduleType()==DataFormat::Module::RpcRtm); 00403 }
DayaBay::HeadFragment * DayaBay::RawModule::headFragment | ( | ) |
Definition at line 405 of file RawData.cc.
00406 { 00407 unsigned int headFragmentLine = DataFormat::Module::firstFragmentLine; 00408 // Check for CBLT header line 00409 if( DayaBay::RawFragment(this->getPointer(headFragmentLine), 00410 this->majorVersion(), 00411 this->minorVersion()).type() 00412 == DataFormat::CbltHeadFragment::type){ 00413 // Skip CBLT header line 00414 headFragmentLine += DataFormat::CbltHeadFragment::size; 00415 } 00416 DayaBay::RawFragment* rawFragment = 00417 this->makeNewFragment( 00418 this->getPointer(headFragmentLine), 00419 this->majorVersion(), 00420 this->minorVersion()); 00421 DayaBay::HeadFragment* headFragment = 00422 dynamic_cast<DayaBay::HeadFragment*>(rawFragment); 00423 if(!headFragment){ 00424 delete rawFragment; 00425 return 0; 00426 } 00427 return headFragment; 00428 }
DayaBay::DataFragment * DayaBay::RawModule::nextDataFragment | ( | ) |
Definition at line 430 of file RawData.cc.
00431 { 00432 unsigned int nextFragmentLine = m_currentFragmentLine; 00433 if(!m_currentFragmentLine){ 00434 // Find first data fragment 00435 nextFragmentLine = DataFormat::Module::firstFragmentLine; 00436 // Check for CBLT header line 00437 if( DayaBay::RawFragment(this->getPointer(nextFragmentLine), 00438 this->majorVersion(), 00439 this->minorVersion()).type() 00440 == DataFormat::CbltHeadFragment::type){ 00441 // Skip CBLT header line 00442 nextFragmentLine += DataFormat::CbltHeadFragment::size; 00443 } 00444 // Check for header line 00445 if( DayaBay::RawFragment(this->getPointer(nextFragmentLine), 00446 this->majorVersion(), 00447 this->minorVersion()).type() 00448 == DataFormat::HeadFragment::type){ 00449 // Skip header line 00450 nextFragmentLine += DataFormat::HeadFragment::size; 00451 } 00452 }else{ 00453 DayaBay::DataFragment* fragment = 00454 this->makeNewDataFragment(this->getPointer(m_currentFragmentLine), 00455 this->majorVersion(), 00456 this->minorVersion()); 00457 nextFragmentLine += fragment->size(); 00458 delete fragment; 00459 } 00460 if(nextFragmentLine >= this->size()){ 00461 return 0; 00462 } 00463 DayaBay::DataFragment* nextFragment = 00464 this->makeNewDataFragment(this->getPointer(nextFragmentLine), 00465 this->majorVersion(), 00466 this->minorVersion()); 00467 if( !nextFragment ) return 0; 00468 m_currentFragmentLine = nextFragmentLine; 00469 return nextFragment; 00470 }
void DayaBay::RawModule::resetDataFragment | ( | ) |
std::ostream & DayaBay::RawModule::dump | ( | std::ostream & | str | ) | [virtual] |
Reimplemented from DayaBay::RawData.
Definition at line 477 of file RawData.cc.
00477 { 00478 // Print the module information 00479 str << "Module {" << std::endl << " "; 00480 this->RawData::dump(str); 00481 str << " size: " << this->size() << std::endl 00482 << " headerSize: " << this->headerSize() << std::endl 00483 << " siteId: " << this->siteId() << std::endl 00484 << " detectorId: " << this->detectorId() << std::endl 00485 << " moduleType: " << this->moduleType() << std::endl 00486 << " slot: " << this->slot() << std::endl << " "; 00487 DayaBay::HeadFragment* headFragment = this->headFragment(); 00488 if(headFragment) 00489 this->headFragment()->dump(str); 00490 unsigned int fragmentLine = m_currentFragmentLine; 00491 this->resetDataFragment(); 00492 DayaBay::DataFragment* dataFragment = 0; 00493 while( (dataFragment=this->nextDataFragment()) ){ 00494 str << std::endl << " "; 00495 dataFragment->dump(str); 00496 } 00497 m_currentFragmentLine = fragmentLine; // Restore module line counter 00498 return str << "}" << std::endl; 00499 }
DayaBay::RawFragment * DayaBay::RawModule::makeNewFragment | ( | unsigned int * | buffer = 0 , |
|
unsigned int | majorVersion = 0 , |
|||
unsigned int | minorVersion = 0 , |
|||
bool | isOwner = false | |||
) |
Definition at line 501 of file RawData.cc.
00506 { 00507 // Make a new raw fragment. Automatically set the correct class 00508 // type using the type() defined in the raw data. 00509 // 00510 // The caller is responsible for deleting the returned object. 00511 00512 DayaBay::RawFragment* newFragment = 0; 00513 // Convert to the proper record type 00514 switch (DayaBay::RawFragment(buffer,majorVersion,minorVersion).type()){ 00515 case DataFormat::HeadFragment::type: 00516 newFragment = this->makeNewHeadFragment(buffer, majorVersion, minorVersion, 00517 isOwner); 00518 break; 00519 case DataFormat::DataFragment::type: 00520 case DataFormat::FeePeakData_v1::chargeLineType: 00521 case DataFormat::FeePeakData_v1::timeLineType: 00522 newFragment = this->makeNewDataFragment(buffer,majorVersion,minorVersion, 00523 isOwner); 00524 break; 00525 case DataFormat::TailFragment::type: 00526 newFragment = this->makeNewTailFragment(buffer, majorVersion, minorVersion, 00527 isOwner); 00528 break; 00529 default: 00530 newFragment = new DayaBay::RawFragment(buffer, majorVersion, minorVersion, 00531 isOwner); 00532 break; 00533 } 00534 return newFragment; 00535 }
DayaBay::HeadFragment * DayaBay::RawModule::makeNewHeadFragment | ( | unsigned int * | buffer = 0 , |
|
unsigned int | majorVersion = 0 , |
|||
unsigned int | minorVersion = 0 , |
|||
bool | isOwner = false | |||
) |
Definition at line 537 of file RawData.cc.
00542 { 00543 // Make a new head fragment. Automatically set the correct class 00544 // type using the type() defined in the raw data. 00545 // 00546 // The caller is responsible for deleting the returned object. 00547 00548 DayaBay::HeadFragment* newFragment = 0; 00549 if( DayaBay::RawFragment(buffer,majorVersion,minorVersion).type() != 00550 DataFormat::HeadFragment::type ){ 00551 return 0; 00552 } 00553 if( this->isPmtFeeModule() ){ 00554 // Use FEE-specific data head 00555 newFragment = new DayaBay::FeeHeadFragment(buffer, majorVersion, 00556 minorVersion, isOwner); 00557 }else if( this->isLocalTriggerModule() ){ 00558 // Use LTB-specific data head 00559 newFragment = new DayaBay::LtbHeadFragment(buffer, majorVersion, 00560 minorVersion, isOwner); 00561 }else{ 00562 // Use generic data head 00563 newFragment = new DayaBay::HeadFragment(buffer, majorVersion, 00564 minorVersion, isOwner); 00565 } 00566 return newFragment; 00567 }
DayaBay::TailFragment * DayaBay::RawModule::makeNewTailFragment | ( | unsigned int * | buffer = 0 , |
|
unsigned int | majorVersion = 0 , |
|||
unsigned int | minorVersion = 0 , |
|||
bool | isOwner = false | |||
) |
Definition at line 569 of file RawData.cc.
00574 { 00575 // Make a new tail fragment. Automatically set the correct class 00576 // type using the type() defined in the raw data. 00577 // 00578 // The caller is responsible for deleting the returned object. 00579 00580 DayaBay::TailFragment* newFragment = 0; 00581 if( DayaBay::RawFragment(buffer,majorVersion,minorVersion).type() != 00582 DataFormat::TailFragment::type ){ 00583 return 0; 00584 } 00585 if( this->isPmtFeeModule() ){ 00586 // Use FEE-specific data tail 00587 newFragment = new DayaBay::FeeTailFragment(buffer, majorVersion, 00588 minorVersion, isOwner); 00589 }else if( this->isLocalTriggerModule() ){ 00590 // Use LTB-specific data tail 00591 newFragment = new DayaBay::LtbTailFragment(buffer, majorVersion, 00592 minorVersion, isOwner); 00593 }else{ 00594 // Use generic data tail 00595 newFragment = new DayaBay::TailFragment(buffer, majorVersion, 00596 minorVersion, isOwner); 00597 } 00598 return newFragment; 00599 }
DayaBay::DataFragment * DayaBay::RawModule::makeNewDataFragment | ( | unsigned int * | buffer = 0 , |
|
unsigned int | majorVersion = 0 , |
|||
unsigned int | minorVersion = 0 , |
|||
bool | isOwner = false | |||
) |
Definition at line 602 of file RawData.cc.
00607 { 00608 // Make a new data fragment. Automatically set the correct class 00609 // type using the type() defined in the raw data. 00610 // 00611 // The caller is responsible for deleting the returned object. 00612 00613 DayaBay::DataFragment* newFragment = 0; 00614 unsigned int fragmentType = 00615 DayaBay::RawFragment(buffer,majorVersion,minorVersion).type(); 00616 if( (fragmentType != DataFormat::DataFragment::type) 00617 && (fragmentType != DataFormat::FeePeakData_v1::chargeLineType) 00618 && (fragmentType != DataFormat::FeePeakData_v1::timeLineType) ){ 00619 return 0; 00620 } 00621 if( this->isPmtFeeModule() ){ 00622 // FIXME: need to discriminate different data fragment types! 00623 // Assume ADC/TDC Peak-finding blocks for all PMT data 00624 DayaBay::HeadFragment* head = this->headFragment(); 00625 DayaBay::FeeHeadFragment* feeHead = 00626 dynamic_cast<DayaBay::FeeHeadFragment*>( head ); 00627 if(!feeHead){ 00628 // DEBUG 00629 std::cout << "ERROR: Failed to find FEE Header" << std::endl; 00630 }else{ 00631 newFragment = new DayaBay::FeePeakData(buffer, majorVersion, 00632 minorVersion, 00633 feeHead->feeDataVersion(), 00634 isOwner); 00635 } 00636 delete head; 00637 }else if( this->isLocalTriggerModule() ){ 00638 DayaBay::HeadFragment* head = this->headFragment(); 00639 DayaBay::LtbHeadFragment* ltbHead = 00640 dynamic_cast<DayaBay::LtbHeadFragment*>( head ); 00641 if(!ltbHead){ 00642 // DEBUG 00643 std::cout << "ERROR: Failed to find LTB Header" << std::endl; 00644 }else{ 00645 newFragment = new DayaBay::LocalTriggerData(buffer, majorVersion, 00646 minorVersion, 00647 ltbHead->ltbDataVersion(), 00648 isOwner); 00649 } 00650 delete head; 00651 }else{ 00652 // Use generic data fragment 00653 newFragment = new DayaBay::DataFragment(buffer, majorVersion, minorVersion, 00654 isOwner); 00655 } 00656 return newFragment; 00657 }
unsigned int DayaBay::RawData::type | ( | ) | const [inherited] |
Reimplemented in DayaBay::RawFragment.
Definition at line 40 of file RawData.cc.
00041 { 00042 // Return the type of this raw data 00043 return this->getValue(DataFormat::Data::typeLine); 00044 }
unsigned int DayaBay::RawData::majorVersion | ( | ) | const [inherited] |
Definition at line 58 of file RawData.cc.
00059 { 00060 // Return the major version of this data 00061 return m_majorVersion; 00062 }
unsigned int DayaBay::RawData::minorVersion | ( | ) | const [inherited] |
Definition at line 64 of file RawData.cc.
00065 { 00066 // Return the minor version of this data 00067 return m_minorVersion; 00068 }
bool DayaBay::RawData::isEventType | ( | ) | const [inherited] |
Definition at line 46 of file RawData.cc.
00047 { 00048 // Is this event data? 00049 return (this->type()==DataFormat::Event::type); 00050 }
bool DayaBay::RawData::isModuleType | ( | ) | const [inherited] |
Definition at line 52 of file RawData.cc.
00053 { 00054 // Is this module data? 00055 return (this->type()==DataFormat::Module::type); 00056 }
DayaBay::RawData * DayaBay::RawData::makeNewData | ( | unsigned int * | buffer = 0 , |
|
unsigned int | majorVersion = 0 , |
|||
unsigned int | minorVersion = 0 , |
|||
bool | isOwner = false | |||
) | [static, inherited] |
Definition at line 101 of file RawData.cc.
00104 { 00105 // Make a new raw data object. Automatically set the correct class 00106 // type using the type() defined in the raw data. 00107 // 00108 // The caller is responsible for deleting the returned data object. 00109 00110 DayaBay::RawData* newData = 0; 00111 // Convert to the proper record type 00112 DayaBay::RawData rawData(buffer,majorVersion,minorVersion); 00113 if( rawData.isEventType() ){ 00114 newData = new DayaBay::RawEvent(buffer, majorVersion, minorVersion, 00115 isOwner); 00116 }else if( rawData.isModuleType() ){ 00117 newData = new DayaBay::RawModule(buffer, majorVersion, minorVersion, 00118 isOwner); 00119 }else{ 00120 newData = new DayaBay::RawData(buffer, majorVersion, minorVersion, 00121 isOwner); 00122 } 00123 return newData; 00124 }
unsigned int * DayaBay::RawBuffer::buffer | ( | ) | const [inherited] |
Definition at line 52 of file RawBuffer.cc.
00053 { 00054 // Return the pointer to the internal memory buffer 00055 return m_buffer; 00056 }
unsigned int DayaBay::RawBuffer::bufferSize | ( | ) | const [inherited] |
Definition at line 58 of file RawBuffer.cc.
00059 { 00060 // Return the allocated size of the internal memory buffer, if known 00061 return m_bufferSize; 00062 }
bool DayaBay::RawBuffer::isOwner | ( | ) | const [inherited] |
Definition at line 64 of file RawBuffer.cc.
00065 { 00066 // Does this RawBuffer own this memory buffer? 00067 return m_isOwner; 00068 }
void DayaBay::RawBuffer::setOwner | ( | bool | isOwner = true |
) | [inherited] |
bool DayaBay::RawBuffer::isValid | ( | ) | const [virtual, inherited] |
Definition at line 74 of file RawBuffer.cc.
00075 { 00076 // Does this RawBuffer contain data? 00077 return (m_buffer != 0); 00078 }
unsigned int * DayaBay::RawBuffer::getPointer | ( | const unsigned int & | line | ) | const [inherited] |
Definition at line 80 of file RawBuffer.cc.
00081 { 00082 // Return a pointer to a specific line in the data block 00083 if(m_bufferSize>0 && line>=m_bufferSize) return 0; 00084 return (m_buffer + line); 00085 }
unsigned int DayaBay::RawBuffer::getValue | ( | const unsigned int & | line, | |
const unsigned int & | firstBit = 0 , |
|||
const unsigned int & | bitLength = 32 | |||
) | const [inherited] |
Definition at line 87 of file RawBuffer.cc.
00090 { 00091 // Read a value from the memory buffer 00092 // line = line number in the memory block (line = integer length) 00093 // firstBit = first bit to read (max=31) 00094 // bitLength = length of bits to read (max=32) 00095 if(bitLength>32 || firstBit>31) return 0; 00096 unsigned int* pointer = this->getPointer(line); 00097 if(!pointer) return 0; 00098 // Catch request for full line 00099 if(firstBit==0 && bitLength==32) return *pointer; 00100 // Prepare bit mask 00101 unsigned int oneBit = 0x1; 00102 unsigned int mask = 0; 00103 for(unsigned int shift=0; shift<bitLength; shift++) 00104 mask += (oneBit << shift); 00105 // Shift value, mask, and return 00106 return (*pointer >> firstBit) & mask; 00107 }
char * DayaBay::RawBuffer::getString | ( | const unsigned int & | line, | |
const unsigned int & | byteOffset = 0 | |||
) | const [inherited] |
Definition at line 109 of file RawBuffer.cc.
00111 { 00112 // Return a char pointer to a specific byte in the data block 00113 // line = line number in the memory block (line = integer length) 00114 // byteOffset = offset if string starts at an uneven byte position (max=3) 00115 if(byteOffset>3) return 0; 00116 unsigned int* pointer = this->getPointer(line); 00117 if(!pointer) return 0; 00118 return (char*)(pointer + byteOffset); 00119 }
unsigned int DayaBay::RawModule::m_currentFragmentLine [private] |
unsigned int DayaBay::RawData::m_majorVersion [protected, inherited] |
unsigned int DayaBay::RawData::m_minorVersion [protected, inherited] |