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

In This Package:

FadcTraits.cc
Go to the documentation of this file.
00001 /*
00002  *  FadcTraits.cc
00003  *  FadcReadoutFormat
00004  *
00005  *  Created by Simon Patton on 7/21/10.
00006  *  Copyright 2010 DayaBay Collaboration. All rights reserved.
00007  *
00008  */
00009 #include "FadcReadoutFormat/FadcTraits.h"
00010 
00011 #include <map>
00012 
00013 #include "FadcReadoutFormat/FadcTraits_v1_2.h"
00014 #include "FadcReadoutFormat/FadcTraits_v1_5.h"
00015 #include "FadcReadoutFormat/FadcTraits_v2_0.h"
00016 
00017 using DybDaq::FadcTraits;
00018 
00019 // Components in this format
00020 const unsigned int FadcTraits::kHead = 0;
00021 const unsigned int FadcTraits::kData = FadcTraits::kHead + 1;
00022 const unsigned int FadcTraits::kFoot = FadcTraits::kData + 1;
00023 
00024 const unsigned int FadcTraits::kHeadTriggerNumber = 0;
00025 const unsigned int FadcTraits::kMajorVersion = FadcTraits::kHeadTriggerNumber + 1;
00026 const unsigned int FadcTraits::kMinorVersion = FadcTraits::kMajorVersion + 1;
00027 //
00028 const unsigned int FadcTraits::kTriggerType = FadcTraits::kMinorVersion + 1;
00029 const unsigned int FadcTraits::kNoData = FadcTraits::kTriggerType + 1;
00030 //
00031 const unsigned int FadcTraits::kChannelId = FadcTraits::kNoData + 1;
00032 const unsigned int FadcTraits::kHighDataByte = FadcTraits::kChannelId + 1;
00033 const unsigned int FadcTraits::kMiddleDataByte = FadcTraits::kHighDataByte + 1;
00034 const unsigned int FadcTraits::kLowDataByte = FadcTraits::kMiddleDataByte + 1;
00035 //
00036 const unsigned int FadcTraits::kFootTriggerNumber = FadcTraits::kLowDataByte + 1;
00037 const unsigned int FadcTraits::kFootDataLength = FadcTraits::kFootTriggerNumber + 1;
00038 
00039 // Improvements to 1.2
00040 const unsigned int FadcTraits::kHeadMarker = FadcTraits::kFootDataLength + 1;
00041 const unsigned int FadcTraits::kAdcDataMarker = FadcTraits::kHeadMarker + 1;
00042 const unsigned int FadcTraits::kFootMarker = FadcTraits::kAdcDataMarker + 1;
00043 
00044 // Added in 1.5
00045 const unsigned int FadcTraits::kProtectionStatus = FadcTraits::kFootMarker + 1;
00046 const unsigned int FadcTraits::kScaleEnabled = FadcTraits::kProtectionStatus + 1;
00047 const unsigned int FadcTraits::kDuringPrevious = FadcTraits::kScaleEnabled + 1;
00048 
00049 // Added in 2.0
00050 const unsigned int FadcTraits::kChannelHeadMarker = FadcTraits::kDuringPrevious + 1;
00051 const unsigned int FadcTraits::kChannelHeadCheck = FadcTraits::kChannelHeadMarker + 1;
00052 const unsigned int FadcTraits::kChannelFootMarker = FadcTraits::kChannelHeadCheck + 1;
00053 const unsigned int FadcTraits::kChannelFootCheck = FadcTraits::kChannelFootMarker + 1;
00054 const unsigned int FadcTraits::kSample1 = FadcTraits::kChannelFootCheck + 1;
00055 const unsigned int FadcTraits::kSample2 =  FadcTraits::kSample1 + 1;
00056 const unsigned int FadcTraits::kSample3 =  FadcTraits::kSample2 + 1;
00057 const unsigned int FadcTraits::kSample4 =  FadcTraits::kSample3 + 1;
00058 
00059 
00060 static std::map<const char*, FadcTraits*> m_allTraits;
00061 
00062 FadcTraits::FadcTraits() {
00063 }
00064 
00065 FadcTraits::~FadcTraits() {
00066 }
00067 
00068 const FadcTraits& FadcTraits::defaultTraits() {
00069     if (0 == m_allTraits.size()) {
00070         m_allTraits.insert(std::pair<const char*, FadcTraits*>(FadcTraits_v1_2::key(),new FadcTraits_v1_2()));
00071         m_allTraits.insert(std::pair<const char*, FadcTraits*>(FadcTraits_v1_5::key(),new FadcTraits_v1_5()));
00072         m_allTraits.insert(std::pair<const char*, FadcTraits*>(FadcTraits_v2_0::key(),new FadcTraits_v2_0()));
00073     }
00074     return *m_allTraits[FadcTraits_v2_0::key()];
00075 }
00076 
00077 const FadcTraits* FadcTraits::readTraits(const char*& buffer) {
00078     unsigned int major = 0;
00079     const unsigned int minor = readUnsignedInt(buffer,
00080                                              defaultTraits(),
00081                                              FadcTraits::kMinorVersion);
00082     
00083     const FadcTraits* result = 0;
00084     if (0U == major && 0U == minor) {
00085         result = m_allTraits[FadcTraits_v1_2::key()];
00086     } else if (0U == major && 1U == minor) {
00087             result = m_allTraits[FadcTraits_v1_5::key()];
00088     } else if (0U == major && 2U == minor) {
00089             result = m_allTraits[FadcTraits_v2_0::key()];
00090     }
00091     return result;
00092 }
00093 
00094 unsigned int FadcTraits::illegalMarker() const {
00095     return 0xffffffffU;
00096 }
00097 
00098 unsigned int FadcTraits::illegalField() const {
00099     return 0xffffffffU;
00100 }
00101 
00102 const char* FadcTraits::triggerTypeAsString(unsigned int triggerType) const {
00103     if (triggerType >= triggerTypeEnd()) {
00104         return "Unknown";
00105     }
00106     return triggerTypeStrings()[triggerType];
00107 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:52:58 for FadcReadoutFormat by doxygen 1.7.4