/* This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus * * MAUS is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MAUS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MAUS. If not, see . * */ #include "MDevent.h" MDevent::MDevent(void *d):MDdataContainer(d),nFragments(0) { MDevent::SetDataPtr( d ); }; void MDevent::Init( ) { fragment.clear(); InitFragments(); subEvent.clear(); InitSubEvents(); } bool MDevent::InitFragments() { if ( ( EventType() != PHYSICS_EVENT && EventType() != CALIBRATION_EVENT) || IsSuperEvent() ) return false; unsigned long32 neq = 0; MDeventFragment evtFrg; unsigned char* ptr = PayLoadPtr(); while (ptr < _data + EventSize() ) { neq++; evtFrg.SetDataPtr(ptr); fragment.push_back(ptr); ptr += evtFrg.EquipmentSize(); } nFragments = neq; return true; } bool MDevent::InitSubEvents() { if ( !IsSuperEvent() ) return false; unsigned long32 nsub = 0; MDevent subEvt; unsigned char* ptr = _data + HeadSize() ; while (ptr < _data + EventSize() ) { nsub++; subEvt.SetDataPtr(ptr); subEvent.push_back(ptr); ptr += subEvt.EventSize(); } nSubEvents = nsub; return true; } void MDevent::SetDataPtr( void *d ) { MDdataContainer::SetDataPtr(d); if ( _data ) { if ( *MagicPtr() == EVENT_MAGIC_NUMBER ) { _valid = true; _size = *EventSizePtr(); } Init(); } } void MDevent::Dump(int atTheTime){ MDeventType eventType(EventTypePtr()); MDeventId eventId(EventIdPtr()); MDeventTypeAttribute attr(EventTypeAttributePtr()); MDtriggerPattern triggerPattern(TriggerPatternPtr()); MDdetectorPattern detectorPattern(DetectorPatternPtr()); MDevent subEvt; MDeventFragment evtFrg; MDdataContainer dc; cout << dec; if (IsSuperEvent()) { cout << "========================= MDevent Dump ========================================" << endl; } else { cout << "......................... MDevent Dump ........................................" << endl; } cout << "Size:" << *EventSizePtr() << " (header:" << *HeadSizePtr() <<") Version:0x"<< setfill('0') << setw(8) << hex << *VersionPtr() << " " << eventType ; if (IsSuperEvent()) { cout << " Subevents:" << NsubEvent(); } cout << dec << endl; cout << "runNb:" << *RunNbPtr() << " " << eventId << " ldcId:"; if ( *LdcIdPtr() == VOID_ID ) cout << "VOID"; else cout << *LdcIdPtr(); cout << " gdcId:" ; if (*GdcIdPtr() == VOID_ID ) cout << "VOID"; else cout << *GdcIdPtr(); uint32_t *xTime = (uint32_t*) TimeStampPtr(); time_t xMyTime = *xTime; cout << " time:" << ctime( &xMyTime ); // Note: ctime will add endl cout << attr << endl << triggerPattern << " " << detectorPattern << endl; if ( *HeadSizePtr() > EVENT_HEAD_BASE_SIZE ){ cout << "Header extension (" << dec << *HeadSizePtr() - EVENT_HEAD_BASE_SIZE << " bytes(s)):" << endl; dc.SetDataPtr( _data + EVENT_HEAD_BASE_SIZE ); dc.SetSize( *HeadSizePtr() - EVENT_HEAD_BASE_SIZE ); dc.Dump(4); cout << "Payload:" << endl; } if ( PayLoadSize() ) { unsigned char* ptr = PayLoadPtr(); if( IsSuperEvent() ) { for (unsigned int ise=0; ise