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

In This Package:

LtbFrame.cc
Go to the documentation of this file.
00001 /*
00002  *  LtbFrame.cc
00003  *  LtbReadoutFormat
00004  *
00005  *  Created by Simon Patton on 7/21/10.
00006  *  Copyright 2010 DayaBay Collaboration. All rights reserved.
00007  *
00008  */
00009 #include <cstring>
00010 #include "LtbReadoutFormat/LtbFrame.h"
00011 
00012 #include "DaqReadoutFormat/ByteBuffer.h"
00013 #include "LtbReadoutFormat/LtbTime.h"
00014 #include "LtbReadoutFormat/LtbTraits.h"
00015 
00016 using DybDaq::ByteBuffer;
00017 using DybDaq::LtbBuffer;
00018 using DybDaq::LtbFrame;
00019 using DybDaq::LtbTime;
00020 using DybDaq::LtbTraits;
00021 
00022 LtbFrame::LtbFrame(const unsigned int readoutType,
00023                    const unsigned int triggerMask,
00024                    const LtbTraits::LtbDateTime& dateTime,
00025                    const unsigned int halfNanoseconds,
00026                    const int accumulation,
00027                    const unsigned int hitSum,
00028                    const bool totalEsum,
00029                    const bool highEsum,
00030                    const bool lowEsum,
00031                    const unsigned int energySum,
00032                    const unsigned int crossTriggerSource,
00033                    const bool accumulationStatus,
00034                    const bool validGps,
00035                    const bool usingUtc,
00036                    const bool validClockSystem,
00037                    const bool feeBufferFull,
00038                    const bool ltbBufferFull,
00039                    const unsigned int blockedTriggerCount,
00040                    const LtbTraits& traits) :
00041 LtbBuffer(new char[traits.frameSize() * kBytesInInt],
00042           traits),
00043 m_time(0) {
00044     traits.initializeFrame(buffer());
00045     setFrameNumber(0);
00046     setReadoutType(readoutType);
00047     setTriggerMask(triggerMask);
00048     m_time = new LtbTime(dateTime,
00049                          halfNanoseconds,
00050                          accumulation,
00051                          traits);
00052     setHitSum(hitSum);
00053     setTotalEsum(totalEsum);
00054     setHighEsum(highEsum);
00055     setLowEsum(lowEsum);
00056     setEnergySum(energySum);
00057     setCrossTriggerSource(crossTriggerSource);
00058     setAccumulationStatus(accumulationStatus);
00059     setValidGps(validGps);
00060     setUsingUtc(usingUtc);
00061     setValidClockSystem(validClockSystem);
00062     setFeeBufferFull(feeBufferFull);
00063     setLtbBufferFull(ltbBufferFull);
00064     setBlockedTriggerCount(blockedTriggerCount);
00065 }
00066 
00067 
00068 LtbFrame::LtbFrame(const ByteBuffer& byteBuffer,
00069                    const LtbTraits& traits) :
00070 LtbBuffer(byteBuffer,
00071           traits),
00072 m_time(0) {
00073     const unsigned int position = byteBuffer.position();
00074         byteBuffer.position(position + (ltbTraits().timeOffset() * kBytesInInt));
00075     m_time = new LtbTime(byteBuffer,
00076                          traits);
00077         byteBuffer.position(position + (ltbTraits().frameSize() * kBytesInInt));
00078 }
00079 
00080 LtbFrame::~LtbFrame() {
00081     if (0 != m_time) {
00082         delete m_time;
00083     }
00084 }
00085 
00086 unsigned int LtbFrame::frameNumber() const {
00087         return readUnsignedInt(LtbTraits::kFrameNumber);
00088 }
00089 
00090 unsigned int LtbFrame::readoutType() const {
00091         return readUnsignedInt(LtbTraits::kReadoutType);
00092 }
00093 
00094 unsigned int LtbFrame::triggerMask() const {
00095         return readUnsignedInt(LtbTraits::kTriggerMask);
00096 }
00097 
00098 bool LtbFrame::isTriggerLineSet(const unsigned int line) const {
00099     return 0 != (triggerMask() & ltbTraits().triggerLineBit(line));
00100 }
00101 
00102 const LtbTraits::LtbDateTime& LtbFrame::dateTime() const {
00103     return *m_time;
00104 }
00105 
00106 unsigned int LtbFrame::ticks() const {
00107     return m_time->ticks();
00108 }
00109 
00110 unsigned int LtbFrame::halfNanoseconds() const {
00111     return m_time->halfNanoseconds();
00112 }
00113 
00114 int LtbFrame::accumulation() const {
00115     return m_time->accumulation();
00116 }
00117 
00118 unsigned int LtbFrame::hitSum() const {
00119         return readUnsignedInt(LtbTraits::kHitSum);
00120 }
00121 
00122 bool LtbFrame::totalEsum() const {
00123         return readBool(LtbTraits::kTotalEsum);
00124 }
00125 
00126 bool LtbFrame::highEsum() const {
00127         return readBool(LtbTraits::kHighEsum);
00128 }
00129 
00130 bool LtbFrame::lowEsum() const {
00131         return readBool(LtbTraits::kLowEsum);
00132 }
00133 
00134 unsigned int LtbFrame::energySum() const {
00135         return readUnsignedInt(LtbTraits::kEnergySum);
00136 }
00137 
00138 unsigned int LtbFrame::crossTriggerSource() const {
00139     if (4 > ltbTraits().majorVersion() || (4 == ltbTraits().majorVersion() && 6 > ltbTraits().minorVersion())) {
00140         return readUnsignedInt(LtbTraits::kCrossTriggerSource);
00141     }
00142     const unsigned int highCrossTrigger = readUnsignedInt(LtbTraits::kHighCrossTrigger);
00143     const unsigned int lowCrossTrigger = readUnsignedInt(LtbTraits::kLowCrossTrigger);
00144     return (highCrossTrigger << 16U) | lowCrossTrigger;
00145 }
00146 
00147 bool LtbFrame::accumulationStatus() const {
00148         return readBool(LtbTraits::kAccumulationStatus);
00149 }
00150 
00151 bool LtbFrame::validGps() const {
00152         return readBool(LtbTraits::kValidGps);
00153 }
00154 
00155 bool LtbFrame::usingUtc() const {
00156         return readBool(LtbTraits::kUsingUtc);
00157 }
00158 
00159 bool LtbFrame::validClockSystem() const {
00160         return readBool(LtbTraits::kValidClockSystem);
00161 }
00162 
00163 bool LtbFrame::feeBufferFull() const {
00164         return readBool(LtbTraits::kFeeBufferFull);
00165 }
00166 
00167 bool LtbFrame::ltbBufferFull() const {
00168         return readBool(LtbTraits::kLtbBufferFull);
00169 }
00170 
00171 unsigned int LtbFrame::blockedTriggerCount() const {
00172         return readUnsignedInt(LtbTraits::kBlockedTriggerCount);
00173 }
00174 
00175 unsigned int LtbFrame::gather(OutputBufferList& outputBuffers) const {
00176     if (!hasByteBuffer()) {
00177         const LtbTraits& traits = ltbTraits();
00178         memcpy(const_cast<char*>(buffer()) + (traits.timeOffset() * kBytesInInt),
00179                m_time->buffer(),
00180                traits.timeSize() * kBytesInInt);
00181     }
00182     return LtbBuffer::gather(outputBuffers);
00183 }
00184 
00185 
00186 unsigned int LtbFrame::inspect(DaqBuffer::Bytes& inspectors) const {
00187     unsigned int cursor = fillInspectors(inspectors,
00188                                          LtbTraits::kFrameFront,
00189                                          0);
00190     cursor += m_time->inspect(inspectors);
00191     cursor = fillInspectors(inspectors,
00192                           LtbTraits::kFrameBack,
00193                           cursor + 1);
00194     return cursor + 1;
00195 }
00196 
00197 
00198 unsigned int LtbFrame::bufferSize() const {
00199     return ltbTraits().frameSize();
00200 }
00201 
00202 void LtbFrame::setFrameNumber(const unsigned int frameNumber) {
00203     writeField(frameNumber,
00204                LtbTraits::kFrameNumber);
00205 }
00206 
00207 void LtbFrame::setReadoutType(const unsigned int readoutType) {
00208     writeField(readoutType,
00209                LtbTraits::kReadoutType);
00210 }
00211 
00212 void LtbFrame::setTriggerMask(const unsigned int triggerMask) {
00213     writeField(triggerMask,
00214                LtbTraits::kTriggerMask);
00215 }
00216 
00217 void LtbFrame::setTriggerLine(const unsigned int line) {
00218     writeField((triggerMask() | ltbTraits().triggerLineBit(line)),
00219                LtbTraits::kTriggerMask);
00220 }
00221 
00222 void LtbFrame::setDateTime(const LtbTraits::LtbDateTime& dateTime) {
00223     m_time->setDateTime(dateTime);
00224 }
00225 
00226 void LtbFrame::setHalfNanoseconds(const unsigned int halfNanoseconds) {
00227     m_time->setHalfNanoseconds(halfNanoseconds);
00228 }
00229 
00230 void LtbFrame::setAccumulation(const int accumulation) {
00231     m_time->setAccumulation(accumulation);
00232 }
00233 
00234 void LtbFrame::setHitSum(const unsigned int hitSum) {
00235     writeField(hitSum,
00236                LtbTraits::kHitSum);
00237 }
00238 
00239 void LtbFrame::setTotalEsum(const bool totalEsum) {
00240     writeField(totalEsum,
00241                LtbTraits::kTotalEsum);
00242 }
00243 
00244 void LtbFrame::setHighEsum(const bool highEsum) {
00245     writeField(highEsum,
00246                LtbTraits::kHighEsum);
00247 }
00248 
00249 void LtbFrame::setLowEsum(const bool lowEsum) {
00250     writeField(lowEsum,
00251                LtbTraits::kLowEsum);
00252 }
00253 
00254 void LtbFrame::setEnergySum(const unsigned int energySum) {
00255     writeField(energySum,
00256                LtbTraits::kEnergySum);
00257 }
00258 
00259 void LtbFrame::setCrossTriggerSource(const unsigned int crossTriggerSource) {
00260     if (4 > ltbTraits().majorVersion() || (4 == ltbTraits().majorVersion() && 6 > ltbTraits().minorVersion())) {
00261         writeField(crossTriggerSource,
00262                    LtbTraits::kCrossTriggerSource);
00263     }
00264     writeField((crossTriggerSource >> 16U) & 0x0000ffffU,
00265                LtbTraits::kHighCrossTrigger);
00266     writeField(crossTriggerSource & 0x0000ffffU,
00267                LtbTraits::kLowCrossTrigger);
00268 }
00269 
00270 void LtbFrame::setAccumulationStatus(const bool accumulationStatus) {
00271     writeField(accumulationStatus,
00272                LtbTraits::kAccumulationStatus);
00273 }
00274 
00275 void LtbFrame::setValidGps(const bool validGps) {
00276     writeField(validGps,
00277                LtbTraits::kValidGps);
00278 }
00279 
00280 void LtbFrame::setUsingUtc(const bool usingUtc) {
00281     writeField(usingUtc,
00282                LtbTraits::kUsingUtc);
00283 }
00284 
00285 void LtbFrame::setValidClockSystem(const bool validClockSystem) {
00286     writeField(validClockSystem,
00287                LtbTraits::kValidClockSystem);
00288 }
00289 
00290 void LtbFrame::setFeeBufferFull(const bool feeBufferFull) {
00291     writeField(feeBufferFull,
00292                LtbTraits::kFeeBufferFull);
00293 }
00294 
00295 void LtbFrame::setLtbBufferFull(const bool ltbBufferFull) {
00296     writeField(ltbBufferFull,
00297                LtbTraits::kLtbBufferFull);
00298 }
00299 
00300 void LtbFrame::setBlockedTriggerCount(const unsigned int blockedTriggerCount) {
00301     writeField(blockedTriggerCount,
00302                LtbTraits::kBlockedTriggerCount);
00303 }
00304 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:53:06 for LtbReadoutFormat by doxygen 1.7.4