/* * acrootRecord.hh * * Created on: Mar 24, 2014 * Author: yqiang * * Modified on * Nov 19, 2014: added beam current and gain, yqiang * */ #ifndef ACROOTRECORD_HH_ #define ACROOTRECORD_HH_ #include #include #include class acrootRecord: public TObject { private: struct timespec prrTime; // POSIX timestamp TArrayF prrData; // ROOT array of floats float prrCurrent; // Beam current short prrGain; // Amplifier gain public: acrootRecord(struct timespec posixTime, unsigned nElm, const float* arrayPtr, float beamCurrent, short gain) : TObject(), prrTime(posixTime), prrData(nElm, arrayPtr), prrCurrent( beamCurrent), prrGain(gain) { ; } acrootRecord& operator=(const acrootRecord &record) { *dynamic_cast(this) = record; prrTime = record.prrTime; prrData = record.prrData; prrCurrent = record.prrCurrent; prrGain = record.prrGain; return *this; } virtual ~acrootRecord() { } ; void CopyToBuffer(void* bufferPtr); inline struct timespec GetTimeStamp() const { return prrTime; } inline TArrayF& GetData() { return prrData; } inline float GetCurrent() { return prrCurrent; } inline short GetGain() { return prrGain; } inline struct timespec SetTimeStamp(struct timespec posixTime) { return prrTime = posixTime; } inline TArrayF& SetData(Int_t nElm, const Float_t* arrayPtr) { return prrData = TArrayF(nElm, arrayPtr); } inline TArrayF& SetData(const TArrayF& array) { return prrData = array; } inline float SetCurrent(const float current) { return prrCurrent = current; } inline short SetGain(const short gain) { return prrGain = gain; } }; void acrootRecord::CopyToBuffer(void* bufferPtr) { // Copy second memcpy(bufferPtr, &(prrTime.tv_sec), sizeof(Long64_t)); // Copy Nanosecond void * currentPtr = &((static_cast(bufferPtr))[1]); memcpy(currentPtr, &(prrTime.tv_nsec), sizeof(Long64_t)); // Copy Data array currentPtr = &((static_cast(bufferPtr))[2]); memcpy(currentPtr, prrData.fArray, prrData.GetSize() * sizeof(Float_t)); // Copy Current currentPtr = &((static_cast(bufferPtr))[4 + prrData.GetSize()]); memcpy(currentPtr, &prrCurrent, sizeof(Float_t)); // Copy Gain currentPtr = &((static_cast(bufferPtr))[5 + prrData.GetSize()]); memcpy(currentPtr, &prrGain, sizeof(Short_t)); return; } #endif /* ACROOTRECORD_HH_ */