00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "EventReadoutFormat/EventTraits_v0_6.h"
00011
00012 #include "DaqReadoutFormat/BitsDefinition.h"
00013 #include "DaqReadoutFormat/DaqBuffer.h"
00014
00015 using DybDaq::DaqTraits;
00016 using DybDaq::EventTraits_v0_6;
00017 using std::string;
00018
00019 static const unsigned int m_markers[] = {
00020 0xaa1234aaU,
00021 0xbb1234bbU
00022 };
00023
00024 static const unsigned int m_headerLengths[] = {
00025 8U,
00026 3U
00027 };
00028
00029 static const unsigned int m_indices[] = {
00030 0U,
00031 1U,
00032 1U,
00033 2U,
00034 2U,
00035 3U,
00036 3U,
00037 4U,
00038 5U,
00039 6U,
00040 7U,
00041 7U,
00042 7U,
00043 7U,
00044 1U,
00045 1U,
00046 2U,
00047 2U,
00048 2U,
00049 2U
00050 };
00051
00052 static const unsigned int m_shifts[] = {
00053 0U,
00054 24U,
00055 16U,
00056 24U,
00057 0U,
00058 20U,
00059 16U,
00060 0U,
00061 0U,
00062 28U,
00063 17U,
00064 16U,
00065 1U,
00066 0U,
00067 24U,
00068 0U,
00069 20U,
00070 16U,
00071 8U,
00072 0U
00073 };
00074
00075 static const unsigned int m_masks[] = {
00076 0xffffffffU,
00077 0x000000ffU,
00078 0x000000ffU,
00079 0x000000ffU,
00080 0x00ffffffU,
00081 0x0000000fU,
00082 0x0000000fU,
00083 0xffffffffU,
00084 0xffffffffU,
00085 0x0000000fU,
00086 0x00000001U,
00087 0x00000001U,
00088 0x00000001U,
00089 0x00000001U,
00090 0x000000ffU,
00091 0x00ffffffU,
00092 0x0000000fU,
00093 0x0000000fU,
00094 0x000000ffU,
00095 0x000000ffU
00096 };
00097
00098 static const std::string m_description[] = {
00099 "Event Record Type",
00100 "Major File Format Version",
00101 "Minor File Format Version",
00102 "Event Header Size",
00103 "Total Event Size",
00104 "Event Site",
00105 "Event Detector",
00106 "Event Run",
00107 "Event Number",
00108 "Event Data Type",
00109 "CBLT Wrapping",
00110 "Raw CBLT Data",
00111 "LTB Mismatch",
00112 "Invalid Data",
00113 "ROM Header Size",
00114 "ROM Event Size",
00115 "ROM Site",
00116 "ROM Detector",
00117 "ROM Module Type",
00118 "ROM Slot"
00119 };
00120
00121 static const unsigned int kEventHeaderElements[] = {
00122 0U,
00123 1U,
00124 2U,
00125 3U,
00126 4U,
00127 5U,
00128 6U,
00129 7U,
00130 8U,
00131 9U,
00132 10U,
00133 11U,
00134 12U,
00135 13U
00136 };
00137
00138 static const unsigned int kRomHeaderElements[] = {
00139 0U,
00140 14U,
00141 15U,
00142 16U,
00143 17U,
00144 18U,
00145 19U
00146 };
00147
00148 static const unsigned int* m_componentFields[] = {
00149 kEventHeaderElements,
00150 kRomHeaderElements
00151 };
00152
00153 static const unsigned int m_componentFieldsEnd[] = {
00154 14U,
00155 7U
00156 };
00157
00158 static DaqTraits::Definitions* m_definitions[] = {
00159 0,
00160 0
00161 };
00162
00163 static const char* m_sites[] = {
00164 "TST",
00165 "DYB",
00166 "LAN",
00167 "FAR",
00168 "MID",
00169 "FIL",
00170 "SAB",
00171 "UNK"
00172 };
00173
00174 static const char* m_detectors[] = {
00175 "TST",
00176 "AD1",
00177 "AD2",
00178 "AD3",
00179 "AD4",
00180 "IWP",
00181 "OWP",
00182 "RPC"
00183 };
00184
00185 static const char* m_dataTypes[] = {
00186 "NORMAL",
00187 "CALIBRATION",
00188 "ELECTRONICS_CALIBRATION",
00189 "PEDESTAL"
00190 };
00191
00192 static const unsigned int m_moduleTypes[] = {
00193 1U,
00194 2U,
00195 3U,
00196 4U,
00197 5U,
00198 6U
00199 };
00200
00201 static const char* m_moduleTypeStrings[] = {
00202 "UNK",
00203 "PMT_FEE",
00204 "Flash_ADC",
00205 "Local_Trigger",
00206 "RPC_ROM",
00207 "RPC_RTM",
00208 "Master_Trigger"
00209 };
00210
00211 const char* EventTraits_v0_6::key() {
00212 return "Event Format 0.6";
00213 }
00214
00215 EventTraits_v0_6::EventTraits_v0_6() {
00216 }
00217
00218 EventTraits_v0_6::~EventTraits_v0_6() {
00219 }
00220
00221 unsigned int EventTraits_v0_6::majorVersion() const {
00222 return 0U;
00223 }
00224
00225 unsigned int EventTraits_v0_6::minorVersion() const {
00226 return 6U;
00227 }
00228
00229 const string EventTraits_v0_6::versionString() const {
00230 return key();
00231 }
00232
00233 unsigned int EventTraits_v0_6::headerSize(const unsigned int marker) const {
00234 if (marker >= markersEnd()) {
00235 return illegalMarker();
00236 }
00237 return m_headerLengths[marker];
00238 }
00239
00240 void EventTraits_v0_6::initializeHeader(const unsigned int markerToInit,
00241 char* buffer) const {
00242 for (unsigned int count = 0;
00243 count != headerSize(markerToInit);
00244 ++count) {
00245 *((unsigned int*)(buffer + (count * DaqBuffer::kBytesInInt))) = 0x00000000U;
00246 }
00247 *((unsigned int*)buffer) = marker(markerToInit);
00248 if (markerToInit == kEventHeader) {
00249 *(((unsigned int*)buffer) + index(EventTraits::kEventDetector)) = 0xC0000000U;
00250 }
00251 }
00252
00253 unsigned int EventTraits_v0_6::markersEnd() const {
00254 return kRomHeader + 1;
00255 }
00256
00257 const unsigned int* EventTraits_v0_6::markers() const {
00258 return m_markers;
00259 }
00260
00261 unsigned int EventTraits_v0_6::fieldsEnd() const {
00262 return kRomSlot + 1;
00263 }
00264
00265 const unsigned int* EventTraits_v0_6::indices() const {
00266 return m_indices;
00267 }
00268
00269 const unsigned int* EventTraits_v0_6::shifts() const {
00270 return m_shifts;
00271 }
00272
00273 const unsigned int* EventTraits_v0_6::masks() const {
00274 return m_masks;
00275 }
00276
00277 const std::string* EventTraits_v0_6::descriptions() const {
00278 return m_description;
00279 }
00280
00281 DaqTraits::Definitions* EventTraits_v0_6::definitions(unsigned int component) const {
00282 return m_definitions[component];
00283 }
00284
00285 void EventTraits_v0_6::setDefinitions(DaqTraits::Definitions* definitions,
00286 unsigned int component) {
00287 m_definitions[component] = definitions;
00288 }
00289
00290 const unsigned int* EventTraits_v0_6::componentFields(unsigned int component) const {
00291 return m_componentFields[component];
00292 }
00293
00294 const unsigned int EventTraits_v0_6::componentFieldsEnd(unsigned int component) const {
00295 return m_componentFieldsEnd[component];
00296 }
00297
00298 unsigned int EventTraits_v0_6::maxSite() const {
00299 return 7U;
00300 }
00301
00302 const char** EventTraits_v0_6::siteStrings() const {
00303 return m_sites;
00304 }
00305
00306 unsigned int EventTraits_v0_6::maxDetector() const {
00307 return 7U;
00308 }
00309
00310 const char** EventTraits_v0_6::detectorStrings() const {
00311 return m_detectors;
00312 }
00313
00314 unsigned int EventTraits_v0_6::maxDataType() const {
00315 return 3U;
00316 }
00317
00318 const char** EventTraits_v0_6::dataTypeStrings() const {
00319 return m_dataTypes;
00320 }
00321
00322 unsigned int EventTraits_v0_6::maxModuleType() const {
00323 return kMtbModule;
00324 }
00325
00326 const unsigned int* EventTraits_v0_6::moduleTypes() const {
00327 return m_moduleTypes;
00328 }
00329
00330 const char** EventTraits_v0_6::moduleTypeStrings() const {
00331 return m_moduleTypeStrings;
00332 }