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

In This Package:

EventTraits.cc
Go to the documentation of this file.
00001 /*
00002  *  EventTraits.cc
00003  *  RawFileReading
00004  *
00005  *  Created by Simon Patton on 7/19/10.
00006  *  Copyright 2010 DayaBay Collaboration. All rights reserved.
00007  *
00008  */
00009 #include "EventReadoutFormat/EventTraits.h"
00010 
00011 #include <map>
00012 #include "EventReadoutFormat/EventTraits_v0_6.h"
00013 #include "EventReadoutFormat/EventTraits_v0_7.h"
00014 
00015 using DybDaq::EventTraits;
00016 using DybDaq::EventTraits_v0_6;
00017 using DybDaq::EventTraits_v0_7;
00018 
00019 const unsigned int EventTraits::kEventHeader = 0;
00020 const unsigned int EventTraits::kRomHeader = EventTraits::kEventHeader + 1;
00021 
00022 //
00023 
00024 const unsigned int EventTraits::kMarker = 0;
00025 const unsigned int EventTraits::kMajorVersion = EventTraits::kMarker + 1;
00026 const unsigned int EventTraits::kMinorVersion = EventTraits::kMajorVersion + 1;
00027 const unsigned int EventTraits::kEventHeaderSize = EventTraits::kMinorVersion + 1;
00028 const unsigned int EventTraits::kEventTotalSize = EventTraits::kEventHeaderSize + 1;
00029 const unsigned int EventTraits::kEventSite = EventTraits::kEventTotalSize + 1;
00030 const unsigned int EventTraits::kEventDetector = EventTraits::kEventSite + 1;
00031 const unsigned int EventTraits::kEventRun = EventTraits::kEventDetector + 1;
00032 const unsigned int EventTraits::kEventNumber = EventTraits::kEventRun + 1;
00033 const unsigned int EventTraits::kEventDataType = EventTraits::kEventNumber + 1;
00034 const unsigned int EventTraits::kCbltWrapping = EventTraits::kEventDataType + 1;
00035 const unsigned int EventTraits::kRawCblt = EventTraits::kCbltWrapping + 1;
00036 const unsigned int EventTraits::kLtbMismatch = EventTraits::kRawCblt + 1;
00037 const unsigned int EventTraits::kInvalidData = EventTraits::kLtbMismatch + 1;
00038 const unsigned int EventTraits::kRomHeaderSize = EventTraits::kInvalidData + 1;
00039 const unsigned int EventTraits::kRomTotalSize = EventTraits::kRomHeaderSize + 1;
00040 const unsigned int EventTraits::kRomSite = EventTraits::kRomTotalSize + 1;
00041 const unsigned int EventTraits::kRomDetector = EventTraits::kRomSite + 1;
00042 const unsigned int EventTraits::kRomModuleType = EventTraits::kRomDetector + 1;
00043 const unsigned int EventTraits::kRomSlot = EventTraits::kRomModuleType + 1;
00044 
00045 // Added v0.7
00046 
00047 const unsigned int EventTraits::kRpcSortDisabled = EventTraits::kRomSlot + 1;
00048 const unsigned int EventTraits::kDataSortTimeout = EventTraits::kRpcSortDisabled + 1;
00049 
00050 //
00051 
00052 const unsigned int EventTraits::kFeeModule = 0;
00053 const unsigned int EventTraits::kFadcModule = EventTraits::kFeeModule + 1;
00054 const unsigned int EventTraits::kLtbModule = EventTraits::kFadcModule + 1;
00055 const unsigned int EventTraits::kRpcRomModule = EventTraits::kLtbModule + 1;
00056 const unsigned int EventTraits::kRpcRtmModule = EventTraits::kRpcRomModule + 1;
00057 const unsigned int EventTraits::kMtbModule = EventTraits::kRpcRtmModule + 1;
00058 
00059 static std::map<const char*, EventTraits*> m_allTraits;
00060 
00061 EventTraits::EventTraits() {
00062 }
00063 
00064 EventTraits::~EventTraits() {
00065 }
00066 
00067 const EventTraits& EventTraits::defaultTraits() {
00068     if (0 == m_allTraits.size()) {
00069         m_allTraits.insert(std::pair<const char*, EventTraits*>(EventTraits_v0_6::key(),new EventTraits_v0_6()));
00070         m_allTraits.insert(std::pair<const char*, EventTraits*>(EventTraits_v0_7::key(),new EventTraits_v0_7()));
00071     }
00072     return *m_allTraits[EventTraits_v0_7::key()];
00073 }
00074 
00075 const EventTraits* EventTraits::readTraits(const char*& buffer) {
00076     const EventTraits& traits = defaultTraits(); 
00077     const unsigned int major = readUnsignedInt(buffer,
00078                                                traits,
00079                                                kMajorVersion);
00080     const unsigned int minor = readUnsignedInt(buffer,
00081                                                traits,
00082                                                kMinorVersion);
00083     const EventTraits* result = 0;
00084     if (0U == major && 6U == minor) {
00085         result = m_allTraits[EventTraits_v0_6::key()];
00086     } else if (0U == major && 7U == minor) {
00087         result = m_allTraits[EventTraits_v0_7::key()];
00088     }
00089     return result;
00090 }
00091 
00092 unsigned int EventTraits::illegalMarker() const {
00093     return 0xffffffffU;
00094 }
00095 
00096 unsigned int EventTraits::illegalField() const {
00097     return 0xffffffffU;
00098 }
00099 
00100 const char* EventTraits::siteAsString(const unsigned int site) const {
00101     return siteStrings()[site];
00102 }
00103 
00104 const char* EventTraits::detectorAsString(const unsigned int detector) const {
00105     return detectorStrings()[detector];
00106 }
00107 
00108 const char* EventTraits::dataTypeAsString(const unsigned int dataType) const {
00109     return dataTypeStrings()[dataType];
00110 }
00111 
00112 unsigned int EventTraits::moduleType(const unsigned int module) const {
00113         if (module > maxModuleType()) {
00114                 return 0;
00115         }
00116         return moduleTypes()[module];
00117 }
00118 
00119 const char* EventTraits::moduleTypeAsString(const unsigned int moduleType) const {
00120     return moduleTypeStrings()[moduleType];
00121 }
00122 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:53:15 for EventReadoutFormat by doxygen 1.7.4