| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

DayaBay::RawEvent Class Reference

#include <RawData.h>

Inheritance diagram for DayaBay::RawEvent:

[legend]
Collaboration diagram for DayaBay::RawEvent:
[legend]
List of all members.

Public Member Functions

 RawEvent (unsigned int *buffer=0, unsigned int majorVersion=0, unsigned int minorVersion=0, bool isOwner=false)
 ~RawEvent ()
unsigned int size () const
unsigned int headerSize () const
unsigned int eventMajorVersion () const
unsigned int eventMinorVersion () const
unsigned int siteId () const
unsigned int detectorId () const
unsigned int runNumber () const
unsigned int eventId () const
unsigned int eventType () const
unsigned int eventTypeValue () const
unsigned int formatFlag () const
unsigned int statusFlag () const
DayaBay::RawModulenextModule ()
void resetModule ()
DayaBay::RawEventclone () const
virtual std::ostream & dump (std::ostream &str)
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::RawDatamakeNewData (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_currentModuleLine

Detailed Description

Definition at line 263 of file RawData.h.


Constructor & Destructor Documentation

DayaBay::RawEvent::RawEvent ( unsigned int *  buffer = 0,
unsigned int  majorVersion = 0,
unsigned int  minorVersion = 0,
bool  isOwner = false 
)

Definition at line 128 of file RawData.cc.

00132   : RawData(buffer,majorVersion,minorVersion,isOwner),
00133     m_currentModuleLine(0)
00134 {
00135   // Default constructor
00136   if(buffer){
00137     // Override the version based on the version defined within the data block
00138     m_majorVersion = this->eventMajorVersion();
00139     m_minorVersion = this->eventMinorVersion();
00140   }
00141 }

DayaBay::RawEvent::~RawEvent (  ) 

Definition at line 143 of file RawData.cc.

00144 {
00145   // Destructor
00146   m_currentModuleLine=0;
00147 }


Member Function Documentation

unsigned int DayaBay::RawEvent::size (  )  const

Definition at line 167 of file RawData.cc.

unsigned int DayaBay::RawEvent::headerSize (  )  const

Definition at line 174 of file RawData.cc.

unsigned int DayaBay::RawEvent::eventMajorVersion (  )  const

Definition at line 181 of file RawData.cc.

unsigned int DayaBay::RawEvent::eventMinorVersion (  )  const

Definition at line 188 of file RawData.cc.

unsigned int DayaBay::RawEvent::siteId (  )  const

Definition at line 195 of file RawData.cc.

unsigned int DayaBay::RawEvent::detectorId (  )  const

Definition at line 202 of file RawData.cc.

unsigned int DayaBay::RawEvent::runNumber (  )  const

Definition at line 209 of file RawData.cc.

00210 {
00211   return this->getValue(DataFormat::Event::runNumberLine);
00212 }

unsigned int DayaBay::RawEvent::eventId (  )  const

Definition at line 214 of file RawData.cc.

00215 {
00216   return this->getValue(DataFormat::Event::eventIdLine);
00217 }

unsigned int DayaBay::RawEvent::eventType (  )  const

Definition at line 220 of file RawData.cc.

unsigned int DayaBay::RawEvent::eventTypeValue (  )  const

Definition at line 227 of file RawData.cc.

unsigned int DayaBay::RawEvent::formatFlag (  )  const

Definition at line 234 of file RawData.cc.

unsigned int DayaBay::RawEvent::statusFlag (  )  const

Definition at line 241 of file RawData.cc.

DayaBay::RawModule * DayaBay::RawEvent::nextModule (  ) 

Definition at line 248 of file RawData.cc.

00249 {
00250   // Return the next Module data block in this event
00251   // Return 0 if no more modules
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 }

void DayaBay::RawEvent::resetModule (  ) 

Definition at line 278 of file RawData.cc.

00279 {
00280   m_currentModuleLine=0;
00281 }

DayaBay::RawEvent * DayaBay::RawEvent::clone (  )  const

Definition at line 149 of file RawData.cc.

00150 {
00151   // Make a full copy of this event
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 /*isOwner*/);
00165 }

std::ostream & DayaBay::RawEvent::dump ( std::ostream &  str  )  [virtual]

Reimplemented from DayaBay::RawData.

Definition at line 283 of file RawData.cc.

00283                                                 {
00284   // Print the record information
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; // Restore module line counter
00310   return str << "}" << std::endl;
00311 }

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]

Definition at line 70 of file RawBuffer.cc.

00070                                                     {
00071   m_isOwner = isOwner;
00072 }

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 }


Member Data Documentation

unsigned int DayaBay::RawEvent::m_currentModuleLine [private]

Definition at line 285 of file RawData.h.

unsigned int DayaBay::RawData::m_majorVersion [protected, inherited]

Definition at line 32 of file RawData.h.

unsigned int DayaBay::RawData::m_minorVersion [protected, inherited]

Definition at line 33 of file RawData.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:07:28 2011 for RawData by doxygen 1.4.7