00001 #include "RawData/RawData.h"
00002 #include "RawData/RawDataFormat.h"
00003 #include <string.h>
00004 #include <sstream>
00005 #include <time.h>
00006
00007 using namespace DayaBay::RawData_v0_6;
00008
00009 DayaBay::RawData::RawData(unsigned int* buffer,
00010 unsigned int majorVersion,
00011 unsigned int minorVersion,
00012 bool isOwner)
00013 : RawBuffer(buffer,isOwner),
00014 m_majorVersion(majorVersion),
00015 m_minorVersion(minorVersion)
00016 {
00017
00018 }
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 DayaBay::RawData::~RawData()
00034 {
00035
00036 m_majorVersion=0;
00037 m_minorVersion=0;
00038 }
00039
00040 unsigned int DayaBay::RawData::type() const
00041 {
00042
00043 return this->getValue(DataFormat::Data::typeLine);
00044 }
00045
00046 bool DayaBay::RawData::isEventType() const
00047 {
00048
00049 return (this->type()==DataFormat::Event::type);
00050 }
00051
00052 bool DayaBay::RawData::isModuleType() const
00053 {
00054
00055 return (this->type()==DataFormat::Module::type);
00056 }
00057
00058 unsigned int DayaBay::RawData::majorVersion() const
00059 {
00060
00061 return m_majorVersion;
00062 }
00063
00064 unsigned int DayaBay::RawData::minorVersion() const
00065 {
00066
00067 return m_minorVersion;
00068 }
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 std::ostream& DayaBay::RawData::dump(std::ostream& str){
00094
00095 return str << "Data {type: 0x" << std::hex << this->type() << std::dec
00096 << ", "
00097 << "majorVersion: " << this->majorVersion() << ", "
00098 << "minorVersion: " << this->minorVersion() << "}" << std::endl;
00099 }
00100
00101 DayaBay::RawData* DayaBay::RawData::makeNewData(unsigned int* buffer,
00102 unsigned int majorVersion,
00103 unsigned int minorVersion,
00104 bool isOwner){
00105
00106
00107
00108
00109
00110 DayaBay::RawData* newData = 0;
00111
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 }
00125
00127
00128 DayaBay::RawEvent::RawEvent(unsigned int* buffer,
00129 unsigned int majorVersion,
00130 unsigned int minorVersion,
00131 bool isOwner)
00132 : RawData(buffer,majorVersion,minorVersion,isOwner),
00133 m_currentModuleLine(0)
00134 {
00135
00136 if(buffer){
00137
00138 m_majorVersion = this->eventMajorVersion();
00139 m_minorVersion = this->eventMinorVersion();
00140 }
00141 }
00142
00143 DayaBay::RawEvent::~RawEvent()
00144 {
00145
00146 m_currentModuleLine=0;
00147 }
00148
00149 DayaBay::RawEvent* DayaBay::RawEvent::clone() const
00150 {
00151
00152 unsigned int* newBuffer = 0;
00153 if(this->buffer()){
00154 unsigned int size = this->size();
00155 if( size>0 ){
00156 newBuffer = new unsigned int[size];
00157 memcpy( newBuffer, this->buffer(), size*sizeof(unsigned int) );
00158 if(!newBuffer) return 0;
00159 }
00160 }
00161 return new DayaBay::RawEvent(newBuffer,
00162 this->majorVersion(),
00163 this->minorVersion(),
00164 true );
00165 }
00166
00167 unsigned int DayaBay::RawEvent::size() const
00168 {
00169 return this->getValue(DataFormat::Event::totalSizeLine,
00170 DataFormat::Event::totalSizeBitOffset,
00171 DataFormat::Event::totalSizeBitLength);
00172 }
00173
00174 unsigned int DayaBay::RawEvent::headerSize() const
00175 {
00176 return this->getValue(DataFormat::Event::headerSizeLine,
00177 DataFormat::Event::headerSizeBitOffset,
00178 DataFormat::Event::headerSizeBitLength);
00179 }
00180
00181 unsigned int DayaBay::RawEvent::eventMajorVersion() const
00182 {
00183 return this->getValue(DataFormat::Event::majorVersionLine,
00184 DataFormat::Event::majorVersionBitOffset,
00185 DataFormat::Event::majorVersionBitLength);
00186 }
00187
00188 unsigned int DayaBay::RawEvent::eventMinorVersion() const
00189 {
00190 return this->getValue(DataFormat::Event::minorVersionLine,
00191 DataFormat::Event::minorVersionBitOffset,
00192 DataFormat::Event::minorVersionBitLength);
00193 }
00194
00195 unsigned int DayaBay::RawEvent::siteId() const
00196 {
00197 return this->getValue(DataFormat::Event::siteIdLine,
00198 DataFormat::Event::siteIdBitOffset,
00199 DataFormat::Event::siteIdBitLength);
00200 }
00201
00202 unsigned int DayaBay::RawEvent::detectorId() const
00203 {
00204 return this->getValue(DataFormat::Event::detectorIdLine,
00205 DataFormat::Event::detectorIdBitOffset,
00206 DataFormat::Event::detectorIdBitLength);
00207 }
00208
00209 unsigned int DayaBay::RawEvent::runNumber() const
00210 {
00211 return this->getValue(DataFormat::Event::runNumberLine);
00212 }
00213
00214 unsigned int DayaBay::RawEvent::eventId() const
00215 {
00216 return this->getValue(DataFormat::Event::eventIdLine);
00217 }
00218
00219
00220 unsigned int DayaBay::RawEvent::eventType() const
00221 {
00222 return this->getValue(DataFormat::Event::eventTypeLine,
00223 DataFormat::Event::eventTypeBitOffset,
00224 DataFormat::Event::eventTypeBitLength);
00225 }
00226
00227 unsigned int DayaBay::RawEvent::eventTypeValue() const
00228 {
00229 return this->getValue(DataFormat::Event::eventTypeValueLine,
00230 DataFormat::Event::eventTypeValueBitOffset,
00231 DataFormat::Event::eventTypeValueBitLength);
00232 }
00233
00234 unsigned int DayaBay::RawEvent::formatFlag() const
00235 {
00236 return this->getValue(DataFormat::Event::formatFlagLine,
00237 DataFormat::Event::formatFlagBitOffset,
00238 DataFormat::Event::formatFlagBitLength);
00239 }
00240
00241 unsigned int DayaBay::RawEvent::statusFlag() const
00242 {
00243 return this->getValue(DataFormat::Event::statusFlagLine,
00244 DataFormat::Event::statusFlagBitOffset,
00245 DataFormat::Event::statusFlagBitLength);
00246 }
00247
00248 DayaBay::RawModule* DayaBay::RawEvent::nextModule()
00249 {
00250
00251
00252 unsigned int nextModuleLine = m_currentModuleLine;
00253 if(!m_currentModuleLine){
00254 nextModuleLine = DataFormat::Event::firstModuleLine;
00255 }else{
00256 unsigned int moduleSize =
00257 DayaBay::RawModule(this->getPointer(m_currentModuleLine),
00258 this->majorVersion(),
00259 this->minorVersion()).size();
00260 nextModuleLine += moduleSize;
00261 }
00262 if(nextModuleLine >= this->size()){
00263 return 0;
00264 }
00265 DayaBay::RawData* nextData = DayaBay::RawData::makeNewData(
00266 this->getPointer(nextModuleLine),
00267 this->majorVersion(),
00268 this->minorVersion());
00269 DayaBay::RawModule* nextModule = dynamic_cast<DayaBay::RawModule*>(nextData);
00270 if( !nextModule ){
00271 delete nextData;
00272 return 0;
00273 }
00274 m_currentModuleLine = nextModuleLine;
00275 return nextModule;
00276 }
00277
00278 void DayaBay::RawEvent::resetModule()
00279 {
00280 m_currentModuleLine=0;
00281 }
00282
00283 std::ostream& DayaBay::RawEvent::dump(std::ostream& str){
00284
00285 str << "Event {" << std::endl << " ";
00286 this->RawData::dump(str);
00287 str << " size: " << this->size() << std::endl
00288 << " headerSize: " << this->headerSize() << std::endl
00289 << " eventMajorVersion: " << this->eventMajorVersion()
00290 << std::endl
00291 << " eventMinorVersion: " << this->eventMinorVersion()
00292 << std::endl
00293 << " siteId: " << this->siteId() << std::endl
00294 << " detectorId: " << this->detectorId() << std::endl
00295 << " runNumber: " << this->runNumber() << std::endl
00296 << " eventId: " << this->eventId() << std::endl
00297 << " eventType: " << this->eventType() << std::endl
00298 << " eventTypeValue: " << this->eventTypeValue() << std::endl
00299 << " formatFlag: 0x" << std::hex << this->formatFlag()
00300 << std::dec << std::endl
00301 << " statusFlag: 0x" << std::hex << this->statusFlag() << std::dec
00302 << std::endl;
00303 DayaBay::RawModule* module = 0;
00304 unsigned int modLine = m_currentModuleLine;
00305 this->resetModule();
00306 while( (module=this->nextModule()) ){
00307 module->dump(str);
00308 }
00309 m_currentModuleLine = modLine;
00310 return str << "}" << std::endl;
00311 }
00312
00313
00315
00316 DayaBay::RawModule::RawModule(unsigned int* buffer,
00317 unsigned int majorVersion,
00318 unsigned int minorVersion,
00319 bool isOwner)
00320 : RawData(buffer,majorVersion,minorVersion,isOwner),
00321 m_currentFragmentLine(0)
00322 {
00323
00324 }
00325
00326 DayaBay::RawModule::~RawModule()
00327 {
00328
00329 m_currentFragmentLine=0;
00330 }
00331
00332 unsigned int DayaBay::RawModule::size() const
00333 {
00334 return this->getValue(DataFormat::Module::totalSizeLine,
00335 DataFormat::Module::totalSizeBitOffset,
00336 DataFormat::Module::totalSizeBitLength);
00337 }
00338
00339 unsigned int DayaBay::RawModule::headerSize() const
00340 {
00341 return this->getValue(DataFormat::Module::headerSizeLine,
00342 DataFormat::Module::headerSizeBitOffset,
00343 DataFormat::Module::headerSizeBitLength);
00344 }
00345
00346
00347 unsigned int DayaBay::RawModule::siteId() const
00348 {
00349 return this->getValue(DataFormat::Module::siteIdLine,
00350 DataFormat::Module::siteIdBitOffset,
00351 DataFormat::Module::siteIdBitLength);
00352 }
00353
00354 unsigned int DayaBay::RawModule::detectorId() const
00355 {
00356 return this->getValue(DataFormat::Module::detectorIdLine,
00357 DataFormat::Module::detectorIdBitOffset,
00358 DataFormat::Module::detectorIdBitLength);
00359 }
00360
00361 unsigned int DayaBay::RawModule::moduleType() const
00362 {
00363 return this->getValue(DataFormat::Module::moduleTypeLine,
00364 DataFormat::Module::moduleTypeBitOffset,
00365 DataFormat::Module::moduleTypeBitLength);
00366 }
00367
00368 unsigned int DayaBay::RawModule::slot() const
00369 {
00370 return this->getValue(DataFormat::Module::slotLine,
00371 DataFormat::Module::slotBitOffset,
00372 DataFormat::Module::slotBitLength);
00373 }
00374
00375 bool DayaBay::RawModule::isLocalTriggerModule() const
00376 {
00377
00378 return (this->moduleType()==DataFormat::Module::LocalTrigger);
00379 }
00380
00381 bool DayaBay::RawModule::isPmtFeeModule() const
00382 {
00383
00384 return (this->moduleType()==DataFormat::Module::PmtFee);
00385 }
00386
00387 bool DayaBay::RawModule::isFlashAdcModule() const
00388 {
00389
00390 return (this->moduleType()==DataFormat::Module::FlashAdc);
00391 }
00392
00393 bool DayaBay::RawModule::isRpcRomModule() const
00394 {
00395
00396 return (this->moduleType()==DataFormat::Module::RpcRom);
00397 }
00398
00399 bool DayaBay::RawModule::isRpcRtmModule() const
00400 {
00401
00402 return (this->moduleType()==DataFormat::Module::RpcRtm);
00403 }
00404
00405 DayaBay::HeadFragment* DayaBay::RawModule::headFragment()
00406 {
00407 unsigned int headFragmentLine = DataFormat::Module::firstFragmentLine;
00408
00409 if( DayaBay::RawFragment(this->getPointer(headFragmentLine),
00410 this->majorVersion(),
00411 this->minorVersion()).type()
00412 == DataFormat::CbltHeadFragment::type){
00413
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 }
00429
00430 DayaBay::DataFragment* DayaBay::RawModule::nextDataFragment()
00431 {
00432 unsigned int nextFragmentLine = m_currentFragmentLine;
00433 if(!m_currentFragmentLine){
00434
00435 nextFragmentLine = DataFormat::Module::firstFragmentLine;
00436
00437 if( DayaBay::RawFragment(this->getPointer(nextFragmentLine),
00438 this->majorVersion(),
00439 this->minorVersion()).type()
00440 == DataFormat::CbltHeadFragment::type){
00441
00442 nextFragmentLine += DataFormat::CbltHeadFragment::size;
00443 }
00444
00445 if( DayaBay::RawFragment(this->getPointer(nextFragmentLine),
00446 this->majorVersion(),
00447 this->minorVersion()).type()
00448 == DataFormat::HeadFragment::type){
00449
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 }
00471
00472 void DayaBay::RawModule::resetDataFragment()
00473 {
00474 m_currentFragmentLine=0;
00475 }
00476
00477 std::ostream& DayaBay::RawModule::dump(std::ostream& str){
00478
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;
00498 return str << "}" << std::endl;
00499 }
00500
00501 DayaBay::RawFragment* DayaBay::RawModule::makeNewFragment(
00502 unsigned int* buffer,
00503 unsigned int majorVersion,
00504 unsigned int minorVersion,
00505 bool isOwner)
00506 {
00507
00508
00509
00510
00511
00512 DayaBay::RawFragment* newFragment = 0;
00513
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 }
00536
00537 DayaBay::HeadFragment* DayaBay::RawModule::makeNewHeadFragment(
00538 unsigned int* buffer,
00539 unsigned int majorVersion,
00540 unsigned int minorVersion,
00541 bool isOwner)
00542 {
00543
00544
00545
00546
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
00555 newFragment = new DayaBay::FeeHeadFragment(buffer, majorVersion,
00556 minorVersion, isOwner);
00557 }else if( this->isLocalTriggerModule() ){
00558
00559 newFragment = new DayaBay::LtbHeadFragment(buffer, majorVersion,
00560 minorVersion, isOwner);
00561 }else{
00562
00563 newFragment = new DayaBay::HeadFragment(buffer, majorVersion,
00564 minorVersion, isOwner);
00565 }
00566 return newFragment;
00567 }
00568
00569 DayaBay::TailFragment* DayaBay::RawModule::makeNewTailFragment(
00570 unsigned int* buffer,
00571 unsigned int majorVersion,
00572 unsigned int minorVersion,
00573 bool isOwner)
00574 {
00575
00576
00577
00578
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
00587 newFragment = new DayaBay::FeeTailFragment(buffer, majorVersion,
00588 minorVersion, isOwner);
00589 }else if( this->isLocalTriggerModule() ){
00590
00591 newFragment = new DayaBay::LtbTailFragment(buffer, majorVersion,
00592 minorVersion, isOwner);
00593 }else{
00594
00595 newFragment = new DayaBay::TailFragment(buffer, majorVersion,
00596 minorVersion, isOwner);
00597 }
00598 return newFragment;
00599 }
00600
00601
00602 DayaBay::DataFragment* DayaBay::RawModule::makeNewDataFragment(
00603 unsigned int* buffer,
00604 unsigned int majorVersion,
00605 unsigned int minorVersion,
00606 bool isOwner)
00607 {
00608
00609
00610
00611
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
00623
00624 DayaBay::HeadFragment* head = this->headFragment();
00625 DayaBay::FeeHeadFragment* feeHead =
00626 dynamic_cast<DayaBay::FeeHeadFragment*>( head );
00627 if(!feeHead){
00628
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
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
00653 newFragment = new DayaBay::DataFragment(buffer, majorVersion, minorVersion,
00654 isOwner);
00655 }
00656 return newFragment;
00657 }
00658
00660
00661
00662 DayaBay::RawFragment::RawFragment(unsigned int* buffer,
00663 unsigned int majorVersion,
00664 unsigned int minorVersion,
00665 bool isOwner)
00666 : RawData(buffer,majorVersion,minorVersion,isOwner)
00667 {
00668
00669 }
00670
00671 DayaBay::RawFragment::~RawFragment()
00672 {
00673
00674 }
00675
00676 unsigned int DayaBay::RawFragment::size() const
00677 {
00678 return DataFormat::RawFragment::size;
00679 }
00680
00681 unsigned int DayaBay::RawFragment::type() const
00682 {
00683 return this->getValue(DataFormat::RawFragment::typeLine,
00684 DataFormat::RawFragment::typeBitOffset,
00685 DataFormat::RawFragment::typeBitLength);
00686 }
00687
00688 std::ostream& DayaBay::RawFragment::dump(std::ostream& str){
00689
00690 str << "RawFragment {"
00691 << " type: " << this->type() << ", "
00692 << " size: " << this->size() << std::endl << " ";
00693 this->RawData::dump(str);
00694 return str << "}" << std::endl;
00695 }
00696
00698
00699 DayaBay::HeadFragment::HeadFragment(unsigned int* buffer,
00700 unsigned int majorVersion,
00701 unsigned int minorVersion,
00702 bool isOwner)
00703 : RawFragment(buffer,majorVersion,minorVersion,isOwner)
00704 {
00705
00706 }
00707
00708 DayaBay::HeadFragment::~HeadFragment()
00709 {
00710
00711 }
00712
00713 unsigned int DayaBay::HeadFragment::size() const
00714 {
00715 return DataFormat::HeadFragment::size;
00716 }
00717
00718 unsigned int DayaBay::HeadFragment::headType() const
00719 {
00720 return DataFormat::HeadFragment::headType;
00721 }
00722
00723 unsigned int DayaBay::HeadFragment::status() const
00724 {
00725 return this->getValue(DataFormat::HeadFragment::statusLine,
00726 DataFormat::HeadFragment::statusBitOffset,
00727 DataFormat::HeadFragment::statusBitLength);
00728 }
00729
00730 unsigned int DayaBay::HeadFragment::triggerNumber() const
00731 {
00732 return this->getValue(DataFormat::HeadFragment::triggerNumberLine,
00733 DataFormat::HeadFragment::triggerNumberBitOffset,
00734 DataFormat::HeadFragment::triggerNumberBitLength);
00735 }
00736
00737 std::ostream& DayaBay::HeadFragment::dump(std::ostream& str){
00738
00739 str << "HeadFragment {"
00740 << " status: " << this->status() << ", "
00741 << " triggerNumber: " << this->triggerNumber() << std::endl;
00742 this->RawFragment::dump(str);
00743 return str << "}" << std::endl;
00744 }
00745
00747
00748 DayaBay::TailFragment::TailFragment(unsigned int* buffer,
00749 unsigned int majorVersion,
00750 unsigned int minorVersion,
00751 bool isOwner)
00752 : RawFragment(buffer,majorVersion,minorVersion,isOwner)
00753 {
00754
00755 }
00756
00757 DayaBay::TailFragment::~TailFragment()
00758 {
00759
00760 }
00761
00762 unsigned int DayaBay::TailFragment::size() const
00763 {
00764 return DataFormat::TailFragment::size;
00765 }
00766
00767 unsigned int DayaBay::TailFragment::tailType() const
00768 {
00769 return DataFormat::TailFragment::tailType;
00770 }
00771
00772 unsigned int DayaBay::TailFragment::dataSize() const
00773 {
00774 return this->getValue(DataFormat::TailFragment::dataSizeLine,
00775 DataFormat::TailFragment::dataSizeBitOffset,
00776 DataFormat::TailFragment::dataSizeBitLength);
00777 }
00778
00779 std::ostream& DayaBay::TailFragment::dump(std::ostream& str){
00780
00781 str << "TailFragment {"
00782 << " dataSize: " << this->dataSize() << std::endl;
00783 this->RawFragment::dump(str);
00784 return str << "}" << std::endl;
00785 }
00786
00788
00789 DayaBay::LtbHeadFragment::LtbHeadFragment(unsigned int* buffer,
00790 unsigned int majorVersion,
00791 unsigned int minorVersion,
00792 bool isOwner)
00793 : HeadFragment(buffer,majorVersion,minorVersion,isOwner)
00794 {
00795
00796 }
00797
00798 DayaBay::LtbHeadFragment::~LtbHeadFragment()
00799 {
00800
00801 }
00802
00803 unsigned int DayaBay::LtbHeadFragment::headType() const
00804 {
00805 return DataFormat::LtbHeadFragment::headType;
00806 }
00807
00808 unsigned int DayaBay::LtbHeadFragment::clockError() const
00809 {
00810 return this->getValue(DataFormat::LtbHeadFragment::clockErrorLine,
00811 DataFormat::LtbHeadFragment::clockErrorBitOffset,
00812 DataFormat::LtbHeadFragment::clockErrorBitLength);
00813 }
00814
00815 unsigned int DayaBay::LtbHeadFragment::ltbDataVersion() const
00816 {
00817 return this->getValue(DataFormat::LtbHeadFragment::ltbDataVersionLine,
00818 DataFormat::LtbHeadFragment::ltbDataVersionBitOffset,
00819 DataFormat::LtbHeadFragment::ltbDataVersionBitLength);
00820 }
00821
00822 unsigned int DayaBay::LtbHeadFragment::numberInternalLocalTrigger() const
00823 {
00824 return this->getValue(DataFormat::LtbHeadFragment::numIltLine,
00825 DataFormat::LtbHeadFragment::numIltBitOffset,
00826 DataFormat::LtbHeadFragment::numIltBitLength);
00827 }
00828
00829 unsigned int DayaBay::LtbHeadFragment::numberSavedInternalLocalTrigger() const
00830 {
00831 return this->getValue(DataFormat::LtbHeadFragment::numSavedIltLine,
00832 DataFormat::LtbHeadFragment::numSavedIltBitOffset,
00833 DataFormat::LtbHeadFragment::numSavedIltBitLength);
00834 }
00835
00836 std::ostream& DayaBay::LtbHeadFragment::dump(std::ostream& str){
00837
00838 str << "LtbHeadFragment {"
00839 << " ltbDataVersion: "
00840 << this->ltbDataVersion() << ", "
00841 << " clockError: "
00842 << this->clockError() << ", "
00843 << " numberInternalLocalTrigger: "
00844 << this->numberInternalLocalTrigger() << ", "
00845 << " numberSavedInternalLocalTrigger: "
00846 << this->numberSavedInternalLocalTrigger() << std::endl;
00847 this->HeadFragment::dump(str);
00848 return str << "}" << std::endl;
00849 }
00850
00852
00853
00854 DayaBay::LtbTailFragment::LtbTailFragment(unsigned int* buffer,
00855 unsigned int majorVersion,
00856 unsigned int minorVersion,
00857 bool isOwner)
00858 : TailFragment(buffer,majorVersion,minorVersion,isOwner)
00859 {
00860
00861 }
00862
00863 DayaBay::LtbTailFragment::~LtbTailFragment()
00864 {
00865
00866 }
00867
00868 unsigned int DayaBay::LtbTailFragment::tailType() const
00869 {
00870 return DataFormat::LtbTailFragment::tailType;
00871 }
00872
00873 std::ostream& DayaBay::LtbTailFragment::dump(std::ostream& str){
00874
00875 str << "LtbTailFragment {" << std::endl;
00876 this->TailFragment::dump(str);
00877 return str << "}" << std::endl;
00878 }
00879
00880
00882
00883 DayaBay::FeeHeadFragment::FeeHeadFragment(unsigned int* buffer,
00884 unsigned int majorVersion,
00885 unsigned int minorVersion,
00886 bool isOwner)
00887 : HeadFragment(buffer,majorVersion,minorVersion,isOwner)
00888 {
00889
00890 }
00891
00892 DayaBay::FeeHeadFragment::~FeeHeadFragment()
00893 {
00894
00895 }
00896
00897 unsigned int DayaBay::FeeHeadFragment::headType() const
00898 {
00899 return DataFormat::FeeHeadFragment::headType;
00900 }
00901
00902 unsigned int DayaBay::FeeHeadFragment::feeDataVersion() const
00903 {
00904 return this->getValue(DataFormat::FeeHeadFragment::feeDataVersionLine,
00905 DataFormat::FeeHeadFragment::feeDataVersionBitOffset,
00906 DataFormat::FeeHeadFragment::feeDataVersionBitLength);
00907 }
00908
00909 std::ostream& DayaBay::FeeHeadFragment::dump(std::ostream& str){
00910
00911 str << "FeeHeadFragment {"
00912 << " feeDataVersion: "
00913 << this->feeDataVersion()
00914 << std::endl;
00915 this->HeadFragment::dump(str);
00916 return str << "}" << std::endl;
00917 }
00918
00920
00921
00922 DayaBay::FeeTailFragment::FeeTailFragment(unsigned int* buffer,
00923 unsigned int majorVersion,
00924 unsigned int minorVersion,
00925 bool isOwner)
00926 : TailFragment(buffer,majorVersion,minorVersion,isOwner)
00927 {
00928
00929 }
00930
00931 DayaBay::FeeTailFragment::~FeeTailFragment()
00932 {
00933
00934 }
00935
00936 unsigned int DayaBay::FeeTailFragment::tailType() const
00937 {
00938 return DataFormat::FeeTailFragment::tailType;
00939 }
00940
00941 std::ostream& DayaBay::FeeTailFragment::dump(std::ostream& str){
00942
00943 str << "FeeTailFragment {" << std::endl;
00944 this->TailFragment::dump(str);
00945 return str << "}" << std::endl;
00946 }
00947
00949
00950
00951 DayaBay::DataFragment::DataFragment(unsigned int* buffer,
00952 unsigned int majorVersion,
00953 unsigned int minorVersion,
00954 bool isOwner)
00955 : RawFragment(buffer,majorVersion,minorVersion,isOwner)
00956 {
00957
00958 }
00959
00960 DayaBay::DataFragment::~DataFragment()
00961 {
00962
00963 }
00964
00965 unsigned int DayaBay::DataFragment::size() const
00966 {
00967 return DataFormat::DataFragment::size;
00968 }
00969
00970 unsigned int DayaBay::DataFragment::dataType() const
00971 {
00972 return DataFormat::DataFragment::dataType;
00973 }
00974
00975 bool DayaBay::DataFragment::isLocalTriggerData() const
00976 {
00977
00978 return (this->dataType()==DataFormat::LocalTriggerData::dataType);
00979 }
00980
00981 bool DayaBay::DataFragment::isFeePeakData() const
00982 {
00983
00984 return (this->dataType()==DataFormat::FeePeakData::dataType);
00985 }
00986
00987 std::ostream& DayaBay::DataFragment::dump(std::ostream& str){
00988
00989 str << "DataFragment {"
00990 << " dataType: " << this->dataType() << ", "
00991 << " contents: 0x" << std::hex << this->getValue(0) << std::dec
00992 << std::endl << " ";
00993 this->RawFragment::dump(str);
00994 return str << "}" << std::endl;
00995 }
00996
00998
00999 DayaBay::LocalTriggerData::LocalTriggerData(unsigned int* buffer,
01000 unsigned int majorVersion,
01001 unsigned int minorVersion,
01002 unsigned int ltbDataVersion,
01003 bool isOwner)
01004 : DataFragment(buffer,majorVersion,minorVersion,isOwner),
01005 m_ltbDataVersion(ltbDataVersion)
01006 {
01007
01008 }
01009
01010 DayaBay::LocalTriggerData::~LocalTriggerData()
01011 {
01012
01013 }
01014
01015 unsigned int DayaBay::LocalTriggerData::ltbDataVersion() const
01016 {
01017 return m_ltbDataVersion;
01018 }
01019
01020 unsigned int DayaBay::LocalTriggerData::size() const
01021 {
01022 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01023 return DataFormat::LocalTriggerData_v2::size;
01024 return DataFormat::LocalTriggerData::size;
01025 }
01026
01027 unsigned int DayaBay::LocalTriggerData::dataType() const
01028 {
01029 return DataFormat::LocalTriggerData::dataType;
01030 }
01031
01032 unsigned int DayaBay::LocalTriggerData::sequenceNumber() const
01033 {
01034 return this->getValue(DataFormat::LocalTriggerData::sequenceNumberLine,
01035 DataFormat::LocalTriggerData::sequenceNumberBitOffset,
01036 DataFormat::LocalTriggerData::sequenceNumberBitLength);
01037 }
01038
01039 unsigned int DayaBay::LocalTriggerData::readOutType() const
01040 {
01041 return this->getValue(DataFormat::LocalTriggerData::readOutTypeLine,
01042 DataFormat::LocalTriggerData::readOutTypeBitOffset,
01043 DataFormat::LocalTriggerData::readOutTypeBitLength);
01044 }
01045
01046 unsigned int DayaBay::LocalTriggerData::triggerType() const
01047 {
01048 return this->getValue(DataFormat::LocalTriggerData::triggerTypeLine,
01049 DataFormat::LocalTriggerData::triggerTypeBitOffset,
01050 DataFormat::LocalTriggerData::triggerTypeBitLength);
01051 }
01052
01053 unsigned int DayaBay::LocalTriggerData::year() const
01054 {
01055 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01056 return 0;
01057 return this->getValue(DataFormat::LocalTriggerData::yearLine,
01058 DataFormat::LocalTriggerData::yearBitOffset,
01059 DataFormat::LocalTriggerData::yearBitLength);
01060 }
01061
01062 unsigned int DayaBay::LocalTriggerData::month() const
01063 {
01064 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01065 return 0;
01066 return this->getValue(DataFormat::LocalTriggerData::monthLine,
01067 DataFormat::LocalTriggerData::monthBitOffset,
01068 DataFormat::LocalTriggerData::monthBitLength);
01069 }
01070
01071 unsigned int DayaBay::LocalTriggerData::day() const
01072 {
01073 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01074 return 0;
01075 return this->getValue(DataFormat::LocalTriggerData::dayLine,
01076 DataFormat::LocalTriggerData::dayBitOffset,
01077 DataFormat::LocalTriggerData::dayBitLength);
01078 }
01079
01080 unsigned int DayaBay::LocalTriggerData::hour() const
01081 {
01082 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version ){
01083 unsigned int bcdHour =
01084 this->getValue(DataFormat::LocalTriggerData_v2::hourLine,
01085 DataFormat::LocalTriggerData_v2::hourBitOffset,
01086 DataFormat::LocalTriggerData_v2::hourBitLength);
01087 return (bcdHour & 0xf) + (bcdHour>>4 & 0xf)*10;
01088 }
01089 return this->getValue(DataFormat::LocalTriggerData::hourLine,
01090 DataFormat::LocalTriggerData::hourBitOffset,
01091 DataFormat::LocalTriggerData::hourBitLength);
01092 }
01093
01094 unsigned int DayaBay::LocalTriggerData::minute() const
01095 {
01096 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version ){
01097 unsigned int bcdMin =
01098 this->getValue(DataFormat::LocalTriggerData_v2::minuteLine,
01099 DataFormat::LocalTriggerData_v2::minuteBitOffset,
01100 DataFormat::LocalTriggerData_v2::minuteBitLength);
01101 return (bcdMin & 0xf) + (bcdMin>>4 & 0xf)*10;
01102 }
01103 return this->getValue(DataFormat::LocalTriggerData::minuteLine,
01104 DataFormat::LocalTriggerData::minuteBitOffset,
01105 DataFormat::LocalTriggerData::minuteBitLength);
01106 }
01107
01108 unsigned int DayaBay::LocalTriggerData::second() const
01109 {
01110 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version ){
01111 unsigned int bcdSec =
01112 this->getValue(DataFormat::LocalTriggerData_v2::secondLine,
01113 DataFormat::LocalTriggerData_v2::secondBitOffset,
01114 DataFormat::LocalTriggerData_v2::secondBitLength);
01115 return (bcdSec & 0xf) + (bcdSec>>4 & 0xf)*10;
01116 }
01117 return this->getValue(DataFormat::LocalTriggerData::secondLine,
01118 DataFormat::LocalTriggerData::secondBitOffset,
01119 DataFormat::LocalTriggerData::secondBitLength);
01120 }
01121
01122 unsigned int DayaBay::LocalTriggerData::clock() const
01123 {
01124 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01125 return 0;
01126 return this->getValue(DataFormat::LocalTriggerData::clockLine,
01127 DataFormat::LocalTriggerData::clockBitOffset,
01128 DataFormat::LocalTriggerData::clockBitLength);
01129 }
01130
01131 unsigned int DayaBay::LocalTriggerData::hsum() const
01132 {
01133 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01134 return this->getValue(DataFormat::LocalTriggerData_v2::hsumLine,
01135 DataFormat::LocalTriggerData_v2::hsumBitOffset,
01136 DataFormat::LocalTriggerData_v2::hsumBitLength);
01137 return this->getValue(DataFormat::LocalTriggerData::hsumLine,
01138 DataFormat::LocalTriggerData::hsumBitOffset,
01139 DataFormat::LocalTriggerData::hsumBitLength);
01140 }
01141
01142 unsigned int DayaBay::LocalTriggerData::esumComp() const
01143 {
01144 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01145 return this->getValue(DataFormat::LocalTriggerData_v2::esumCompLine,
01146 DataFormat::LocalTriggerData_v2::esumCompBitOffset,
01147 DataFormat::LocalTriggerData_v2::esumCompBitLength);
01148 return this->getValue(DataFormat::LocalTriggerData::esumCompLine,
01149 DataFormat::LocalTriggerData::esumCompBitOffset,
01150 DataFormat::LocalTriggerData::esumCompBitLength);
01151 }
01152
01153 unsigned int DayaBay::LocalTriggerData::esum() const
01154 {
01155 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01156 return this->getValue(DataFormat::LocalTriggerData_v2::esumLine,
01157 DataFormat::LocalTriggerData_v2::esumBitOffset,
01158 DataFormat::LocalTriggerData_v2::esumBitLength);
01159 return this->getValue(DataFormat::LocalTriggerData::esumLine,
01160 DataFormat::LocalTriggerData::esumBitOffset,
01161 DataFormat::LocalTriggerData::esumBitLength);
01162 }
01163
01164 unsigned int DayaBay::LocalTriggerData::crossTriggerSource() const
01165 {
01166 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01167 return this->getValue(
01168 DataFormat::LocalTriggerData_v2::crossTriggerSourceLine,
01169 DataFormat::LocalTriggerData_v2::crossTriggerSourceBitOffset,
01170 DataFormat::LocalTriggerData_v2::crossTriggerSourceBitLength);
01171 return this->getValue(DataFormat::LocalTriggerData::crossTriggerSourceLine,
01172 DataFormat::LocalTriggerData::crossTriggerSourceBitOffset,
01173 DataFormat::LocalTriggerData::crossTriggerSourceBitLength);
01174 }
01175
01176
01177 unsigned int DayaBay::LocalTriggerData::accumulationStatus() const
01178 {
01179 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01180 return this->getValue(
01181 DataFormat::LocalTriggerData_v2::accumulationStatusLine,
01182 DataFormat::LocalTriggerData_v2::accumulationStatusBitOffset,
01183 DataFormat::LocalTriggerData_v2::accumulationStatusBitLength);
01184 return 0;
01185 }
01186
01187 unsigned int DayaBay::LocalTriggerData::gpsValid() const
01188 {
01189 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01190 return this->getValue(DataFormat::LocalTriggerData_v2::gpsValidLine,
01191 DataFormat::LocalTriggerData_v2::gpsValidBitOffset,
01192 DataFormat::LocalTriggerData_v2::gpsValidBitLength);
01193 return 0;
01194 }
01195
01196 unsigned int DayaBay::LocalTriggerData::timestampType() const
01197 {
01198 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01199 return this->getValue(DataFormat::LocalTriggerData_v2::timestampTypeLine,
01200 DataFormat::LocalTriggerData_v2::timestampTypeBitOffset,
01201 DataFormat::LocalTriggerData_v2::timestampTypeBitLength);
01202 return 0;
01203 }
01204
01205 unsigned int DayaBay::LocalTriggerData::clockValid() const
01206 {
01207 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01208 return this->getValue(DataFormat::LocalTriggerData_v2::clockValidLine,
01209 DataFormat::LocalTriggerData_v2::clockValidBitOffset,
01210 DataFormat::LocalTriggerData_v2::clockValidBitLength);
01211 return 0;
01212 }
01213
01214 unsigned int DayaBay::LocalTriggerData::unixtimeHigh() const
01215 {
01216 if( this->isUnixTime() )
01217 return this->getValue(DataFormat::LocalTriggerData_v2::unixtimeHighLine,
01218 DataFormat::LocalTriggerData_v2::unixtimeHighBitOffset,
01219 DataFormat::LocalTriggerData_v2::unixtimeHighBitLength);
01220 return 0;
01221 }
01222
01223 unsigned int DayaBay::LocalTriggerData::unixtimeLow() const
01224 {
01225 if( this->isUnixTime() )
01226 return this->getValue(DataFormat::LocalTriggerData_v2::unixtimeLowLine,
01227 DataFormat::LocalTriggerData_v2::unixtimeLowBitOffset,
01228 DataFormat::LocalTriggerData_v2::unixtimeLowBitLength);
01229 return 0;
01230 }
01231
01232 unsigned int DayaBay::LocalTriggerData::unixtime() const
01233 {
01234 if( this->isUnixTime() )
01235 return (this->unixtimeHigh()<<DataFormat::LocalTriggerData_v2::unixtimeLowBitLength | this->unixtimeLow());
01236 return 0;
01237 }
01238
01239 unsigned int DayaBay::LocalTriggerData::days() const
01240 {
01241 if( this->isUtcTime() )
01242 return this->getValue(DataFormat::LocalTriggerData_v2::daysLine,
01243 DataFormat::LocalTriggerData_v2::daysBitOffset,
01244 DataFormat::LocalTriggerData_v2::daysBitLength);
01245 return 0;
01246 }
01247
01248 unsigned int DayaBay::LocalTriggerData::accumulationHigh() const
01249 {
01250 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01251 return this->getValue(DataFormat::LocalTriggerData_v2::accumulationHighLine,
01252 DataFormat::LocalTriggerData_v2::accumulationHighBitOffset,
01253 DataFormat::LocalTriggerData_v2::accumulationHighBitLength);
01254 return 0;
01255 }
01256
01257 unsigned int DayaBay::LocalTriggerData::nanosecondHigh() const
01258 {
01259 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01260 return this->getValue(DataFormat::LocalTriggerData_v2::nanosecondHighLine,
01261 DataFormat::LocalTriggerData_v2::nanosecondHighBitOffset,
01262 DataFormat::LocalTriggerData_v2::nanosecondHighBitLength);
01263 return 0;
01264 }
01265
01266 unsigned int DayaBay::LocalTriggerData::accumulationLow() const
01267 {
01268 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01269 return this->getValue(DataFormat::LocalTriggerData_v2::accumulationLowLine,
01270 DataFormat::LocalTriggerData_v2::accumulationLowBitOffset,
01271 DataFormat::LocalTriggerData_v2::accumulationLowBitLength);
01272 return 0;
01273 }
01274
01275 unsigned int DayaBay::LocalTriggerData::nanosecondLow() const
01276 {
01277 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01278 return this->getValue(DataFormat::LocalTriggerData_v2::nanosecondLowLine,
01279 DataFormat::LocalTriggerData_v2::nanosecondLowBitOffset,
01280 DataFormat::LocalTriggerData_v2::nanosecondLowBitLength);
01281 return 0;
01282 }
01283
01284 int DayaBay::LocalTriggerData::accumulation() const
01285 {
01286 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01287 return int(this->accumulationHigh()<<DataFormat::LocalTriggerData_v2::accumulationLowBitLength | this->accumulationLow())/2;
01288 return 0;
01289 }
01290
01291 unsigned int DayaBay::LocalTriggerData::nanosecond() const
01292 {
01293 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01294 return (this->nanosecondHigh()<<DataFormat::LocalTriggerData_v2::nanosecondLowBitLength | this->nanosecondLow())/2;
01295 return 0;
01296 }
01297
01298 unsigned int DayaBay::LocalTriggerData::feeBufferStatus() const
01299 {
01300 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01301 return this->getValue(DataFormat::LocalTriggerData_v2::feeBufferStatusLine,
01302 DataFormat::LocalTriggerData_v2::feeBufferStatusBitOffset,
01303 DataFormat::LocalTriggerData_v2::feeBufferStatusBitLength);
01304 return 0;
01305 }
01306
01307 unsigned int DayaBay::LocalTriggerData::ltbBufferStatus() const
01308 {
01309 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01310 return this->getValue(DataFormat::LocalTriggerData_v2::ltbBufferStatusLine,
01311 DataFormat::LocalTriggerData_v2::ltbBufferStatusBitOffset,
01312 DataFormat::LocalTriggerData_v2::ltbBufferStatusBitLength);
01313 return 0;
01314 }
01315
01316 unsigned int DayaBay::LocalTriggerData::blockedTrigger() const
01317 {
01318 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01319 return this->getValue(DataFormat::LocalTriggerData_v2::blockedTriggerLine,
01320 DataFormat::LocalTriggerData_v2::blockedTriggerBitOffset,
01321 DataFormat::LocalTriggerData_v2::blockedTriggerBitLength);
01322 return 0;
01323 }
01324
01325 bool DayaBay::LocalTriggerData::isUtcTime() const
01326 {
01327 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01328 return (this->timestampType() & this->clockValid() & this->gpsValid());
01329 return false;
01330 }
01331
01332 bool DayaBay::LocalTriggerData::isUnixTime() const
01333 {
01334 if( this->ltbDataVersion() >= DataFormat::LocalTriggerData_v2::version )
01335 return !this->isUtcTime();
01336 return false;
01337 }
01338
01339 bool DayaBay::LocalTriggerData::isManualTrigger() const
01340 {
01341
01342 return (this->triggerType() & DataFormat::LocalTriggerData::TriggerType::kManual);
01343 }
01344
01345 bool DayaBay::LocalTriggerData::isCrossTrigger() const
01346 {
01347
01348 return (this->triggerType() & DataFormat::LocalTriggerData::TriggerType::kCross);
01349 }
01350
01351 bool DayaBay::LocalTriggerData::isPeriodicTrigger() const
01352 {
01353
01354 return (this->triggerType() & DataFormat::LocalTriggerData::TriggerType::kPeriodic);
01355 }
01356
01357 bool DayaBay::LocalTriggerData::isMultiplicityTrigger() const
01358 {
01359
01360 return (this->triggerType() & DataFormat::LocalTriggerData::TriggerType::kMultiplicity);
01361 }
01362
01363 bool DayaBay::LocalTriggerData::isEsumAdcTrigger() const
01364 {
01365
01366 return (this->triggerType() & DataFormat::LocalTriggerData::TriggerType::kEsumAdc);
01367 }
01368
01369 bool DayaBay::LocalTriggerData::isEsumCompHighTrigger() const
01370 {
01371
01372 return (this->triggerType() & DataFormat::LocalTriggerData::TriggerType::kEsumCompHigh);
01373 }
01374
01375 bool DayaBay::LocalTriggerData::isEsumCompLowTrigger() const
01376 {
01377
01378 return (this->triggerType() & DataFormat::LocalTriggerData::TriggerType::kEsumCompLow);
01379 }
01380
01381 bool DayaBay::LocalTriggerData::isEsumCompAllTrigger() const
01382 {
01383
01384 return (this->triggerType() & DataFormat::LocalTriggerData::TriggerType::kEsumCompAll);
01385 }
01386
01387 std::ostream& DayaBay::LocalTriggerData::dump(std::ostream& str){
01388
01389 str << "LocalTriggerData {" << std::endl << " ";
01390 this->DataFragment::dump(str);
01391 str << " sequenceNumber: " << this->sequenceNumber() << ", "
01392 << " readOutType: " << this->readOutType() << ", "
01393 << " triggerType: " << this->triggerType() << " [ ";
01394 if(this->isManualTrigger()) str << "Manual, ";
01395 if(this->isCrossTrigger()) str << "Cross, ";
01396 if(this->isPeriodicTrigger()) str << "Periodic, ";
01397 if(this->isMultiplicityTrigger()) str << "Multiplicity, ";
01398 if(this->isEsumAdcTrigger()) str << "EsumAdc, ";
01399 if(this->isEsumCompHighTrigger()) str << "EsumCompHigh, ";
01400 if(this->isEsumCompLowTrigger()) str << "EsumCompLow, ";
01401 if(this->isEsumCompAllTrigger()) str << "EsumCompAll, ";
01402 str << " ], ";
01403 if( this->ltbDataVersion()>=DataFormat::LocalTriggerData_v2::version ){
01404 str << " accumulationStatus: " << this->accumulationStatus() << ", "
01405 << " gpsValid: " << this->gpsValid() << ", "
01406 << " timestampType: " << this->timestampType() << ", "
01407 << " clockValid: " << this->clockValid() << ", ";
01408 }
01409 if( this->ltbDataVersion() == DataFormat::LocalTriggerData::version ){
01410 str << " year: " << this->year() << ", "
01411 << " month: " << this->month() << ", "
01412 << " day: " << this->day() << ", "
01413 << " hour: " << this->hour() << ", "
01414 << " minute: " << this->minute() << ", "
01415 << " second: " << this->second() << ", "
01416 << " clock: " << this->clock() << ", ";
01417 }else if( this->ltbDataVersion()>=DataFormat::LocalTriggerData_v2::version ){
01418 if( this->isUtcTime() ){
01419 str << " days: " << this->day() << ", "
01420 << " hour: " << this->hour() << ", "
01421 << " minute: " << this->minute() << ", "
01422 << " second: " << this->second() << ", ";
01423 }else{
01424
01425 time_t unixtime = this->unixtime();
01426 str << " unixtimeHigh: " << this->unixtimeHigh() << ", "
01427 << " unixtimeLow: " << this->unixtimeLow() << ", "
01428 << " unixtime (formatted): "
01429 << ctime(&unixtime);
01430 }
01431 str << " nanosecond: " << this->nanosecond() << ", "
01432 << " accumulation: " << this->accumulation() << ", "
01433 << " nano+accum: " << this->nanosecond()+this->accumulation() << ", ";
01434 }
01435
01436 str << " hsum: " << this->hsum() << ", "
01437 << " esumComp: " << this->esumComp() << ", "
01438 << " esum: " << this->esum() << ", ";
01439 if( this->ltbDataVersion()>=DataFormat::LocalTriggerData_v2::version ){
01440 str << " feeBufferStatus: " << this->feeBufferStatus() << ", "
01441 << " ltbBufferStatus: " << this->ltbBufferStatus() << ", "
01442 << " blockedTrigger: " << this->blockedTrigger() << ", ";
01443 }
01444 str << " crossTriggerSource: " << this->crossTriggerSource()
01445 << std::endl
01446 << "}" << std::endl;
01447 return str;
01448 }
01449
01451
01452
01453 DayaBay::FeePeakData::FeePeakData(unsigned int* buffer,
01454 unsigned int majorVersion,
01455 unsigned int minorVersion,
01456 unsigned int feeDataVersion,
01457 bool isOwner)
01458 : DataFragment(buffer,majorVersion,minorVersion,isOwner),
01459 m_feeDataVersion(feeDataVersion)
01460 {
01461
01462 }
01463
01464 DayaBay::FeePeakData::~FeePeakData()
01465 {
01466
01467 }
01468
01469 unsigned int DayaBay::FeePeakData::feeDataVersion() const
01470 {
01471 return m_feeDataVersion;
01472 }
01473
01474 unsigned int DayaBay::FeePeakData::size() const
01475 {
01476 return DataFormat::FeePeakData::size;
01477 }
01478
01479 unsigned int DayaBay::FeePeakData::dataType() const
01480 {
01481 return DataFormat::FeePeakData::dataType;
01482 }
01483
01484 unsigned int DayaBay::FeePeakData::channel() const
01485 {
01486 return this->adcChannel();
01487 }
01488 unsigned int DayaBay::FeePeakData::adcChannel() const
01489 {
01490 if( this->feeDataVersion() >= DataFormat::FeePeakData_v1::version )
01491 return this->getValue(DataFormat::FeePeakData_v1::adcChannelLine,
01492 DataFormat::FeePeakData_v1::adcChannelBitOffset,
01493 DataFormat::FeePeakData_v1::adcChannelBitLength);
01494 return this->getValue(DataFormat::FeePeakData::adcChannelLine,
01495 DataFormat::FeePeakData::adcChannelBitOffset,
01496 DataFormat::FeePeakData::adcChannelBitLength);
01497 }
01498
01499 unsigned int DayaBay::FeePeakData::tdcChannel() const
01500 {
01501 if( this->feeDataVersion() >= DataFormat::FeePeakData_v1::version )
01502 return this->getValue(DataFormat::FeePeakData_v1::tdcChannelLine,
01503 DataFormat::FeePeakData_v1::tdcChannelBitOffset,
01504 DataFormat::FeePeakData_v1::tdcChannelBitLength);
01505 return this->getValue(DataFormat::FeePeakData::tdcChannelLine,
01506 DataFormat::FeePeakData::tdcChannelBitOffset,
01507 DataFormat::FeePeakData::tdcChannelBitLength);
01508 }
01509
01510 unsigned int DayaBay::FeePeakData::tdc() const
01511 {
01512 return this->getValue(DataFormat::FeePeakData::tdcLine,
01513 DataFormat::FeePeakData::tdcBitOffset,
01514 DataFormat::FeePeakData::tdcBitLength);
01515 }
01516
01517 unsigned int DayaBay::FeePeakData::tdcHitCount() const
01518 {
01519 if( this->feeDataVersion() >= DataFormat::FeePeakData_v1::version )
01520 return this->getValue(DataFormat::FeePeakData_v1::tdcHitCountLine,
01521 DataFormat::FeePeakData_v1::tdcHitCountBitOffset,
01522 DataFormat::FeePeakData_v1::tdcHitCountBitLength);
01523 return this->getValue(DataFormat::FeePeakData::tdcHitCountLine,
01524 DataFormat::FeePeakData::tdcHitCountBitOffset,
01525 DataFormat::FeePeakData::tdcHitCountBitLength);
01526 }
01527
01528 unsigned int DayaBay::FeePeakData::peakCycle() const
01529 {
01530 if( this->feeDataVersion() >= DataFormat::FeePeakData_v1::version )
01531 return this->getValue(DataFormat::FeePeakData_v1::peakCycleLine,
01532 DataFormat::FeePeakData_v1::peakCycleBitOffset,
01533 DataFormat::FeePeakData_v1::peakCycleBitLength);
01534 return this->getValue(DataFormat::FeePeakData::peakCycleLine,
01535 DataFormat::FeePeakData::peakCycleBitOffset,
01536 DataFormat::FeePeakData::peakCycleBitLength);
01537 }
01538
01539 unsigned int DayaBay::FeePeakData::adcRange() const
01540 {
01541 if( this->feeDataVersion() >= DataFormat::FeePeakData_v1::version )
01542 return this->getValue(DataFormat::FeePeakData_v1::adcRangeLine,
01543 DataFormat::FeePeakData_v1::adcRangeBitOffset,
01544 DataFormat::FeePeakData_v1::adcRangeBitLength);
01545 return this->getValue(DataFormat::FeePeakData::adcRangeLine,
01546 DataFormat::FeePeakData::adcRangeBitOffset,
01547 DataFormat::FeePeakData::adcRangeBitLength);
01548 }
01549
01550 unsigned int DayaBay::FeePeakData::adc() const
01551 {
01552 return this->getValue(DataFormat::FeePeakData::adcLine,
01553 DataFormat::FeePeakData::adcBitOffset,
01554 DataFormat::FeePeakData::adcBitLength);
01555 }
01556
01557 unsigned int DayaBay::FeePeakData::adcPedestal() const
01558 {
01559 if( this->feeDataVersion() >= DataFormat::FeePeakData_v1::version )
01560 return this->getValue(DataFormat::FeePeakData_v1::adcPedestalLine,
01561 DataFormat::FeePeakData_v1::adcPedestalBitOffset,
01562 DataFormat::FeePeakData_v1::adcPedestalBitLength);
01563 return 0;
01564 }
01565
01566 bool DayaBay::FeePeakData::hasAdcPedestal() const
01567 {
01568 if( this->feeDataVersion() >= DataFormat::FeePeakData_v1::version )
01569 return true;
01570 return false;
01571 };
01572
01573 std::ostream& DayaBay::FeePeakData::dump(std::ostream& str){
01574
01575 str << "FeePeakData {" << std::endl << " ";
01576 this->DataFragment::dump(str);
01577 str << " channel: " << this->channel() << ", "
01578 << " tdc: " << this->tdc() << ", "
01579 << " adc: " << this->adc() << ", ";
01580 if( this->hasAdcPedestal() )
01581 str << " adcPedestal: " << this->adcPedestal() << ", ";
01582 str << " peakCycle: " << this->peakCycle() << ", "
01583 << " adcRange: " << this->adcRange() << std::endl
01584 << "}" << std::endl;
01585 return str;
01586 }
01587
01588