00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "LtbReadoutFormat/LtbTraits_v4_3.h"
00010
00011 #include <ctime>
00012
00013 #include "DaqReadoutFormat/BitsDefinition.h"
00014 #include "DaqReadoutFormat/DaqBuffer.h"
00015 #include "LtbReadoutFormat/LtbTime.h"
00016
00017 using DybDaq::DaqTraits;
00018 using DybDaq::LtbTime;
00019 using DybDaq::LtbTraits;
00020 using DybDaq::LtbTraits_v4_3;
00021 using std::string;
00022
00023 static const unsigned int m_indices[] = {
00024 0U,
00025 0U,
00026 0U,
00027 0U,
00028 0U,
00029 0U,
00030 0U,
00031 0U,
00032 0U,
00033 0U,
00034 0U,
00035 1U,
00036 1U,
00037 0U,
00038 5U,
00039 5U,
00040 5U,
00041 5U,
00042 5U,
00043 6U,
00044 0U,
00045
00046 0U,
00047 0U,
00048 0U,
00049 0U,
00050 0U,
00051 0U,
00052 2U,
00053 1U,
00054 0U,
00055 1U,
00056 3U,
00057 1U,
00058 6U,
00059 6U,
00060 6U
00061 };
00062
00063 static const unsigned int m_shifts[] = {
00064 22U,
00065 16U,
00066 0U,
00067 0U,
00068 18U,
00069 16U,
00070 0U,
00071 0U,
00072 0U,
00073 6U,
00074 0U,
00075 7U,
00076 0U,
00077 0U,
00078 16U,
00079 14U,
00080 13U,
00081 12U,
00082 0U,
00083 0U,
00084 0U,
00085
00086 0U,
00087 8U,
00088 27U,
00089 26U,
00090 25U,
00091 24U,
00092 0U,
00093 16U,
00094 0U,
00095 0U,
00096 0U,
00097 20U,
00098 27U,
00099 26U,
00100 16U
00101 };
00102
00103 static const unsigned int m_masks[] = {
00104 0x0000003fU,
00105 0x0000003fU,
00106 0x00000000U,
00107 0x000000ffU,
00108 0x0000003fU,
00109 0x00000003U,
00110 0x0000ffffU,
00111 0x00000000U,
00112 0x00000000U,
00113 0x000003ffU,
00114 0x0000003fU,
00115 0x0000007fU,
00116 0x0000007fU,
00117 0x00000000U,
00118 0x000001ffU,
00119 0x00000001U,
00120 0x00000001U,
00121 0x00000001U,
00122 0x00000fffU,
00123 0x000003ffU,
00124 0x000000ffU,
00125
00126 0x00008000U,
00127 0x0000000fU,
00128 0x00000001U,
00129 0x00000001U,
00130 0x00000001U,
00131 0x00000001U,
00132 0x0fffffffU,
00133 0x0000000fU,
00134 0x0000ffffU,
00135 0x0000ffffU,
00136 0x0fffffffU,
00137 0x0000000fU,
00138 0x00000001U,
00139 0x00000001U,
00140 0x00003fffU
00141 };
00142
00143 static const std::string m_description[] = {
00144 "LTB Raw Trigger Total",
00145 "Number Raw Triggers Saved",
00146 "LTB status",
00147 "Local Trigger Seq. Number",
00148 "Frame Number in LTB Package",
00149 "LTB Readout Type",
00150 "LTB Trigger Mask",
00151 "Trigger Time's Year",
00152 "Trigger Time's Month",
00153 "Trigger Time's Day",
00154 "Trigger Time's Hour",
00155 "Trigger Time's Minutes",
00156 "Trigger Time's Seconds",
00157 "Trigger Time's Ticks",
00158 "Sum of Hits in FEE",
00159 "Total Energy Sum Comparison",
00160 "High Energy Sum Comparison",
00161 "Low Energy Sum Comparison",
00162 "ESUM ADC",
00163 "Cross Trigger Source",
00164 "LTB Package Data Length",
00165
00166 "LTB Clock Error",
00167 "LTB Format Stamp",
00168 "LTB Accumulaiton Status",
00169 "LTB Has Valid GPS",
00170 "LTB Using UTC",
00171 "LTB Has Valid Clock",
00172 "LTB High Bits of Nanoseconds",
00173 "LTB Low Bits of Nanoseconds",
00174 "LTB High Bits of Unix Time",
00175 "LTB Low Bits of Unix Time",
00176 "LTB High Bits of Accumulation",
00177 "LTB Low Bits of Accumulation",
00178 "LTB FEE Buffer Full",
00179 "LTB Buffer Full",
00180 "LTB Number Blocked Triggers"
00181 };
00182
00183 static const unsigned int kLtbHeadElements[] = {
00184 0U,
00185 1U,
00186 21U,
00187 22U,
00188 3U
00189 };
00190
00191 static const unsigned int kLtbFrameFrontElements[] = {
00192 23U,
00193 24U,
00194 25U,
00195 26U,
00196 4U,
00197 5U,
00198 6U
00199 };
00200
00201 static const unsigned int kLtbTimeElements[] = {
00202 29U,
00203 32U,
00204 28U,
00205 30U,
00206 27U,
00207 31U
00208 };
00209
00210 static const unsigned int kLtbFrameBackElements[] = {
00211 14U,
00212 15U,
00213 16U,
00214 17U,
00215 18U,
00216 33U,
00217 34U,
00218 35U,
00219 19U
00220 };
00221
00222 static const unsigned int kLtbFootElements[] = {
00223 20U
00224 };
00225
00226 static const unsigned int kLtbUnixTimeElements[] = {
00227 29U,
00228 32U,
00229 28U,
00230 30U,
00231 27U,
00232 31U
00233 };
00234
00235 static const unsigned int kLtbGpsTimeElements[] = {
00236 9U,
00237 10U,
00238 32U,
00239 28U,
00240 11U,
00241 12U,
00242 27U,
00243 31U
00244 };
00245
00246 static const unsigned int* m_componentFields[] = {
00247 kLtbHeadElements,
00248 kLtbFrameFrontElements,
00249 kLtbTimeElements,
00250 kLtbFrameBackElements,
00251 kLtbFootElements,
00252 kLtbUnixTimeElements,
00253 kLtbGpsTimeElements,
00254 };
00255
00256 static const unsigned int m_componentFieldsEnd[] = {
00257 5U,
00258 7U,
00259 6U,
00260 9U,
00261 1U,
00262 6U,
00263 8U
00264
00265 };
00266
00267 static DaqTraits::Definitions* m_definitions[] = {
00268 0,
00269 0,
00270 0,
00271 0,
00272 0,
00273 0,
00274 0
00275 };
00276
00277 static const char* m_triggerLines[] = {
00278 "MANUAL_TRIGGER",
00279 "CROSS_TRIGGER_IN",
00280 "PERIODIC_TRIGGER",
00281 "PEDESTAL_TRIGGER",
00282 "CALIB_TRIGGER",
00283 0,
00284 0,
00285 0,
00286 "MULTIPLICITY_TRIGGER",
00287 "ESUM_ADC_TRG",
00288 "HIGH_ESUM_COMP_TRG",
00289 "LOW_ESUM_COMP_TRG",
00290 "ALL_ESUM_COMP_TRG"
00291 };
00292
00293 static const unsigned int m_triggerBits[] = {
00294 0x0001U,
00295 0x0002U,
00296 0x0004U,
00297 0x0008U,
00298 0x0010U,
00299 0x0020U,
00300 0x0040U,
00301 0x0080U,
00302 0x0100U,
00303 0x0200U,
00304 0x0400U,
00305 0x0800U,
00306 0x1000U
00307 };
00308
00309 const char* LtbTraits_v4_3::key() {
00310 return "LTB Format 4.3";
00311 }
00312
00313 LtbTraits_v4_3::LtbTraits_v4_3() {
00314 }
00315
00316 LtbTraits_v4_3::~LtbTraits_v4_3() {
00317 }
00318
00319 unsigned int LtbTraits_v4_3::majorVersion() const {
00320 return 4U;
00321 }
00322
00323 unsigned int LtbTraits_v4_3::minorVersion() const {
00324 return 1U;
00325 }
00326
00327 const string LtbTraits_v4_3::versionString() const {
00328 return key();
00329 }
00330
00331 unsigned int LtbTraits_v4_3::headSize() const {
00332 return 1U;
00333 }
00334
00335 unsigned int LtbTraits_v4_3::frameSize() const {
00336 return 7U;
00337 }
00338
00339 unsigned int LtbTraits_v4_3::timeSize() const {
00340 return 4U;
00341 }
00342
00343 unsigned int LtbTraits_v4_3::footSize() const {
00344 return 1U;
00345 }
00346
00347 void LtbTraits_v4_3::initializeHead(char* buffer) const {
00348 *((unsigned int*)buffer) = 0x40000200U;
00349 }
00350
00351 void LtbTraits_v4_3::initializeFrame(char* buffer) const {
00352 for (unsigned int count = 0;
00353 count != frameSize();
00354 ++count) {
00355 *((unsigned int*)(buffer + (count * DaqBuffer::kBytesInInt))) = 0x00000000U;
00356 }
00357 }
00358
00359 void LtbTraits_v4_3::initializeTime(char* buffer) const {
00360 for (unsigned int count = 0;
00361 count != timeSize();
00362 ++count) {
00363 *((unsigned int*)(buffer + (count * DaqBuffer::kBytesInInt))) = 0x00000000U;
00364 }
00365
00366 *((unsigned int*)buffer) = 0x00a10000U;
00367 }
00368
00369 void LtbTraits_v4_3::initializeFoot(char* buffer) const {
00370 *((unsigned int*)buffer) = 0xa0000000U;
00371 }
00372
00373 unsigned int LtbTraits_v4_3::timeOffset() const {
00374 return 1U;
00375 }
00376
00377 unsigned int LtbTraits_v4_3::markersEnd() const {
00378 return 0U;
00379 }
00380
00381 const unsigned int* LtbTraits_v4_3::markers() const {
00382 return 0;
00383 }
00384
00385 unsigned int LtbTraits_v4_3::fieldsEnd() const {
00386 return kBlockedTriggerCount + 1;
00387 }
00388
00389 const unsigned int* LtbTraits_v4_3::indices() const {
00390 return m_indices;
00391 }
00392
00393 const unsigned int* LtbTraits_v4_3::shifts() const {
00394 return m_shifts;
00395 }
00396
00397 const unsigned int* LtbTraits_v4_3::masks() const {
00398 return m_masks;
00399 }
00400
00401 const std::string* LtbTraits_v4_3::descriptions() const {
00402 return m_description;
00403 }
00404
00405 DaqTraits::Definitions* LtbTraits_v4_3::definitions(unsigned int component) const {
00406 return m_definitions[component];
00407 }
00408
00409 void LtbTraits_v4_3::setDefinitions(DaqTraits::Definitions* definitions,
00410 unsigned int component) {
00411 m_definitions[component] = definitions;
00412 }
00413
00414 const unsigned int* LtbTraits_v4_3::componentFields(unsigned int component) const {
00415 return m_componentFields[component];
00416 }
00417
00418 const unsigned int LtbTraits_v4_3::componentFieldsEnd(unsigned int component) const {
00419 return m_componentFieldsEnd[component];
00420 }
00421
00422 unsigned int LtbTraits_v4_3::triggerLineEnd() const {
00423 return 13U;
00424 }
00425
00426 const char** LtbTraits_v4_3::triggerLineStrings() const {
00427 return m_triggerLines;
00428 }
00429
00430 const unsigned int* LtbTraits_v4_3::triggerLineBits() const {
00431 return m_triggerBits;
00432 }
00433