00001 #ifndef EVENTREADOUTFORMAT_EVENTTRAITS_H 00002 #define EVENTREADOUTFORMAT_EVENTTRAITS_H 00003 00004 /* 00005 * EventTraits.h 00006 * EventReadoutFormat 00007 * 00008 * Created by Simon Patton on 7/19/10. 00009 * Copyright 2010 DayaBay Collaboration. All rights reserved. 00010 * 00011 */ 00012 00013 #include "DaqReadoutFormat/DaqTraits.h" 00014 00015 namespace DybDaq { 00016 00017 class EventTraits : public DaqTraits { 00018 00019 public: 00020 00021 // Block constants. 00022 00026 static const unsigned int kEventHeader; 00027 00031 static const unsigned int kRomHeader; 00032 00033 // For All Headers. 00034 00038 static const unsigned int kMarker; 00039 00040 // For Event Header. 00041 00045 static const unsigned int kMajorVersion; 00046 00050 static const unsigned int kMinorVersion; 00051 00055 static const unsigned int kEventHeaderSize; 00056 00060 static const unsigned int kEventTotalSize; 00061 00065 static const unsigned int kEventSite; 00066 00070 static const unsigned int kEventDetector; 00071 00075 static const unsigned int kEventRun; 00076 00080 static const unsigned int kEventNumber; 00081 00085 static const unsigned int kEventDataType; 00086 00090 static const unsigned int kCbltWrapping; 00091 00095 static const unsigned int kRawCblt; 00096 00100 static const unsigned int kLtbMismatch; 00101 00105 static const unsigned int kInvalidData; 00106 00107 // For Rom Fragment. 00108 00112 static const unsigned int kRomHeaderSize; 00113 00117 static const unsigned int kRomTotalSize; 00118 00122 static const unsigned int kRomSite; 00123 00127 static const unsigned int kRomDetector; 00128 00132 static const unsigned int kRomModuleType; 00133 00137 static const unsigned int kRomSlot; 00138 00139 // Enumeration of supported modules. 00140 00144 static const unsigned int kFeeModule; 00145 00149 static const unsigned int kFadcModule; 00150 00154 static const unsigned int kLtbModule; 00155 00159 static const unsigned int kRpcRomModule; 00160 00164 static const unsigned int kRpcRtmModule; 00165 00169 static const unsigned int kMtbModule; 00170 00174 static const EventTraits& defaultTraits(); 00175 00179 static const EventTraits* readTraits(const char*& buffer); 00180 00184 virtual ~EventTraits(); 00185 00189 virtual unsigned int illegalMarker() const; 00190 00194 virtual unsigned int illegalField() const; 00195 00199 virtual unsigned int headerSize(const unsigned int marker) const = 0; 00200 00204 virtual void initializeHeader(const unsigned int marker, 00205 char* buffer) const = 0; 00206 00210 const char* siteAsString(const unsigned int site) const; 00211 00215 const char* detectorAsString(const unsigned int detector) const; 00216 00220 const char* dataTypeAsString(const unsigned int dataType) const; 00221 00225 unsigned int moduleType(const unsigned int module) const; 00226 00230 const char* moduleTypeAsString(const unsigned int moduleType) const; 00231 00232 protected: 00233 00237 EventTraits(); 00238 00242 virtual unsigned int maxSite() const = 0; 00243 00247 virtual const char** siteStrings() const = 0; 00248 00252 virtual unsigned int maxDetector() const = 0; 00253 00257 virtual const char** detectorStrings() const = 0; 00258 00262 virtual unsigned int maxDataType() const = 0; 00263 00267 virtual const char** dataTypeStrings() const = 0; 00268 00272 virtual unsigned int maxModuleType() const = 0; 00273 00277 virtual const unsigned int* moduleTypes() const = 0; 00278 00282 virtual const char** moduleTypeStrings() const = 0; 00283 00284 private: 00285 00289 EventTraits(EventTraits& rhs); 00290 00294 EventTraits& operator=(EventTraits& rhs); 00295 00296 }; 00297 00298 } 00299 00300 #endif // EVENTREADOUTFORMAT_EVENTTRAITS_H